akhauriyash/Code-Regression huggingface dataset:
# ABC075B - Minesweeper
import sys
input = sys.stdin.readline

def main():
    H, W = tuple(map(int, input().split()))
    S = tuple(input().rstrip() for _ in range(H))
    moves = [(-1, -1), (-1, 0), (-1, 1), (0, -1)]
    moves += [(0, 1), (1, -1), (1, 0), (1, 1)]
    A = [""] * H
    for i, s in enumerate(S):
        for j, a in enumerate(s):
            if a == "#":
                A[i] += "#"
            else:
                cnt = sum(
                    S[i + x][j + y] == "#"
                    for x, y in moves
                    if 0 <= i + x < H and 0 <= j + y < W
                )
                A[i] += str(cnt)
    print(*A, sep="\n")


if __name__ == "__main__":
    main()

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


using ll = long long;


int main()
{
    int N;
    cin >> N;
    ll s = 0;
    for (int x = 1; x <= N; x++) {
        if (x % 3 != 0 && x % 5 != 0)
            s += x;
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>

std::vector<long long> split(std::string str, char del) {
    int first = 0;
    int last = str.find_first_of(del);

    std::vector<long long> result;

    while (first < str.size()) {
        std::string subStr(str, first, last - first);

        result.push_back(std::stoll(subStr));

        first = last + 1;
        last = str.find_first_of(del, first);

        if (last == std::string::npos) {
            last = str.size();
        }
    }

    return result;
}
int main()
{
    std::string str;
    std::getline(std::cin, str);
    long long n = std::stoi(str);

    std::getline(std::cin, str);
    auto val = split(str, ' ');
    
    long long max = val[0];
    long long sum = 0;
    for (int i = 1; i < val.size(); i++)
    {
        if (val[i] <= max)
        {
            sum += (max - val[i]);
        }
        else
        {
            max = val[i];
        }
    }
    std::cout << sum << std::endl;
    
}

Measured memory_bytes: 11276
a, b, x = list(map(int, input().split()))
x = x / (a**2)

if b < 2 * x:
    tangent = (b-x) / (a/2)
else:
    tangent = b / (x * a * 2 / b)

import math
print(math.atan(tangent) * (180 / math.pi))

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
typedef long long ll;
ll gcd(ll n,ll m){
	if(m==0) return n;
	else return gcd(m,n%m);
}
ll lcm(ll n,ll m){
	return n*(m/gcd(n,m));
}

int main(){
	int n;
	cin >> n;
	long long ans=1;
	for(int i=0;i<n;i++){
		long long t;
		cin >> t;
		ans=lcm(ans,t);
	}
	cout << ans << endl;
}


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

using namespace std;

struct UnionFind{
private:
  std::vector<int> data;

public:
  UnionFind(int n = 0) : data(n, -1){}

  int find(int x){
    return data[x] < 0 ? x : data[x] = find(data[x]);
  }

  bool unite(int x, int y){
    x = find(x); y = find(y);

    if(x == y) return false;
    else{
      if(data[x] > data[y]) std::swap(x, y);
      data[x] += data[y];
      data[y] = x;
      return true;
    }
  }

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

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

int main(){
  int H, W;
  cin >> H >> W;
  
  vector<string> S(H);
  for(int i = 0; i < H; i++) cin >> S[i];
  
  UnionFind uf(H * W);
  
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      if(i && S[i][j] != S[i - 1][j]){
        uf.unite(i * W + j, (i - 1) * W + j);
      }
      if(j && S[i][j] != S[i][j - 1]){
        uf.unite(i * W + j, i * W + j - 1);
      }
    }
  }
  
  vector<int> black(H * W, 0);
  vector<int> white(H * W, 0);
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      if(S[i][j] == '#') ++black[uf.find(i * W + j)];
      else ++white[uf.find(i * W + j)];
    }
  }
  
  long long p = 0;
  vector<bool> used(H * W, false);
  for(int t = 0; t < H * W; t++){
    if(used[uf.find(t)]) continue;
    
    p += (long long)black[uf.find(t)] * white[uf.find(t)];
    used[uf.find(t)] = true;
  }
  
  cout << p << endl;
  
  return 0;
}

Measured memory_bytes: 2432
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

int N;

