akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <complex>
#include <vector>
#include <limits>
#include <iomanip>
#include <cassert>

using namespace std;

typedef long long ll;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n-1;i >= 0;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second

const long double pi = 3.141592653589793;
const int mod = 1e9 + 7;

ll money = 1000, share = 0;
ll A[100], N;


int main() {

 // freopen("input.in","r",stdin);
 // freopen("output.out","w",stdout);

 ios_base::sync_with_stdio(false);
 cin.tie(NULL);

 cin>>N;
 rep(i,N)cin>>A[i];

 rep(i,N-1) {
   if(A[i] < A[i+1]) {
     share += money/A[i];
     money = money%A[i];
     money += share*A[i+1];
     share=0;
   }
 }
 cout<<money<<endl;










 return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll a,b,x,ct,p,q,r;
    string s,s1,s2;
    cin>>s;
    p=s.size();
    ct=0;
    if(p%2==0)
    {
    for(ll i=0,j=p-1;i<j;i++,j--)
    {
        if(s[i]!=s[j]) ct++;
    }
    cout<<ct<<endl;
    }
    else
    {
    for(ll i=0,j=p-1;i+1<j;i++,j--)
    {
        if(s[i]!=s[j]) ct++;
    }
    cout<<ct<<endl;
    }
}




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

int N, W;
int dp[101][300];

int max(int a, int b) { return a > b ? a : b; }
int min(long long int a, long long int b) {
	long long int tmp;
	tmp = a < b ? a : b;
	if (tmp < 0) tmp = -1;
	return (int)tmp;
}

