akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
using namespace std;

int main() {
  int up, middle, down;
  scanf(" %d %d %d", &up, &middle, &down);

  if ((up == 5 && middle == 5 && down == 7) ||
      (up == 5 && middle == 7 && down == 5) ||
      (up == 7 && middle == 5 && down == 5)) {
    cout << "YES" << "\n";
  } else {
    cout << "NO" << "\n";
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
void solve(){
  ll k,n;
  cin>>k>>n;
  vector<ll> v(n);
  for(ll i=0;i<n;i++)
    cin>>v[i];
  ll res=v[n-1]-v[0];
  for(ll i=0;i<n-1;i++)
    res=min(res,k-v[i+1]+v[i]);
  cout<<res;
}
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll q=1;
  for(ll i=1;i<=q;i++)
    solve();
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
#include<iostream>
#include<iomanip>
#include<cmath>
#include<vector>
#include<set>

using namespace std;
int main(){
  string s;
  cin >>s;

  int c0=0,c1=0;
  int n=s.length();
  for(int i=0;i<n;i++){
    if(s[i]=='0') c0++;
    else c1++;
  }
  
  cout<<min(c0,c1)*2<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>  // ver1.8
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
#define PAI 3.14159265358979
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() {
  cout << fixed << setprecision(14);
  int n;
  cin >> n;
  Vi a(n);
  rep(i,0,n) cin >> a[i];
  int now=0,ans=INF;
  repeq(i,-100,100){
    now = 0;
    rep(j,0,n){
      now += abs(i-a[j])*abs(i-a[j]);
    }
    ans = min(ans,now);
  }
  cout << ans << endl;
  return 0;
}


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

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define For(i,a,b) for(int (i)=(a); (i)<(b); (i)++)

int main() {
    int n;
    cin >> n;
    vector<pair<int, int> > v;
    REP(i,n) {
        string s;
        int j;
        cin >> s >> j;
        if (s == "S") {
            v.push_back(make_pair(0, j));
        }else if (s == "H") {
            v.push_back(make_pair(1, j));
        }else if (s == "C") {
            v.push_back(make_pair(2, j));
        }else {
            v.push_back(make_pair(3, j));
        }
    }
    
    sort(v.begin(), v.end());
    vector<pair<int, int> > w;
    REP(i,4) {
        For(j, 1, 14) {
            if(!binary_search(v.begin(), v.end(), make_pair(i, j))) {
                w.push_back(make_pair(i, j));
            }
        }
    }
    REP(i,w.size()) {
        switch (w[i].first) {
            case 0:
                cout << "S " << w[i].second << endl;
                break;
            case 1:
                cout << "H " << w[i].second << endl;
                break;
            case 2:
                cout << "C " << w[i].second << endl;
                break;
            case 3:
                cout << "D " << w[i].second << endl;
                break;
                
            default:
                break;
        }
    }
    return 0;
}

Measured memory_bytes: 1212
#![allow(unused_imports)]
use itertools::Itertools;
use proconio::{input, marker::*};
use std::cmp::*;
use std::collections::*;
use superslice::*;
fn main() {
    input! {
        a: usize, b: usize, n: usize,
    }
    let mut ans: usize = 0;
    let al = if b -1 > n {
        n
    } else {
        b - 1
    };
    let left = al * a / b;
    let right = (al / b) * a;
    ans = max(ans, left - right);
    println!("{}", ans);
}


Measured memory_bytes: 2096
N, A, B = map(int,input().split())
#print(N,A,B)


#print(length_N)

count = 0
for i in range(1,N+1):
  total = 0
  string_N = list(str(i))
  length_N = len(str(i))
  
  for j in range(length_N):
    total += int(string_N[j])
  if total >= A and total <= B:
    count += i

print(count)

Measured memory_bytes: 73552
package main

import (
	"fmt"
)

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

	is_all_even := true
	for i := 0; i < N; i++ {
		var a int
		fmt.Scan(&a)
		if a%2 == 1 {
			is_all_even = false
		}
	}

	if is_all_even {
		fmt.Println("second")
	} else {
		fmt.Println("first")
	}
}


Measured memory_bytes: 5504
#pragma warning disable
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System;
using System.Collections;
using static System.Math;
using static System.Console;
class E { static void Main() => new J(); }
class J
{
	const int Mod = 1000000007;
	int F() => int.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	public J()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var N = F();
		var s = new int[N];
		var sum = 0;
		for (var i = 0; i < N; i++) sum += s[i] = F();
		if (sum % 10 == 0)
		{
			var min = sum;
			foreach (var p in s) if (p % 10 != 0) min = Min(min, p);
			WriteLine(sum - min);
		}
		else WriteLine(sum);
	}
	long GCD(long a, long b)
	{
		var n = (ulong)Abs(a); var m = (ulong)Abs(b);
		if (n == 0) return (long)m; if (m == 0) return (long)n;
		int zm = 0, zn = 0;
		while ((n & 1) == 0) { n >>= 1; zn++; }
		while ((m & 1) == 0) { m >>= 1; zm++; }
		while (m != n)
		{
			if (m > n) { m -= n; while ((m & 1) == 0) m >>= 1; }
			else { n -= m; while ((n & 1) == 0) n >>= 1; }
		}
		return (long)n << Min(zm, zn);
	}
}

Measured memory_bytes: 13140
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int x = scan.nextInt();
			int y = scan.nextInt();
			if(x == 0 && y == 0){
				break;
			}
			if(x < y){
				int t = x;
				x = y;
				y = t;
			}
			int r = x % y;
			int count = 1;
			while(r != 0){
				x = y;
				y = r;
				r = x % y;
				count++;
			}
			System.out.println(y + " " + count);
		}
	}
}

