akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int64_t k;

int64_t gcd(int64_t a, int64_t b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}

int64_t gcd3(int64_t a, int64_t b, int64_t c) {
    return gcd(gcd(a, b), c);
}

void solve() {
    int64_t ans = 0;
    for (int64_t i = 1; i <= k; i++) {
        for (int64_t j = 1; j <= k; j++) {
            for (int64_t l = 1; l <= k; l++) {
                ans += gcd3(i, j, l);
            }
        }
    }
    cout << ans << endl;
}

int main() {
    cin >> k;
    solve();
}

Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   " << endl;
		for(int j=0; j<v[i].size(); j++){
			cout << v[i][j] << "   ";
		}
		cout << endl;
	}
}




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

	const int H_MAX = 10000;
	const int B_MAX = 10000;
	const int INF = H_MAX*B_MAX+1;
	//dp[n][h]: 0~n-1番目までの魔法を考慮して体力hを減らすのに必要な最小魔力
	vector<vector<int>> dp(N+1, vector<int>(H+H_MAX+1, INF));
	dp[0][0] = 0;//魔法使わないで体力0を減らすのに必要な魔力は0
	for(int n=0; n<=N; n++) dp[n][0] = 0;

	// for(int n=0; n<N; n++){
	// 	for(int h=0; h<=H+H_MAX; h++){
	for(int h=0; h<H+H_MAX; h++){
		for(int n=0; n<N; n++){
			dp[n+1][h] = min(dp[n+1][h], dp[n][h]+0*B[n]);//魔法n番を使わない
			if(h+A[n] < (int)dp[0].size()) dp[n+1][h+A[n]] = min(dp[n+1][h+A[n]], dp[n][h] + B[n]);//魔法nを使う(1回目)
			if(h+A[n] < (int)dp[0].size()) dp[n+1][h+A[n]] = min(dp[n+1][h+A[n]], dp[n+1][h]+B[n]);//魔法nを使う(2回目以降)(1回目の時のh+A[n]が今回のhと等しくなる時に影響)
		}
	}
	//print_vec2(dp);
	int ans = INF;
	for(int h=H; h<=H+H_MAX; h++){//答えは体力H以上削った場合の最小消費体力
		ans = min(ans, dp[N][h]);
	}
	cout << ans << endl;

}


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

string s, t, ans;
int dp[3010][3010];

int f(int n, int m) {
	if (n<0 || m<0) return 0;
	if (dp[n][m] != -1) return dp[n][m];
	if (s[n] == t[m]) dp[n][m] = 1 + f(n-1, m-1);
	else dp[n][m] = max(f(n-1, m), f(n, m-1));
	return dp[n][m];
}

void rec(int n, int m) {
	if (n<0 || m<0) return;
	if (s[n] == t[m]) {ans = s[n] + ans; rec(n-1, m-1);}
	else if (f(n-1, m) > f(n, m-1)) rec(n-1, m);
	else rec(n, m-1);
}

int main() {
	cin >> s;
	cin >> t;
	memset(dp,-1, sizeof(dp));
	rec(s.length()-1, t.length()-1);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 36096
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void input() {

    }

    void solve() {
        input();
        ll L, R;
        cin >> L >> R;
        if (R - L > 3000) {
            cout << 0 << endl;
            return;
        }

        ll ans = INF;
        for (ll i = L; i < R; ++i) {
            for (ll j = i + 1; j <= R; ++j) {
                ll tmp = (i * j) % 2019;
                chmin(ans, tmp);
            }
        }

        cout << ans << endl;
    }
};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)



