int main(void) {
	int i, j, k, w1, w, v, ans = 0;
	memset(dp, -1, sizeof(dp));
	scanf("%d%d", &N, &W);

	scanf("%d%d", &w1, &v);
	dp[0][0] = 0;
	dp[1][0] = v;
	for (i = 1; i < N; i++) {
		scanf("%d%d", &w, &v);
		w -= w1;
		for (j = i; j >= 0; j--) {
			for (k = 299 - w; k >= 0; k--) {
				if (dp[j][k] != -1) {
					dp[j + 1][k + w] = max(dp[j + 1][k + w], dp[j][k] + v);
				}
			}
		}
	}
	for (i = 0; i <= N; i++) {
		for (j = min(W - (long long int)w1 * i, 299); j >= 0; j--) {
			if (dp[i][j] != -1) {
				ans = max(dp[i][j], ans);
			}
		}
	}
	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
ll solve(int N, ll X) {
	if (X == 0) return 0;
	if (N == 0) return 1;
	if (X == 1) return 0;
	X--;
	if (X < (1LL << (N + 1)) - 3) {
		return solve(N - 1, X);
	}
	else {
		ll ret = (1LL << (N)) - 1;
		X -= (1LL << (N + 1)) - 3;
		if (X > 0) {
			ret++;
			X--;
			ret += solve(N - 1, X);
		}
		return ret;
	}

}
int main() {
	int N;
	ll X;
	cin >> N >> X;
	cout << solve(N, X) << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.BitSet;


public class Main {

	public static void main(String[] args) {
		try {
			BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
			String[] input1 = bf.readLine().split(" ");
			int n = Integer.parseInt(input1[0]);
			int m = Integer.parseInt(input1[1]);

			// 電球に紐づくスイッチの番号をbitで保持
			// ※スイッチの数が10、紐づくスイッチが1, 3, 5　→　"0000010101"
			BitSet[] switchConv = new BitSet[m + 1];
			for (int i = 1; i <= m; i++) {
				String[] input2 = bf.readLine().split(" ");
				int k = Integer.parseInt(input2[0]);
				switchConv[i] = new BitSet(n);
				for (int j = 0; j < k; j++) {
					switchConv[i].set(Integer.parseInt(input2[j + 1]) - 1);
				}
			}

			// 各電球ごとの点灯判断となるp値を保持
			int[] p = new int[m + 1];
			String[] input3 = bf.readLine().split(" ");
			for (int i = 1; i <= m; i++) {
				p[i] = Integer.parseInt(input3[i - 1]);
			}

			// スイッチのonoff状況を全件探索して、全点灯する組み合わせを数える
			int cnt = 0;
			double max = Math.pow(2, n);
			for (int i = 0; i < max; i++) {
				BitSet bitS = new BitSet(n);
				String onoff = Integer.toBinaryString(i);
				int bitNum = onoff.length() - 1;
				for (int j = bitNum; j >= 0; j--) {
					int bit = Integer.parseInt(onoff.substring(j, j + 1));
					if (bit == 1) {
						bitS.set(bitNum - j);
					}
				}
				boolean result = true;
				for (int j = 1; j <= m; j++) {
					BitSet clone = (BitSet) switchConv[j].clone();
					clone.and(bitS);
					if (p[j] != clone.cardinality() % 2) {
						result = false;
						break;
					}
				}
				if (result) {
					cnt++;
				}
			}

			System.out.println(cnt);
		} catch (Exception e) {
		}
	}
}


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

using namespace std;

typedef long long LL;

int main()
{
    int n;
    LL a[200010];
    cin>>n;
    LL stool=0,maxx;
    cin>>maxx;
    for (int i=1;i<n;++i)
    {
        cin>>a[i];
        if (maxx<=a[i])
            maxx=a[i];
        else
            stool=stool+maxx-a[i];
    }
    cout<<stool;
}


Measured memory_bytes: 5180
s = input()
K = int(input())

ans_stack = []

for i in range(len(s)):
    str_length = 1
    while str_length <= K and i+str_length <= len(s):
        if not s[i:i+str_length] in ans_stack:
            ans_stack.append(s[i:i+str_length])
            ans_stack = sorted(ans_stack)[0:K]
#        print(ans_stack)
#        print(s[i:i+str_length])
#        print()
        str_length += 1
print(ans_stack[K-1])


Measured memory_bytes: 3064
s=input()
K=int(input())
S=[c for c in s]
def diff(c):
    return ord('z')-ord(c)
for i in range(len(s)):
    d=diff(S[i])
    if d<min(25,K):
        K-=d+1
        S[i]='a'
k=K%26
S[-1]=chr(ord(S[-1])+k) if k<=diff(S[-1]) else chr(ord(S[-1])+k-26)
print(''.join(S))

Measured memory_bytes: 4212
import numpy as np
n=3
a=[input() for i in range(n)]

S=list(a[1])
s=len(S)
K=int(a[2])-1

for i in range(s):
  if S[i]!=S[K]:
    S[i]="*"
mojiretu = ''
    
for x in S:
    mojiretu += x
    
print(mojiretu)

Measured memory_bytes: 21564
function main()
  
  n = parse(Int,readline())
  p = map(x -> parse(Int,x), split(readline()))
  
  count = 0
  
  for i in 1:n-2
    
    if p[i] >= p[i+1] >= p[i+2] || p[i+2] >= p[i+1] >= p[i]
      count += 1
    end
    
  end
  
  println(count)
  
end

main()

Measured memory_bytes: 112396
#include <bits/stdc++.h>
using namespace std;
template <typename T> inline void read(T &x){
    char c;
    bool nega=0;
    while((!isdigit(c=getchar()))&&(c!='-'));
    if(c=='-'){
        nega=1;
        c=getchar();
    }
    x=c-48;
    while(isdigit(c=getchar())) x=x*10+c-48;
    if(nega) x=-x;
}
template <typename T> inline void writep(T x){
    if(x>9) writep(x/10);
    putchar(x%10+48);
}
template <typename T> inline void write(T x){
    if(x<0){
        putchar('-');
        x=-x;
    }
    writep(x);
}
template <typename T> inline void writeln(T x){
    write(x);
    putchar('\n');
}
#define pb push_back
#define mp make_pair
#define NMAX 105

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
char a[NMAX][NMAX];
int n,m;
int main(){
  //  freopen("out.out","w",stdout);
    read(n);read(m);
    n--;
    m--;
    write(100);putchar(' ');writeln(100);
    for(int i=1;i<=50;i++) for(int j=1;j<=100;j++) a[i][j]='.';
    for(int i=1;i<=49;i+=2){
        for(int j=1;j<=100;j+=2){
            if(!m) break;
            m--;
            a[i][j]='#';
        }
    }
    for(int i=51;i<=100;i++){
        for(int j=1;j<=100;j++) a[i][j]='#';
    }
    for(int i=100;i>=51;i-=2){
        for(int j=1;j<=100;j+=2){
            if(!n) break;
            n--;
            a[i][j]='.';
        }
    }
    for(int i=1;i<=100;i++){
        for(int j=1;j<=100;j++) putchar(a[i][j]);
        putchar('\n');
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
template<typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}
template<typename T>
void chmin(T &a,T b){
  if(a>b)a=b;
}
template<typename T>
void chmax(T &a,T b){
  if(a<b)a=b;
}
using ld=long double;

signed main(){
  int n;cin>>n;
  vector<int> v(n);
  for(int i=0;i<n;i++)cin>>v[i];
  map<int,int> m;
  for(int i=0;i<n;i++)m[v[i]]++;
  int ans=0;
  for(auto p:m)ans+=p.second*(p.second-1)/2;
  for(int i=0;i<n;i++){
    int A=m[v[i]];
    int tmp=ans;
    tmp-=A*(A-1)/2;tmp+=(A-1)*(A-2)/2;
    cout<<tmp<<endl;
  }
}


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

int main() {
  int A, B;
  cin >> A >> B;
  
  int count = 0;
  for (int i = 1; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      for (int k = 0; k < 10; k++) {
        int a = 10001 * i + 1010 * j + 100 * k;
        if (A <= a && a <= B) {
          count += 1;
        }
      }
    }
  }
  cout << count << endl;
}
       

Measured memory_bytes: 3604
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
int main()
{
    int e=0;
    ll n,W;
    cin>>n>>W;
    ll w[n],v[n];
    for(int i=0;i<n;i++){
        cin>>w[i]>>v[i];
        e+=v[i];
    }
    ll dp[e+1];
    for(int i=0;i<=e;i++)dp[i]=1000000000000;
    dp[0]=0;
    for(int i=0;i<n;i++){
        for(int j=e-v[i];j>=0;j--){
            dp[j+v[i]]=min(dp[j+v[i]],dp[j]+w[i]);
        }
    }
    ll ans=0;
    for(int i=0;i<=e;i++){
        if(dp[i]<=W){
            ans=max(ans,(ll)i);
    }
    }
    cout<<ans;
}


Measured memory_bytes: 1024
import numpy as np

N, A = map(int, input().split())
x = list(map(int, input().split()))
r = 0
l = 0
for y in x:
    y -= A
    if y < 0:
        l += y
    else:
         r += y

M = r-l+1
dp = np.zeros((N+1,M), dtype='i8')
dp[0][-l] = 1

for i in range(1, N+1):
    for j in range(M):
        dp[i][j] = dp[i-1][j]
        j2 = j-x[i-1]+A
        if 0 <= j2 and j2 < M:
            dp[i][j] += dp[i-1][j2]

print(dp[N][-l]-1)


Measured memory_bytes: 13404
#1 から n までの数の中から、重複無しで３つの数を選びそれらの合計が x となる組み合わせの数を求める
while true
n,x=gets.split(" ").map(&:to_i) #n とx数字をとる
break if n==0 && x==0       #値ゼロの場合終了

count=0
for a in 1..n           #loopを始める
    for b in 1+a..n
        for c in b+1..n
            count += 1 if a+b+c==x
        end
    end
end
puts count
end



Measured memory_bytes: 6872
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int a = scanner.nextInt();
			int b = scanner.nextInt();
			int x = scanner.nextInt();

			if (x - a <= b && x - a >= 0) {
				System.out.println("YES");
			} else {
				System.out.println("NO");
			}
		}
	}
}


