akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printv(x) for(int i = 0; i < x.size(); i++){ cout << (x[i]) << " "; } cout << endl; 
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define INF (1e9)
typedef long long ll;
typedef struct{
    int x;
    int y;
} P;

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    double A,B,C,D,E,F;
    cin >> A >> B >> C >> D >> E >> F;
    double density_max = 0;
    double water_max = 0;
    double sugar_max = 0;
    rep(i,0,31){
        rep(j,0,31){
            rep(k,0,101){
                rep(l,0,101){
                    double water = 100 * A * i + 100 * B * j;
                    double sugar = C * k + D * l;
                    if(water + sugar <= F && water + sugar != 0 && water != 0){
                        double density = 100 * sugar /(water + sugar);
                        double d_E = 100 * E / (100 + E);
                        if(density <= d_E){
                            if(density >= density_max){
                                density_max = density;
                                water_max = water;
                                sugar_max = sugar;
                            }

                        }
                    }
                }
            }

        }
    }
    cout << water_max + sugar_max << " " << sugar_max << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
#include <queue>
#include <string>
#include <tuple>
using namespace std;

const int INF = 1 << 20;

int main(void){
  int N,M;
  cin >> N >> M;
  
  vector<int> C(M+1);
  C[0] = 0;
  for(int i=1;i<=M;i++){
    cin >> C[i];
  }

  vector<vector<int>> dp(N+1);
  for(int n=0;n<=N;n++){
    for(int m=0;m<=M;m++){
      if(n==0){
        dp[n].push_back(0);
      } else {
        dp[n].push_back(INF);
      }
    }
  }
  
  for(int n=1;n<=N;n++){
    for(int m=1;m<=M;m++){
      if(n-C[m]>=0){
        dp[n][m] = min(dp[n][m-1],dp[n-C[m]][m]+1);
      } else {
        dp[n][m] = dp[n][m-1];
      }
    }
  }
  
  /*
  for(int n=0;n<=N;n++){
    for(int m=0;m<=M;m++){
      cout << dp[n][m] << " ";
    }
    cout << endl;
  }
  */
  
  cout << dp[N][M] << endl;
}



Measured memory_bytes: 11048
#pragma GCC optimize("Ofast,fast-math,unroll-loops")

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

typedef long long ll;
typedef string str;

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
	
	ll a,b;
	cin >> a >> b;
	ll g = __gcd(a,b);
	ll ans = (a*b)/g;
	cout << ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <string>
using namespace std;

#define rep(i,n) for(int i=0; i<n; i++)
#define repa(i,s,e) for(int i=s; i<=e; i++)
#define repd(i,s,e) for(int i=s; i>=e; i--)

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

int n;
string train;

string rev(string s) {
	string t = "";
	int l = s.size();
	rep(i,s.size()) {
		t.push_back(s[l-i-1]);
	}
	return t;
}

int solve(string train) {
	set<string> s;
	int length = train.size();
	repa(i,1,length-1) {
		string f = train.substr(0, i);
		string b = train.substr(i);
		
		s.insert(f + b);
		s.insert(b + f);
		s.insert(rev(f) + b);
		s.insert(b + rev(f));
		s.insert(f + rev(b));
		s.insert(rev(b) + f);
		s.insert(rev(f) + rev(b));
		s.insert(rev(b) + rev(f));
	}
	return (int)s.size();
}

int main() {
	cin >> n;
	rep(i,n) {
		cin >> train;
		cout << solve(train) << endl;
	}
}

Measured memory_bytes: 1308
#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)

typedef long long ll;
#define INF 1e9