int main(){
    ll k, a, b;
    cin >> k >> a >> b;
    for(ll i = a; i <= b; i++){
        if(i % k == 0){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

const int INF = 1 << 24;
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

typedef unsigned long long ull;
typedef std::pair<int,int> P;

int N, M, H[1501], W[1501];
std::map<int,int> sH;

int main(){
    while(std::cin >> N >> M, N){
        sH.clear();

        H[0] = 0;
        FOR(i, 1, N+1){
            std::cin >> H[i];
            H[i] += H[i-1];
        }

        REP(i, N+1){
            FOR(j, i+1, N+1){
                sH[H[j]-H[i]]++;
            }
        }

        W[0] = 0;
        FOR(i, 1, M+1){
            std::cin >> W[i];
            W[i] += W[i-1];
        }

        int res = 0;
        REP(i, M+1){
            FOR(j, i+1, M+1){
                res += sH[W[j]-W[i]];
            }
        }

        std::cout << res << std::endl;
    }
}

Measured memory_bytes: 19044
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.IO.Pipes;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorders
{
	public class Program
	{
		static void Main(string[] args)
		{
			var ab = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
			int ans = (ab[0] + ab[1] + 1) / 2;
			Console.WriteLine(ans);
		}
	}
}

Measured memory_bytes: 13268
N = gets.to_i
lists = []
lists1 = []
lists2 = []
N.times do
  s, t, u = gets.split.map(&:to_i)
  if u != 0
    lists1 << [s, t, u]
  else
    lists2 << [s, t, u]
  end
  lists << [s, t, u]
end

(0..100).each do |i|
  (0..100).each do |j|
    pre = nil
    check = true
    dist = nil
    lists.each do |x, y, z|
      next if z == 0
      dist = z + (i - x).abs + (j - y).abs
      if (pre ||= dist) != dist
        check = false
        break
      end
    end
    next if !check

    lists.each do |x, y, z|
      next if z != 0
      dist = (i - x).abs + (j - y).abs
      if pre > dist
        check = false
        break
      end
    end
    if check
      puts "#{i} #{j} #{pre}"
      exit
    end
  end
end

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

int main(){
  ll a,v,b,w,t;
  cin >>a >>v >>b >>w >>t;
  ll d = abs(a-b);
  ll d2 = (v-w)*t;
  if(d<=d2) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

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

using namespace std;
using ll = long long;

using Field = vector<vector<int>>;
using Graph = vector<vector<int>>;
using VI = vector<int>;
using VC = vector<char>;
using PI = pair<int, int>;

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

struct Island {
    int a, b;
};

const int mod = 1000000007;



int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n, m; cin >> n >> m;
    vector<Island> ab(m);
    REP(i, m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        ab.at(i).a = a;
        ab.at(i).b = b;
    }

    sort(ab.begin(), ab.end(), [] (const Island &x, const Island &y) {return x.b < y.b;});

    int ans = 1;

    int a = ab.at(0).a;
    int b = ab.at(0).b;

    REP(i, m) {
        if (ab.at(i).a < b || ab.at(i).b < b) continue;
        b = ab.at(i).b;
        ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
K, N = map(int, input().split())
Nlist = list(map(int, input().split()))
ans = min(Nlist[N-1]-Nlist[0], Nlist[0]+K-Nlist[N-1])
sa = Nlist[0]
for i in range(1, N):
    if Nlist[i]-sa > ans:
        ans = Nlist[i]-sa
    sa = Nlist[i]

print(K-ans)


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

/*
到達できないケースは、次の2通り
1.必要移動距離が長くて、時間が足りない場合。
2.余った時間が、奇数の場合。

方針は、全予定に対して、上の条件に抵触しないかどうかチェックすればよい。
*/


int main(){
	int n;
	cin >> n;
	
	bool flag = true;
	int st = 0, sx = 0, sy = 0;
	for(int i=0; i<n; i++){
		int t, x, y;
		cin >> t >> x >> y;
		int d = (x - sx) + (y - sy);
		if(t - st < d) flag = false;
		else if(t - st != d && (t - st - d) % 2) flag = false;
	}
	
	if(flag) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}

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

using namespace std;

int B(string& S, string& T) {
	int cnt = 0;
	for (int i = 0; i < S.length(); i++)
		cnt += S[i] != T[i];
	return cnt;
}

int main() {
	string S, T;
	cin >> S >> T;
	cout << B(S, T);
	return 0;
}

Measured memory_bytes: 3916
import java.util.Scanner;

public class Main {
	public static void main(String [] args) {
		Scanner stdIn = new Scanner(System.in);
		int W = stdIn.nextInt();
		int H = stdIn.nextInt();
		int x = stdIn.nextInt();
		int y = stdIn.nextInt();
		int r = stdIn.nextInt();
		
		while(W <= 0 || W > 100 || H <= 0 || H > 100 || r <= 0 || r > 100
				|| x < -100 || x > 100 || y < -100 || y > 100){
			W = stdIn.nextInt();
			H = stdIn.nextInt();
			x = stdIn.nextInt();
			y = stdIn.nextInt();
			r = stdIn.nextInt();
		}
		
		if( 0 <= x - r && W >= x + r && 0 <= y - r && H >= y + r ) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		
		
	}
}


Measured memory_bytes: 26392
#include <iostream>
#include<algorithm>
#include<vector>
#include<string>
#include <cmath>
#include <iomanip>
#include <math.h>
using namespace std;

int main() {
	long double N, K, sum = 0;
	long long int cnt;
	cin >> N >> K;
	if (K <= 1) {
		cout << 1.0000000000000 << endl;
		return 0;
	}
	for (long double i = 1; i <= N; i++) {
		if (i >= K) sum += 1 / N;
		else {
			cnt = ceill(log2(K / i));
			sum += (pow(0.5, cnt)) / N;
		}
	}
	cout << setprecision(12) << sum << endl;
	return 0;
}

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

const int MOD = 1e+9 + 7;

int main(){
    ll n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    ll cnt = 0;
    vector<ll> smaller(n, 0);
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            if(a[i] > a[j]){
                cnt++;
                smaller[i]++;
            } else if(a[i] < a[j]){
                smaller[j]++;
            }
        }
    }
    cnt = cnt * k % MOD;
    for(int i = 0; i < n; i++){
        ll temp = (k * (k-1) / 2) % MOD;
        temp = temp * smaller[i] % MOD;
        cnt = cnt + temp % MOD;
    }
    cout << cnt % MOD << endl;
    return 0;
}

Measured memory_bytes: 3636
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.HashSet;
import java.util.Set;
import java.math.*;

public class Main {
    private static Scanner sc;

    public static void main(final String[] args) {
        final Main instance = new Main();
        sc = instance.new Scanner();
        instance.solve();
    }

    private class Scanner {
        String[] s;
        int i;
        BufferedReader br;
        String regex = " ";

        public Scanner() {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        @Override
        protected void finalize() throws Throwable {
            try {
                super.finalize();
            } finally {
                destruction();
            }
        }

        private void destruction() throws IOException {
            if (br != null)
                br.close();
        }

        public String next() throws IOException {
            if (i < s.length)
                return s[i++];
            String st = br.readLine();
            while (st == "")
                st = br.readLine();
            s = st.split(regex, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public Long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }

        public Double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }

        public long[] nextLongArray(int n) throws NumberFormatException, IOException {
            long[] ret = new long[n];
            for (int i = 0; i < n; i++) {
                ret[i] = nextLong();
            }
            return ret;
        }

        public int[] nextIntArray(int n) throws NumberFormatException, IOException {
            int[] ret = new int[n];
            for (int i = 0; i < n; i++) {
                ret[i] = nextInt();
            }
            return ret;
        }
    }

    private void solve() {
        try {
            String n = sc.next();
            if (Character.isUpperCase(n.charAt(0))) {
                System.out.println("A");
            } else {
                System.out.println("a");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

}


Measured memory_bytes: 32708
# 入力
N=int(input())

l1=[]
for i in range(N):
  l1.append(input())

M=int(input())

l2=[]
for i in range(M):
  l2.append(input())

# 考えられる最低得点で初期化
mx=-len(l2)

for x in l1:
  # 得点
  a=l1.count(x)

  # 失点
  b=l2.count(x)

  mx=max(mx,a-b)

# 得点が負だった場合は0を出力
print(max(mx,0))

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

int main(){
    int N;
    cin >> N;
    set<int> s;
    for(int i = 0; i < N; i++){
        int d;
        cin >> d;
        s.insert(d);
    }
    cout<<s.size() <<endl;
}

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

int main(){
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> ab(n);
    rep(i,n) cin >> ab[i].first >> ab[i].second;
    vector<pair<int, int>> cd(m);
    rep(i,m) cin >> cd[i].first >> cd[i].second;

    rep(i,n){
        auto p = ab[i];
        int mini = INT_MAX, ans = 0;
        rep(j,m){
            auto cp = cd[j];
            if(mini > (abs(cp.first - p.first) + abs(cp.second - p.second))){
                mini = abs(cp.first - p.first) + abs(cp.second - p.second);
                ans = j;
            }
        }
        cout << ans+1 << endl;
    }
}


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

using namespace std;

int main(){
    int k,n;
    cin >> k >> n;
    vector<int> v(n);
    for(int i=0;i<n;i++)cin >> v[i];
    int min1=INT_MAX;
    for(int i=0;i<n;i++){
       if(i==n-1){
          int a =k-(k - v[i] + v[0]);
          int b = k - (v[i]-v[i-1]);
          min1=min({a,b,min1});
           
       }
       else if(i==0){
           int a = k -(k-v[n-1] + v[0]);
           int b = k - (v[i+1]-v[i]);
           min1=min({a,b,min1});
       }
       else{
           int a = k - (v[i]-v[i-1]);
           int b = k- (v[i+1]-v[i]);
           min1=min({a,b,min1});
       
       } 
    }
    cout << min1;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<ll> p;
ll a[505],n,k,sum,sum1[505],sum2[505];
bool check(ll x){
    vector<pair<ll,ll>> b;
    b.push_back({0,0});
    for(int i=1;i<=n;i++){
        if(a[i]%x==0) b.push_back({0,0});
        else b.push_back({a[i]%x,x-a[i]%x});
    }
    sort(b.begin(),b.end());
    for(int i=1;i<=n;i++){
        sum1[i]=sum1[i-1]+b[i].first;
        sum2[i]=sum2[i-1]+b[i].second;
    }
    for(int i=1;i<=n;i++){
        if(sum1[i]==sum2[n]-sum2[i]){
            return sum1[i]<=k;
        }
    }
    return false;
}
int main(){
    ll i;
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    for(i=1;i*i<sum;i++){
        if(sum%i==0){
            p.push_back(i);
            p.push_back(sum/i);
        }
    }
    if(i*i==sum) p.push_back(i);
    sort(p.begin(),p.end());
    for(int i=p.size()-1;i>=0;i--){
        if(check(p[i])){
            cout<<p[i]<<endl;
            return 0;
        }
    }
}

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

int main(){
    //入力
    int N;
    cin >> N;
    char s[N];
    for(int i=0;i<N;i++){
        cin >> s[i];
    }

    if(N%2==0){
        int half = N/2;
        char first[half];
        char second[half];
        for(int i=0;i<half;i++){
            first[i]=s[i];
        }
        for(int i=0;i<half;i++){
            second[i]=s[i+half];
        }

        int ans=0;

        for(int i=0;i<half;i++){
            if(first[i]==second[i]){
                ans++;
            }
        }

        if(ans==half){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
N,K=map(int,input().split())
a = [[0 for n in range(N)] for k in range(K)]

for k in range(K):
    d=int(input())
    have_k=map(int,input().split())
    for h in have_k:
        a[k][h-1]=1

an=[0]*N
for k in range(K):
  for n in range(N):
    an[n] = an[n]+a[k][n]

result=0
for i in an:
  if i == 0:
    result+=1

print(result)

Measured memory_bytes: 9264
#include <iostream>
#include <bitset>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);i <= (e);(i)++)
#define int long long

#define space(x) (x) << " "

int N;
vector<vector<int>> edges;

vector<i64> A;

i64 dfs(int v,int f){
  i64 MAX = -1;
  i64 SUM = 0;
  for(int to : edges[v]){
    if(f != to){
      i64 dp = dfs(to,v);

      if(dp == -1) return -1;
      MAX = max(MAX,dp);
      SUM += dp;
    }
  }

  if(MAX == -1){
    return A[v];
  }

  i64 Y = SUM - A[v];
  i64 X = A[v] - Y;

  i64 able = SUM / 2;
  if(MAX > able){
    able = SUM - MAX;
  }
 
  if(!(X >= 0 && Y >= 0 && able >= Y)){
    return -1;
  }

  return X;
}

bool solve(){
  if(N == 2){
    return A[0] == A[1];
  }
  rep(i,0,N - 1){
    if(edges[i].size() > 1) return dfs(i,-1) == 0;
  }
}
signed main(){
  cin >> N;
  edges.resize(N);
  A.resize(N);
  rep(i,0,N - 1){
    cin >> A[i];
  }
  rep(i,1,N - 1){
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    edges[a].push_back(b);
    edges[b].push_back(a);
  }
  if(solve()){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }

  return 0;
}



Measured memory_bytes: 11776
#ABC054

n,m = map(int,input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]

c = False
exist = False

for i in range(n-m+1):
    for j in range(n-m+1):
        if a[i][j] == b[0][0]:
            c = True
            for k in range(m):
                for l in range(m):
                    if a[i+k][j+l] != b[k][l]:
                        c = False
            if c:
                exist = True

if exist:
    print("Yes")
else:
    print("No")
    

Measured memory_bytes: 3064
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());
        int d = Integer.parseInt(sc.next());
        if(a+b > c+d) System.out.println("Left");
        else if(a+b < c+d) System.out.println("Right");
        else System.out.println("Balanced");
    }  
}

Measured memory_bytes: 23764
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
int[] num = new int[N];
		for(int i = 0;i < N;++i){
num[i] = sc.nextInt();
		}

int score = 0;
for(int i = 0;i < N;++i)
  score += num[i] -1;

System.out.println(score);
}
}

Measured memory_bytes: 27220
#include<bits/stdc++.h>
using namespace std;
long long n,x,a,b,ans,t; 
int main ()
{
	cin>>n>>x;
	cin>>a;
	if(a>x)
	ans+=a-x, a=x;
	for(int i=2;i<=n;i++)
	{
		cin>>b;
		if(a+b>x)
		{
			t=a+b-x;ans+=t;b=b-t;
		}
		a=b;
	}
	cout<<ans;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
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; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int n, x;
    cin >> n >> x;
    vector<int> a(n);
    REP(i, n) cin >> a[i];
    
    vector<int> b = a;
    REP(i, n) {
        if (b[i] > x) b[i] = x;
    }

    REP(i, n-1) {
        if (b[i] + b[i+1] > x) {
            int tmp = (b[i]+b[i+1]) - x;
            if (b[i+1] > tmp) b[i+1] -= tmp;
            else {
                b[i] -= tmp - b[i+1];
                b[i+1] = 0;
            }
        }
    }

    ll ans = 0;
    REP(i, n) {
        ans += a[i] - b[i];
    }

    cout << ans << endl;
    

    return 0;
}

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

#define N 26

int calc(char s){
	int d = s;
	if((d >= 65) && (d <=90)){
		return (d-65);
	}else if((d>=97) && (d<=122)){
		return (d-97);
	}
	return -1;
}

int main(void){
	char s;
	int num[N];
	int d=0;

	for(int i=0;i<N;i++){
		num[i]=0;
	}

	while(scanf("%c",&s)!=EOF){
		d=calc(s);
		if(d!=-1){
			num[d]++;
		}
	}

	for(int i=0;i<N;i++){
		printf("%c : %d\n",(97+i),num[i]);
	}
}


Measured memory_bytes: 2120
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,s,e) for(int i = (s); i < (e); i++)
#define FOE(i,s,e) for(int i = (s); i <= (e); i++)
#define FOD(i,s,e) for(int i = (s); i >= (e); i--)
#define ll long long
#define pb push_back
#define mp make_pair

int n, m, x, y, z, k, w;

int main ()
{
	scanf("%d %d %d", &n, &x, &y);
	if (abs(x - y) % 2 == 0) printf("Alice\n"); else printf("Borys\n");
	return 0;
}

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

using namespace std;

int main(){
	int n, m, mod = 1e9+7;
	cin >> n >> m;

	bool a[n][m];
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			char c;
			cin >> c;
			if(c == '.')
				a[i][j] = 1;
			else{
				a[i][j] = 0;
			}
		}
	}

	int dp[n][m];
	memset(dp, 0, sizeof(dp));
	for(int j=0;j<m;j++){
		if(a[0][j]){
			dp[0][j] = 1;
		}
		else{
			break;
		}
	}
	for(int i=0;i<n;i++){
		if(a[i][0]){
			dp[i][0] = 1;
		}
		else{
			break;
		}
	}

	for(int i=1;i<n;i++){
		for(int j=1;j<m;j++){
			if(a[i][j]){
				dp[i][j] = ((dp[i-1][j]%mod) + (dp[i][j-1]%mod))%mod;
			}
		}
	}

	cout << dp[n-1][m-1];
	return 0;
}

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

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

char memo[4];

int main() {
  scanf("%s", memo);
  int sum = 700;
  REP(i,3) {
    if (memo[i] == 'o') sum += 100;
  }

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

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

const int INF=1e9+5;
const int maxN = 100005;
int dp[maxN];
int h[maxN];

int main()
{
    int n; cin >> n;
    for (int i=1; i<=n; i++){
        cin >> h[i];
    }
    dp[1]=0; dp[2]=abs(h[1]-h[2]);
    for (int i=3; i<=n; i++){
        int a = dp[i-1]+abs(h[i]-h[i-1]);
        int b = dp[i-2]+abs(h[i]-h[i-2]);
        dp[i]=min(a,b);
    }
    cout << dp[n];
    
}

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

int main()
{
  int N,Ans=0;
  cin >> N;
  int A[N];
  for(int i = 0;i < N ;i++){
  	cin >> A[i];
  }
  int B[N];
  for(int i = 0;i < N ;i++){
  	cin >> B[i];
  }
    int C[N-1];
  for(int i = 0;i < N-1 ;i++){
  	cin >> C[i];
  }
  for(int i = 0;i < N ;i++){
  	Ans += B[A[i]-1];
    if(i < N-1){
      if(A[i] == A[i+1] - 1){
        Ans += C[A[i]-1];
      }
    }
  }
  
  cout << Ans << endl;
  return 0;
}

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

int main(){
    int n;
    while(cin >> n, n){
        vector<int> a(n);
        int sum = 0, ans = 0;
        int mean;
        for(int i = 0;i < n;++i){
            int tmp;
            cin >> tmp;
            a[i] = tmp;
            sum += tmp;
        }
        mean = sum / n;
        for(int i = 0;i < n;++i){
            if(a[i] <= mean){
                ans += 1;
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3116
from pprint import pprint

T = int(raw_input())

for T_ in xrange(T):
  log = []
  curX = 0
  curY = 0

  log.append((0, 0))
  rx, ry = log[0]

  while True:
    dx, dy = map(int, raw_input().split())
    if dx == 0 and dy == 0:
      break
    elif dx == 0:
      if dy > 0:
        for y_ in xrange(dy):
          curY += 1
          log.append((curX, curY))
      else:
        for y_ in xrange(-dy):
          curY -= 1
          log.append((curX, curY))
    elif dy == 0:
      if dx > 0:
        for x_ in xrange(dx):
          curX += 1
          log.append((curX, curY))
      else:
        for x_ in xrange(-dx):
          curX -= 1
          log.append((curX, curY))

    x_, y_ = curX, curY

    if rx * rx + ry * ry < x_ * x_ + y_ * y_:
      rx = x_
      ry = y_
    elif rx * rx + ry * ry == x_ * x_ + y_ * y_ and rx < x_:
      rx = x_
      ry = y_


  print rx, ry

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

int main() {
  int c1,c2,ans,n;
  ans=1;
  c1=0;
  cin >> n;
  for (int i=1;i<n+1;i++){
       int m;
       m=i;
       c2=0;
    while(m%2==0){
        m=m/2;
        c2=c2+1;
    }
    if(c1<c2){
      ans=i;
      c1=c2;
    }
  }
  cout<< ans <<endl;
}

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

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

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

for(int i=a;i<=a+b;i++){
if(i==x){
cout<<"YES"<<endl;
return 0;
}
}
cout<<"NO"<<endl;

  return 0;
}


Measured memory_bytes: 256
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
	return list(map(int,input().split()))
def m(): #複数文字
	return map(int,input().split())
def onem(): #Nとかの取得
	return int(input())
def s(x): #圧縮
	a = []
	if len(x) == 0:
		return []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa != x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x): #listをスペースごとに分ける
	return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
	return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
	ll = 0
	rr = r
	while True:
		mid = (ll+rr)//2

	if rr == mid:
		return ll
	if (ここに評価入れる):
		rr = mid
	else:
		ll = mid+1
"""

l,r,d = m()

ans = 0

for i in range(l,r+1):
	if i % d == 0:
		ans += 1
print(ans)


Measured memory_bytes: 65156
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner =new Scanner(System.in);
		int R =scanner.nextInt();
		if((0<=R)&&(R<1200)){
			System.out.println("ABC");
		}else if(((1200<=R)&&(R<2800))) {
			System.out.println("ARC");
		}else {
			System.out.println("AGC");

		}
	}

}


Measured memory_bytes: 23252
lines = list(input())
total = 0
size = 0

stack = []
ponds = []
size = 0
for i in range(len(lines)):
    if lines[i] == "\\":
        stack.append(i)
    elif lines[i] == "/":
        if not stack == []:
            left_index = stack.pop()
            size = i - left_index
            target_index = left_index
            
            #order is tricky
            while not ponds == [] and ponds[-1][0] > left_index:
                direct = ponds.pop()
                target_index = direct[0]
                size += direct[1]
            ponds.append([target_index,size])




ans = []
ans.append(len(ponds))
for _ in ponds:
    ans.append(_[1])

print(sum(ans[1:]))
print(" ".join(map(str,ans)))


Measured memory_bytes: 6388
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (n); i++)
int main()
{
  int n;
  cin >> n;
  ll sum = 1;
  ll a[100010];
  rep(i, n)
  {
    cin >> a[i];
  }
  rep(i, n)
  {
    if (a[i] == 0)
    {
      cout << 0 << endl;
      return 0;
    }
  }
  rep(i, n)
  {
    if (a[i] == 0)
    {
      cout << 0 << endl;
      return 0;
    }
    if (a[i] <= ll(1e18) / sum)
    {
      sum *= a[i];
    }
    else
    {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 4356
n=int(input())
L=[*range(n)]
S=[1]*n
for i in range(2,n):
  for j in range(i,n,i):
    a=0
    while L[j]%i<1:
      L[j]//=i
      a+=1
    S[j]*=a+1
print(sum(S)-1)

Measured memory_bytes: 83828
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

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

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  long long n; cin >> n;
  long long mn = LINF;
  REP(i, 5) {
    long long a; cin >> a;
    mn = min(mn, a);
  }
  cout << 5 + (n + mn - 1) / mn - 1 << '\n';
  return 0;
}


Measured memory_bytes: 256
import math

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def main():
    N = ii()
    l = ''
    while N:
        if N%26:
            tmp = N%26
            N //= 26
        else:
            tmp = 26
            N //= 26
            N -= 1
        l += chr(96+tmp)
    print(l[::-1])


if __name__ == '__main__':
    main()

Measured memory_bytes: 62076
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#define mod 1000000007
typedef long long ll;
using namespace std;

const int MAX = 100005;
bool is_AC[MAX];
int n,m,pena[MAX];
int ans_ac, ans_pena;
int main(){
  cin >> n >> m;
  for(int i=1;i<=n;i++){
    is_AC[i] = false;
    pena[i] = 0;
  }

  for(int i=0;i<m;i++){
    int p;
    string s;
    cin >> p >> s;
    if(s=="AC"){
      if(is_AC[p]==false){
        is_AC[p] = true;
        ans_ac++;
        ans_pena += pena[p];
      }
    }
    if(s=="WA"){
      if(is_AC[p]==false){
        pena[p]++;
      }
    }

  }
  cout << ans_ac << " " << ans_pena << endl;
}

Measured memory_bytes: 768
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <queue>
#include <bitset>
#include <random>
#include <stack>
#include <deque>
#include <chrono>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef pair<int,int> pii;
#define REP(i, a, b) for (int i = int(a); i <= int(b); i++)
#define REPb(j, d, c) for (int j = int(d); j >= int(c); j--)
#define ff first
#define ss second
#define pb push_back
#define len(x) int((x).size())

int n;
int MAX_N = 1e5;
vector<vector<pii>> adj_list(MAX_N+1);
vb visited(MAX_N+1);
vb colour(MAX_N+1);

void dfs(int v)
{
	visited[v]=true;

	for(auto u:adj_list[v])
	{
		if(visited[u.ff]) continue;
		colour[u.ff] = (colour[v])^(u.ss%2==1);

		//cout << v << " " << u.ff << " " << colour[u.ff] << endl;

		dfs(u.ff);
	}

	return;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	//ifstream cin("input.txt");
	//ifstream cin("test.in");
	//ofstream cout("test.out");

	cin>>n;

	REP(i,1,n-1)
	{
		int u,v,w;
		cin>>u>>v>>w;
		adj_list[u].pb({v,w});
		adj_list[v].pb({u,w});
	}

	dfs(1);

	REP(i,1,n) cout << int(colour[i]) << endl;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
const int MOD=(int)1e9+7;
using namespace std;
int main(){
    long long int n,k,ans;
    cin>>n>>k;
    ans=(n/k)*(n/k)*(n/k);
    if(k%2==0){
        ans+=((n+k/2)/k)*((n+k/2)/k)*((n+k/2)/k);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <functional>
#include <iostream>
#include <vector>

using namespace std;

int p[100001];

// Union-Find-Tree
struct UnionFind {
  vector<int> par;    //そのノードの親ノード
                      //（根ノードは自分を参照）
  vector<int> sizes;  //そのノードを根とする木のサイズ
                      //（根でないノードについては無意味）
  int N;

  UnionFind(int n) : par(n), sizes(n, 1) {
    for (int i = 0; i < n; i++) par[i] = i;
    N = n;
  }

  int find(int x) {
    if (par[x] == x)
      return x;
    else
      return par[x] = find(par[x]);
  }

  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;

    if (sizes[x] < sizes[y]) {
      par[x] = y;
      sizes[y] += sizes[x];
    } else {
      par[y] = x;
      sizes[x] += sizes[y];
    }
  }

  bool same(int x, int y) { return find(x) == find(y); }

  int size(int x) { return sizes[find(x)]; }
};

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

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

  UnionFind uf(n);

  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;

    uf.unite(x - 1, y - 1);
  }

  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (uf.same(i, p[i])) cnt++;
  }

  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 1408
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():

    return

#B
def B():
    n = I()
    a = LI()
    b = LI()
    c = LI()
    ans = sum(b)
    for i in range(n-1):
        x = a[i]
        y = a[i+1]
        if y == x+1:
            ans += c[x-1]
    print(ans)
    return

#C
def C():

    return

#D
def D():

    return

#E
def E():

    return

#F
def F():

    return

#Solve
if __name__ == "__main__":
    B()


Measured memory_bytes: 39152
N = int(input())
A = list(map(int,input().split()))

a,b,c = [-1],[-1],[-1]
ans = 1
#「どのグル－プに行けるか」 を行けるグループ数だけかけていく
for i in range(N):
  tmp = 0
  if(a[-1] == A[i]-1): 
      tmp += 1
      if(tmp == 1): a.append(A[i])
  if(b[-1] == A[i]-1): 
      tmp += 1
      if(tmp == 1): b.append(A[i])
  if(c[-1] == A[i]-1): 
      tmp += 1
      if(tmp == 1): c.append(A[i])
  ans = ans*tmp
  ans = ans%((10**9)+7)
  
print(ans)   

Measured memory_bytes: 14072
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  using namespace std;
  long long n;
  cin>>n;
  long long ans = 0;
  for(long long a = 1; a <= 1'000'000; a++) ans += (n - 1) / a;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
#define pb push_back
const int N=20005;
const int MOD=1e9+7;
 

// lower_bound - which does not compare less than val
// upper_bound - which compares greater than val
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
 int a[N],b[N],c[N];
 
int32_t main()
{
  
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  /* stuff you should look for
  * int overflow, array bounds
  * special cases (n=1?)
  * do smth instead of nothing and stay organized
*/

string s;
cin>>s;
cout<<s.substr(0,3);
	 
}




Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong

signed main(){
    int A[5] = {};
    REP(i,6){
        int tmp;
        cin >> tmp;
        A[tmp] ++;
    }
    A[0] = 100;
    sort(A,A+5);
    if(A[0] == 1 and A[1] == 1 and A[2] == 2 and A[3] == 2) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
 
#define loop(n, i) for(int i=0;i<n;i++)
#define from_to(from, to, i) for(int i=from;i<=to;i++)

using namespace std;

const int MAX = 10000;

int main(int argc, char const* argv[])
{
    vector<int> prime(MAX+1);
    for (int i = 2; i <= MAX; i++) {
        bool p = true;
        for (int j = 2; j*j <= i; j++) {
            if (i%j == 0) p = false;
        }
        prime[i] = p;
    }

    int N;
    while (cin >> N) {
        int ans = 0;
        for (int i = 1; i <= N; i++) {
            if (prime[i] && prime[N-i+1]) ans++;
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int y,m,d;
  char a,b;
  cin>>y>>a>>m>>b>>d;
  if (m<5){
    cout <<"Heisei"<<endl;
    return 0;
  }
  else{
    cout <<"TBD"<<endl;
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
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 vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 
const int mod = 1000000007;
// const int mod = 998244353;
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 { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
  int N,K; cin>>N>>K;
  mint ans = 0;
  mint n = N;
  for (ll k=K; k <= N+1; k++) {
    mint now = k;
    mint upper = (n+n-now+1)*now /2;
    mint lower = (now-1)*now /2;
    mint sum = upper - lower +1;
    ans =( ans + sum );
  }
  printf("%lld\n", ans.x);
  return 0;
}

Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vpii = vector<pair<int,int>>;
using vpll = vector<pair<ll,ll>>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int) n;i++)
#define rep1(i,m,n) for(int i=(int) m;i<(int) n;i++)
#define fix(n) cout << fixed << setprecision((int)n)

void absll(ll &x) {
    if(x>=0) return ;
    else x=-x; return;
}

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

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

const ll INF = 1LL << 60;

//DPテーブル
vector<ll> dp(100010);

ll rec(int i) {
    if(dp.at(i)<INF) return dp.at(i);
    if(i==0) return dp.at(i)=0;
    ll res=INF;

    chmin(res,rec(i-1)+1);
    
    if(i>=9) {
        for(int j=1;pow(9,j)<=i;j++) chmin(res,rec(i-pow(9,j))+1);
    }
    if(i>=6) {
        for(int j=1;pow(6,j)<=i;j++) {
            chmin(res,rec(i-pow(6,j))+1);
            cout << "i:" << i << ",res;" << res << endl;
        }
    }
    return dp.at(i)=res;
}

int main() {
    int N;
    cin >> N;
    vi dem={1};
    int i=6;
    while(i<100000) {
        dem.push_back(i);
        i*=6;
    }
    i=9;
    while(i<100000) {
        dem.push_back(i);
        i*=9;
    }
    int count=0;
    sort(dem.begin(),dem.end(),greater<int>());
    vector<ll> dp(9*9*9*9*9+N+1,INF);
    dp.at(0)=0;
    rep(i,N){
    for(int d:dem) {
        chmin(dp.at(i+d),dp.at(i)+1);
    }
}
    cout << dp.at(N) << endl;
}

Measured memory_bytes: 2304
from collections import defaultdict

N = int(input())
A = list(map(int, input().split()))
d = defaultdict(int)

max1, max2 = 0, 0

for a in A:
    d[a] += 1
    if d[a] == 2:
        if a > max1:
            max2 = max1
            max1 = a
        elif a > max2:
            max2 = a

if d[max1] >= 4:
    ans = max1 * max1
else:
    ans = max1 * max2
print(ans)



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

#define MOD 1000000007

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

	int rows, cols;
	cin >> rows >> cols;
	int dp[rows][cols]; // number of ways to get here;
	char c;
	for (int i = 0; i < rows; i++) {
		for (int j = 0; j < cols; j++) {
			cin >> c;
			dp[i][j] = ((i == 0 && j == 0) ? 1 : 0);
			if (c == '.') {
				if (i > 0) dp[i][j] += dp[i - 1][j];
				if (j > 0) dp[i][j] += dp[i][j - 1];
				dp[i][j] %= MOD;
			}
		}
	}

//	for (int i = 0; i < rows; i++) {
//		for (int j = 0; j < cols; j++)
//			cout << dp[i][j] << ' ';
//		cout << '\n';
//	}

	cout << dp[rows - 1][cols - 1] << '\n';
}


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

const int maxn=2005;
int n,a[maxn],l[maxn],r[maxn];
long long p=0,lq,rq,k;

int main(){
    memset(a,0,sizeof(a));
    memset(l,0,sizeof(l));
    memset(r,0,sizeof(r));
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            if(a[i]>a[j]) l[i]++;
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=i-1;j>=1;j--){
            if(a[i]>a[j]) r[i]++;
        }
    }
    rq=k*(k-1)/2%1000000007;
    lq=(rq+k)%1000000007;
    for(int i=1;i<=n;i++){
        p+=l[i]*lq+r[i]*rq;
        p=p%1000000007;
    }
    printf("%lld",p);
    return 0;
}


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

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

    int res = 0;
    rep_s(i, A, B + 1)
    {
        int _i = i;
        int after = 0;

        int keta = 10000;
        while (_i > 0)
        {
            after += (_i % 10) * keta;
            _i /= 10;
            keta /= 10;
        }

        if (i == after)
        {
            res++;
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 384
n, k =map(int, input().split())
used = [False] * (n + 10)
for i in range(k):
    x = int(input())
    #print("x", x)
    dat = list(map(int, input().split()))
    #print(dat)
    for j in range(len(dat)):
        used[dat[j]] = True
res = 0
#print(used)
for i in range(n):
    #print(i)
    if used[i + 1] is False:
        res += 1
print(res)

Measured memory_bytes: 67664