Measured memory_bytes: 24916
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    S = input()
    T = input()

    dict_st = {}
    dict_ts = {}

    for s, t in zip(S, T):
        if s not in dict_st:
            dict_st[s] = t
        else:
            if dict_st[s] != t:
                print("No")
                break

        if t not in dict_ts:
            dict_ts[t] = s
        else:
            if dict_ts[t] != s:
                print("No")
                break
    else:
        print("Yes")


if __name__ == "__main__":
    main()


Measured memory_bytes: 3632
#puts "Sを入力"
S = (gets.to_s).delete("\n")
#puts "結果：" + S

#puts "Tを入力"
T = (gets.to_s).delete("\n")
#puts "結果：" + T

T_alpha = T[0, T.length - 1]
#puts "T_alpha：" + T_alpha


if S.match(T_alpha)
  if T.length == T_alpha.length + 1
    puts "Yes"
  end
else
  puts "No"
end



Measured memory_bytes: 14184
def gcd(a,b):
    while b>0:
        a,b = b, a%b
    return a

def lcm(a,b):
    return a*b//gcd(a,b)

n, m = map(int, input().split())
s = input()
t = input()

g = gcd(n,m)
for i in range(g):
    if s[n//g*i] != t[m//g*i]:
        print(-1)
        exit()
print(lcm(n,m))


Measured memory_bytes: 3316
#!/usr/bin/env python3
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

import itertools
N,M = map(int,readline().split())
S = [list(map(int,readline().rstrip().split()))[1:] for m in range(M)]
P = list(map(int,readline().rstrip().split()))

ans = 0
for t in itertools.product([0,1],repeat=N):
    bool = True
    for i in range(M):
        Q = sum([t[s-1] for s in S[i]])
        if (Q-P[i])%2 != 0:
            bool = False
            break
    if bool:
        ans += 1
print(ans)

Measured memory_bytes: 3064
#include <iostream>

#define ll long long

using namespace std;

long long gcd(ll a, ll b){
    if(b == 0){
        return a;
    }else{
        return gcd(b, a % b);
    }
}

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

int main(){
    int n, i;
    long long time[110];
    cin >> n;
    for(i = 0; i < n; i++){
        cin >> time[i];
    }
    ll answer = time[0];
    for(i = 0; i < n; i++){
        answer = lcm(answer, time[i]);
    }
    cout << answer << endl;
    return 0;
}


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

using namespace std;

using PII = pair<int, int>;

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

	vector<int> a(n + m - 1, 0);
	auto b = a;
	vector<set<int>> children(n + 1, set<int>());
	vector<set<int>> parents(n + 1, set<int>());
	for (int i = 0; i < a.size(); i++) {
		cin >> a[i] >> b[i];
		children[a[i]].insert(b[i]);
		parents[b[i]].insert(a[i]);
	}

	int root = -1;
	for (int i = 1; i < parents.size(); i++) {
		if (parents[i].size() == 0) {
			root = i;
			// break;
		}
	}
	// printf("root %d\n", root);

	auto tmp_children = children;
	auto tmp_parents = parents;

	vector<int> L;
	set<int> S;
	S.insert(root);

	while (!S.empty()) {
		int x = *S.begin();
		S.erase(x);
		L.emplace_back(x);

		for (auto y: tmp_children[x]) {
			tmp_parents[y].erase(x);
			if (tmp_parents[y].empty()) {
				S.insert(y);
			}
		}
		tmp_children[x].clear();
	}

	vector<int> distance(n + 1, -1);
	distance[root] = 0;
	for (auto x: L) {
		for (auto y: children[x]) {
			// printf("x %d, y %d\n", x, y);
			distance[y] = distance[x] + 1;
		}
	}

	vector<int> ans(n + 1, -1);
	ans[root] = 0;
	for (int i = 0; i < a.size(); i++) {
		if (distance[a[i]] + 1 == distance[b[i]]) {
			ans[b[i]] = a[i];
		}
	}

	for (int i = 1; i < ans.size(); i++) {
		cout << ans[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 39676
package main

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

var sc = bufio.NewScanner(os.Stdin)
var buff []byte

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buff, bufio.MaxScanTokenSize*1024)
	log.SetFlags(log.Lshortfile)
}

func main() {
	a := nextInt()
	b := nextInt()
	c := nextInt()
	d := nextInt()
	for {
		c -= b
		if c <= 0 {
			fmt.Println("Yes")
			break
		}
		a -= d
		if a <= 0 {
			fmt.Println("No")
			break
		}
	}
}

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

func nextFloat64() float64 {
	sc.Scan()
	f, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return f
}

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

func nextInts(n int) (r []int) {
	r = make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var MAX = math.MaxInt32

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}


Measured memory_bytes: 1756
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <unordered_map>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;

int main() {
    int N;
    scanf("%d", &N);
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            int ans = 0, tmp = (i ^ j);
            while (tmp) {
                  ans++;
                  tmp >>= 1;
            }
            printf("%d ", ans);
        }
        puts("");
    }
    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

