akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;
const ll IINF = 1e9;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;

#define dump(x) cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
template <typename T>
void dumpvec(vector<T> vec) {
  for (T cnt : vec) {
    cout << cnt << ", ";
  }
  cout << endl;
}

void chmin(ll &a, ll b) {
  if (a > b) {
    a = b;
  }
}
void chmax(ll &a, ll b) {
  if (a < b) {
    a = b;
  }
}

int main() {
  int N, X, Y;
  cin >> N >> X >> Y;
  vector<vector<ll>> distances =
      vector<vector<ll>>(N + 1, vector<ll>(N + 1, 1));

  for (int i = 1; i <= N; i++) {
    for (int j = i + 1; j <= N; j++) {
      distances[i][j] = 1;
      // 1. 自然順序
      distances[i][j] = (j - i);

      // 2. Xを使う経路
      // i -> X -> Y -> j
      int pathViaX = abs(X - i) + 1 + abs(Y - j);
      chmin(distances[i][j], pathViaX);

      // 3. Yを使う経路
      // i -> Y -> X -> j
      int pathViaY = abs(Y - i) + 1 + abs(X - j);
      chmin(distances[i][j], pathViaY);
    }
  }

  vector<int> sums = vector<int>(N, 0);
  for (int i = 1; i <= N; i++) {
    for (int j = i + 1; j <= N; j++) {
      sums[distances[i][j]]++;
    }
  }

  for (int i = 1; i < N; i++) {
    cout << sums[i] << endl;
  }
}

Measured memory_bytes: 31616
#include <bits/stdc++.h>
using namespace std;
#define maxn 100010
#define ll long long
#define db double
#define vi vector<int>
#define pb push_back
#define mod 998244353
ll ksm(ll a, ll b) {
   if (!b) return 1;
   ll ns = ksm(a, b >> 1);
   ns = ns * ns % mod;
   if (b & 1) ns = ns * a % mod;
   return ns;
}
// head
int a[maxn], b[maxn], p[maxn], q[maxn];
int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) 
		cin >> p[i], q[p[i]] = i;
	int mn = 0;
	for (int i = 1; i <= n; i++) {
		int ea = a[i - 1] + 1, eb = b[i - 1] - 1;
		if (ea + eb < q[i]) ea = q[i] - eb;
		else eb = q[i] - ea;
		a[i] = ea, b[i] = eb;
		mn = min(mn, b[i]);
	}
	for (int i = 1; i <= n; i++)
		b[i] += -mn + 1;
	for (int i = 1; i <= n; i++)
		printf("%d ", a[i]);
	printf("\n");
	for (int i = 1; i <= n; i++)
		printf("%d ", b[i]);
	return 0;
}


Measured memory_bytes: 896
import java.util.*;
import java.io.*;

import static java.lang.System.in;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long P = sc.nextLong();
        if(n==1){
            System.out.println(P);
            System.exit(0);
        }
        long upper = (long) Math.sqrt(P)+1;
        long ans=1;
        for(long i=2;i<=upper&&i<=P;i++){
            if(P%i!=0) continue;
            long cnt=0;
            while(P%i==0){
                cnt++;
                P = P/i;
            }
            long now = cnt/n;
            ans*=(long) Math.pow(i,now);
        }
        PrintWriter out = new PrintWriter(System.out);
        out.println(ans);
        out.flush();
    }
}


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

using namespace std;

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

// Sorting
void insertionSort(int n,int*a,int g=1){for(int i=g;i<n;++i){int v=a[i],j=i-g;while(j>=0&&a[j]>v){a[j+g]=a[j];j-=g;}a[j+g]=v;}}
void shellSort(int n,int*a){vector<int>G;for(int h=1;;){if(h>n)break;G.push_back(h);h=3*h+1;}for(int i=G.size()-1;i>=0;--i)insertionSort(n,a,G[i]);}
int bubbleSort(int n,int*a){int s=0,j;bool f=1;for(int i=0;f;++i){f=0;for(j=n-1;j>=i+1;--j){if(a[j]<a[j-1]){swap(a[j],a[j-1]);f=1;s++;}}}return s;}
int selectionSort(int n,int*a){int s=0,j,m;for(int i=0;i<n-1;++i){m=i;for(j=i;j<n;++j)if(a[j]<a[m])m=j;swap(a[i],a[m]);if(i!=m)++s;}return s;}

// Searching
int binarySearch(int n,int*a,int k){int m,l=0,r=n;while(l<r){m=l+(r-l)/2;if(k<a[m])r=m;else if(a[m]<k)l=m+1;else return m;}return-1;}

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

// Visualization
void printArray(int n,int*a){for(int i=0;i<n;++i)printf(i>0?" %d":"%d",a[i]);printf("\n");}

int main(){
	string s,t; cin >> s >> t;
	cout << t << s << endl;
}

Measured memory_bytes: 256
// Problem : B - Substring
// Contest : AtCoder - AtCoder Beginner Contest 177
// URL : https://atcoder.jp/contests/abc177/tasks/abc177_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

// Delete the dynamically allocated memory

#include<bits/stdc++.h>
using namespace std;
 