int main(){
  string S;
  cin >> S;
  ll ans = 0;
  ll x = 0;

  REP(i, (1 << (S.length()-1))){
    x = 0;
    REP(j, S.length()+1){
      if(j == 0){
        x += S[j]-'0';
      }
      else if(j == S.length()){
        //cout << x << endl;
        ans += x;
        x = 0;
      }
      else if((i >> (j-1)) & 1){
        //cout << x << endl;
        ans += x;
        x = S[j] - '0';
      }
      else{
        x = x * 10 + S[j]-'0';
      }
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
n=int(input())
v=list(map(int,input().split()))
c=list(map(int,input().split()))
rv=[v[i]-c[i] if v[i]-c[i]>=0 else 0 for i in range(n)]
ans=0
for j in range(n):
    ans+=rv[j]
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
priority_queue<int> ha;
priority_queue<int> hb;
priority_queue<int> hc;
int main(){
    int x, y, a, b, c, d;
    long long ans = 0;
	scanf(" %d %d %d %d %d", &x, &y, &a, &b, &c);
	for(int i = 0; i < a; i++){
        scanf(" %d", &d);
        ha.push(d);
	}
	for(int i = 0; i < b; i++){
        scanf(" %d", &d);
        hb.push(d);
	}
	for(int i = 0; i < c; i++){
        scanf(" %d", &d);
        hc.push(d);
	}
    int cou = 0;
    while(x+y > cou){
        int state = 0, maxa = 0;
        if(!ha.empty() && x > 0){
            if(ha.top() > maxa){
                maxa = ha.top();
                state = 1;
            }
        }
        if(!hb.empty() && y > 0){
            if(hb.top() > maxa){
                maxa = hb.top();
                state = 2;
            }
        }
        if(!hc.empty()){
            if(hc.top() > maxa){
                maxa = hc.top();
                state = 3;
            }
        }
        if(state == 1){
            ha.pop();
            x--;
        }
        if(state == 2){
            hb.pop();
            y--;
        }
        if(state == 3){
            hc.pop();
            cou++;
        }
        ans += maxa;

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


Measured memory_bytes: 1784
#include <stdio.h>

int main() {
	int N;
	int d[50];
	int i, j, tmp;
	int ans = 0;
	scanf("%d", &N);
	for(i = 0; i < N; i++) {
		scanf("%d", &d[i]);
	}

	for(i = 0; i < N-1; i++) {
		for(j = i+1; j < N; j++) {
			ans += d[i] * d[j];
		}
	}
	printf("%d\n", ans);
}

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

using namespace std;

int main()
{
    string input;
    cin >> input;

    int a = 0,b = 0;
    for(const auto &s: input){
        if(s == 'A'){
            a++;
        }else{
            b++;
        }
    }

    if(a != 0 && b != 0){
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << std::endl;

    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

type Student struct {
	Number int
	inClassNum  int
}

type ByClassNum []Student

func (a ByClassNum) Len() int { return len(a) }
func (a ByClassNum) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a ByClassNum) Less(i, j int) bool { return a[i].inClassNum < a[j].inClassNum }



func main() {

	var n int
	fmt.Scan(&n)

	//構造体を持つスライスの作成
	student := make([]Student,n)

	//構造体のプロパティの代入
	for i := 0; i < n; i++ {

		student[i].Number = i+ 1

		var num int
		fmt.Scan(&num)

		student[i].inClassNum = num

	}

	//inClassNumでソート
	sort.Sort(ByClassNum(student))

	for i := 0; i < n; i++ {

		fmt.Println(student[i].Number)

	}






}

Measured memory_bytes: 5888
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef struct _data {
	int x;
	int y;
} data;

int  main()
{
	vector<pair<int ,int> > a(3);
	map <int , int> mp;
	rep(i, 3)
	{
		cin >> a.at(i).first >> a.at(i).second;
		mp[a.at(i).first] += 1;
		mp[a.at(i).second] += 1;
	}
	// rep(i,3)
	// {
	// 	if(abs(a.at(i).first -  a.at(i).second) != 1)
	// 	{
	// 		cout << "NO\n"; return 0;
	// 	}
	// }
	for(int i= 1; i <= 4; i++)
	{
		if (i == 1 || i == 4)
		{
			if (mp[i] != 1)
			{
				cout << "NO\n"; return 0;
			}
		}
		else
		{
			if (mp[i] != 2)
			{
				cout << "NO\n"; return 0;
			}
		}
	}
	cout << "YES\n";
	return (0);
}


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

long long n;
long long q,h,s,d,ans;

int main(){
	cin>>q>>h>>s>>d>>n;
	n*=8;
	ans=0;
	if (d<s*2 && d<h*4 && d<q*8){
		ans+=d*(n/16);
		n%=16;
	}
	if (s<h*2 && s<q*4){
		ans+=s*(n/8);
		n%=8;
	}
	if (h<q*2){
		ans+=h*(n/4);
		n%=4;
	}
	ans+=q*(n/2);
	n%=2;
	cout<<ans<<endl;
	return 0;
}

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

int main(){
    int N;
    cin >> N;
    string s = to_string(N);
    for(int i = 0; i < s.size(); i++){
        if(s[i] == '7'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3692
fun main(args: Array<String>) {
    val (n, a, b) = readLine()!!.split(" ").map(String::toInt)
    val maxMinPair = maxMinSub(n, a, b)
    print("${maxMinPair.first} ${maxMinPair.second}")
}

/**
 * Pair max, min
 */
fun maxMinSub(n: Int, a: Int, b: Int) : Pair<Int, Int> {
    return if (n <= (a + b)) { // 10 5 7
        Pair(Math.min(a, b), Math.abs(a+b-n))
    } else {  // 10 3 5
        Pair(Math.min(a, b), 0)
    }
}

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

using namespace std;

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
const int inf = 1e9 + 7;
const int maxN = 1e6 + 5;

int m, a, b, ans[maxN], z;
ll n,x;
vector<vector<ll>> A(105);
bool used[maxN];
int arr[maxN], arr1[maxN];
vi graph[maxN];
queue<int> Q;


int main() {
	scanf("%lld%lld",&n,&x);
	ll ans = n;
	n = n - x;
	while (n % x != 0) {
		if (x > n) swap(n,x);
		else {
			ans += (n / x) * 2 * x;
			n = (n % x);
		}
		//printf("%lld %lld %lld\n",ans, n, x);
	}
	ans += ((n / x * 2) - 1) * x;
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 23680
def main():
    import sys, itertools as ite
    n = int(sys.stdin.readline())
    A = tuple(map(int, sys.stdin.readline().split()))
    #print(A)
    q = int(sys.stdin.readline())
    M = map(int, sys.stdin.readline().split())
    bit = ite.product([0,1], repeat=n)
    ans = []
    for b in bit:
        tmp = 0
        for i in range(n):
            tmp +=b[i]*A[i]
        ans += [tmp]
        
    for m in M:
        if m in ans:
            print('yes')
        else:
            print('no')







if __name__=='__main__':
    main()



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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



i64 n, a[101010];
void solve(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	
	if(a[n-1] != 2){
		cout << -1 << endl;
		return;
	}
	i64 cnt = 2, ma = 3;
	for(int i = n-2; i >= 0; i--){
		if(cnt < 2 || a[i] > ma){
			cout << -1 << endl;
			return;
		}
		cnt = (cnt+a[i]-1)/a[i] * a[i];
		if(cnt - cnt%a[i+1] > ma){
			cout << -1 << endl;
			return;
		}
		//chmax(ma, cnt+a[i]-1);
		/*if(ma%a[i] > 0)*/ chmax(ma, ma + a[i]-ma%a[i]-1);
		//cout << cnt << " " << ma << endl;
	}
	cout << cnt << " " << ma << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


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

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

    vector<int> c(n, 0);

    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        c.at(a - 1) += 1;
        c.at(b - 1) += 1;
    }

    for (int i = 0; i < n; i++) {
        cout << c.at(i) << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef long long ll;
const ll p = 1e9 + 7;
ll n, m, a[2005], b[2005], ans, f[2005][2005];

int main()
{
	cin >> n >> m;
	for (ll i = 1; i <= n; i++) cin >> a[i];
	for (ll i = 1; i <= m; i++) cin >> b[i];
	for (ll i = 1; i <= n; i++)
	{
		for (ll j = 1; j <= m; j++)
		{
			f[i][j] = (f[i - 1][j] + f[i][j - 1] - f[i - 1][j - 1] + p) % p;
			if (a[i] == b[j])
			{
				f[i][j] = (f[i][j] + f[i - 1][j - 1] + 1 + p) % p;
			} 
			//cout << i << " " << j << " " << f[i][j] << endl;
		}
	}
	cout << (f[n][m] + 1 + p) % p << endl;
	return 0;
} 

Measured memory_bytes: 31616
// 2011/06/22 Tazoe

#include <iostream>
using namespace std;

void sieve(bool is_prime[], int n)
{
	for(int i=0; i<n; i++)
		is_prime[i] = true;

	if(n>=1)
		is_prime[0] = false;
	if(n>=2)
		is_prime[1] = false;

	for(int i=2; i*i<n; i++)
		if(is_prime[i])
			for(int j=i*i; j<n; j+=i)
				is_prime[j] = false;
}

int main()
{
	bool is_prime[10000001];
	sieve(is_prime, 10000001);

	while(true){
		int n;
		cin >> n;
		if(n==0)
			break;

		for(int i=n; i>=13; i--)
			if(is_prime[i]&&is_prime[i-2]&&is_prime[i-6]&&is_prime[i-8]){
				cout << i << endl;
				break;
			}
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <numeric>

using namespace std;

#define int long long
typedef long double ld;
#define pii pair<int, int>
#define vi vector<int>
#define vii vector<vi>
#define viii vector<vii>
#define vpii vector<pii>
#define vb vector<bool>
#define vbb vector<vb>
#define vs vector<string>
#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define in(a) for (int i = 0; i < (a).size(); ++i) cin >> (a)[i]
#define out(a) for (auto qwe : a) cout << qwe << " "

const int INF = 1e9;
const int INF64 = 1e18;
const int MOD = 1e9 + 7;
const int MOD9 = 1e9 + 9;
const int MOD3 = 998244353;
const int P = 37;

const int mxn = 300;

string s, t;

string rec(int l, int r, vii* dp) {
    int x = dp->at(l)[r];

    if (x == 0) return "";

    if (dp->at(l - 1)[r] == x - 1 && dp->at(l)[r - 1] == x - 1 && dp->at(l - 1)[r - 1] == x - 1) {
        return rec(l - 1, r - 1, dp) + s[l - 1];
    } else {
        if (dp->at(l - 1)[r] == x) {
            string a = rec(l - 1, r, dp);

            if (!a.empty()) return a;
        }

        if (dp->at(l)[r - 1] == x) {
            string a = rec(l, r - 1, dp);

            if (!a.empty()) return a;
        }
    }

    return "";
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin >> s >> t;

    int n = s.size();
    int m = t.size();

    vii dp(n + 1, vi(m + 1, 0));

    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            if (s[i - 1] == t[j - 1]) {
                dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - 1] + 1);
            } else {
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            }
        }
    }

    cout << rec(n, m, &dp);
}

Measured memory_bytes: 71040
# N = gets.chomp.to_i
# A, B, C = gets.chomp.split.map(&:to_i)
S = gets.chomp.chars
T = gets.chomp.chars

n = S.size()
m = T.size()
if (m == n+1) && S == T[0..-2] 
  print "Yes\n"
else
  print "No\n"
end


Measured memory_bytes: 14392
input_string = input().split(" ")
n = int(input_string[0])
a = int(input_string[1])
b = int(input_string[2])
numbers_generated_by_n_list = []
numbers_between_a_and_b_sum = 0

for val in range(1, n+1):
  fixed_a = list(str(val))
  fixed_a_list = list(map(int,fixed_a))
  fixed_a_list_sum = sum(fixed_a_list)
  numbers_generated_by_n_list.append(fixed_a_list_sum)

for index, val in enumerate(numbers_generated_by_n_list):
  if val >= a and val <= b:
    numbers_between_a_and_b_sum += (index+1)

print(numbers_between_a_and_b_sum)

Measured memory_bytes: 3316
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    h, w = i_map()
    str_list = s_row_list(h)
    
    for i in range(h):
        for j in range(w):
            if str_list[i][j] == '.':
                continue
            if i != 0:
                if str_list[i-1][j] == '#':
                    continue
            if j != 0:
                if str_list[i][j-1] == '#':
                    continue
            if i != h - 1:
                if str_list[i+1][j] == '#':
                    continue
            if j != w - 1:
                if str_list[i][j+1] == '#':
                    continue
            print('No')
            exit()

    print('Yes')

if __name__ == '__main__':
    main()


Measured memory_bytes: 10520
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <stdio.h>
#include <set>
#include <vector>
using namespace std;


int main(){
    int n, k;
    cin>>n>>k;
    int i, j;
    int x[n];
    for(i=0; i<n; i++){
        cin>>x[i];
    }
    int ans = 0;
    for(i=0; i<n; i++){
        if(x[i]<abs(x[i]-k)){
            ans += x[i]*2;
        }
        else{
            ans += abs(x[i]-k)*2;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  string a;
  cin >> a;
  string hoge;
  for (int i = 0; i < a.length(); i++){
    hoge += string{'x'};
  }
  cout << hoge << endl;
  
}

Measured memory_bytes: 256
#include<iostream>

#include<algorithm>

#include<cstdio>

#include<cstring>

using namespace std;

struct Q

{

	int l,r,id;

}q[1000000];

int a[1000000],w[1000000],ans[1000000],n,m,p[2000000];

void update(int x,int w){for(;x<=n;x+=x&(-x))a[x]+=w;}

int query(int x){int ans=0;for(;x;x-=x&(-x))ans+=a[x];return ans;}

int cmp(const Q &a,const Q &b)

{

	return a.r<b.r;

}

int getin()

{

	int x=0;char ch=getchar();

	while(ch<'0'||ch>'9')ch=getchar();

	while(ch>='0'&&ch<='9')x=x*10+ch-48,ch=getchar();

	return x;

}

int wt[30];

void putout(int x)

{

	if(!x){putchar('0');return;}

	int l=0;

	while(x)wt[++l]=x%10,x/=10;

	while(l)putchar(wt[l--]+48);

}

int main()

{

	n=getin();	m=getin();

	for(int i=1;i<=n;i++)w[i]=getin();



	for(int i=1;i<=m;i++)q[i].id=i,q[i].l=getin(),q[i].r=getin();

	sort(q+1,q+m+1,cmp);

	int t=1;

	for(int i=1;i<=n&&t<=m;i++)

	{

		if(p[w[i]])update(p[w[i]],-1);

		update(i,1),p[w[i]]=i;

		while(q[t].r==i)ans[q[t].id]=query(i)-query(q[t].l-1),t++;

	}

	for(int i=1;i<=m;i++)putout(ans[i]),putchar(10);

}

Measured memory_bytes: 17428
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)
  
n =int(input())
n += 1
sum = 0
for i in range(1, n):
  for j in range(1, n):
    for m in range(1, n):
      sum += gcd(i, j, m)

print(sum)

Measured memory_bytes: 69436
#include <bits/stdc++.h>
using namespace std;
int res, n;
void dfs(long long now, int msk){
  if(now > n) return;
  if(msk == 7) res++;
  dfs(now*10 + 3, msk|1);
  dfs(now*10 + 5, msk|2);
  dfs(now*10 + 7, msk|4);
}
int main(){
  cin >> n;
  dfs(0, 0);
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
using namespace std;
#include<iostream>
#include<bits/stdc++.h>
#include<algorithm>
#define w(x) int x;cin>>x;while(x--)

#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

#define ll long long

void abc()
{
	FIO;
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
}





int main()
{
	abc();

	string s;
	cin >> s;
	if (s[s.size() - 1] == 's') {
		s += "es";
	}
	else {
		s += "s";
	}
	cout << s;

}

Measured memory_bytes: 3652
def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def ok(W):
    if W.count("AGC") >= 1:
        return False

    for i in range(1, 4):
        L = list(W)
        L[i - 1], L[i] = L[i], L[i - 1]
        if "".join(L).count("AGC") >= 1:
            return False
    return True


def main():
    mod = 10 ** 9 + 7
    dp = {}
    W = "ACGT"
    for a in W:
        for b in W:
            for c in W:
                w = a + b + c
                if w in ("AGC", "ACG", "GAC"):
                    continue
                dp[w] = 1

    N = int(input())
    for n in range(N - 3):
        dp2 = {}
        for a in dp.keys():
            for b in W:
                if ok(a + b):
                    w = a[1:] + b
                    dp2[w] = (dp[a] + dp2.setdefault(w, 0)) % mod
        dp.update(dp2)
    print(sum(v for v in dp.values()) % mod)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
# coding: utf-8

import heapq

def dj(adjm, sn, start):
    n = len(adjm)
    d = [float("inf")] * n
    d[start] = 0
    q = []
    heapq.heappush(q, (0, start))

    while(q):
        td, v = heapq.heappop(q)
        for k in adjm[v].keys():
            nd = td + adjm[v][k][sn]
            if d[k] > nd:
                d[k] = nd
                heapq.heappush(q, (nd, k))
    return d


def main():
    N, M, S, T = map(int, input().split(" "))
    S -= 1
    T -= 1
    adjm = [{} for _ in range(N)]
    for i in range(M):
        u, v, a, b = map(int, input().split(" "))
        u -= 1
        v -= 1
        adjm[u][v] = adjm[v][u] = (a, b)
    cy = dj(adjm, 0, S)
    cs = dj(adjm, 1, T)
    cl = [(cy[i] + cs[i], i) for i in range(N)]
    heapq.heapify(cl)

    ic = int(1e15)
    c, y = heapq.heappop(cl)
    for i in range(N):
        while y < i:
            c, y = heapq.heappop(cl)
        print(ic-c)


if __name__ == "__main__":
    main()

Measured memory_bytes: 78188
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const int INF = 1001001001;

int main(){
    string s; cin >> s;
    s = '0' + s;
    ll n = s.size();
    ll dp[n+1][2];
    ll x = s.at(n-1) -'0';
    dp[1][0] = x;
    dp[1][1] = 10-x;
    for(int i=1;i<n;i++){
        x = s.at(n-1-i) - '0';
        dp[i+1][0] = min(dp[i][0]+x , dp[i][1]+x+1);
        dp[i+1][1] = min(dp[i][0]+(10-x), dp[i][1]+(10-(x+1)));
    }
    cout << min(dp[n][0],dp[n][1]) << endl;
    return 0;
}


Measured memory_bytes: 16944
from collections import deque
H, W = map(int, input().split())
M = [list(input()) for _ in range(H)]
white = 0
for line in M:
    white += line.count('.')
visited = [[False for _ in range(W)] for _ in range(H)]
que = deque()
que.append((0, 0, 1))
visited[0][0] = True
dirction = ((1, 0), (0, 1), (-1, 0), (0, -1))
while que:
    h, w, count = que.popleft()
    if (h, w) == (H - 1, W - 1):
        print(white - count)
        break
    for i in range(4):
        nh, nw = (h + dirction[i][0], w + dirction[i][1])
        if 0 <= nh <= H - 1 and 0 <= nw <= W - 1:
            if M[nh][nw] == '.' and not visited[nh][nw]:
                que.append((nh, nw, count + 1))
                visited[nh][nw] = True
else:
    print(-1)

Measured memory_bytes: 3316
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

namespace io {
    void setIn(string s) { freopen(s.c_str(),"r",stdin); }
    void setOut(string s) { freopen(s.c_str(),"w",stdout); }
    void setIO(string s = "") {
        ios_base::sync_with_stdio(0); cin.tie(0);
        if (sz(s)) { setIn(s+".in"), setOut(s+".out"); }
    }
    
    // double input seems slow on CF
    void re(double& x) { string t; cin >> t; x = stod(t); } 
    void re(ld& x) { string t; cin >> t; x = stold(t); }
    template<class T> void re(T& x) { cin >> x; }
    template<class Arg, class... Args> void re(Arg& first, Args&... rest) { re(first); re(rest...); }
    
    // pair
    template<class T1, class T2> istream& operator>>(istream& is, pair<T1,T2>& p) {
        is >> p.f >> p.s;
        return is;
    }
    template<class T1, class T2> ostream& operator<<(ostream& os, const pair<T1,T2>& a) {
        os << '{' << a.f << ", " << a.s << '}';
        return os;
    }
    
    // vector
    template<class T> istream& operator>>(istream& is, vector<T>& a) {
        int sz; is >> sz; a.resize(sz);
        F0R(i,sz) is >> a[i];
        return is;
    }
    template<class T> ostream& operator<<(ostream& os, const vector<T>& a) {
        os << "{";
        F0R(i,sz(a)) {
            if (i) os << ", ";
            os << a[i];
        }
        os << "}";
        return os;
    }
}

using namespace io;

ll N,M;
string S,T;
map<ll,char> m;

int main() {
    setIO(); re(N,M,S,T);
    ll x = N*M/__gcd(N,M);
    F0R(i,N) m[i*x/N] = S[i];
    F0R(i,M) if (m.count(i*x/M) && m[i*x/M] != T[i]) {
        cout << -1;
        exit(0);
    }
    cout << x;
}
/* 
* (Actually read this pls)
    * Rlly bad errors: int overflow, array bounds
    * Less bad errors: special cases (n=1?), set tle
    * Common sense: do smth instead of nothing
*/

Measured memory_bytes: 6144
input1 = raw_input().replace("\n", "")
input2 = int(raw_input().replace("\n", ""))

def count_ones(xs):
    count = 0
    for x in xs:
        if int(x) != 1:
            break
        else:
            count += 1
    return count

if int(input1[0]) > 1:
    print input1[0]
else:
    len_ones = count_ones(input1)
    if input2 <= len_ones:
        print 1
    else:
        print input1[len_ones]

Measured memory_bytes: 2696
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"n,m,*a=open(0).read().split();n,m=int(n),int(m);r=range(n-m+1);print('YNeos'[all(a[n:]!=[t[j:j+m]for t in a[i:i+m]]for i in r for j in r)::2])\n"
"\"";
  system(s);
  return 0;
}            

Measured memory_bytes: 7236
#include <bits/stdc++.h>
using namespace std;
int main(){
  int K;
  cin>>K;
  /*1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51*/
  if(K==1)cout<<1<<endl;
  if(K==2)cout<<1<<endl;
  if(K==3)cout<<1<<endl;
  if(K==4)cout<<2<<endl;
  if(K==5)cout<<1<<endl;
  if(K==6)cout<<2<<endl;
  if(K==7)cout<<1<<endl;
  if(K==8)cout<<5<<endl;
  if(K==9)cout<<2<<endl;
  if(K==10)cout<<2<<endl;
  if(K==11)cout<<1<<endl;
  if(K==12)cout<<5<<endl;
  if(K==13)cout<<1<<endl;
  if(K==14)cout<<2<<endl;
  if(K==15)cout<<1<<endl;
  if(K==16)cout<<14<<endl;
  if(K==17)cout<<1<<endl;
  if(K==18)cout<<5<<endl;
  if(K==19)cout<<1<<endl;
  if(K==20)cout<<5<<endl;
  if(K==21)cout<<2<<endl;
  if(K==22)cout<<2<<endl;
  if(K==23)cout<<1<<endl;
  if(K==24)cout<<15<<endl;
  if(K==25)cout<<2<<endl;
  if(K==26)cout<<2<<endl;
  if(K==27)cout<<5<<endl;
  if(K==28)cout<<4<<endl;
  if(K==29)cout<<1<<endl;
  if(K==30)cout<<4<<endl;
  if(K==31)cout<<1<<endl;
  if(K==32)cout<<51<<endl;
}

Measured memory_bytes: 3568
n=int(input())
a=[0]*n
b=[0]*n
ans=0
for i in range(n):
    a[i],b[i]=map(int,input().split())
for i in range(n-1,-1,-1):
    a[i]+=ans
    if a[i]%b[i]!=0:
        if b[i]<=a[i]:
            ans+=(a[i]//b[i]+1)*b[i]-a[i]
        else:
            ans+=b[i]-a[i]
print(ans)



Measured memory_bytes: 14836
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

int main(){
    int N;cin >> N;
    map<int,ll> a;
    vector<ll> r;
    rep(i,N){
        ll b;
        cin >> b;
        a[b]++;
        if(a[b]==1)r.push_back(b);
    }
    sort(All(r));
    if(r[0]==0){
        if(a.size()==1){
            cout << "Yes" << endl;
            return 0;
        }else if(a.size()==2){
            if(2*a[r[0]]==a[r[1]]){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    if(r.size()==3){
        if((r[0]^r[1])==r[2]&&(a[r[0]]==a[r[1]]&&a[r[1]]==a[r[2]]))cout << "Yes" << endl;
        else cout << "No" << endl;
    }else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 5748
n = int(input())
cards = dict()

for i in range (n):
    card = input()
    cards[card] = True
    
for m in ["S", "H", "C", "D"]:
    for i in range(1, 14):
        key = m + " " + str(i)
        if not key in cards:
            print(key)


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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9 +7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

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

#############
# Main Code #
#############

N = inputI()
l = inputIL()

now = 0
boom = 0
for i in l:
  if i != now + 1:
    boom += 1
  else:
    now += 1
    
if boom == N:
  print("-1")
else:
  print(boom)

Measured memory_bytes: 96584
# https://atcoder.jp/contests/abc161/tasks/abc161_d
from collections import deque

K = int(input())
ans = 0
count = 0
queue = deque()
for i in range(1, 10):
    queue.append(i)

while True:
    count += 1
    a = queue.popleft()
    if count == K:
        print(a)
        exit(0)

    for i in range(-1, 2):
        d = a % 10 + i
        if d < 0 or d > 9:
            continue
        queue.append(a * 10 + d)


Measured memory_bytes: 12404
/**
 * Author : Dhakad_123
 * Created: 28.06.2020
 **/

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


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

	int a;
	cin >> a;

	int sum =  a + (a * a) + (a * a * a);
	cout << sum <<"\n";

	return 0;
}


Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {

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

		boolean bool1 = false,bool2 = false;
		for(int i=0;i<str.length();i++){
			char c = str.charAt(i);
			if(c=='C'){
				bool1 = true;
			}
			if(bool1&&c=='F'){
				bool2 = true;
			}
		}
		if(bool2) System.out.println("Yes");
		else System.out.println("No");

	}

}

Measured memory_bytes: 9940
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  loop(i,0,n)
#define all(c) c.begin(),c.end()
#define vi vector<int>
#define vl vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>

int main(){
    ll int N;
    ll int A[5];
    cin>>N;
    cin>>A[0]>>A[1]>>A[2]>>A[3]>>A[4];

    ll int m=A[0];
    ll int c=0;
    rep(i,4){
        if(A[i+1]<m){
            m=A[i+1];
            c++;
        }
    }
    //cout<<(N/A[0])+5+c<<endl;
    if(N%m==0)cout<<N/m+4<<endl;
    else cout<<N/m+5<<endl;
    //cout<<N*1.0/1<<endl;
}

Measured memory_bytes: 256
import math

n = int(input())
aL = list(map(int, input().split(" ")))

mc = 0
for a in aL:
    if a < 0:
        mc += 1

aL = list(map(lambda x: abs(x), aL))

if mc % 2 == 0:
    print(sum(aL))
else:
    print(sum(aL) - (2 * min(aL)))


Measured memory_bytes: 20512
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, k, *a = map(int, read().split())
now = []
ans = 0
for i, aa in enumerate(a):
    v = aa
    now.append(v)
    for aaa in a[i + 1:]:
        v += aaa
        now.append(v)
for m in range(40, -1, -1):
    ans *= 2
    cnt = 0
    bit = 1 << m
    nxt = []
    for num in now:
        if num & bit:
            cnt += 1
            nxt.append(num)
    if k <= cnt:
        ans += 1
        now = nxt
print(ans)


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

using namespace std;

int main(){
    int a,b;
    cin >> a >> b;
    if(a==b){
        cout << "Draw" << endl;
    }else if(a==1){
        cout << "Alice" << endl;
    }else if(b == 1){
        cout << "Bob" << endl;
    }else if(a>b){
         cout << "Alice" << endl;
    }else{
        cout << "Bob" << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
using namespace std;


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

int h, w;
vector<vector<char> > s(50, vector<char>(50));
void solve(void){
  int nx[4] = {0, 0, 1, -1};
  int ny[4] = {1, -1, 0, 0};

  for(int i = 0; i < h; ++i){
    for(int j = 0; j < h; ++j){
      bool is_exist;

      if(s[i][j] == '#'){
        is_exist = false;
        for(int k = 0; k < 4; ++k){
          if(j + nx[k] < 0 || j + nx[k] >= w) continue;
          if(i + ny[k] < 0 || i + ny[k] >= h) continue;
          if(s[i + ny[k]][j + nx[k]] == '#')  is_exist = true;
        }
        if(!is_exist){
          cout << "No" << endl;
          return;
        }
      }
    }
  }
  cout << "Yes" << endl;
  return;
}

int main(){
  cin >> h >> w;
  rep(i, h){
    rep(j, w){
      cin >> s[i][j];
    }
  }

  solve();

}


Measured memory_bytes: 256
use std::io::{stdin, BufReader, StdinLock, BufRead};

fn main() {
    let std_in = stdin();
    let mut br = BufReader::new(std_in.lock());

    let s = rs(&mut br);
    let f = s[0].to_digit(10).unwrap() * 10 + s[1].to_digit(10).unwrap();
    let b = s[2].to_digit(10).unwrap() * 10 + s[3].to_digit(10).unwrap();
    let fb = f > 0 && f < 13;
    let bb = b > 0 && b < 13;
    if fb && bb {
        println!("AMBIGUOUS");
    } else if fb {
        println!("MMYY");
    } else if bb {
        println!("YYMM");
    } else {
        println!("NA");
    }
}


//////////////////////////////////////////////////////////////////////////////////
#[allow(dead_code)]
fn rs(br: &mut BufReader<StdinLock>) -> Vec<char> {
    let mut buf = String::new();
    br.read_line(&mut buf).ok();
    buf.trim().chars().collect()
}

#[allow(dead_code)]
fn rn<T: std::str::FromStr>(br: &mut BufReader<StdinLock>) -> T {
    let mut buf = String::new();
    br.read_line(&mut buf).ok();
    buf.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn rvs(br: &mut BufReader<StdinLock>) -> Vec<Vec<char>> {
    let mut buf = String::new();
    br.read_line(&mut buf).ok();
    buf.trim().split_whitespace().map(|e| e.chars().collect()).collect()
}

#[allow(dead_code)]
fn rvn<T: std::str::FromStr>(br: &mut BufReader<StdinLock>) -> Vec<T> {
    let mut buf = String::new();
    br.read_line(&mut buf).ok();
    buf.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}



Measured memory_bytes: 4352
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;

typedef pair<ll,int> P;

struct edge{int to;ll cost;};
ll INF=pow(10,18);

//隣接リスト
vector<vector<edge>> G;

//最短距離
vec d;

void dijkstra(int s){
    priority_queue<P,vector<P>,greater<P>> que;
    fill(d.begin(),d.end(),INF);
    d[s]=0;
    que.push(P(0,s));

    while(!que.empty()){
        P p=que.top();que.pop();
        int v=p.second;
        if(d[v]<p.first) continue;
        for(auto e:G[v]){
            if(d[e.to]>d[v]+e.cost){
                d[e.to]=d[v]+e.cost;
                que.push(P(d[e.to],e.to));
            }
        }
    }
}

int main(){
    int N;cin>>N;
    d.resize(310);
    G.resize(310);
    ll A;
    tuple<ll,int,int> t[100000];
    int k=0;
    for(int i=1;i<=N;i++){
        for(int j=1;j<=N;j++){
            cin>>A;
            if(i<j){
                t[k]=make_tuple(A,i,j);
                k++;
            }
        }
    }
    sort(t,t+k);
    ll ans=0;
    for(int i=0;i<k;i++){
        int x=get<1>(t[i]),y=get<2>(t[i]);
        ll dist=get<0>(t[i]);
        dijkstra(x);
        if(d[y]<dist){
            cout<<"-1"<<endl;
            return 0;
        }
        else if(d[y]>dist){
            G[x].push_back((edge){y,dist});
            G[y].push_back((edge){x,dist});
            ans+=dist;
        }
    }
    cout<<ans<<endl;
    return 0;

}

Measured memory_bytes: 1920
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


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

  vector<int> h(N);
  REP(i, N) cin >> h[i];

  int ok = 1e9;
  int ng = -1;
  while(ok-ng > 1){
    int mid = (ok+ng)/2;
    int cnt = 0;
    REP(i, N){
      if(h[i]-mid*B > 0) cnt += (h[i]-mid*B+(A-B)-1)/(A-B);
    }
    if(cnt <= mid) ok = mid;
    else ng = mid;
  }

  cout << ok << endl;

  return 0;
}

Measured memory_bytes: 1024
import sys
n=int(input())
sys.setrecursionlimit(k:=2*n)
T=[[]for _ in"_"*k]
for _ in range(n-1):a,b=map(int,input().split());T[a]+=b,;T[b]+=a,
def d(v,p):
 r=0
 for s in T[v]:
  if s!=p:r^=d(s,v)+1
 return r
print("ABloibc e"[d(1,1)<1::2])

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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

ll gcd(ll a, int b)
{
    if (a < b)
        gcd(b, a);
    if (b == 0)
        return a;
    int r;
    while ((r = a % b))
    {
        a = b;
        b = r;
    }
    return b;
}

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    string s;
    cin >> s;

    int al[26] = {};

    bool f = true;
    for (int i = 0; i < s.size(); i++)
    {
        if (al[s[i] - 'a']++ > 0)
            f = false;
    }

    if (f)
        cout << "yes" << endl;
    else
        cout << "no" << endl;
}


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

const int INF = 1 << 30;
int n,r[200000];

void solve(){
  int ans = -INF, pos = 0;
  for(int i=1;i<n;i++){
    ans = max(ans,r[i] - r[pos]);
    if(r[pos] > r[i]){
      pos = i;
    }
  }
  cout << ans << endl;
}

int main(){
  while(cin >> n){
    for(int i=0;i<n;i++) cin >> r[i];
    solve();
  }
}

Measured memory_bytes: 1940
#include<bits/stdc++.h>
#define H 1000000000
using namespace std;
int main(){
    int n,K;
    scanf("%d%d",&n,&K);
    vector<int> h(n);
    for(int i=0;i<n;i++){
        scanf("%d",&h[i]);
    }
    vector<int> dp(n,H);
    dp[0] = 0;
    for(int i=1;i<n;i++){
        for(int k=1;k<=K;k++){
            if(i>=k)
                dp[i] = min(dp[i],dp[i-k]+abs(h[i]-h[i-k]));
        }
    }
    printf("%d\n",dp[n-1]);
    return 0;
}

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

int main(void) {
    int N;
    char n[255];
    char n2;
    int S=0;
    int S2=0;
    int i;
    
    scanf("%d",&N);
    sprintf(n, "%d", N);
    for (i=0; i<=strlen(n)-1; i++) {
        n2=n[i];
        S2=atoi(&n2);
        S=S+S2;
    }
    if (N%S == 0) {
        printf("Yes");
    } else {
        printf("No");
    }
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<climits>

#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

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


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
const int INF = INT32_MAX / 3;
const ll MOD = 1e9 + 7;

int dx[4] = { 1,0,0,-1 };
int dy[4] = { 0,1,-1,0 };


/******************************************************************************************/


int main() {

	
	int q;
	cin >> q;
	map<string,int> mp;

	for (int i = 0; i < q; i++)
	{
		string s;
		int c, d;
		cin >> c;
		
		
		if (c == 0) {
			cin >> s;
			cin >> d;
			mp[s] = d;
		}
		else if (c == 1) {
			cin >> s;
			cout << mp[s] << endl;
		}
		else
		{
			cin >> s;
			mp.erase(s);
		}
	}
	

	
	return 0;
}


Measured memory_bytes: 27820
#include<bits/stdc++.h>
#define MN 400
#define mod 1000000007
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n,m,a[MN+5],b[MN+5],sum[MN+5][MN+5],f[MN+5][MN+5];
int main()
{  
    n=read();m=read();
    for(int i=1;i<=n;++i) a[i]=read();
    for(int i=1;i<=n;++i) b[i]=read();
    for(int i=1;i<=400;++i)
        for(int j=0,k=1;j<=400;++j) 
            sum[j][i]=(sum[j][i-1]+k)%mod,k=1LL*k*i%mod;
    f[0][0]=1;
    for(int i=1;i<=n;++i) for(int j=0;j<=m;++j) if(f[i-1][j])
        for(int k=0;j+k<=m;++k)
            f[i][j+k]=(f[i][j+k]+1LL*f[i-1][j]*(sum[k][b[i]]-sum[k][a[i]-1]+mod))%mod;
    printf("%d\n",f[n][m]);
    return 0;
}

Measured memory_bytes: 1536
import java.util.Scanner;
import java.util.InputMismatchException;

class Main {
   public static void main(String args[]) {
      int x=0 ,y=0, z=0;
      int sum = 0;
      try {
         Scanner scanner = new Scanner(System.in);
         x = scanner.nextInt();
         y = scanner.nextInt();
         z = scanner.nextInt();
         scanner.close();
      } catch (InputMismatchException e) {
         System.out.println("error");
      }
      for (int i=x; i<z+1; i=i+x) {
         sum = sum+y;
      }
      System.out.println(sum);
   }
}


Measured memory_bytes: 23252