int main(){
  int a, b;
  scanf("%d %d", &a, &b);

  if(a == b){
    printf("Draw\n");
  }
  else if(a == 1){
    printf("Alice\n");
  }
  else if(b == 1){
    printf("Bob\n");
  }
  else if(a > b){
    printf("Alice\n");
  }
  else if(b > a){
    printf("Bob\n");
  }

  return 0;
}


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

int main(){
string s;
int f=0;
cin >> s;
for(int i=0;i<3;i++){
    if(s[i] == '7'){
        cout << "Yes" << endl;
        f = 1;
        break;
    }
}
if(f == 0)cout << "No" << endl;
return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;
typedef long long ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

void Main() {
  Cin(int, n);
  vector<int> vi(n);
  for (auto& e : vi) cin >> e;

  sort(all(vi));
  int sum = accumulate(all(vi), 0) - vi.back();
  puts(vi.back() < sum ? "Yes" : "No");
  return;
}

int main() {
  cout << fixed << setprecision(15);
  Main();
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const int MOD = 1000000007;

int main(){
    str S,T;
    cin>>S;
    //cout<<S<<endl;
    cin>>T;
    REP(i,S.size()){
        char last = S[S.size()-1];
        //cout<<last<<endl;
        str newS;
        newS.push_back(last);
        REP(j,S.size()-1){
            newS.push_back(S[j]);
        }
        //cout<<newS<<endl;
        if(newS==T){
           cout<<"Yes";
            return 0;
        }
        S = newS;
    }
    cout<<"No";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int n;
    cin >> n;
    bool flag = false;
    FOR(i, 1, 10){
        if(n % i == 0 and n / i < 10) flag = true;
    }

    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var A, B int
	fmt.Scan(&A, &B)
	p := A + B
	m := A - B
	x := A * B
	max := p
	if max < m {
		max = m
	}
	if max < x {
		max = x
	}
	fmt.Println(max)
}


Measured memory_bytes: 512
import static java.util.Arrays.deepToString;

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	Scanner sc = new Scanner(System.in);
	public void run() {
		for (;sc.hasNext();) {
			int n = sc.nextInt();
			if (n == 0) break;
			for (int i = 0; i < n; i++) {
				solve();
			}
		}
	}
	
	int[][] pos = {
			{0,1,2,3},
			{1,0,3,2},
			{2,3,0,1},
			{3,2,1,0},
	};
	int[][] sign = {
		{1, 1, 1, 1},
		{1, -1, 1, -1},
		{1, -1, -1, 1},
		{1, 1, -1, -1},
	};
	
	
	void solve() {
		int[] t = new int[4]; for (int i = 0; i < 4; i++) t[i] = sc.nextInt();
		int[] s = new int[4]; for (int i = 0; i < 4; i++) s[i] = sc.nextInt();
		
		int[] m = new int[4];
		
		for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 4; j++) {
			m[ pos[i][j] ] += sign[i][j] * t[i] * s[j];
		}
		}
		System.out.println(m[0] + " " + m[1] + " " + m[2] + " " + m[3]);
	}
}

Measured memory_bytes: 23608
import Data.List
import qualified Data.ByteString.Char8 as B
import qualified Data.Array.IArray as A
import Data.Maybe
 
q = 10^9+7
 