#define ff              first
#define ss              second
#define pb              push_back
#define pr              pair<long long,long long>
#define mp(a,b)         make_pair(a,b)
#define vr              vector<long long>
#define mod1            1000000007
#define mod2            998244353
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define fill(a,b)       memset(a, b, sizeof(a))
#define mk(arr,n,type)  type *arr=new type[n];
#define ll              long long
#define ld	            long double
#define w(x)            int x; cin>>x; while(x--)

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	string s,t;
	cin>>s>>t;
	ll mn=inf;
	for(ll i=0;i<=s.length()-t.length();i++){
		string a=s.substr(i,t.length());
		ll z=0;
		for(ll j=0;j<t.length();j++){
			if(t[j]!=a[j]){
				z++;
			}
		}
		mn=min(mn,z);
	}
	cout<<mn<<"\n";
	return 0;
	}

Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
long long ans = INT64_MAX;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    vector<pair<int, int> > XY(N);
    set<int> XS, YS;
    for (auto &xy : XY) {
        cin >> xy.first >> xy.second;
        XS.insert(xy.first);
        YS.insert(xy.second);
    }
    vector<int> X(XS.begin(), XS.end()), Y(YS.begin(), YS.end());
    int Xsize = X.size(), Ysize = Y.size();
    for (int i = 0; i < Xsize; i++) for (int j = i; j < Xsize; j++) for (int k = 0; k < Ysize; k++) for (int l = k; l < Ysize; l++) {
        int count = 0;
        for (auto &xy : XY) {
            if (X[i] <= xy.first && X[j] >= xy.first && Y[k] <= xy.second && Y[l] >= xy.second) count++;
        }
        if (count >= K) ans = min(ans, ((long long)X[j]-X[i])*((long long)Y[l]-Y[k]));
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#define D(x) cout<<"D:"<<#x<<'='<<x<<endl;
using namespace std;
typedef long long ll;
int main(void)
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int T;
	cin>>T;
	while(T--)
	{
		int k;
		cin>>k;
		if(!(k%2) && k%3 && k%5)
		{
			puts("DENIED");
			return 0;
		}
	}
	puts("APPROVED");
	return 0;
}
//自作，无改编

Measured memory_bytes: 256
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var s = input.ReadLine();

        long bcount = 0;
        long sum = 0;

        for(int i=s.Length-1; i>=0; i--) {
            var c = s[i];
            if (c == 'A') {
                sum += bcount;
            } else if (c == 'C' && i > 0 && s[i - 1] == 'B') {
                bcount++;
                i--;
            } else {
                bcount = 0;
            }
        }

        return sum;
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 11744
import collections

N, K = map(int, input().split())
values = list(map(int, input().split()))

obj, cnt = zip(*collections.Counter(values).most_common()[::-1])
cnt = [i for i in cnt]

N_diff = max(0, len(cnt) - K)
ans = sum(cnt[: N_diff])
print(ans)


Measured memory_bytes: 41236
#include <iostream>

int main() {
    int n, k;
    std::cin >> n >> k;

    int ans = 0;
    for (int i = 0; i < n; i++) {
        int h;
        std::cin >> h;
        if (h >= k) {
            ans++;
        }
    }

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


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define MOD 1000000007LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(int)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a, b;
	cin >> a >> b;
	if(a == b) {
		cout << a << endl;
		return 0;
	}
	if(a + 1 == b) {
		cout << (a ^ b) << endl;
		return 0;
	}
	ll ans = 0;
	if(a % 2) {
		ans ^= a;
		a++;
	}
	if(b % 2 == 0) {
		ans ^= b;
		b--;
	}
	if(((b - a + 1) / 2) % 2) {
		ans ^= 1;
	}
	cout << ans << endl;
}
/* --------------------------------------- */


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define re return
#define ll long long
#define ld long double
#define f first
#define s second
#define pi acos(-1)
#define oo (int)1e9
#define OO (ll)1e18
#define EPS 1e-7
#define FX(n) fixed<<setprecision(n)
#define mm(o,k) memset(o,k,sizeof o)
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int maxn=505;

int main()
{
    IO;
    ll n,m;
    cin >> n >> m;
    cout<<abs((n*m)-(((n+m)*2)-4))<<endl;
    re 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
int n,a[200010];
int k,cnt[200010];
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=k;i++){
		bool flg=1;
		int cur=0;
		for(int i=1;i<=n;cnt[i]=0,i++){
			if(a[i]!=n)flg=0;
		}
		if(flg)break;
		for(int i=1;i<=n;i++){
			cnt[max(1,i-a[i])]++;
			cnt[min(n+1,i+a[i]+1)]--;
		}
		for(int i=1;i<=n;i++){
			cur+=cnt[i];
			a[i]=cur;
		}
	}
	for(int i=1;i<=n;i++)cout<<a[i]<<" ";
}


Measured memory_bytes: 5172
#include <stdio.h>
#include <stdlib.h>

#define NMAX    111
#define WMAX    111111

long max(long x, long y) {
    return (x > y) ? x : y;
}

int main() {
    int i, j;
    long n, w, weight, val;
    scanf("%ld %ld", &n, &w);
    long weights[n], values[n];

    static long dp[NMAX][WMAX] = {0};

    for (int i = 0; i < n; i++) {
        scanf("%ld %ld", &weights[i], &values[i]);

    }

    getchar();

    for (i = 0; i < n; i++) {
        for (j = 0; j <= w; j++) {
            if (i == 0 && j == 0) dp[i][j] = 0;
            else if (i == 0) {
                //printf("%ld\n", values[i]);
                if (j >= weights[i]) dp[i][j] = values[i];
                //printf("%ld\n", dp[i][j]);
            } else {
                if (j < weights[i] && j == 0) dp[i][j] = dp[i - 1][j];
                else if (j < weights[i]) dp[i][j] = dp[i - 1][j];
                else if (j == weights[i]) {

                    dp[i][j] = max(dp[i - 1][j], values[i]);
                }
                else if (j > weights[i]) {
                    dp[i][j] = max(max(dp[i - 1][j - weights[i]] + values[i], dp[i - 1][j]), dp[i][j - 1]);

                }
            }
        }
    }

    printf("%ld\n", dp[i - 1][j - 1]);

}

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