Measured memory_bytes: 24648
# Solution reference: https://betrue12.hateblo.jp/entry/2019/07/05/012450
# Dinic reference: https://atcoder.jp/contests/abc091/submissions/5569121
class Dinic
  attr_accessor :g
  def initialize(v, inf = 2 ** 30)
    @V = v
    @inf = inf
    @g = Array.new(v) { [] }
    @level = Array.new(v, 0)
    @iter = Array.new(v, 0)
  end

  def add_edge(from, to, cap)
    @g[from] << {to: to, cap: cap, rev: @g[to].size}
    @g[to] << {to: from, cap: 0, rev: @g[from].size - 1}
  end

  def max_flow(s, t)
    flow = 0
    loop do
      bfs(s)
      return flow if @level[t] < 0
      @iter = Array.new(@V, 0)
      f = dfs(s, t, @inf)
      while f > 0
        flow += f
        f = dfs(s, t, @inf)
      end
    end
  end

  private
    def bfs(s)
      @level = Array.new(@V, -1)
      @level[s] = 0
      q = [s]
      until q.empty?
        v = q.shift
        @g[v].size.times do |i|
          e = @g[v][i]
          if e[:cap] > 0 && @level[e[:to]] < 0
            @level[e[:to]] = @level[v] + 1
            q << e[:to]
          end
        end
      end
    end

    def dfs(v, t, f)
      return f if v == t
      (@iter[v]...@g[v].size).each do |i|
        @iter[v] = i
        e = @g[v][i]
        if e[:cap] > 0 && @level[v] < @level[e[:to]]
          d = dfs(e[:to], t, [f, e[:cap]].min)
          if d > 0
            e[:cap] -= d
            @g[e[:to]][e[:rev]][:cap] += d
            return d
          end
        end
      end
      0
    end
end

INF = 10 ** 100
n = gets.to_i
dinic = Dinic.new(n + 2)
s = n
t = s + 1
jewels = gets.split.map(&:to_i)
reward = 0
# 罰金化して最小カット問題に帰着
jewels.each_with_index do |jewel, index|
  if jewel > 0
    reward += jewel
    # 残したら罰金 0
    dinic.add_edge(s, index, 0)
    dinic.add_edge(index, t, jewel)
  else
    dinic.add_edge(s, index, -jewel)
    # 割ったら罰金 0
    dinic.add_edge(index, t, 0)
  end
end

# 制約違反の時に、グラフがカットされないように INF の罰金を張る
1.upto(n) do |index|
  ngs = (index * 2).step(n, index).to_a
  ngs.each do |ng|
    dinic.add_edge(index - 1, ng - 1, INF)
  end
end

puts reward - dinic.max_flow(s, t)


Measured memory_bytes: 4092
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

int main(){
  int A, B, M; cin >> A >> B >> M;

  int a[A], b[B];
  for (int i = 0; i < A; i++) cin >> a[i];
  for (int i = 0; i < B; i++) cin >> b[i];

  int X[M], Y[M], C[M];
  for (int i = 0; i < M; i++){
    cin >> X[i] >> Y[i] >> C[i];
    X[i]--; Y[i]--;
  }
  
  int ans = 1e9;
  for (int i = 0; i < M; i++){
    ans = min(ans, a[X[i]] + b[Y[i]] - C[i]);
  }
  
  sort(a, a + A);
  sort(b, b + B);
  ans = min(ans, a[0] + b[0]);
  cout << ans  << endl;
  

  return 0;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
const unsigned int M = 1000000007;
using namespace std;
int main()
{
    
    long long int n,sum=0,ans=0;
    cin>>n;
    long long int a[n],i;
    
    for(i=0;i<n;i++)
    {cin>>a[i]; sum+=a[i];}
    for(i=0;i<n;i++)
    {
      sum-=a[i];
      ans+=((sum%M)*(a[i]%M))%M;
    }
    cout<<ans%M;
}

Measured memory_bytes: 5140
#define _USE_MATH_DEFINES
#include <math.h>
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    if((a + b) >= c)
    {
        cout << "Yes\n";
    }
    else
    {
        cout << "No\n";
    }
    
    return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.algorithm;
import std.array;
import std.conv;
import std.datetime;
import std.numeric;
import std.math;
import std.string;

string my_readln() { return chomp(readln()); }

void main()
{//try{
	auto tokens = split(my_readln());
	auto N = to!ulong(tokens[0]);
	auto W = to!ulong(tokens[1]);

	long[] w, v;
	foreach (i; 0..N)
	{
		auto tokens2 = split(my_readln());
		{
			w ~= to!long(tokens2[0]);
			v ~= to!long(tokens2[1]);
		}
	}

	ulong[int][] dp;
	dp.length = 110;
	dp[0][0] = 0;

	foreach (i; 0..N)
	{
		foreach (j; 0..100001)
		{
			auto tmp1 = dp[i].get(cast(int)(j - v[i]), long.max);
			auto tmp2 = dp[i].get(cast(int)j, long.max);
			ulong x   = min(tmp1 + w[i], tmp2);
			if (x <= W) dp[i+1][j] = x;
		}
	}

	auto keys = dp[N].keys.sort!"a > b"();
	writeln(keys[0]);
	stdout.flush();
	/*}catch (Throwable e)
	{
	writeln(e.toString());
	}
	readln();*/
}

Measured memory_bytes: 179068
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(m)]