int main() {

	cin >> N;

	rep(i, 3) {
		if (N % 10 == 7) {
			cout << "Yes" << endl;
			return 0;
		}
		N /= 10;
	}

	cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;

template<class _T> static void getint(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void getint(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void getint(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}

static void ABC122C();

#if 1
int main()
{
	ABC122C();
	fflush(stdout);
	return 0;
}
#endif

static void ABC122C()
{
	int N, Q;
	getint(N, Q);

	std::string orgs;
	std::cin >> orgs;

	std::vector<int> acCounts(N + 1, 0);
	for (int i = 2; i <= N; i++) {
		acCounts[i] = acCounts[i - 1];
		if ((orgs[i - 1] == 'C') && (orgs[i - 2] == 'A')) {
			acCounts[i]++;
		}
	}
	for (int q = 0; q < Q; q++) {
		int li, ri;
		getint(li, ri);
		printf("%d\n", acCounts[ri] - acCounts[li]);
	}
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <utility>

typedef long long ll;
typedef unsigned long long ull;

#define vi std::vector<int>
#define vl std::vector<ll>
#define floop(n) for(int i = 0; i < n; ++i)
#define print(x) std::cout << x << std::endl;

const ll INF = 1e18;

int main()
{
    ll a, b, c, d, max;
    std::cin >> a >> b >> c >> d;

    max = a*c;
    if(max < a*d)
        max = a*d;
    if(max < b*c)
        max = b*c;
    if(max < b*d)
        max = b*d;
    
    print(max);

    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n, a, b;
  in(n);
  vector<ll> c(n), d(n);
  rep(i, n)
    in(c[i]);
  rep(i, n)
    in(d[i]);
  a = 0;
  rep(i, n){
    b = 0;
    rep(j, i + 1)
      b += c[j];
    rep2(j, i, n)
      b += d[j];
    a = max(a, b);
  }
  out(a);
  memi;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const int INF = 100100100;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl

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

  int ans = 0;
  REP(i, N){
    if(h[i] >= K) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <fstream>

using namespace std;
int main(){
int a,b;
string op;
cin >> a >> op >> b;
if(op == "+") {
  cout << a+b << endl;
}
else {
  cout << a-b << endl;
}
    return 0;
}

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

int b[4], c[4][4];

int main() {
  for (int i = 1; i <= 3; ++i) {
    for (int j = 1; j <= 3; ++j) {
      cin >> c[i][j];
    }
  }
  for (int a1 = -111; a1 <= 111; ++a1) {
    b[1] = c[1][1] - a1;
    b[2] = c[1][2] - a1;
    b[3] = c[1][3] - a1;
    bool ok = true;
    for (int k = 2; k <= 3; ++k) {
      for (int j = 2; j <= 3; ++j) {
        if (c[k][j] - b[j] != c[k][j - 1] - b[j - 1])
          ok = false;
      }
    }
    if (ok) {
      cout << "Yes\n";
      return 0;
    }
  }
  cout << "No\n";
  return 0;
}


Measured memory_bytes: 256
/*================================================
# ~  file:A.cpp
# ~~ date:2020-02-22
# ~~~author: SoMnus_L
#        |everybody finds love,in the end|
#   人の運命か,人の希望は悲しみにつづられているね
=================================================*/

#include <iostream>
#include <cstdio>
#include <cstring>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#define ll long long
const int N=1e6+10;
using namespace std;
typedef pair<int,int>PII;

int n,r;
int main(){
 ios::sync_with_stdio(false);
   cin>>n>>r;
   if(n>=10){
     cout<<r<<endl;
      return 0;
   }
   else cout<<r+100*(10-n)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
using namespace std;


int main()
{
	long int n;
	cin >> n;
	unsigned int sum = 0;
	for (int i = 0; i < n; ++i) {
		long long unsigned int num;
		cin >> num;
		if (num == 2) {
			++sum;
		}
		else if (num % 2 != 0) {
			++sum;
			long unsigned int lim = ceil(sqrt(num));
			for (long long unsigned int i = 3; i <= lim; i = i + 2) {
				if (num % i == 0)
				{
					--sum;
					break;
				}
			}
		}
	}
	cout << sum << endl;
}



Measured memory_bytes: 3080
using System;
using System.IO;
using System.Text;
using System.Collections.Generic;


class Solver {
  const int M = 9999999;
  const int MOD = 1000000007;
  public long exp(long x, long t) {
    if (t == 0) return 1;
    long ret = exp(x, t >> 1);
    ret = ret * ret % MOD;
    if ((t & 1) == 1) ret = ret * x % MOD;
    return ret;
  }
  public int f(int x) {
    if (x <= 9) return 1;
    if (x <= 99) return 2;
    if (x <= 999) return 3;
    if (x <= 9999) return 4;
    if (x <= 99999) return 5;
    if (x <= 999999) return 6;
    if (x <= 9999999) return 7;
    return 8;
  }
  public void solve() {
    int n = cin.readInt();
    long ans = 0;
    for (int i = 1, r = 1, sum = 0; i <= M; i++) {
      while (sum < n && r <= M) {
        sum += f(r); r++;
      }
      if (sum < n) {
        if ((n - sum) % 8 == 0) ans++;
      } else {
        if (sum == n) ans++;
      }
      sum -= f(i);
    }
    List<int> fac = new List<int>();
    for (int i = 1; i * i <= n; i++) {
      if (n % i != 0) continue;
      fac.Add(i);
      if (n/i != i) fac.Add(n/i);
    }
    foreach(int x in fac) {
      if (x < 8) continue;
      ans += (exp(10, x-1) * 9) - (n / x - 1) + MOD;
      ans %= MOD;
    }
    {
      int r = n / 8;
      ans += r;
      ans %= MOD;
      foreach (int x in fac) {
        if (x < 8) continue;
        if (n/x <= r) {
          ans += MOD - 1;
          ans %= MOD;
        }
      }
    }
    ans = (ans % MOD + MOD) % MOD;
    Console.Out.WriteLine(ans);
  }

  public Istream cin = new Istream(Console.OpenStandardInput());
  static public void swap<T>(ref T a, ref T b) { var tmp = a; a = b; b = tmp; }
}


#region Istream
class Istream {
  public Istream(Stream _ins) { ins = _ins; }

  const int BUF_SZ = 1024;
  private Stream ins;
  private byte[] buf = new byte[BUF_SZ];
  private int len, ptr;

  private byte readByte() {
    if (ptr >= len) {
      ptr = 0;
      len = ins.Read(buf, 0, BUF_SZ);
      if (len == 0) return 0;
    }
    return buf[ptr++];
  }
  public char nextChar() {
    byte b;
    do b = readByte(); while (b < 33 && 126 < b);
    return (char)b;
  }
  public string read() {
    var sb = new StringBuilder();
    for (char c = nextChar(); (33 <= c && c <= 126); c = (char)readByte()) sb.Append(c);
    return sb.ToString();
  }
  public string readLine() {
    var sb = new StringBuilder();
    for (char c = nextChar(); (c != '\n' && c != 0); c = (char)readByte()) sb.Append(c);
    return sb.ToString();
  }
  public long readLong() { return long.Parse(read()); }
  public int readInt() { return int.Parse(read()); }
  public double readDouble() { return double.Parse(read()); }
}
#endregion


#region Main
class ReSha {
  static void Main() {
    new Solver().solve();
  }
}
#endregion

Measured memory_bytes: 13268
#include <algorithm>
#include <iostream>

using namespace std;

constexpr static int MAXN = 1e6;
constexpr static int MOD = 1e9 + 7;

bool solve() {
    int64_t N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;

    int64_t G = abs(B - A);
    for (int i = 0; i < N; i++) {
        int64_t minpos = i * C, maxpos = i * D;
        int64_t minneg = (N - i - 1) * C, maxneg = (N - i - 1) * D;
        int64_t minval = minpos - maxneg;
        int64_t maxval = maxpos - minneg;
        if (G >= minval && G <= maxval)
            return true;
    }
    return false;
}

int main() {
    cout << (solve() ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
import numpy as np
import math
a,b,k = input().split()
a = int(a)
b = int(b)
k = int(k)
count_k = 0
for d in range(100,0, -1):
    if a % d == 0 and b % d == 0:
        count_k += 1
        if count_k == k:
            break

print(d)


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  int n, k;
  cin >> n >> k;
  int r, s, p;
  cin >> r >> s >> p;
  string t;
  cin >> t;

  vector<bool> flg(n, false);

  int ans = 0;
  rep(i, n) {
    if (flg[i]) continue;
    if (t[i] == 'r') ans += p;
    if (t[i] == 's') ans += r;
    if (t[i] == 'p') ans += s;
    if (i + k < n && t[i] == t[i + k]) flg[i + k] = true;
  }

  cout << ans << endl;
}


Measured memory_bytes: 512
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#include <functional>
#include <map>
#include <set>
#include <cmath>
#include <string>
#define SIZE 200005
#define INF 1000000005LL

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int n;
ll K;

ll solve(ll a){
	ll ans=0;
	while(a%2==0 && a>0){
		a /= 2;
		ans ++;
	}
	return ans;
}

int main()
{
	scanf("%d",&n);
	ll a;
	ll ans=0;
	for(int i=0;i<n;i++){
		scanf("%lld",&a);
		ans += solve(a);
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 128
n = int(input())
a = []
b = []

for i in range(n):
    x, y = map(int,input().split())
    a.append(x)
    b.append(y)

ans = 0

for i in range(n):
    if (ans+a[-1-i])%b[-1-i] == 0:
        continue
    ans += b[-1-i]-(ans+a[-1-i])%b[-1-i]

print(ans)


Measured memory_bytes: 16872
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1e9+7;

ll kai(int n){
    ll res = 1;
    for(int i = 0; i < n; i++) res *= (i+1);
    return res;
}

int main(){
    int n;
    cin >> n;
    vector<pair<int,int>> p(n);
    for(int i = 0; i < n; i++){
        int x,y;
        cin >> x >> y;
        p[i] = {x,y};
    }    
    double ans = 0;
    for(int i = 0; i < kai(n); i++){
        for(int j = 0; j < n-1; j++){
            ans += sqrt(pow(p[j].first-p[j+1].first,2)+pow(p[j].second-p[j+1].second,2));
        }
        next_permutation(p.begin(),p.end());
    }
    ans /= kai(n);
    cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int a,b;
    scanf("%d %d",&a,&b);
    if(a<b) {
        printf("a < b\n");
        }
        else if(a>b) {
            printf("a > b\n");
        }    
            else printf("a == b\n");
    return 0;
}



Measured memory_bytes: 2040
#include <iostream>
#include <map>
using namespace std;
typedef long long ll;
ll n, M=1e9+7;
map<ll, ll> m;
ll f(ll p) {
	if(p<2) return p+1;
	if(m[p]) return m[p];
	return m[p] = (f(p/2) + f((p-1)/2) + f((p-2)/2)) % M;
}

int main() {
	cin>>n;
	cout<<f(n);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
@SuppressWarnings("resource")
public static void main(String[] args) {
	Scanner sc =new Scanner(System.in);
	int N=sc.nextInt();
	int M=sc.nextInt();
	int pena=0;
	int AC=0;
	boolean flag[]=new boolean[N];
	int pena2[]=new int[N];
	for(int i=0;i<M;i++) {
	int p=sc.nextInt();
	String S=sc.next();
		if(S.equals("WA")) {
			if(!flag[p-1]) {
				pena2[p-1]++;
			}
		}else {
			if(!flag[p-1]) {
			flag[p-1]=true;
			pena+=pena2[p-1];
			AC++;}
		}

	}
	System.out.println(AC+" "+pena);


}
}

Measured memory_bytes: 63904
def main():
  s = input()
  length = len(s)

  nagasa = int((length - 1) / 2)
  former = list(s)[:nagasa]
  later = list(s)[-nagasa:]

  if former == later[::-1] and former == former[::-1] and later == later[::-1]:
    print('Yes')
  else:
    print('No')
main()

Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N, M, H[100005];
vector<int> G[100005];
int Ans[100005];

void dfs(int idx, int prev) { // prevがtrueはprevの方が高い
  if (Ans[idx]>=0) return;
  vector<int> vec = G[idx];
  bool flag = true;
  if (!prev) {
    rep(i, vec.size()) {
      int n = vec[i];
      if (H[n]>=H[idx]) {
        flag = false;
        break;
      }
    }
  } else flag = false; // 可能性もあるというだけ
  Ans[idx]=flag?1:0;
  rep(i, vec.size()) {
    int n = vec[i];
    dfs(n, flag);
  }
}

int main() {
  INCANT;
  cin >> N >> M;
  rep(i, N) cin >> H[i];
  int a,b;
  rep(i, M) {
    cin >> a >> b;
    a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  rep(i, N) Ans[i]=-1;
  rep(i, N) dfs(i,false);
  int ans=0;
  rep(i, N) ans+=Ans[i];
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 11996
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <numeric>
using namespace std;


int main(){
    int A;
    cin >> A;
    if(A == 1){
        cout << "Hello World" << endl;
    }
    else{
        int B,C;
        cin >> B >> C;
        cout << B + C << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string a;
  cin >> a;
  vector<int> A(500);
  int key = 0;
  for(int i = 0;i<a.size();i++){
    A.at(a.at(i))++;
  }
  for(int i = 0;i<A.size();i++){
    if(A.at(i) > 1){
      cout << "no" << endl;
      key = 1;
      break;
    }
  }
  if(key == 0)
    cout << "yes" << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

/**
 * Main
 */
public class Main {

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

        int S = sc.nextInt();
        int W = sc.nextInt();

        if(W >= S){
            System.out.println("unsafe");
        }else{
            System.out.println("safe");
        }
    }
}

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

#define  ll long long
#define  il inline
#define INF 0x3f3f3f3f
#define pii pair<int,int>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define dep(i,a,b) for(int i=(a);i>=(b);--i)

const int mod = 1e9 + 7;
const int maxn = 1e6 + 5;
const int maxm = 2e5 + 10;
const double PI = acos(-1.0);

int n;
vector<pii>v;

bool cmp(pair<int,int>a,pair<int,int>b)
{
    if(a.first == b.first) return a.second < b.second;
    else return a.first < b.first;
}

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    cin >> n;
    int a, b;
    rep(i,1,n){
        cin >> a >> b;
        v.push_back({b,a});
    }
    sort(v.begin(),v.end());
    ll sum = 0;
    rep(i,0,n - 1){
        //cout << v[i].first << endl;
        sum += v[i].second;
        if(sum > v[i].first){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;

}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
int a,b,c;
void solve()
{
    int m1=a<b?a:b,m2=m1<c?m1:c,m3=a>b?a:b,m4=m3>c?m3:c;
    cout<<m4-m2<<endl;
}
int main()
{
    while(cin>>a>>b>>c)
        solve();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	ll N,K,c,ans;
	char l,tmp;
	cin >> N >> K;
	vector<ll> v;
	c = 1;
	ans = 0;
	cin >> tmp;
	for (ll i = 1;i < N;i++){
		cin >> l;
		if (l == tmp){
			c++;
		}
		else{
			v.pb(c);
			tmp = l;
			c = 1;
		}		
	}
	v.pb(c);
	for (int i = 0;i < v.size();i++){
		if (i % 2 == 1 && K > 0){
			if (i == v.size() - 1){
				ans+= v[i];
			}
			else{
				K--;
				ans +=  v[i] + 1;
			}
		}
		else{
			ans += v[i] - 1;
		}
	}
	cout << ans <<endl;
	return 0;
}

Measured memory_bytes: 1400
#include <stdio.h>

int main(void)
{
	int x, a = 0, b, p, i, t;
	scanf("%d", &x);
	for (b = 1; b <= x; b++) {
		t = b;
		for (p = 2; p <= x; p++) {
			t *= b;
			if (t <= x && a < t) a = t;
			/*for (i = 0; i < p; i++) {
				if (i) t *= b;
				else t = b;
				if (t <= x && a < t) a = t;
			}*/
		}
	}
	if (x == 1) a = 1;
	printf("%d", a);
	return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
using namespace std;
const int N=200005;
int head[N],nxt[N],to[N],e;
int sg[N];
inline void init(){memset(head,-1,sizeof(head));e=0;}
inline void add_edge(int x,int y){to[e]=y;nxt[e]=head[x];head[x]=e++;}
void dfs(int x,int f)
{
	sg[x]=0;
	for(int i=head[x];i+1;i=nxt[i])if(to[i]!=f)
	{
		dfs(to[i],x);
		sg[x]^=(sg[to[i]]+1);
	}
	return;
}
int main()
{
	int n;scanf("%d",&n);init();
	rep(i,1,n-1){int x,y;scanf("%d%d",&x,&y);add_edge(x,y);add_edge(y,x);}
	dfs(1,0);
	if(sg[1]) puts("Alice");
	else puts("Bob");
	return 0;
}

Measured memory_bytes: 7552
import java.util.*;
// warm-up
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		String alps = "abcdefghijklmnopqrstuvwxyz";
		for (char ch : sc.next().toCharArray()) if (alps.indexOf(ch)!=-1) alps = alps.replaceAll(""+ch,"");
		System.out.println(alps.length()==0 ? "None" : alps.charAt(0));
		sc.close();		
	}

	public static void main(String args[]) {
		solve();
	}

}

Measured memory_bytes: 41804
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

h,w = mi()

if h==1 or w ==1:
    print(1)
    exit()

ans = ((h+1)//2) *((w+1)//2) + (h//2) * (w//2)
print(ans)

if h==1 or w ==1:
    print(1)
    exit()


Measured memory_bytes: 38384
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}
struct multi {
  ll first;
  ll second;
  ll third;
  multi(ll first, ll second, ll third)
      : first(first), second(second), third(third) {}
};
bool multicomp(const multi &a, const multi &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string S;
  cin >> S;
  vvl D = VVL(27, S.size() + 2, 0);
  ll N = S.size();
  REP(i, N) {
    D[S[i] - 'a'][i + 1]++;
    REP(j, 26) { D[j][i + 1] += D[j][i]; }
  }
  ll ans = 0;
  REP(i, N - 1) {
    ll add = N - i - 1 - (D[S[i] - 'a'][N] - D[S[i] - 'a'][i + 1]);
    ans += add;
  }
  cout << ans + 1 << endl;
  return 0;
}


Measured memory_bytes: 44308
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#define ll long long
using namespace std;
struct node{
    ll t,l,h;
};
bool cmp(node a,node b){
    if(a.t!=b.t){
        return a.t<b.t;
    }else{
        return a.l<b.l;
    }
}
int main(){
    int n,t;
    cin>>n;
    int f=1;
    for(int i=0;i<n;i++){
        cin>>t;
        if(t%2==0){
            if(t%3==0||t%5==0){
            }else{
                f=0;
            }
        }
    }
    if(f==1){
        cout<< "APPROVED"<<endl;
    }else{
        cout<< "DENIED"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
/**
*    author:  y_takano
*    created: 22.06.2020 17:04:34
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

using namespace std;

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    string str, pr, p, tmp;
    int q, a, b;

    cin >> str >> q;

    REP(i, q)
    {
        cin >> pr >> a >> b;;
        if (pr == "print")
        {
            cout << str.substr(a, b - a + 1) << '\n';
        }
        else if (pr == "reverse")
        {
            tmp = str.substr(a, b - a + 1);
            REP(j, tmp.size())
            {
                str[a + j] = tmp[tmp.size() - 1 - j];
            }
        }
        else
        {
            cin >> p;
            str.replace(a, b - a + 1, p);
        }
        
    }

    return 0;
}


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

typedef long long int ll;
typedef vector<long long>lve;
typedef vector<pair<ll,ll> > lvp;
typedef vector<vector<int> > ivve;

#define sp         ' '
#define endl       '\n'
#define F          first
#define S          second
#define pb         push_back
#define mp         make_pair 
#define GCD(x,y)   __gcd(x,y)
#define lb         lower_bound
#define up         upper_bound
#define setp       setprecision
#define bs         binary_search
#define all(x)     x.begin(),x.end()
#define LCM(x,y)   ((x*y)/__gcd(x,y))
#define spc(x)     cout<<fixed<<setp(x)

const   long long  inf = 1e18;
const   long long  cs =  200005;
const   long long  mod = 1000000007;
const   double     PI =  2 * acos(0.0);
void solve()
{
    ll t,n,m,a,b,c,d,e,i,j,k,x,y,z,cnt=0,cnt1=0;
    bool flag = false;
    
    cin>>n;
    string s;
    cin>>s;
    x=s.length();
    map<char,ll>ap;
    for(i=0;i<x;i++)
    {
        ap[s[i]]++;
    }
    for(auto &ss:ap)
    {
        if(ss.S&1)
        {
            cout<<"No"<<endl;
            return ;
        }
    }
    cout<<"Yes"<<endl;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);    cout.tie(NULL);

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

    // int32_t tc;
    // cin>>tc;
    // while(tc--)
    solve();

    return 0;
}

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

int main(){
	string S;
	cin >> S;
	int s=S.size();
	vector<int> N(s);
	for(int i=0;i<s;i++)N[i]=S[i]-'0';
	
	vector<long long> p(2019,0);
	
	int b=1;
	int c=0;
	for(int i=0;i<s;i++){
		c+=N[s-i-1]*b;
		c%=2019;
		p[c]++;
		b*=10;
		b%=2019;
	}
	
	long long ans=0;
	for(int i=0;i<2019;i++){
		if(i==0)ans+=p[i]*(p[i]+1)/2;
		else ans+=p[i]*(p[i]-1)/2;
	}
	cout << ans << endl;
	return 0;
}

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

#define watch(x) cout << (#x) << " is " << (x) << endl
#define fr(i,n) for(int i=0; i<n; i++)
#define rep(i, st, en) for(int i=st; i<=en; i++)
#define repn(i, st, en) for(int i=st; i>=en; i--)
#define sq(a) (a*a)
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll mod = 1e9+7;


/// this question translates into finding a binary tree whose leaves are the n slimes, and the sum of all internal nodes is minimum

const int nax = 405;
ll dp[nax][nax];

void min_self(ll &a, ll b){
    a = min(a, b);
}

const ll inf = 1e18+5;

void solve(){
    int n;
    cin>>n;
    vector<int> a(n);
    vector<ll> pref(n);
    ll sum = 0ll;
    fr(i, n) {
        cin>>a[i];
        pref[i] = sum + a[i];
        sum = pref[i];
    }

    for(int L = n - 1; L >= 0; L--){
        dp[L][L] = (ll) a[L];
        for(int R = L + 1; R < n; R++){
            dp[L][R] = inf;
            for(int K = L; K < R; K++){
                min_self(dp[L][R], dp[L][K] + dp[K+1][R]);
            }
            dp[L][R] += pref[R];
            if(L) dp[L][R] -= pref[L-1];
        }
    }

    cout<<dp[0][n-1] - pref[n-1];
}

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

    ll t = 1;
    //  cin>>t;
    while(t--){
        solve();
    }

    return 0;
}



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


int main()
{

	int N;
	string S;

	cin >> N >> S;

	int count = 0;
	for (int i = 0; i < (N-2); i++)
	{
		if (S[i] == 'A' && S[i+1] == 'B'&& S[i+2] == 'C' ){
			count++;
		}
	}
	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var x int
	var y int
	fmt.Scan(&x)

	var cnt500 int

	cnt500 = int(x / 500)
	y = x - cnt500*500

	var cnt5 int

	cnt5 = int(y / 5)

	fmt.Println(cnt500*1000 + cnt5*5)

}


Measured memory_bytes: 512
using System;
using System.Linq;
class ARC061_C
{
    static void Main()
    {
        string S = Console.ReadLine();
        long len = S.Length;
        Console.WriteLine(
            S.Select(i => long.Parse(i.ToString())).Select((i, index) =>
            {
                long result = 0;
                for (int j = 0; j < len - index - 1; j++)
                {
                    result += (long)(i * Math.Pow(10, j) * Math.Pow(2, len - 2 - j));
                }
                result += (long)(i * Math.Pow(10, len - index - 1) * Math.Pow(2, index));
                return result;
            }
            ).Sum());
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

constexpr int P = 1000000007;

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

    int n;
    cin >> n;

    ll r = 0, s = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        
        r += s * a;
        r %= P;
        s += a;
        s %= P;
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 3660
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    // let n: usize = sc.cin();
    let mut s: Vec<char> = sc.chars();
    let mut t: Vec<char> = sc.chars();
    s.sort(); t.sort();
    t.reverse();
    let a: String = s.iter().map(|&c|c).collect();
    let b: String = t.iter().map(|&c|c).collect();
    if a < b {
        put!("Yes");
    } else {
        put!("No");
    }
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


Measured memory_bytes: 4352
n=[int(input()) for i in range(5)]
ans=sum([(i//10+1)*10 if i%10!=0 else i for i in n])
k=10


for i in n:
    i2=str(i)
    i2=i2[len(i2)-1]
    if i2!="0" and int(i2)<k:
        k=int(i2)

print(ans-(10-k))


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

int main(){
	ll N;
	ll *A;
	cin >> N;
	A =(ll*) malloc(N * sizeof(*A));
	for(int i=0;i<N;i++) {
		cin >> A[i];
		A[i]-=i+1;
	}
	sort(A,A+N);
	ll b = A[N/2];

	ll ans;
	for(int i=0;i<N;i++) ans += abs(A[i]-b);
	
	cout << ans << "\n";
	return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

typedef tree<
ll,
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
// ordered_set X;
// *X.find_by_order(i) = ith largest element (counting from zero)
// X.order_of_key(k) = number of items in X < k (strict lt)

int ncrpar(int n, int r) {
    while (r > 0) {
        if ((n & 1) == 0 && (r & 1) == 1) return 0;
        n/=2; r/=2;
    }
    return 1;
}

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

    int N;
    cin >> N;

    string S;
    cin >> S;

    vi A(N);
    for (int i=0;i<N;i++) A[i] = S[i] - '0';

    int parity = 0;
    for (int i=0;i<N;i++) {
        parity += A[i]*ncrpar(N-1, i);
        parity &= 1;
    }

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

    vi step(N-1);
    for(int i=0;i<N-1;i++) step[i] = abs(A[i+1]-A[i]);

    for(int i=0;i<N-1;i++) {
        if ((step[i] & 1) == 1) {
            cout << 0 << endl;
            return 0;
        }
    }

    // all even
    int subpar = 0;
    for (int i=0;i<N-1;i++) {
        subpar += (step[i]/2) * ncrpar(N-2, i);
        subpar &= 1;
    }

    if (subpar == 1) {
        cout << 2 << endl;
    } else {
        cout << 0 << endl;
    }
    

    return 0;
}

Measured memory_bytes: 9244
#include <iostream>
#include <stdio.h>
using namespace std;

int main(){
    int A[1001];
    int num;
    for(int i=0;i<1001;i++){
        A[i] = 0;
    }
    
    cin >>num;
    
    for(int i=0;i<num;i++){
        cin>>A[i];
    }
    void insertionSort(int* A,int N);
    insertionSort(A,num);
    
    return 0;
}

void insertionSort(int* A,int N){
    int key,j;
    
    for(int k=0;k<N-1;k++){
        cout <<A[k] <<" ";
    }
    cout <<A[N-1];
    cout <<endl;
    
    for(int i=1;i<N;i++){
        key = A[i];
        j = i -1;
        while(j >= 0 && A[j] > key){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = key;
        
        for(int k=0;k<N-1;k++){
            cout <<A[k] <<" ";
        }
        cout <<A[N-1];
        cout <<endl;
    }
}

Measured memory_bytes: 1164
import sys
input = sys.stdin.readline
from collections import Counter
n = int(input())
v = list(map(int,input().split()))
a = []
b = []
for i in range(n):
    if i % 2 == 0:
        a.append(v[i])
    else:
        b.append(v[i])
 
a = Counter(a)
amc = a.most_common()
b = Counter(b)
bmc = b.most_common()
amc.append((0,0))
bmc.append((0,0))
rewrite = 0
 
if amc[0][0] == bmc[0][0]:
    rewrite = max(amc[0][1]+bmc[1][1],amc[1][1]+bmc[0][1])
else:
    rewrite = amc[0][1]+bmc[0][1]
print(n-rewrite)

Measured memory_bytes: 21120
#include <iostream>
#include <fstream>
#include <algorithm>
#include <bits/stdc++.h>
//#define LOCAL
using namespace std;
typedef long long ll;


int main() {
#ifdef LOCAL
ifstream fin("1.txt");
streambuf*p;
p=cin.rdbuf(fin.rdbuf());
#endif // LOCAL
ll q;
cin>>q;
bitset<64>a(0);
for(ll t=0;t<q;t++){
    ll com, i;
    cin>>com;
    switch(com){
        case 0:cin>>i;
        (a.test(i))?puts("1"):puts("0");
        break;

        case 1:cin>>i;
        a.set(i);
        break;

        case 2:cin>>i;
        a.reset(i);
        break;

        case 3:cin>>i;
        a.flip(i);
        break;

        case 4:(a.all())?puts("1"):puts("0");
        break;

        case 5:(a.any())?puts("1"):puts("0");
        break;

        case 6:(a.none())?puts("1"):puts("0");
        break;

        case 7:cout<<a.count()<<endl;
        break;

        case 8:cout<<a.to_ulong()<<endl;
        break;
    }
}

#ifdef LOCAL
fin.close();
#endif // LOCAL
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
#include <algorithm>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
using namespace std;
typedef long long ll;
 
int main() {

    int a,b;
    cin >> a >> b;

    for(int i=1;i<1000000;i++) {
        if((i*8)/100==a&&(i*10)/100==b) {
            cout<<i<<endl;
            return 0;
        }
    }

    cout<<-1<<endl;

 return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> ii;
 
int main() {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    int rez = 0;
    for (int ctr1 = 0; ctr1 < n; ++ctr1) {
        if (s[ctr1] == 'L' && ctr1 > 0)
            rez += s[ctr1 - 1] == 'L';
        if (s[ctr1] == 'R' && ctr1 + 1 < n)
            rez += s[ctr1 + 1] == 'R';
    }
    cout << min(rez + 2 * k, n - 1);
    return 0;
}

Measured memory_bytes: 512
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.stream.Collectors;


public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		String[] str = new String[k];
		for (int i = 0 ; i < k ; i ++){
			str[i] = sc.next();
		}
		long answer = 0 ;
		ArrayList<String> ay_st = new ArrayList<>();
		for (int i = 0 ; i < k ; i ++){
			char[] c = str[i].toCharArray();
			Arrays.sort(c);
			str[i] = new String(c);
			ay_st.add(str[i]);
		}
		
		Map<String, Long> map = new HashMap<>();
		for (String s : ay_st) {
		    map.merge(s, (long) 1, Long::sum);
		}
		
		for (String key : map.keySet()){
			if (map.get(key) > 1) {
				answer = answer + (map.get(key)-1)*map.get(key)/2;
			}	
		}
		
		System.out.println(answer);
	}
}


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

int a[100];

int main(void) {
  int N;
  cin >> N;
  int sum = 0;
  for (int i = 0; i <  N; i++) {
	  cin >> a[i];
	  sum += a[i];
  }
  
  double ave = (double)sum / N;
  double diff = 101;

  int ans = 0;
  for (int i = 0; i < N; i++) {
	  if (abs(ave-a[i]) < diff) {
		  ans = i;
		  diff = abs(ave-a[i]);
	  }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
using namespace std;
using ll = long long;

const ll MOD = 1e9 + 7;

int main(void)
{
    int H, N;
    int A, B;
    int i, j;
    int answer = MOD;

    vector<int> dp(20000, MOD);
    dp[0] = 0;

    cin >> H >> N;

    for (i = 1; i <= N; i++)
    {
        cin >> A >> B;
        for (j = 1; j <= H; j++)
        {
            dp[j] = min(dp[j], dp[max(0, j - A)] + B);
        }
    }

    cout << dp[H] << endl;
}

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

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

const int MAX = 50;

int H, W;
int map[MAX][MAX];
int dp[MAX + 1][MAX + 1];

void solve()
{
  dp[0][0] = 0;
  for(int i = 1; i < H; i++)
    dp[i][0] = map[i][0] + dp[i - 1][0];
  for(int i = 1; i < W; i++)
    dp[0][i] = map[0][i] + dp[0][i - 1];
  for(int i = 1; i < H; i++)
    for(int j = 1; j < W; j++)
      dp[i][j] = min(dp[i - 1][j] + map[i][j], dp[i][j - 1] + map[i][j]);
}

int main()
{
  cin >> H >> W;
  char buf[W + 1];
  REP(j, H){
    cin >> buf;
    REP(i, W)
      map[j][i] = buf[i] - '0';
  }
  solve();
  cout << dp[H - 1][W - 1] << endl;
}

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

template <class T>
bool chmax(T &a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}

template <class T>
bool chmin(T &a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}

int main()
{
	int N, K;
	cin >> N >> K;
	double ans = 0;
	for (int i = 1; i <= N; ++i)
	{
		double p = 1;
		for (int j = 1; i * pow(2, j - 1) < K; ++j)
		{
			p *= 0.5;
		}
		ans += p;
	}
	ans /= (double)N;
	printf("%0.15f\n", ans);
}

Measured memory_bytes: 256
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N = int(input())
    a = list(int(_) for _ in input().split())
    print(max(a)-min(a))
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 3828
'use strict'

function main(input) {
  const nums = input.split('\n').map(n => parseInt(n, 10))
  const mochis = nums.slice(1, nums.length)

  console.log(mochis.filter((n, i) => mochis.indexOf(n) === i).length)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
#define int long long 

int32_t main()
{
    int n, K;
    cin>>n>>K;
    vector<int>a(n);
    int sum=0;
    for(auto &x: a) 
    {
        cin>>x;
        sum+=x;
    }

    vector<int>f;
    for(int i=1; i*i<=sum; ++i)
    {
        if(sum%i==0)
        {
            f.push_back(i);
            if(i*i!=sum) f.push_back(sum/i);
        }
    }
    int ans=0;
    for(auto F: f)
    {
        vector<int>ms;
        sum=0;
        for(auto x: a)
        {
            ms.push_back(x%F);
            sum+=F-(x%F);
        }
        sort(ms.begin(), ms.end());
        int k=sum/F;
        int cnt=0;
        for(int i=0; i<k; ++i)
        {
            cnt+=ms[i];
        }
        if(cnt<=K) ans=max(ans, F);
    }
    cout<<ans;
}

Measured memory_bytes: 256
// itp1_4_D Computation - A / B Problem
#include<stdio.h>

int main() {
	int a,b;
	scanf("%d %d",&a, &b);
	int d = a/b;
	int r = a%b;
	double f = double(a)/double(b);
	
	printf("%d %d %lf\n", d, r, f);
	
	return 0;
}

Measured memory_bytes: 1064