int main() {
  int N;
  cin >> N;

  map<string, int> m;
  rep(i, N) {
    string s;
    cin >> s;

    decltype(m)::iterator it = m.find(s);
    if (it != m.end()) {
      int cnt = it->second;
      m.erase(s);
      m.emplace(s, cnt + 1);
    } else {
      m.emplace(s, 1);
    }
  }

  int M;
  cin >> M;
  rep(i, M) {
    string s;
    cin >> s;

    decltype(m)::iterator it = m.find(s);
    if (it != m.end()) {
      int cnt = it->second;
      m.erase(s);
      m.emplace(s, cnt - 1);
    } else {
      m.emplace(s, 1);
    }
  }

  int ret = accumulate(
      m.begin(), m.end(), 0,
      [](int acc, std::pair<string, int> p) { return max(acc, p.second); });

  ret = max(0, ret);
  cout << ret << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
#include<map>
#include<iostream>
using namespace std;
int a[1000010];
int n,h,w,k;

int main(){
    //freopen("sort.in","r",stdin);
    //freopen("sort.out","w",stdout);
    while (scanf("%d",&h)!=EOF) {
        printf("%d\n",(1000-h%1000)%1000);
    }
    return 0;
}



Measured memory_bytes: 3232
N = gets.to_i

ans = Array.new # 昇順

N.times do 
    a = gets.to_i

    if ans.size == 0
        ans.push(a)
        next
    end

    idx = ans.bsearch_index { |x| x >=  a }

    if idx == nil
        # a is the biggest
        ans[ans.size - 1] = a
    elsif idx == 0
        # a is the smallest
        ans.unshift(a)
    else
        ans[idx - 1] = a
    end
end

puts ans.size

Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K;
  cin >> N >> K;
  int x[N];
  for (int i = 0; i < N; i++)
    cin >> x[i];
  int num = 0;
  
  for (int i = 0; i < N; i++){
  	if(x[i] >= K - x[i]){
    	num += K - x[i];
    }else{
    	num += x[i];
    }
  }
    cout << num *2 << endl;
 
}

Measured memory_bytes: 3516
n,k=map(int,input().split())
for i in range(99999):
  if 2**i<k:
    continue
  else:
    start=i
    break

key=start
def p(n):
  return 2**(n)

ans=1
for i in range(2,n+1):
  if i<k:
    if i*p(key-1)<k<i*p(key):
      pass
    elif i*p(key-1)==k:
      key-=1
    elif i*p(key-2)<k<i*p(key-1):
      key-=1
    ans+=p(start-key)
  else:
    ans+=p(start)
print('{:.11f}'.format(ans/(p(start)*n)))

Measured memory_bytes: 3064
//
// Created on 2019/12/05.
//

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(x) x.begin(),x.end()
#define DEBUG

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

    int ans = 0;
    if(a > b) ans = 2 * a - 1;
    else if(a < b) ans = 2 * b - 1;
    else if(a == b) ans = a * 2;

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



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
#define inf 1e9


int main(){
string s;
cin>>s;
int res = inf;
int p = 0;
int d=0;
for(int i=0;i<s.size();i++){
	if(s[i]-'0'==p)d++;
	p++;
	p%=2;
}
res = d;
d = 0;
p=1;
for(int i=0;i<s.size();i++){
	if(s[i]-'0'==p)d++;
	p++;
	p%=2;
}
cout<<min(res,d)<<endl;


	return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int m = sc.nextInt();
			int f = sc.nextInt();
			int r = sc.nextInt();
			if (m == -1 && f == -1 && r == -1) break;
			System.out.println(grade(m, f, r));
		}
		sc.close();
	}
	
	private static char grade(int m, int f, int r) {
		int mf = m + f;
		if (m == -1 || f == -1 || mf < 30) {
			return 'F';
		} else if (30 <= mf && mf < 50) {
			if (r >= 50) {
				return 'C';
			}
			return 'D';
		} else if (50 <= mf && mf < 65) {
			return 'C';
		} else if (65 <= mf && mf < 80) {
			return 'B';
		} else {
			return 'A';
		}
	}
}

Measured memory_bytes: 26212
n, Y = map(int, input().split())
x = -1
y = -1
z = -1
for i in range(min(n, Y // 10000), -1, -1):
    for j in range(n - i, -1, -1):
        if 10000 * i + 5000 * j + 1000 * (n - i - j) == Y:
            x = i
            y = j
            z = n - i - j
            break
print(x, y, z)


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


def read():
    S = input().strip()
    return S,


def is_palindrome(seq):
    n = len(seq)
    for i in range(n//2):
        if seq[i] != seq[n-i-1]:
            return False
    return True


def solve(S):
    S = "*" + S + "*"
    T = [a for a in S if a != "x"]
    N = len(T) // 2 + len(T) % 2
    if not is_palindrome(T):
        return -1
    l = 0
    r = len(S)-1
    c = 0
    while c < N:
        if S[l] != "x":
            c += 1
        l += 1
    c = 0
    while c < N:
        if S[r] != "x":
            c += 1
        r -= 1
    
    L = S[:l]
    R = S[r+1:][::-1]
    ans = 0
    l, r = 0, 0
    for i in range(N+1):
        lc = 0
        rc = 0
        while l < len(L) and L[l] == "x":
            lc += 1
            l += 1
        while r < len(R) and R[r] == "x":
            rc += 1
            r += 1
        ans += abs(lc-rc)
        l += 1
        r += 1
    return ans


if __name__ == '__main__':
    inputs = read()
    print(solve(*inputs))


Measured memory_bytes: 9948
import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}

import scala.annotation.tailrec

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val n = in.readLine().toInt

    def negbin(n: Int): List[Int] = {
      @tailrec
      def inner(n: Int, acc: List[Int]): List[Int] = {
        if (n == 0) {
          acc match {
            case Nil => 0 :: Nil
            case acc => acc
          }
        } else if (n % 2 == 0) {
          inner(n / -2, 0 :: acc)
        } else {
          inner((n - 1) / -2, 1 :: acc)
        }
      }

      inner(n, Nil)
    }

    out.println(
      negbin(n).mkString("")
    )

    out.flush()
  }
}