(*%) x y = mod (x*y) q

main = do
 n <- readLn
 as <- map (fst. fromJust .  B.readInt) . B.words <$> B.getLine
 let [(i,_),(j,_)] = sort . head . filter ((==2) . length) . groupBy (\(_,x) (_,y) -> x==y) . sortOn snd . zip [0..] $ as
 let t = factTable (n+1)
 mapM_ (print . (`mod` q) . ss t n as (i,j)) [1..n+1]

ss :: A.Array Int (Int,Int) -> Int -> [Int] -> (Int,Int) -> Int -> Int
ss t n as (i,j) k = comb t (n+1) k - comb t (n-(j-i)) (k-1)

comb :: A.Array Int (Int,Int) -> Int -> Int -> Int
comb t n r
 | n < r = 0
 | otherwise = fst (t A.! n) *% snd (t A.! r) *% snd (t A.! (n-r))

pow x n
 | n == 0 = 1
 | odd n = x *% pow x (n-1)
 | otherwise = mod ((pow x (div n 2))^2) q

factTable :: Int -> A.Array Int (Int,Int)
factTable n = A.listArray (0,n) (zip facts factInvs)
 where
  facts = scanl (\acc x -> acc *% x) 1 [1..n]
  factInvs = map (\x -> mod (pow x (q-2)) q) facts

Measured memory_bytes: 57596
import Data.List (sort)

main = do
  getLine
  li <- getLine
  let ds = map read $ words li
  let answer = compute ds
  print answer

compute :: [Int] -> Int
compute ds = d2 - d1
  where
    ds1 = sort ds
    n2 = length ds `div` 2
    d1 : d2 : _ = drop (n2-1) ds1


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

using namespace std;

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

typedef long long ll;
typedef long double ld;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(12);
    ld a, b, c;
    cin >> a >> b >> c;
    if (c > a + b + 2 * sqrt(a) * sqrt(b)) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}



Measured memory_bytes: 256
n,k=map(int,input().split())
l=list(map(int,input().split()))
A=sorted(l)
x=[];d=[]
m=10**9+7
for i in range(n):
  ct=0
  for j in range(i+1,n):
    if l[i]>l[j]:ct+=1
  x.append(ct)
for i in range(n):
  d.append(A.index(l[i]))
ans=0
for i in range(n):
  ans+=((k*(2*x[i]+(k-1)*d[i]))//2)%m
print(ans%m)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using  namespace std;
typedef long long ll;
ll keta(ll n){
    ll keta=0;
    while(n!=0){
        keta++;  
        n = n/10;
    }
    return keta;
}
int main(){
    ll n, a, b, ans = 1000;
    cin >> n;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            a = i;
            b = n/i;
            ans = min(ans, max(keta(a), keta(b))); 
        }
    }

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


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define N 100
#define WHITE 0
#define BLACK 2
#define GRAY 1

void dfs();
void visit(int);
void push(int);
int pop();
int stackEmpty();
int next(int);

int n;
int time;
int top = -1;
int stack[N];
int color[N];
int d[N];  // find time
int f[N];  // complete time
int m[N][N] = {0};

int main() {
  int i, j;
  int k, u, v;

  // input
  scanf("%d", &n);
  for(i = 0; i < n; i++) {
    scanf("%d", &u);
    scanf("%d", &k);
    for(j = 0; j < k; j++) {
      scanf("%d", &v);
      m[u - 1][v - 1] = 1;
    }
  }

  dfs();

  // output

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

  return 0;
}

void dfs() {
  int i;
  
  for(i = 0; i < n; i++) {
    color[i] = WHITE;
  }
  time = 0;
  for(i = 0; i < n; i++) {
    if(color[i] == WHITE) visit(i);
  }
}

void visit(int r) {
  int u, v;
  static int cnt = 0;

  push(r+1);
  color[r] = GRAY;
  d[r] = ++time;
  while(stackEmpty() != 0) {
    u = stack[top];
    v = next(u);
    if(v != -1) {
      if(color[v-1] == WHITE) {
	push(v);
	color[v-1] = GRAY;
	d[v-1] = ++time;
      } 
    }
    else {
      color[u-1] = BLACK;
      f[u-1] = ++time;
      u = pop();
    }
  }
}

void push(int r) {
  top = top + 1;
  stack[top] = r;
}

int stackEmpty() {
  if(top == -1) return 0;
  else return 1;
}

int pop() {
  if(stackEmpty() == 0){
    printf("error\n");
    exit(4);
  }
  else {
    top = top - 1;
    return stack[top];
  }
}

int next(int u) {
  int i, j;

  // search the next vertex and return it
  for(i = 0; i < n; i++) {
    if((m[u - 1][i] == 1)&&(color[i] == WHITE)) {
      return i+1;
    }
  }
  return -1;
}



Measured memory_bytes: 2052
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPm(i,n) for(int i=(n)-1;i>=0;i--)
#define REP1(i,n) for(int i=1;i<=(n);i++)
typedef long long ll;