a = [0] * n

for i in range(m):
    if ab[i][0] == 1:
        a[ab[i][1]] += 1
    if ab[i][1] == n:
        a[ab[i][0]] += 1

if max(a) == 2:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')


Measured memory_bytes: 53276
#include<stdio.h>

int main(){
	int S, h, m, s;
	scanf("%d", &S);
	h = S / 3600;
	m = S % 3600 / 60;
	s = S % 60;
	printf("%d:%d:%d",h, m, s);
	printf("\n");
	return 0;
}


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

using namespace std;

int main() {
	string S, alpha = { "abcdefghijklmnopqrstuvwxyz" };
	bool flag[26], flag2 = true;

	for (int i = 0; i < 26; i++) {
		flag[i] = false;
	}

	cin >> S;

	for (int i = 0; i < S.size(); i++) {
		for (int j = 0; j < alpha.size(); j++) {
			if (S[i] == alpha[j]) {
				flag[j] = true;
			}
		}
	}
	for (int i = 0; i < alpha.size(); i++) {
		if (flag[i] == false) {
			cout << alpha[i] << endl;
			flag2 = false;
			break;
		}
	}
	if (flag2 == true) {
		cout << "None" << endl;
	}


	return 0;
}

Measured memory_bytes: 512
import sys
input = sys.stdin.buffer.readline

N, M, Q = map(int, input().split())
L, R = [], []
X = [[0]*N for _ in range(N)]
for i in range(M):
    l, r = map(int, input().split())
    L.append(l-1)
    R.append(r-1)
    X[l-1][r-1] += 1
C =[[0]*(N+1) for _ in range(N)]
for i in range(N):
    for j in range(N):
        C[i][j+1] = C[i][j] + X[i][j]

for i in range(Q):
    p, q = map(int, input().split())
    ans = 0
    for j in range(p-1, q):
        ans += C[j][q] - C[j][p-1]
    print(ans)


Measured memory_bytes: 71492
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define mo 1000000007
#define mod2 1000000000
#define mod1 998244353
#define lol ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(x) (x).begin(), (x).end()
#define F(i, n) for (ll (i) = 0; (i) < (n); (i)++)
#define pb push_back
#define pf push_front
#define mp make_pair
#define f first
#define ss second