Measured memory_bytes: 25504
#include <bits/stdc++.h>
using namespace std;
 
//Prints the Longest common subsequence
void printLCS( string s1, string s2, int m, int n )
{
   int L[m+1][n+1];
 
   //Building L[m][n] as in algorithm
   for (int i=0; i<=m; i++)
   {
     for (int j=0; j<=n; j++)
     {
       if (i == 0 || j == 0)
         L[i][j] = 0;
       else if (s1[i-1] == s2[j-1])
         L[i][j] = L[i-1][j-1] + 1;
       else
         L[i][j] = max(L[i-1][j], L[i][j-1]);
     }
   }
 
   //To print LCS
   int index = L[m][n];
   //charcater array to store LCS
   char LCS[index+1];
   LCS[index] = '\0'; // Set the terminating character
   
   //Stroing characters in LCS
   //Start from the right bottom corner character
   int i = m, j = n;
   while (i > 0 && j > 0)
   {
      //if current character in s1 and s2 are same, then include this character in LCS[]
      if (s1[i-1] == s2[j-1])
      {
          LCS[index-1] = s1[i-1]; // Put current character in result
          i--; j--; index--;     // reduce values of i, j and index
      }
      // compare values of L[i-1][j] and L[i][j-1] and go in direction of greater value.
      else if (L[i-1][j] > L[i][j-1])
         i--;
      else
         j--;
   }
 
   // Print the LCS
   cout << LCS<<endl;
}
 
/* Driver program to test above function */
int main()
{
    
  string s1,s2;
  cin>>s1>>s2;
  printLCS(s1, s2, s1.length() , s2.length());
  return 0;
}

Measured memory_bytes: 35456
use POSIX 'floor';
my $input = <STDIN>;
my @inputs = split(/ /,$input);
my $sPeace = int($inputs[0]);
my $cPeace = int($inputs[1]);
if($sPeace * 2 <= $cPeace){
	print floor($sPeace + ($cPeace - $sPeace * 2) / 4) + "\n";
} else {
	my $output = floor($cPeace / 2);
	if($output > $sPeace){
		$output = $sPeace;
	}
	print $output + "\n";	
}


Measured memory_bytes: 1792
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
template<class T> using vv=vector<vector< T > >;