int main(){
    int H,W;
    cin >> H >> W;
    string S[50];
    REP(i,H) cin >> S[i];
    REP(i,H){
        REP(j,W){
            if(S[i][j] == '#') continue;
            int info = 0;
            FOR(k,-1,2){
                FOR(l,-1,2){
                    if(k == 0 && l == 0) continue;
                    if(i+k >= 0 && i+k < H && j+l >= 0 && j+l < W && S[i+k][j+l] == '#') info++;
                }
            }
            S[i][j] = (char)(info+48);
        }
    }
    REP(i,H) cout << S[i] << endl;
    return 0;
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n,k = LI()
    p = LI()
    t = 0
    for i in range(k):
        t += (p[i]+1) / 2
    r = t
    for i in range(k,n):
        t += (p[i]+1) / 2
        t -= (p[i-k]+1) / 2
        if r < t:
            r = t

    return r


print(main())





Measured memory_bytes: 27588
from math import sqrt
from sys import exit
N=int(input())
A=list(map(int,input().split()))

if len(A)==2:
    print(max(A))
    exit()

def gcd(a,b):
    if a<b: a,b=b,a
    if a%b==0: return b
    return gcd(b,a%b)
    
g=gcd(A[0],A[-1])

p=[]

for i in range(1,int(sqrt(g)+1)):
    if g%i==0:
        if i*i==g: p.append(i)
        else: p+=[i,g//i]
        
def ok(n):
    f=False
    for a in A[1:-1]:
        if a%n:
            if f: return False
            f=True
    return True
    
def GCD(L):
    if len(L)==1: return L[0]
    ans=gcd(L[0],L[1])
    if len(L)>2:
        for l in L[2:]:
            ans=gcd(ans,l)
    return ans

p.sort(reverse=True)
for num in p:
    if ok(num):
        ans=num
        break
p1=GCD(A[1:-1])
print(max([ans,gcd(p1,A[0]),gcd(p1,A[-1])]))


Measured memory_bytes: 63984
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
//typedef __int128_t lll;
using namespace std;

int main(int argc, char const *argv[]) {
  string s;std::cin >> s;
  ll a = 0, b = 0;
  re(i, s.size()) (s[i]=='1'?a:b)++;
  ll ans = max(a, b) - min(a, b);
  std::cout << s.size() - ans << '\n';
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  string s;
  cin >> s;
  string ans = "";
  ans += s[0];
  ans += to_string(s.size()-2);
  ans += s[s.size()-1];
  cout << ans << endl;
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> inline T bis(T ok, T ng, function<bool(T)> f, T eps = 1) { while (abs(ok - ng) > eps) { T mi = (ok + ng) / 2; (f(mi) ? ok : ng) = mi; } return ok; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int n;
  cin >> n;
  int now = 1;
  int ans = 0;
  rep(i, n) {
    int a;
    cin >> a;
    if (now == a) {
      now++;
    } else {
      ans++;
    }
  }
  if (now == 1) {
    cout << -1 << endl;
    return;
  }
  cout << ans << endl;
}


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

int dp[41][500][500];
signed main(){
    memset(dp,0x3f,sizeof(dp));
    int a,b,c;cin>>a>>b>>c;
    dp[0][0][0]=0;
    for(int d=0;d<a;d++){
	int e,f,g;cin>>e>>f>>g;
	for(int h=0;h<500;h++){
	    for(int i=0;i<500;i++){
		if(h<e||i<f)dp[d+1][h][i]=dp[d][h][i];
		else dp[d+1][h][i]=min(dp[d][h][i],dp[d][h-e][i-f]+g);
		}
	    }
	}
	int MIN=1<<29;
	for(int i=1;i*b<500&&i*c<500;i++){
	    MIN=min(MIN,dp[a][i*b][i*c]);
	    }
	    if(MIN==1<<29)puts("-1");
	    else cout<<MIN<<endl;
    }


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

#define mod 1000000007
#define pb push_back
#define mp make_pair
#define PI 3.14159265358979323
#define debug(x) cout<<"Case "<<x<<": "
#define For(i,n) for(long long i=0;i<n;i++)
#define Frabs(i,a,b) for(long long i = a; i < b; i++)
#define Frabr(i,a,b) for(long long i = a; i >=b; i--)
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef long long int           ll;
typedef long double             ld;
typedef unsigned long long int ull;
typedef vector <int>            vi;
typedef vector <ll>            vll;
typedef pair <int, int>        pii;
typedef pair <ll, ll>          pll;
typedef vector < pii >        vpii;
typedef vector < pll >        vpll;
typedef vector <string>         vs;

//Handle:cyber_rajat

int main(int argc, char const *argv[])
{
	sync;
	/*#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif*/
	ll n,w;
	cin>>n>>w;
	ll Value[n+5]={0},Weight[n+5]={0};
	//ll dp[n+5][w+5]={0};
	ll**dp = new ll*[n+5];
	for(ll i=0;i<=n+4;i++)
	{
		dp[i] = new ll[w+5];
		for(ll j=0;j<=w+4;j++)
			dp[i][j]=0;
	}
	for(ll i=1;i<=n;i++)
		cin>>Weight[i]>>Value[i];
	for(ll i=1;i<=n;i++)
	{
		for(ll j=1;j<=w;j++)
		{
			dp[i][j]=dp[i-1][j];
			if(Weight[i]<=j)
				dp[i][j]=max(dp[i-1][j],Value[i]+dp[i-1][j-Weight[i]]);
				
		}
	}
	cout<<dp[n][w]<<endl;
	return 0;
}


Measured memory_bytes: 82560
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main(void) {
	int text_num,now_text;
	char buffer[2000];
	int command_num,now_command;
	char command[200];
	char* cptr;
	char* hikisuu;
	int cursor;
	int buffer_length;
	int text_length;
	int word_flag;
	int i;
	scanf("%d ",&text_num);
	for(now_text=0;now_text<text_num;now_text++) {
		fgets(buffer,sizeof(buffer),stdin);
		cptr=strchr(buffer,'\n');
		if(cptr)*cptr=0;
		scanf("%d ",&command_num);
		cursor=0;
		buffer_length=strlen(buffer);
		for(now_command=0;now_command<command_num;now_command++) {
			fgets(command,sizeof(command),stdin);
			cptr=strchr(command,'\n');
			if(cptr)*cptr=0;
			hikisuu=strchr(command,' ');
			if(hikisuu) {
				*hikisuu=0;
				hikisuu++;
			} else hikisuu=&command[strlen(command)];

			if(strcmp(command,"forward")==0) {
				if(strcmp(hikisuu,"char")==0) {
					if(cursor<buffer_length)cursor++;
				} else if(strcmp(hikisuu,"word")==0) {
					word_flag=0;
					for(;cursor<buffer_length;cursor++) {
						if(isspace(buffer[cursor])) {
							if(word_flag)break;
						} else {
							word_flag=1;
						}
					}
				} else return 1;
			} else if(strcmp(command,"backward")==0) {
				if(strcmp(hikisuu,"char")==0) {
					if(cursor>0)cursor--;
				} else if(strcmp(hikisuu,"word")==0) {
					word_flag=0;
					for(cursor--;cursor>=0;cursor--) {
						if(isspace(buffer[cursor])) {
							if(word_flag)break;
						} else {
							word_flag=1;
						}
					}
					cursor++;
				} else return 1;
			} else if(strcmp(command,"insert")==0) {
				text_length=strlen(hikisuu)-2;
				if(hikisuu[0]!='\"' || hikisuu[text_length+1]!='\"') {
					return 1;
				}
				memmove(&buffer[cursor+text_length],&buffer[cursor],
					strlen(&buffer[cursor])+1);
				memmove(&buffer[cursor],&hikisuu[1],text_length);
				cursor+=text_length;
				buffer_length=strlen(buffer);
			} else if(strcmp(command,"delete")==0) {
				if(strcmp(hikisuu,"char")==0) {
					memmove(&buffer[cursor],&buffer[cursor+1],
						strlen(&buffer[cursor+1])+1);
				} else if(strcmp(hikisuu,"word")==0) {
					word_flag=0;
					for(i=0;cursor+i<buffer_length;i++) {
						if(isspace(buffer[cursor+i])) {
							if(word_flag)break;
						} else {
							word_flag=1;
						}
					}
					if(word_flag) {
						memmove(&buffer[cursor],&buffer[cursor+i],
							strlen(&buffer[cursor+i])+1);
					}
				} else return 1;
				buffer_length=strlen(buffer);
			} else return 1;
		}
		for(i=0;i<buffer_length;i++) {
			if(cursor==i)putchar('^');
			putchar(buffer[i]);
		}
		if(cursor==buffer_length)putchar('^');
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n-1); i >= 0; i--)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<60;
const int IINF = 1000000000;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){

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

    ll N; cin >> N;
    ll N2 = N;
    ll sum = 0;
    while (N > 0){
        sum += N % 10;
        N /= 10;
    }
    
    if(N2%sum == 0) cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 3580
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int x = saori.saori_hayami();
		if(x == 3 || x == 5 || x == 7){
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
		
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 23252
#include "bits/stdc++.h"
using namespace std;

/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int main() {
	int N, M;
	cin >> N >> M;
	vector<int>x;
	for (int i = 0; i < M; i++) {
		int a;
		cin >> a;
		x.push_back(a);
	}
	sort(x.begin(), x.end(),greater<int>());
	vector<int>strein;

	if (M == 1) {
		cout << 0;
		return 0;
	}

	for (int i = 0; i < M - 1; i++) {
		strein.push_back(x[i] - x[i + 1]);
	}
	sort(strein.begin(), strein.end(),greater<int>());
	long long int sum = 0;
	for (int i = N-1; i < M - 1; i++) {
		sum = sum + strein[i];
	}
	cout << sum;

}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

int main(){
    string s, t;
    cin >> s >> t;
    bool flag = true;

    for (int i = 0; i < s.length(); ++i) {
        if (s[i] != t[i]) flag = false;
    }
    if (s.length() + 1 != t.length()) flag = false;

    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
using namespace std;

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


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

const int inf = 1e9 + 9;
const int dx[] = {-1, 0, 0, 1};
const int dy[] = {0, -1, 1, 0};

int m[1010][1010];
int d[1010][1010];
int x[1010101], y[1010101];

int main()
{
  int h, w;
  cin >> h >> w;
  for (int i = 0; i < h + 2; i++){
    for (int j = 0; j < w + 2; j++){
      m[i][j] = inf;
      d[i][j] = 0;
    }
  }

  for (int i = 1; i <= h; i++){
    for (int j = 1; j <= w; j++){
      cin >> m[i][j];
    }
  }

  //?????±???????????????
  for (int i = 1; i <= h; i++){
    for (int j = 1; j <= w; j++){
      y[m[i][j]] = i;
      x[m[i][j]] = j;
    }
  }

  int ans = 0;
  for (int i = 1; i <= h * w; i++){
    int r = 0;
    for (int j = 0; j < 4; j++){
      int nx = x[i] + dx[j], ny = y[i] + dy[j];
      //2????????°?????????r???-1?????£??\?????????
      if (m[ny][nx] < i){
        if (r == 0) r = d[ny][nx];
        else if (r != d[ny][nx]) r = -1;
      }
    }

    //?°´??????????????????
    if (r == 0) d[y[i]][x[i]] = i;
    else d[y[i]][x[i]] = r;

    //?°????
    if (r == -1) ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 18804
import java.lang.reflect.Array;
import java.util.*;
import java.math.*;
import java.io.*;
import java.text.*;

class Main{
    class Node{
        long cost;
        int x;


       public Node(int x,long cost){
           this.x=x;
           this.cost=cost;

       }
    }
    //public static PrintWriter pw;
    public static PrintWriter pw = new PrintWriter(System.out);

    public static  void solve() throws IOException {
        //	pw=new PrintWriter(new FileWriter("C:\\Users\\shree\\Downloads\\small_output_in"));
        FastReader sc = new FastReader();
        int n=sc.I();
        long mx=0; long id=-1;
        long ans=0;
        for(int i=1;i<=n;i++){
            long a=sc.I(); long b=sc.I();
            if(a>mx){
                mx=a;
                id=b;
            }
        }
        ans=mx+id;
        pw.println(ans);

        pw.close();
    }


    public static void main(String[] args) {
        new Thread(null, new Runnable() {
            public void run() {
                try {

                    solve();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }, "1", 1 << 26).start();

    }

    static BufferedReader br;
    static long M = (long) 1e9 + 7;

    static class FastReader {

        StringTokenizer st;

        public FastReader() throws FileNotFoundException {
            //br=new BufferedReader(new FileReader("C:\\Users\\shree\\Downloads\\B-small-practice.in"));
            br = new BufferedReader(new InputStreamReader(System.in));

        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int I() {
            return Integer.parseInt(next());
        }

        long L() {
            return Long.parseLong(next());
        }

        double D() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        public boolean hasNext() throws IOException {
            while (st == null || !st.hasMoreTokens()) {
                String s = br.readLine();
                if (s == null) {
                    return false;
                }
                st = new StringTokenizer(s);
            }
            return true;
        }

    }
}

Measured memory_bytes: 43352
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Yes() std::cout << "Yes" << std::endl
#define No() std::cout << "No" << std::endl
#define Say(s) std::cout << s << std::endl
const ll MOD = 1000000007;
const ll INF = 1061109567;

int main()
{
    ll n;
    std::cin >> n;
    if (n == 1) {
        Say(0);
    } else {
        Say(1);
    }
    return 0;
}

Measured memory_bytes: 3564
def check(s):
    l = len(s)
    return True if s[:l / 2] == s[l / 2:] else False


S = raw_input()[:-1]
if len(S) % 2 != 0:
    S = S[:-1]
L = len(S)
for i in range(L):
    if check(S):
        break
    else:
        S = S[:-2]

print len(S)


Measured memory_bytes: 2568
N = int(input())
D = list(map(int, input().split()))
M = 998244353
from collections import Counter

if D[0] != 0:
    print(0)
    exit(0)

cd = Counter(D)
if cd[0] != 1:
    print(0)
    exit(0)

tmp = sorted(cd.items(), key=lambda x: x[0])

ans = 1
for kx in range(1, max(D)+1):
    # __, p = tmp[kx-1]
    # _, v = tmp[kx]
    p = cd[kx-1]
    v = cd[kx]
    # print("{}^{}".format(p, v))
    while v > 0:
        ans *= p
        ans %= M
        v -= 1
# print(cd)

# for kx in range(1, max(D)+1):
#     ans *= pow(cd[kx-1], cd[kx],M)
#     ans %= M

print(ans)

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

int main() {
    int N;
    cin >> N;
    vector<unsigned long long> A(N);
    for (int i=0; i<N; i++) {
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    reverse(A.begin(), A.end());
    unsigned long long ans = 0;
    for (int i=0; i<N-1; i++) {
        ans += A[(i+1)/2]; 
    }
    cout << ans << endl;
}

Measured memory_bytes: 4792