int main()
{
    ll n;cin >> n;
    ll ans = 0;
    for(ll i=1;i<=n;i++)
    {
        ans = ans + i*(n+1-i);
    }
    for(ll i=1;i<=n-1;i++)
    {
        ll l,r;
        cin >> l >> r;
        if(l>r) swap(l,r);
        ans = ans -(l*(n+1-r));
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 3652
MOD = 10**9+7
# dp[i][j] := Sの後ろからi桁を13で割った余りがjとなるようなものの個数
S = input()
l = len(S)
dp = [[0]*13 for _ in range(l+5)]
dp[0][0] = 1
mul = 1

for i in range(l):
    x = S[-(i+1)]
    if x == "?":
        for k in range(10):
            for j in range(13):
                dp[i + 1][(mul * k + j) % 13] += dp[i][j]
                dp[i + 1][(mul * k + j) % 13] %= MOD
    else:
        k = int(x) # これしか選ぶ余地なし
        for j in range(13):
            dp[i + 1][(mul * k + j) % 13] += dp[i][j]
            dp[i + 1][(mul * k + j) % 13] %= MOD
    mul = mul * 10 % 13
print(dp[len(S)][5]%MOD)


Measured memory_bytes: 62428
# frozen_string_literal: true

limit = 10_000
limit_sqrt = 100
numbers = Array.new(limit + 1, true)
numbers[0], numbers[1] = false
primes = []
numbers.each_with_index do |b, i|
  next unless b

  primes << i
  next if i > limit_sqrt

  (2..(limit / i)).each do |j|
    numbers[i * j] = false
  end
end
n = gets.to_i
input_numbers = n.times.map { gets.to_i }
res = input_numbers.count do |x|
  primes.none? { |prime| (x % prime).zero? && x / prime > 1 }
end
puts res



Measured memory_bytes: 7052
#include <iostream>
#include <math.h>
using namespace std;
int main(){
	int i,k[7],n;
	cin >> n;
	for(i=0;i<7;i++){
		k[i] = pow(2,i);
		if(k[i] > n ){
			break;
		}
	}

	cout << k[i-1] << endl;
	return 0;
}

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

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

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

  int a, b;
  cin >> a >> b;
  cout << ((a + b) + 2 - 1) / 2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int main(){
  int n;
  cin >> n;
  vector<mint> pbc(60, 0), mbc(60, 0);
  rep(i, n){
    ll a;
    cin >> a;
    rep(j, 60){
      if((a & (1LL << j)) == 0) mbc.at(j) += 1;
      else pbc.at(j) += 1;
    }
  }

  mint ans = 0;
  rep(i, 60){
    mint now = mbc.at(i) * pbc.at(i);
    mint add = 2;
    add = add.pow(i);
    ans += now * add;
  }
  cout << ans.x << endl;
  return 0;
}

Measured memory_bytes: 3620
import sys
N = int(raw_input())
upper = list()
lower = list()

right_end = 0
search_end = 0 
while True:
    if right_end == 0:
        for q in [['.', '.'], ['.', '#'], ['#', '.'], ['#', '#']]:
            print "".join(upper + [q[0]])
            print "".join(lower + [q[1]])
            sys.stdout.flush()

            r = raw_input()
            if r == 'T':
                upper.append(q[0])
                lower.append(q[1])
                break
            elif r == 'end':
                search_end = 1
                break
            if r == 'F' and q == ['#', '#']:
                right_end = 1
    else:
        for q in [['.', '.'], ['.', '#'], ['#', '.'], ['#', '#']]:
            print "".join([q[0]] + upper)
            print "".join([q[1]] + lower)
            sys.stdout.flush()
            
            r = raw_input()
            if r == 'T':
                upper.insert(0,q[0])
                lower.insert(0,q[1])
                break
            elif r == 'end':
                search_end = 1
                break
    if search_end == 1:
        break




Measured memory_bytes: 3036
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(v) v.begin(), v.end()
//#define mod 1000000007
#define mod2 1000000006
#define inf 1000000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<lli>
#define vii vector<int>
#define is indexed_set
#define eps 0.000001
#define endl '\n'
#define mo 998244353
#define pi 3.141592653589793
#define fi first
#define se second
using namespace std ;
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
lli m=1000000007;
lli mm(lli a, lli b,  lli mod) 
{ 
    long long res = 0; // Initialize result 
  
    // Update a if it is more than 
    // or equal to mod 
    a %= mod; 
  
    while (b) 
    { 
        // If b is odd, add a with result 
        if (b & 1) 
            res = (res + a) % mod; 
  
        // Here we assume that doing 2*a 
        // doesn't cause overflow 
        a = (2 * a) % mod; 
  
        b >>= 1; // b = b / 2 
    } 
  
    return res; 
} 

void solve()
{
	lli n;
	cin>>n;
	lli a[n];
	loop(i,0,n)cin>>a[i];
	lli pre[n];
	pre[n-1]=a[n-1];
	for(lli i=n-2;i>=0;i--){
		pre[i]=pre[i+1]+a[i];
		pre[i]=pre[i]%m;
	}
	lli ani=0;
	for(lli i=0;i<n-1;i++){
		ani+=mm((pre[i+1]%m),(a[i]%m),m);
		ani=ani%m;
	}
	cout<<ani;
}
 
int main()
{
/////////////////////////////////////
    fastio;
    
/////////////////////////////////////  
    lli t,m;
    //cin>>t;
    t=1;
    while(t--)
    {
    	solve();  
    	m++;  
    	cout<<endl;
    }
}

Measured memory_bytes: 5172
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];

        for (int i = 0; i < a.length; i++) {
            a[i] = sc.nextInt();
        }

        for (int i = a.length - 1; i >= 0; i--) {
            if (i == 0) {
                System.out.println(a[i]);
            } else {
                System.out.print(a[i] + " ");
            }
        }

        sc.close();
    }
}


Measured memory_bytes: 26276
#include <bits/stdc++.h>
#define range(i, l, r) for(int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint x;
    cin >> x;
    cout << (x < 1200 ? "ABC" : "ARC") << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
typedef long long ll;

using namespace std;

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

	if ( (a == b && b != c) || (b == c && a != b) || (a == c && a != b) ) {
		cout <<  "Yes";
	} else {
		cout << "No";
	}
	
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

#define N 100