int main() {
  int n, q;
  cin >> n >> q;
  vi a(q);
  vi b(q);
  rep (i, q) {
    cin >> a[i] >> b[i];
    a[i]--; b[i]--;
  }
  int current = 0;
  vi used(n, 0);
  used[1] = 1;
  rep (i, q) {
    if (current == a[i]) {
      current = b[i];
    } else if (current == b[i]) {
      current = a[i];
    }
    swap(used[a[i]], used[b[i]]);
    if (current == 0) {
      used[1] = 1;
    } else if (current == n-1) {
      used[n-2] = 1;
    } else {
      used[current-1] = used[current+1] = 1;
    }
  }
  used[current] = 1;
  int ans = 0;
  rep (i, n) {
    ans += used[i];
  }
  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define pb push_back
#define nl cout<<"\n"
#define db(x) cout<<x<<" "
#define fi(a,b) for(int i=a;i<b;i++)
#define fj(a,b) for(int j=a;j<b;j++)
#define fk(a,b) for(int k=a;k<b;k++)
#define F first
#define S second
#define UM unordered_map<int,int>
#define MP map<int,int>
#define mxsize (int)1e6
void fun(){
    string s;
    cin>>s;
    ll num=0;
    for(auto i:s)
        num+=i-'0';
    if(num%9==0){
        cout<<"Yes\n";
    }
    else{
        cout<<"No\n";
    }
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("/ATOM/input.txt", "r", stdin);
        freopen("/ATOM/output.txt", "w", stdout);
    #endif
    int t=1;
    // cin>>t;
    while(t--){
        fun();
    }
}

Measured memory_bytes: 3728
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
//cout << fixed << setprecision(8) << a << endl;
//cout << "Case " << ca << ": " << ans << endl;
#define Fast_Input ios_base :: sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define MX 100005
#define infinity 20000000
#define pb push_back
#define ll long long int
int main()
{
    double l;
    cin >> l;
    double z,ans;
    z=l/3;
    ans=z*z*z;

    cout << fixed << setprecision(12) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdint>
using namespace std;
uint64_t sq(uint64_t x){ return (x*x) % 998244353;}
uint64_t pow(uint64_t x, uint64_t y){
	return x == 0 ? 0 : y == 0 ? 1 : y == 1 ? x : (sq(pow(x, y / 2))*((y & 1) == 0 ? 1 : x)) % 998244353;
}

int main(){
	unsigned N; cin >> N;
  	vector<unsigned> Dn;
  	for(size_t i = 0; i < N; ++i){
		unsigned tmp; cin >> tmp;
      	if(i == 0 && tmp != 0){
          	cout << 0 << endl;
          	return 0;
        }
      	Dn.resize(max((unsigned)Dn.size(), tmp + 1));
		Dn[tmp]++;
    }
  	if(Dn[0] != 1){ 
      	cout << 0 << endl;
      	return 0;
    }
  	uint64_t ret = 1;
  	for(size_t i = 1; i < Dn.size(); ++i)
    	ret = (ret * (Dn[i - 1] == 1 ? 1 : (size_t)pow(Dn[i - 1], Dn[i]))) % 998244353;
    cout << ret << endl;
}


Measured memory_bytes: 1024
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

h,w = map(int,readline().split())
s = read().split()
color = [[0] * w for _ in range(h)]
for i in range(h):
    for j in range(w):
        if(s[i][j] =='#'):
            color[i][j] = 1

ans = 0
done = [[0] * w for _ in range(h)]
for i in range(h):
    for j in range(w):
        if(done[i][j]==1):
            continue

        cnt = [0]*2
        cnt[(i+j)%2] += 1
        done[i][j] = 1
        stack = [(i,j)]
        while(stack):
            x,y = stack.pop()
            for dx,dy in zip([-1,1,0,0],[0,0,-1,1]):
                dx += x
                dy += y
                if(0 <= dx < h)&(0 <= dy < w):
                    if(done[dx][dy] == 1):
                        continue
                    if(color[x][y] != color[dx][dy]):
                        done[dx][dy] = 1
                        stack.append((dx,dy))
                        cnt[(dx+dy)%2] += 1
        ans += cnt[0] * cnt[1]
        # print(i,j,cnt)

print(ans)

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

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

N = int(input())
ans = 0
for i in range(1, N + 1, 2):
    n = 0
    for j in range(1, i + 1):
        n += (i % j == 0)
    if n == 8:
        ans += 1
print(ans)


Measured memory_bytes: 5956
#include<stdio.h>
int main(){
	int x,a,b,t;
	scanf("%d",&x);
	scanf("%d",&a);
	scanf("%d",&b);
	if(a>=1&&a<=1000 && b>=1&&b<=1000){
		if(x>=a+b && x <=10000){
			t = (x-a) % b;
			printf("%d",t);
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
ll monster(ll h){
    if(h == 1)return 1;
    return 1+2*monster(h/2);
}
int main(){
    ll h;
    cin >> h;
    cout << monster(h) << endl;
    return 0;
}

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

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

    if ( b < c ){
        if( c - b < a){
            cout << b + c << endl;
        }else {
            if( (c - (b + a)) > 0 ){
                cout << 2 * b + a + 1 << endl;
            }else {
                cout << 2 * b + a << endl;
            }
        }
    }else {
        cout << a + c << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<map>
#include<deque>
#include<string>

#define all(x) (x).begin(),(x).end()
#define puts(x) cout<< x << endl;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define fore(i,a) for(auto i:a)
#define ll long long
using namespace std;
ll h,n;
ll a[100005];
int main(){
    cin>>h>>n;
    rep(i,0,n){
        ll x;
        cin>>x;
        h-=x;
    }
    if(h>0){
        puts("No");    
    }else{
        puts("Yes");
    }
}

Measured memory_bytes: 256
N = gets.to_i
A = 2.times.map { gets.split.map(&:to_i) }
max = 0
up = 0
down = A[1].inject(:+)
A[0].unshift 0
A[1].unshift 0
(1..N).each do |i|
  up += A[0][i]
  down -= A[1][i-1]
  max = [max, up + down].max
end
p max


Measured memory_bytes: 1788
#!/usr/bin/env python3
import sys


def solve(N: int, K: int):
    n = len(str(N))
    dp = [[[0]*2 for _ in range(5)] for _ in range(n+1)]
    # dp[i][j][k] = 上からi桁みたときに0以外がjこあり確定フラグ(0が未確定)がkをみたす数字の数
    number = str(N)
    dp[0][0][0] = 1

    for i in range(n):
        for j in range(4):
            if number[i] == "0":
                #　未確定から未確定
                dp[i+1][j][0] += dp[i][j][0]

                # 確定から確定
                dp[i+1][j+1][1] += dp[i][j][1]*9
                dp[i+1][j][1] += dp[i][j][1]        

                # 未確定から確定(なし)
            else:
                # 未確定から未確定
                dp[i+1][j+1][0] += dp[i][j][0]

                # 確定から確定
                dp[i+1][j+1][1] += dp[i][j][1]*9
                dp[i+1][j][1] += dp[i][j][1]

                # 未確定から確定
                dp[i+1][j+1][1] += dp[i][j][0]*(int(number[i])-1)
                dp[i+1][j][1] += dp[i][j][0]

    print(sum(dp[n][K]))
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, K)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>

// 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;
constexpr int MOD = 1000000007;
constexpr int INF = 1e18;

using namespace std;

vector<bool> can_goal;
bool bellmanford(int N, vector<vector<pair<int, int>>>& graph, vector<int>& d){
  for(int i = 0; i < N; i++){
    for(int v = 0; v < N; v++){
      for(int k = 0; k < (int)graph[v].size(); k++){
        pair<int, int> e = graph[v][k];
        if(can_goal[e.first] == false) continue;
        if(d[v] != INF && d[e.first] > d[v] + e.second){
          d[e.first] = d[v] + e.second;
          if(i == N-1) return true;
        }
      }
    }
  }
  return false;
}

signed main() {
  int N, M, P;
  cin >> N >> M >> P;

  vector<int> dist(N, INF);
  dist[0] = 0;
  vector<vector<pair<int, int>>> graph(N);
  vector<int> vec[N];

  int a, b, c;
  REP(i, M){
    cin >> a >> b >> c;
    a--; b--;
    c -= P;
    c *= -1;
    graph[a].push_back(make_pair(b, c));
    vec[b].push_back(a);
  }

  can_goal = vector<bool>(N, false);
  can_goal[N-1] = true;
  queue<int> q;
  q.push(N-1);
  while(!q.empty()){
    int top = q.front(); q.pop();
    for(int v : vec[top]){
      if(!can_goal[v]){
        can_goal[v] = true;
        q.push(v);
      }
    }
  }

  
  if(bellmanford(N, graph, dist)){
    cout << -1 << endl;
    return 0;
  }

  cout << max(0LL, -dist[N-1]) << endl;

  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>
#include <stdlib.h>
#define ll long long
#define MOD_P 1000000007
using namespace std;

int main()
{
	string test;
	int be, af;

	cin >> test;
	be = (int)(test[0] - '0') * 10 + (int)(test[1] - '0');
	af = (int)(test[2] - '0') * 10 + (int)(test[3] - '0');

	if (be == 0 || be > 12) {
		if (af == 0 || af > 12) {
			printf("NA");
		} else {
			printf("YYMM");
		}
	} else {
		if (af == 0 || af > 12) {
			printf("MMYY");
		} else {
			printf("AMBIGUOUS");
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
#define MOD 1000000007
long long n;
 
long long fast_pow(long long base, long long pow) {
  	if (pow==0) return 1;
	if (pow%2) return (fast_pow(base, pow-1)*base)%MOD;
  	else {
    	long long a = fast_pow(base, pow/2);
      	return (a*a)%MOD;
    }
}
 
signed main() {
	cin.tie(0); cout.sync_with_stdio(0);
	cin >> n;
	if (n < 2) {
		cout << "0\n";
		return 0;
	}
	long long ans = fast_pow(10, n)-2*fast_pow(9, n)+fast_pow(8, n);
	while (ans < 0) ans += MOD;
  	cout << ans << '\n';
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
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; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }



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

    long long res = 1<<30;
    for (int x = -200; x <= 200; ++x) {
        long long sum = 0;
        for (int i = 0; i < N; ++i) sum += (a[i]-x)*(a[i]-x);
        chmin(res, sum);
    }
    cout << res << endl;
}
    


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
map<int,int> mmp;
int A[222222];
int main()
{
	int N,K;scanf("%d%d",&N,&K);
	for(int i=1;i<=N;++i) scanf("%d",A+i);
	for(int i=1;i<=N;++i) A[i]=(A[i-1]+A[i]-1)%K;
	LL ans=0;
	mmp[0]++;
	for(int l=0,r=1;r<=N;++r)
	{
		if(r-l==K) mmp[A[l++]]--;
		ans+=mmp[A[r]];
		mmp[A[r]]++;
	}
	printf("%lld",ans);
	return 0;
}

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

int main(void) {
	int a[3];
	int aMax = 0;
	for (int i = 0; i < 3; i++) {
		scanf("%d", &a[i]);
		aMax = max(aMax, a[i]);
	}
	int diffSum = 0;
	for (int i = 0; i < 3; i++) {
		diffSum += aMax - a[i];
	}

	if (diffSum % 2 == 0) printf("%d\n", diffSum / 2);
	else printf("%d\n", diffSum / 2 + 2);

	return 0;
}


Measured memory_bytes: 3820
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long lint;

const int maxn = 52, ncolor = 3, mod = 1e9 + 7;

int dp[maxn][ncolor][ncolor];

int main() {
  int n;
  scanf("%d", &n);
  vector<string> field(2, string(n, ' '));
  for (int y = 0; y < 2; ++y)
    scanf("%s", &field[y][0]);

  for (int c0 = 0; c0 < ncolor; ++c0)
    for (int c1 = 0; c1 < ncolor; ++c1)
      if ((field[0][0] == field[1][0]) != (c0 == c1)) dp[0][c0][c1] = 0;
      else dp[0][c0][c1] = 1;
  for (int i = 0; i + 1 < n; ++i)
    for (int c0 = 0; c0 < ncolor; ++c0)
      for (int c1 = 0; c1 < ncolor; ++c1)
        for (int nextc0 = 0; nextc0 < ncolor; ++nextc0)
          for (int nextc1 = 0; nextc1 < ncolor; ++nextc1) {
            bool ok = true;
            if ((field[0][i + 1] == field[1][i + 1]) != (nextc0 == nextc1))
              ok = false;
            if ((field[0][i] == field[0][i + 1]) != (nextc0 == c0))
              ok = false;
            if ((field[1][i] == field[1][i + 1]) != (nextc1 == c1))
              ok = false;
            if (ok) {
              dp[i + 1][nextc0][nextc1] += dp[i][c0][c1];
              if (dp[i + 1][nextc0][nextc1] >= mod)
                dp[i + 1][nextc0][nextc1] -= mod;
            }
          }
  int result = 0;
  for (int c0 = 0; c0 < ncolor; ++c0)
    for (int c1 = 0; c1 < ncolor; ++c1) {
      result += dp[n - 1][c0][c1];
      if (result >= mod) result -= mod;
    }
  printf("%d\n", result);
  return 0;
}


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

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <tuple>
#include <queue>
#include <stack>
#include <set>
#include <map>

using namespace std;

class Solver {
};

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

		vector<vector<int>> grid(h, vector<int>(6, 0));
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < 5; j++) {
				int val;
				cin >> val;
				grid[i][j] = val;
			}
		}

		int res = 0;
		while (true) {
			bool exit = true;
			for (int i = 0; i < h; i++) {
				int prev = 0;
				int seq = 0;
				for (int j = 0; j < 6; j++) {
					if (prev == grid[i][j]) {
						seq++;
					}
					else {
						if (seq >= 3 && prev > 0) {
							res += prev * seq;
							for (int k = 1; k <= seq; k++) {
								grid[i][j - k] = 0;
							}
							exit = false;
						}
						prev = grid[i][j];
						seq = 1;
					}
				}
			}
			if (exit)break;

			for (int i = 0; i < 5; i++) {
				vector<int>tmp;
				for (int j = h - 1; j >= 0; j--) {
					if (grid[j][i] > 0)tmp.emplace_back(grid[j][i]);
				}
				for (int j = 0; j < h; j++) {
					if (j < tmp.size())grid[h - 1 - j][i] = tmp[j];

					else grid[h - 1 - j][i] = 0;
				}
			}
		}
		cout << res << endl;
	}
}



Measured memory_bytes: 3124
#include <iostream>

using namespace std;
using ll = long long;
using ld = long double;

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

void solve(string a, string b) {
  cout << (a==b ? 'H' : 'D') << endl;
}

int main() {
  string a;
  cin >> a;
  string b;
  cin >> b;
  solve(a, b);
  return 0;
}


Measured memory_bytes: 256
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_i
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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

#define ff first
#define fs second
#define lb lower_bound
#define ub upper_bound

#define int long long
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector< vi >
#define vpii vector< pii >
#define vb vector<bool>
#define si set<int>
#define mii map<int, int>
#define mci map<char, int>
#define md 1000000007
#define pb push_back
#define eb emplace_back
#define fio ios_base::sync_with_stdio (false); cin.tie (NULL);  cout.tie (NULL);
#define qw1(x) cerr<<#x<<": "<<x<<" "<<endl
#define qw2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define qw3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define qw4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl


#define f(i,a,b) for(int i=(int)a;i<=(int)b;i++)
#define rl(i,a,b) for(int i=(int)a;i>=(int)b;i--)
#define all(x) x.begin(),x.end()
#define endl '\n'
void printv(vector<int>  v){ for(int i=0;i<v.size();i++) cout<<v[i]<<' '; cout<<endl;   }
int bem(int m , int n, int mod) { int res=1; while(n){
	     			        if(n%2!=0) { res*=m; res%=mod; }
	    			        m*=m;   m%=mod;   n/=2;
			                          }
				return res;	}
int be(int a, int b) { int res=1; 	while(b){
				if(b%2!=0) res*=a;
				a*=a; b/=2;
				}
			return res;	}
void sieve(int n, vb &prime){
    prime[0]=false;     prime[1]=false;
    for(int i=2;i*i<=n;i++){
         if(prime[i]==true){
              for(int j=i*i;j<=n;j+=i)    prime[j]=false;
             	  }
    	 }
	}
	
	
vector<double> p;
vector< vector<double> > dp;

void solve()
  {
int n; cin>>n;
p.resize(n+1);
f(i, 1, n) cin>>p[i];
// f(i,1, n) cout<<p[i]<<' '; cout<<endl;
dp.resize(n+1, vector< double>(n+1, 1.0*0));
dp[1][0]=1-p[1];
f(i, 2, n) dp[i][0]=dp[i-1][0]*(1-p[i]);
// f(i,1, n) cout<<dp[i][0]<<' '; cout<<endl;
dp[1][1]=p[1];
f(i,2, n) dp[i][i]=dp[i-1][i-1]*p[i];
f(i, 2, n)
	f(j,1, i-1) 
	dp[i][j]=dp[i-1][j]*(1-p[i])+dp[i-1][j-1]*p[i];
double ans;
// f(i,1, n) cout<<dp[n][i]<<' '; cout<<endl;
f(i, ((n+1)/2), n) {ans+=dp[n][i]; }//qw3(i, dp[n][i], ans);}
// f(i, 1, n) { f(j, 1, n) cout<<dp[i][j]<<"   "; cout<<endl;}
cout<<fixed<<setprecision(10)<<ans<<endl;


  }

int32_t main ()
{
//fio
int t=1; 
//cin>>t; 
while(t--){
	solve();
}

}








Measured memory_bytes: 70656
#include <bits/stdc++.h>
 
using namespace std;
#define ll long long
#define ld long double
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<ll>
#define vii vector<pii>
#define pb push_back
#define mp  make_pair
#define all(v) (v).begin(), (v).end()

#define pb push_back
#define mp make_pair
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
ll INF = 1e6;

void solve()
{
    ll a, b;
    cin>>a>>b;
    for(ll i=b*10; i<b*10+10;i++)
    {
        if(i*8/100==a)
        {
            cout<<i;
            exit(0);
        }
    }
    cout<<-1;
}

 
int main()
{
    SPEED;
    ll t = 1;
    //cin>>t;
    while(t--) solve();
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    map<ll,int> mp;
    rep(i,n) mp[a[i]]++;
    for(auto p : mp){
        if(p.second > 1){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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 long long INF = 1LL << 60;

int main(){
  int h, w;
  cin >> h >> w;
  vector<string> field(h);
  rep(i, h) cin >> field[i];

  rep(i, h){
    cout << field[i] << endl;
    cout << field[i] << endl;
  }

  return 0;
}


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

using namespace std;

#define BUF_SIZE 1024

struct Node{
	int data;
	Node* prev;
	Node* next;
};

class ConnectedList{
public:
	ConnectedList(){
		motherNode = new Node();
		motherNode->data = -1;
		motherNode->prev = motherNode;	
		motherNode->next = motherNode;
	};
	~ConnectedList(){
		Node* tmpNode = motherNode->next;
		Node* nextNode;
		while(tmpNode != motherNode){
			nextNode = tmpNode->next;
			delete tmpNode;
			tmpNode = nextNode;
		}
		delete motherNode;
	};
	void insertNode(int x){
		Node* tmpNode = motherNode->next;
		motherNode->next = new Node();
		motherNode->next->data = x;
		motherNode->next->next = tmpNode;
		motherNode->next->prev = motherNode;
		tmpNode->prev = motherNode->next;
	};
	void deleteNode(int x){
		Node* tmpNode = motherNode->next;
		while(tmpNode != motherNode && tmpNode->data != x){
			tmpNode = tmpNode->next;
		}
		if(tmpNode != motherNode){	
			tmpNode->prev->next = tmpNode->next;
			tmpNode->next->prev = tmpNode->prev;
			delete tmpNode;
		}
	};

	void deleteFirst(){
		Node* tmpNode = motherNode->next;
		motherNode->next = motherNode->next->next;
		motherNode->next->prev = motherNode;
		delete tmpNode;	
	};

	void deleteLast(){
		Node* tmpNode = motherNode->prev;
		motherNode->prev = motherNode->prev->prev;
		motherNode->prev->next = motherNode;
		delete tmpNode; 
	};

	void showList(){
		Node* tmpNode = motherNode->next;
		printf("%d",tmpNode->data);
		tmpNode = tmpNode->next;
		while(tmpNode != motherNode){
			printf(" %d",tmpNode->data);
			tmpNode = tmpNode->next;
		}
		printf("\n");
	}

private:
	Node* motherNode;
};


int main(){

	char buf[BUF_SIZE];
	int n = atoi(fgets(buf,BUF_SIZE,stdin));

	ConnectedList list;

	for(int i = 0; i < n; i++){

		fgets(buf,BUF_SIZE,stdin);

		if(buf[6] == 'F'){
			list.deleteFirst();
		}else if(buf[6] == 'L'){
			list.deleteLast();
		}else{
			int S = 0;
			
			if(buf[0] == 'i'){	//insert x

				for(int i = 0; buf[i] != '\0';i++){
					if(buf[i] >= '0' && buf[i] <= '9'){
						S = 10*S + (buf[i] - '0');
					}
				}
				list.insertNode(S);
			}else{	
				for(int i = 0;buf[i] != '\0';i++){
					if(buf[i] >= '0' && buf[i] <= '9'){
						S = 10*S + (buf[i] - '0');
					}
				}
				list.deleteNode(S);
			}

		}

	}

	list.showList();

}

Measured memory_bytes: 34348
#include <iostream>

using namespace std;

bool check(int n)
{
    for(int i = 1 ; i <= 9 ; i++) {
        if(n%i != 0) continue;
        int j = n/i;
        if(j>=1 && j<=9) return true;
    }
    return false;
}
int main()
{
    int n;
    cin >> n;
    
    if(check(n)) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int K = scan.nextInt();
		List<Integer> list = new ArrayList<Integer>();
		for (int i = 0; i < N; i++) {
			list.add(scan.nextInt());
		}
		int total = 0;
		for (int i = 0; i < K ; i++) {
			int price = 1001;
			int idx = 0;
			for (int j = 0; j < list.size(); j++) {
				if (price > list.get(j)) {
					price = list.get(j);
					idx = j;
				}
			}
			list.remove(idx);
			total += price;
		}
		System.out.println(total);
	}

}


Measured memory_bytes: 30684
#include <iostream>
using namespace std;
 
int main(){
	long long n,x,y;
  	cin >> n >> x >> y;
  	long long k[n-1]={};
  	for(int i=1;i<n;++i){
      for(int j=i+1;j<n+1;++j){
        
        if(j<=x)k[j-i-1]+=1;
      	if(i<=x&x<j&j<=y){
          if(j-i<x+y+1-i-j){
            k[j-i-1]+=1;
          }
          else{
            k[x+y+1-i-j-1]+=1;
          }
        }
      	if(i<=x&y<j)k[x-i+1+j-y-1]+=1;
        if(x<i&i<=y&x<j&j<=y){
          if(j-i<i-x+1+y-j){
            k[j-i-1]+=1;
          }
          else{
            k[i-x+1+y-j-1]+=1;
          }
        }
        if(x<i&i<=y&y<j){
          if(j-i<i-x+1+j-y){
            k[j-i-1]+=1;
          }
          else{
            k[i-x+1+j-y-1]+=1;
          }
        }
        if(y<i)k[j-i-1]+=1;
      }
    }
  for(int i=0;i<n-1;++i)cout<<k[i]<<endl;
}

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

using namespace std;

int main() {
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    int answer;
    if (a <= c && b <= c) {
        answer = a * x + b * y;
    } else if (a > c && b > c) {
        if (x >= y) {
            answer = c * 2 * y + min(a * (x - y), c * 2 * (x - y));
        } else {
            answer = c * 2 * x + min(b * (y - x), c * 2 * (y - x));
        }
    } else if (a > c && b <= c) {
        if ((a + b) >= 2 * c) {
            if (x >= y) {
                answer = c * 2 * y + min(a * (x - y), c * 2 * (x - y));
            } else {
                answer = c * 2 * x + b * (y - x);
            }
        } else {
            if (x >= y) {
                answer = a * y + b * y + min(a * (x - y), c * 2 * (x - y));
            } else {
                answer = a * x + b * y;
            }
        }
    } else if (a <= c && b > c) {
        if ((a + b) >= 2 * c) {
            if (x >= y) {
                answer = c * 2 * y + a * (x - y);
            } else {
                answer = c * 2 * x + min(b * (y - x), c * 2 * (y - x));
            }
        } else {
            if (x >= y) {
                answer = a * x + b * y;
            } else {
                answer = a * x + b * x + min(a * (y - x), c * 2 * (y - x));
            }
        }
    }
    cout << answer << endl;
}

Measured memory_bytes: 256