int main(){

  int i,j,k,a[N],n,key;

  scanf("%d",&n);

  for(i=0;i<n;i++)scanf("%d",&a[i]);

  for(i=1;i<n;i++){
    
    for(k=0;k<n-1;k++){
      printf("%d ",a[k]);
    }
    printf("%d\n",a[k]);
    
    key = a[i];
    j = i - 1;
    while(j >= 0 && a[j] > key){
      a[j+1] = a[j];
      j--;
    }
    a[j+1] = key;
  }  
    for(k=0;k<n-1;k++){
      printf("%d ",a[k]);
    }
    printf("%d\n",a[k]);
 
  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const int maxn=100+100;
int n,a;
int tmp;
ll dp[55][3000];
int main(){
	cin>>n>>a;
	memset(dp,0,sizeof(dp));
	dp[0][0]=1;
	for(int i=1;i<=n;i++){
		cin>>tmp;
		for(int j=i-1;j>=0;j--){
			for(int k=0;k<=51*j;k++){
				dp[j+1][k+tmp]+=dp[j][k];
			}
		}
	}
	ll ans=0;
	for(int i=1;i<=n;i++){
		ans+=dp[i][i*a];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1536
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		int ans = 0;

		//1がaが大きい、2はｂが大きい、０は同じ
		if(a.length() > b.length()) {
			ans = 1;
		}else if(a.length() < b.length()) {
			ans = 2;
		}else {
			for (int i = 0; i < a.length(); i++) {
				if (a.charAt(i) > b.charAt(i)) {
					ans = 1;
					break;
				}else if (a.charAt(i) < b.charAt(i)) {
					ans = 2;
					break;
				}
			}
		}
		if(ans == 1) {
			System.out.println("GREATER");
		}else if(ans == 2) {
			System.out.println("LESS");
		}else {
			System.out.println("EQUAL");
		}
		sc.close();
	}
}

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

int main(){
    int N; cin >> N;
    vector<int> A(N); for(int i = 0; i < N; ++i) cin >> A[i];

    bool flg = false;

    for(int i = 0; i < N; ++i) {
        if(A[i] % 2 == 0 && flg == false) {
            if(A[i] % 3 == 0 || A[i] % 5 == 0) {
            } else {
                cout << "DENIED" << endl;
                flg = true;
            }
        }
    }

    if(flg == false) {
        cout << "APPROVED" << endl;
    }
}

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

using namespace std;
using ll = long long;
using ld = long double;
using Vec = vector<int>;

int main() {
    

int n;
cin>>n;
if(n<=599){
    cout<<8<<endl;
}
 else if(n<=799){
     cout<<7<<endl;
 }
 else if(n<=999){
     cout<<6<<endl;
 }
 else if(n<=1199){
     cout<<5<<endl;
 }
 else if(n<=1399){
     cout<<4<<endl;
 }
 else if(n<=1599){
     cout<<3<<endl;
 }
 else if(n<=1799){
     cout<<2<<endl;
 }
 else if(n<=1999){
     cout<<1<<endl;
 }

}
 

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

#define pb push_back
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define beg begin()
#define en end()
#define sz size()
#define mem(a,b) memset(a,b,sizeof a)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int main(){
	ios::sync_with_stdio(false);
	int a,b;
	cin>>a>>b;
	cout<<(a*b)-(a+b-1);cout<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include<string>
#include<cmath>
#include<stack>
#include <vector>
#include<queue>
#include <random>
using namespace std;


int main() {
	long long n,a,dig=-1,ans=0;
	cin >> n;
	n++;
	a = n;
	while (1) {
		n = n / 10;
		dig++;
		if (n == 0) {
			break;
		}
		a = n;
	}
	cout << dig * 9 + a - 1 << endl;

	return 0;
}


Measured memory_bytes: 256
let [| n; x; |] = stdin.ReadLine().Split() |> Array.map int
let xs = stdin.ReadLine().Split() |> Array.map int

let rec gcd x1 x2 =
    let x1,x2 = 
        if x1 >= x2 then x1, x2
        else x2, x1
    if x1 % x2 = 0 then
        x2
    else
        gcd x2 (x1 % x2)

xs |> Array.toList |> fun n -> x::n |> Seq.pairwise |> Seq.map ( fun (before, after) ->abs (after - before))
|> Seq.reduce gcd 
|> stdout.WriteLine

Measured memory_bytes: 30044
N,*A = $<.read.split.map(&:to_i)
M, B = 10**9+7, [0]*60

A.each{|a|
	60.times{|b|
		B[b]+=1 if a[b]==1
	}
}
p 59.downto(0).inject(0){|s,b|
	(s*2 + B[b]*(N-B[b])) % M
}


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



namespace Test1 {

    class ClassMain {
        static int[] syohai = new int[5];
        public static void Main(String[] args) {
            int n;
            while((n=int.Parse(Console.ReadLine()))!=0){
                int[] hands = new int[5];
                //How many times Gu-Choki-Pa appeared in the match. 
                int[] hand_appeared = new int[4];
                hands[0] = n;
                hand_appeared[n]++;

                for (int i = 0; i < 4; i++) {
                    int hand = int.Parse(Console.ReadLine());
                    hands[i + 1] = hand;
                    hand_appeared[hand]++;
                }
                //Draw check. 
                if (hand_appeared[1] == 5 || hand_appeared[2] == 5 || hand_appeared[3] == 5) {
                    for (int i = 0; i < 5; i++) { syohai[i] = 3; }
                }
                else if (hand_appeared[1] > 0 && hand_appeared[2] > 0 && hand_appeared[3] > 0) {
                    for (int i = 0; i < 5; i++) { syohai[i] = 3; }
                }
                    //Not Draw.
                else {
                    calc_syohai(hands);
                }
                for (int i = 0; i < 5; i++) {
                    Console.WriteLine(syohai[i]);
                }





            }

            
        }
        private static void calc_syohai(int[] hands) {
            for (int i = 0; i < 5; i++) {
                for (int j = 0; j < 5; j++) {
                    if (hands[i] != hands[j]) {
                        syohai[i] = (hands[j] - hands[i] == 1 || hands[j] - hands[i] == -2) ? 1 : 2;
                        break;
                    }
                }
            }
        }

      
    }


}

Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
const long long inf = 1000000001; // const 書き換え禁止
const double PI = 3.14159265358979323846; //M_PI はライブラリ

int main(void){
    string s;
    cin >> s;
    int count = 0;
    for(int i=0;i<3;i++){
        if(s[i] == 'R'){
            count++;
        }
    }
    if(s[0] == 'R' && s[1] == 'R' && s[2] == 'R'){
        cout << 3 << endl;
    }else if(s[0] == 'R' && s[2] == 'R'){
        cout << 1 << endl;
    }else{
        cout << count << endl;
    }
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
typedef long long ll;
const ll INF = 1e18L + 1;

int W[110];
int V[110];

int main()
{
  int n, w;
  cin >> n >> w;
  for (int i = 1; i <= n; i++)
  {
    cin >> W[i] >> V[i];
  }
  ll sumVal = 0;
  rep(i, n + 1) sumVal += V[i];
  vector<ll> dp(sumVal + 1, INF);
  dp[0] = 0;
  for (int i = 1; i <= n; i++)
  {
    for (int j = sumVal; j - V[i] >= 0; j--)
    {
      dp[j] = min(dp[j], dp[j - V[i]] + W[i]);
    }
  }
  ll ans = 0;
  for (ll i = 1; i <= sumVal; i++)
    if (dp[i] <= w)
    {
      ans = max(ans, i);
    }
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 1024
// template.cpp {{{
#include <bits/stdc++.h>
using namespace std;

using lint = long long;
#define reps(i, a, n) for (lint i = (a); i < (lint)(n); ++i)
#define rep(i, n) reps(i, 0, n)
struct pre_{pre_(){cin.tie(0);ios::sync_with_stdio(0);}} pre__;
// }}}

int n, m, d;
char field[110][110];
const int dx[] = {1, 0}, dy[] = {0, 1};
int res;

inline bool inside(int y, int x, int h, int w) {
  return 0 <= y && y < h && 0 <= x && x < w;
}

void dfs(int y, int x, int ddy, int ddx, int dep = 0) {
  if (field[y][x] == '#') return;
  if (dep == d - 1) {
    res++;
    return;
  }
  if (!inside(y + ddy, x + ddx, n, m)) return;

  dfs(y + ddy, x + ddx, ddy, ddx, dep + 1);
}

signed main() {
  cin >> n >> m >> d;
  rep(i, n) rep(j, m) {
    cin >> field[i][j];
  }

  rep(i, n) rep(j, m) {
    if (field[i][j] == '#') continue;
    rep(k, 2) {
      int ny = dy[k] + i, nx = dx[k] + j;
      if (!inside(ny, nx, n, m)) continue;
      dfs(i, j, dy[k], dx[k]);
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 3076
from math import pow, ceil
from itertools import product

X = int(input())
max_X = ceil(pow(10 ** 9, 1 / 5))

for a, b in product(range(-2 * max_X, 2 * max_X + 1), repeat=2):
    if (a ** 5 - b ** 5) == X:
        print(a, b)
        break


Measured memory_bytes: 82940
#include <bits/stdc++.h>
 
using namespace std;
 
const long long MOD = 1e9+7;
 
long long memo[2005][2005];
 
long long ncr(int i, int j){
	if(i < j){
		return 0;
	}else if(j == 0){
		return 1;
	}else if(memo[i][j] != -1){
		return memo[i][j];
	}else{
		return memo[i][j] = (ncr(i-1, j)+ncr(i-1, j-1))%MOD;
	}
}
 
int main(){
	int N, K;
	scanf("%d%d", &N, &K);
	
	int B = K;
	int R = N-K;
	
	memset(memo, -1, sizeof(memo));
	
	for(int i = 1; i <= K; i ++){
		printf("%lld\n", ncr(R+1, i)*ncr(B-1, i-1)%MOD);
	}
	
	return 0;
}

Measured memory_bytes: 31744
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if((a+b)%2 == 0){
        System.out.println((a+b)/2);
        }else{
            System.out.println("IMPOSSIBLE");
        }
    }
}

Measured memory_bytes: 21972
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n, k = na()
a = na()

ans = 0
for i in range(n):
    bl = 0
    al = 0
    for j in range(i):
        if a[j] < a[i]:
            bl += 1
    for j in range(i + 1, n):
        if a[j] < a[i]:
            al += 1
    
    ans += al * (k * (k + 1) // 2) + bl * (k * (k - 1) // 2)
    ans %= mod

print(ans % mod)

Measured memory_bytes: 3188
#include<stdio.h>

int ifok(int a);

int main()
{
	int s,y,m;
	scanf("%d",&s);
	y=s/100;
	m=s%100;
	if(ifok(y)&&ifok(m))printf("AMBIGUOUS");
	else if(ifok(y)&&!ifok(m))printf("MMYY");
	else if(!ifok(y)&&ifok(m))printf("YYMM");
	else if(!ifok(y)&&!ifok(m))printf("NA");
}

int ifok(int a)
{
	if(a>12||a==0)return 0;
	else return 1;
}

Measured memory_bytes: 128
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
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(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#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 EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	int n, m; cin >> n >> m;
	vector<LL> a(n+3,0);

	for (int i = 0; i < m; i++) {
		int v; cin >> v;

		a[v] = 1;
	}

	vector<LL> dp(n+3,0);
	dp[0] = 1;

	for (int i = 0; i < n; i++) {
		if (a[i+1] == 0) {
			dp[i + 1] += dp[i];
			dp[i + 1] %= MOD;
		}

		if (a[i + 2] == 0) {
			dp[i + 2] += dp[i];
			dp[i + 2] %= MOD;
		}
	}

	cout << dp[n] << endl;

	return 0;
}

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

int main(){
  int N; cin >>N;
  int h[N];
  for(int i=0;i<N;i++){
    cin >> h[i];
  }

  int dp[100010]; dp[0]=0; dp[1]=0;
  dp[2]=abs(h[1]-h[0]);
  for(int i=2;i<N;i++){
    dp[i+1] = min(dp[i]+abs(h[i]-h[i-1]), dp[i-1]+abs(h[i]-h[i-2]));
  }
  cout << dp[N] << endl;
  return 0;
}


Measured memory_bytes: 1024
using System;
using System.Linq;

class A
{
	static void Main()
	{
		var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
		Console.WriteLine(a[0] >= 13 ? a[1] : a[0] >= 6 ? a[1] / 2 : 0);
	}
}


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

int main() {
  int D;
  cin>>D;
  if(D==22){
    cout<<"Christmas Eve Eve Eve"<<endl;
  }
  if(D==23){
    cout<<"Christmas Eve Eve"<<endl;
  }
  if(D==24){
    cout<<"Christmas Eve"<<endl;
  }
  if(D==25){
    cout<<"Christmas"<<endl;
  }

}

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

int main()
{
   int n, k, q, *a, *p, w;

   cin >> n >> k >> q;

   a = new int[q];
   p = new int[n];

   for(int i=0; i<n; i++){
     p[i] = 0;
   }
/*   for(int i=0; i<q; i++){
     cin >> w;
     for(int j=0; j<n; j++){
        if(j != w-1){
          p[j] = p[j]-1;
        }
     } 
   }
*/

   for(int i=0; i<q; i++){
     cin >> w;
     p[w-1]++;
   }

   for(int i=0; i<n; i++){
     p[i] = k - (q - p[i]);
   }


   for(int i=0; i<n; i++){
      if(p[i]<=0){ cout << "No" << endl;}
      else{cout << "Yes" << endl;}
   }

	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
using namespace std;
int main(){
  int N, ac=0, wa=0, tle=0, re=0;
  cin >> N;
  string S;
  for(int i=0; i<N; i++){
    cin >> S;
    if(S == "AC") ac++;
    else if(S == "WA") wa++;
    else if(S == "TLE") tle++;
    else re++;
  }
  
  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;
  return 0;
}

Measured memory_bytes: 3524
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
using Graph = vector<vector<int>>;

int main() {
    // 頂点数と辺数
    int N, M; cin >> N >> M;

    // グラフ入力受取 (ここでは無向グラフを想定)
    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
      　--a;
        --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    // BFS のためのデータ構造
    vector<int> dist(N, -1); // 全頂点を「未訪問」に初期化
    queue<int> que;
    vector<int> pre(N,-1);
    // 初期条件 (頂点 0 を初期ノードとする)
    dist[0] = 0;
    que.push(0); // 0 を橙色頂点にする

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int nv : G[v]) {
            if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない
            pre[nv] = v;
            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[nv] = dist[v] + 1;
            que.push(nv);
        }
    }
    cout<<"Yes"<<endl;
    // 結果出力 (各頂点の頂点 0 からの距離を見る)
    for (int v = 1; v < N; ++v){
      
      cout<<pre[v]+1<<endl;
    }
}

Measured memory_bytes: 10340
#include <stdio.h>

#define M 120
#define NIL -1
#define INF 100000
#define black 1
#define white 0
#define gray 2

int prim(int);

int find[M];
int color[M];
int p[M];
int A[M][M];

int main(){
  int len;
  int i,j;
  

  scanf("%d",&len);

  for(i=0;i<len;i++){
    for(j=0;j<len;j++){
      scanf("%d",&A[i][j]);
      if(A[i][j]==NIL) A[i][j]=INF;
    }
  }
  printf("%d\n",prim(len));
  
  return 0;
}

int prim(int len){
  int i;
  int mincost,u,sum=0;
  
  for(i=0;i<len;i++){
    find[i]=INF;
    color[i]=white;
    p[i]=NIL;
  }

  find[0]=0;

  while(1){
    mincost=INF;
    u=NIL;
    for(i=0;i<len;i++){
      if(color[i]!=black && find[i]<mincost){
	mincost=find[i];
	u=i;
      }
    }
    
    if(u==NIL) break;
    color[u]=black;
    
    for(i=0;i<len;i++){
      if(A[u][i]!=INF && color[i]!=black){
	if(A[u][i] < find[i]){
	  p[i]=u;
	  find[i]=A[u][i];
	  color[i]=gray;
	}
      }
    }
  }
  
  for(i=0;i<len;i++){
    if(p[i]!=NIL) sum+=A[i][p[i]];
  }
  
  return sum;
}



Measured memory_bytes: 2108
N=int(input())
A1=list(map(int, input().split()))
A2=list(map(int, input().split()))
max_candy=0
for i in range (N):
    output=sum(A1[0:i+1])+sum(A2[i:N])
    if output>=max_candy:
        max_candy=output

print(max_candy)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int a[10],s=0;
int main()
{
	cin>>a[1]>>a[2]>>a[3];
	sort(a+1,a+4);
	while(a[1]!=a[2]||a[2]!=a[3])
	{
		if(a[2]==a[3])
		{
			a[1]=a[1]+2;
			s++;
		}
		else
		{
			a[2]++;
			a[1]++;
			s++;
		}
		sort(a+1,a+4);
	}
	cout<<s;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define ll long long
#define Arman_Sykot ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
 
using namespace std;

int main()
{
/*********************/
// Author:
        Arman_Sykot;
/*********************/
    
    string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (s[s.size() - 1] == 's') {
			cout << s << "es" << "\n";
			break;
		}
		else {
			cout << s << 's' << "\n";
			break;
		}
	}
	
	return 0;
}


Measured memory_bytes: 3648
#座標圧縮
#a=list
#flag=0...座圧済みa flag=1...座圧指標dict
def position_zip(a,flag):
  j=0
  d={}
  for i in sorted(a):
    if i in d:continue
    d[i]=j
    j+=1
  if flag==1:return d
  return [d[i] for i in a]

#-----BinaryIndexedTree-----(0-indexed)
#O(logN)で累積和取得と値の更新
#add(i,x)...i番目にxを加算
#sum(i,j)...[i,j]の累積和を取得
class BinaryIndexedTree:
  def __init__(self,n):
    self.bit=[0]*n
  def add(self,i,x):
    i+=1
    while i<=len(self.bit):
      self.bit[i-1]+=x
      i+=i&-i
  def sum_sub(self,i):
    a=0
    i+=1
    while i:
      a+=self.bit[i-1]
      i-=i&-i
    return a
  def sum(self,i,j):
    a=self.sum_sub(j)
    if i!=0:a-=self.sum_sub(i-1)
    return a

n,k=map(int,input().split())
a=[int(input())-k for _ in range(n)]
b=[0]
for i in a:b.append(b[-1]+i)
b=position_zip(b,0)
bit=BinaryIndexedTree(n+1)
ans=0
for i in b:
  ans+=bit.sum(0,i)
  bit.add(i,1)
print(ans)

Measured memory_bytes: 45972
#include<cmath>
#include<ctime>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define mem(a,b) memset(a,b,sizeof(a))
#define  For(i,a,b) for(int i=a,i##E=b;i<=i##E;++i)
#define rFor(i,a,b) for(int i=a,i##E=b;i>=i##E;--i)
using namespace std;
typedef long long LL;
const int N=110;
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
template<typename T>inline void read(T &x)
{
	x=0;int _f(0);char ch=getchar();
	while(!isdigit(ch))_f|=(ch=='-'),ch=getchar();
	while( isdigit(ch))x=x*10+ch-'0',ch=getchar();
	x=_f?-x:x;
}
inline void file()
{
#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
#endif
}
char s[N][N];
int n,m,c[30],nd1,nd2,nd4;
int main()
{
	read(n),read(m);
	For(i,1,n)scanf("%s",s[i]+1);
	For(i,1,n)For(j,1,m)c[s[i][j]-'a'+1]++;
	nd4=(n/2)*(m/2);
	nd2=((n&1)?m/2:0)+((m&1)?n/2:0);
	nd1=((n&1)&&(m&1))?1:0;
	For(i,1,26)
	{
		while(nd4&&c[i]>=4)
			c[i]-=4,nd4--;
		while(nd2&&c[i]>=2)
			c[i]-=2,nd2--;
		while(nd1&&c[i])
			c[i]--,nd1--;
	}
	if(!nd4&&!nd2&&!nd1)
		puts("Yes");
	else
		puts("No");
	return 0;
}


Measured memory_bytes: 256
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():

    N = in_n()
    S = list(in_s())[::-1]

    cb = [0] * (N + 1)
    cw = [0] * (N + 1)
    for i in range(N):
        if S[i] == '#':
            cb[i + 1] = 1
        else:
            cw[i + 1] = 1

    for i in range(N):
        cb[i + 1] += cb[i]
        cw[i + 1] += cw[i]

    ans = S.count('.')
    for i in range(N + 1):
        ans = min(ans, cw[i] + cb[N] - cb[i])

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 26216
#include <stdio.h>
int main (){
  int n,m,p[1000],i,j,sum,k;
  while (1){
    scanf("%d %d",&n,&m);
    if(n==0 && m==0)break;

    for(i=0;i<n;i++)scanf("%d",&p[i]);

    for(i=0;i<n-1;i++){
      for(j=0;j<n-i-1;j++){
	if(p[j]<p[j+1]){
	  k=p[j];
	  p[j]=p[j+1];
	  p[j+1]=k;
	}
      }
    }
    
    for(i=0;i<n;i++){
      if((i+1)%m==0){
	p[i]=0;
      }
    }
    
    sum=0;

    for(i=0;i<n;i++){
      sum+=p[i];
    }

    printf("%d\n",sum);
  }
  return 0;
}

Measured memory_bytes: 604
#include<stdio.h>
int main(void)
{
    int l, a, b, c, d,x=0,y=0,g=0;
    scanf("%d%d%d%d%d", &l, &a, &b, &c, &d);
    if (a%c == 0) {
        x = a / c;
    }
    else {
        x = a / c + 1;
    }
    if (b%d == 0) {
        y = b / d;
    }
    else {
        y = b / d + 1;
    }
    if (x > y){
        g = l - x;
    }
    else{
        g = l - y;
    }
    printf("%d\n", g);
    return 0;
}

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

const ll maxs = 5e5+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e15;

#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define endl '\n'

void pre(){
    
}

void solve(){
    
    string s,t;
    cin >> s >> t;
    for(ll i=0;i<s.size();i++){
        if(s[i] != t[i]){
            cout << "No";
            return;
        }
    }
    cout << "Yes";


}

int main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input00.txt","r",stdin);
    // #endif
    IOS;
    pre();
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();   
    }
    return 0;
}

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

int main(){
  char s[3]; int nya = 0;
  for(int i = 0;i < 3;i++) {
    std::cin >> s[i];
    if(s[i] == 'o') nya++;
  }

  int ans = 700 + 100 * nya;
  std::cout << ans;
  std::cout << "\n";
  
  return 0;
}


Measured memory_bytes: 256