akhauriyash/Code-Regression huggingface dataset:
/*
─────────────────────
───────────████████──
──────────███▄███████
──────────███████████
──────────███████████
──────────██████─────
──────────█████████──
█───────███████──────
██────████████████───
███──██████████──█───
███████████████──────
███████████████──────
─█████████████───────
──███████████────────
────████████─────────
─────███──██─────────
─────██────█─────────
─────█─────█─────────
─────██────██────────
─────────────────────
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define int long long
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; fori (i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; fori (i, 1, n) {fori (j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) fori (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) fori (i, 1, n) {fori (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define all(v) v.begin(), v.end()
#define sz(s) (int)(s.size())
#define pb push_back
#define fi first
#define se second
#define rz resize
#define fori(i, a, b) for (int i = (a); i <= (b); i++)
#define ford(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
#define setprec(x) cout << fixed << setprecision(x)
 
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair <int, int>> vpi;
typedef vector < vector <int> > vvi;
 
const int INF = 4e18;
const int mod = 1e9+7; 

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

    //start from here

    readc(n, m, l);
    int x, y, d;

    vvi dis (n+1, vi(n+1, INF)), dp (n+1, vi(n+1, INF));

    fori (i, 1, m)
    {
    	cin >> x >> y >> d;

    	dis[x][y] = d; dis[y][x] = d;
    }

    fori (i, 1, n) dis[i][i] = 0, dp[i][i] = 0;

    fori (k, 1, n)
    	fori (i, 1, n) 
    		fori (j, 1, n) 
    			dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);

	fori (i, 1, n)
		fori (j, 1, n) 
			if(i != j && dis[i][j] <= l) 
				dp[i][j] = 1;
    
    fori (k, 1, n)
    	fori (i, 1, n) 
    		fori (j, 1, n) 
    			dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);

    read(q);
    while(q--)
    {
    	cin >> x >> y;
    	if(dp[x][y] == INF) cout << -1 << endl;
    	else cout << dp[x][y] - 1 << endl;
    }

    return 0;
}


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

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        string s = sc.Next();

        string answer = "";
        if (s == "A")
        {
            answer = "T";
        }
        else if (s == "T")
        {
            answer = "A";
        }
        else if (s == "C")
        {
            answer = "G";
        }
        else
        {
            answer = "C";
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    
    if(k<=a){
        cout<<k<<endl;
        
    }else if(k<=a+b){
        cout<<a<<endl;
    }else{
        cout<<a-(k-a-b)<<endl;
    }
    return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>

int main()
{
	int H, W;
	while (1)
	{
		scanf("%d %d", &H, &W);
		if (H == 0 && W == 0) break;

		int i, j;
		for (j = 1; j <= H; j++)
		{
			if (j == 1 || j == H)
			{
				for (i = 1; i <= W - 1; i++)
				{
					printf("#");
				}
				printf("#\n");
			}
			else
			{
				printf("#");
				for (i = 2; i <= W - 1; i++)
				{
					printf(".");
				}
				printf("#\n");
			}
			
		}
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 1016
from collections import deque

(A, B, M) = list(map(int, input().split()))
A_Price = list(map(int, input().split()))
B_Price = list(map(int, input().split()))
Coupon = [list(map(int, input().split())) for _ in range(M)]

tmp_min_price = min(A_Price) + min(B_Price)

discounted_Prices = deque()
for i in range(M):
    discounted_Prices.append(A_Price[Coupon[i][0] - 1] \
                             + B_Price[Coupon[i][1] - 1] \
                             - Coupon[i][2])

min_discounted_price = min(discounted_Prices)
print(min(min_discounted_price, tmp_min_price))


Measured memory_bytes: 80444
K, T = list(map(int, input().split()))
a = list(map(int, input().split()))

# def remax(seq):
#     m = max(seq)
#     for idx,i in enumerate(seq):
#         if m==i:
#             return (idx, m)
#
# lastK = -1
# cnt = 0
# for _k in range(K):
#     remax
#

print(max(0,max(a)*2-sum(a)-1))


Measured memory_bytes: 3064
while s = gets
  s = s.chomp.split(//)

  c = (1..9).each_slice(3).map.to_a.concat((1..3).map{|i| i.step(9, 3).to_a}).concat([[1,5,9],[3,5,7]])

  res = "d"

  c.each do |r|
    case r.map{|i| s[i-1]}.join
    when "ooo"
      res = "o"
      break
    when "xxx"
      res = "x"
      break
    end
  end

  puts res
end

Measured memory_bytes: 8716
import math
n = int(input())
x = [0] * n
y = [0] * n
seq = []
for i in range(n):
    x[i],y[i] = map(int,input().split())
    seq.append(i)
import itertools
sum = 0
seq_list = list(itertools.permutations(seq))
for i in range(len(seq_list)):
    for j in range(n-1):
        sum += math.sqrt((x[seq_list[i][j+1]]-x[seq_list[i][j]])**2 + (y[seq_list[i][j+1]]-y[seq_list[i][j]])**2 )

print(sum/len(seq_list))


Measured memory_bytes: 8052
// -*- coding:utf-8-unix -*-

use proconio::input;

fn lower_bound(v: &Vec<u32>, k: u32) -> usize {
    let mut low = 0;
    let mut high = v.len();

    while low < high {
        let mid = (low + high) / 2;
        if v[mid] < k {
            low = mid + 1;
        } else {
            high = mid;
        }
    }
    low
}

fn main() {
    input! {
        n: usize,
        mut l: [u32; n],
    }

    l.sort();
    let mut ans = 0;
    for i in 0..n {
        for j in i + 1..n {
            let k = lower_bound(&l, l[i] + l[j]);
            ans += k - (j + 1);
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2140
import java.io.*;
public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		//b棟f階のr番目の部屋にv人
		Integer[][][] apartment = {{{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
									{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
									{0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
								   {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
									{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
									{0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
								   {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
									{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
									{0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
								   {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
									{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
									{0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}};
		Integer line_num = Integer.parseInt(br.readLine());
		for(int i=0; i < line_num; i++){
			String input = br.readLine();
			String[] info = input.split(" ");
			Integer b = Integer.parseInt(info[0])-1;
			Integer f = Integer.parseInt(info[1])-1;
			Integer r = Integer.parseInt(info[2])-1;
			Integer v = Integer.parseInt(info[3]);
			apartment[b][f][r] += v;
		}
		for(int i=0; i < 4; i++){
			for(int j=0; j < 3; j++){
				for(int k=0; k < 10; k++){
					System.out.print(" " + apartment[i][j][k]);
				}
				System.out.print("\n");
			}
			if(i < 3){
				System.out.println("####################");
			}
		}
	}


}

Measured memory_bytes: 19340
program main
 implicit none
 integer(8) N, A, B
 integer(8) :: syoN, amrN
 integer(8) :: ao=0
 integer(8) i,ii

 read *, N, A, B

 if (A==0) goto 100

 syoN=N/(a+b)
 amrN=mod(N,(a+b))

 ao=ao+syoN*A

 if (amrN>A)  ao=ao+A
 if (amrN<=A) ao=ao+amrN

100 continue
 print '(i0)', ao

endprogram main


Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <algorithm>
#define INF 1 << 25

using namespace std;

int main(void) {
	int n, m, i, j, k, ans = 0, ok;
	cin >> n >> m;
	vector<vector<int>> d(n + 1, vector<int>(n + 1, INF));
	vector<int> a(m), b(m), c(m);
	for (i = 1; i <= n; i++)
		d[i][i] = 0;
	for (i = 0; i < m; i++) {
		scanf("%d%d%d", &a[i], &b[i], &c[i]);
		d[a[i]][b[i]] = c[i];
		d[b[i]][a[i]] = c[i];
	}
	for (i = 1; i <= n; i++) {
		for (j = 1; j <= n; j++) {
			for (k = 1; k <= n; k++) {
				d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
			}
		}
	}
	for (i = 0; i < m; i++) {
		ok = true;
		for (j = 1; j <= n; j++) {
			if (abs(d[j][a[i]] - d[j][b[i]]) == c[i]) {
				ok = false;
				break;
			}
		}
		if (ok)
			ans++;
	}
	cout << ans << "\n";
	return 0;
}

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

void main()
{
    auto av = readln.split.to!(long[]);
    auto A = av[0];
    auto V = av[1];
    auto bw = readln.split.to!(long[]);
    auto B = bw[0];
    auto W = bw[1];
    auto T = readln.chomp.to!long;

    if (A == B) {
        writeln("YES");
        return;
    }
    writeln(V * T - W * T >= abs(A - B) ? "YES" : "NO");
}

Measured memory_bytes: 2720
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define REP(i,x,n) for(int i = (x); i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);
//const ll mod = 998244353;

vector<ll> dp(440000);

int main(void)
{
    string s;
    ll k;
    cin >> s >> k;
    ll ans=0, n = s.size(), p=0;
    vector<ll> cnt(n+1, 0);
    char tmp = s[0];
    rep(i,n){
        if(s[i] == tmp) cnt[p]++;
        else{
            p++;
            cnt[p]++;
            tmp = s[i];
        }
    }
    if(p == 0) ans = n*k/2;
    else{
        rep(i,p+1) ans += cnt[i]/2;
        ans *= k;
        if(s[0] == s[n-1]){
            ans -= (cnt[0]/2 + cnt[p]/2 - (cnt[0] + cnt[p]) / 2) * (k-1);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6456
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
#include <cctype>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <utility>
#include <fstream>

using namespace std;
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; }
template<typename T> T gcd(T a, T b) { a = abs(a), b = abs(b); while (b > 0) { tie(a, b) = make_pair(b, a % b); } return a; }
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
//constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353;
constexpr int MAX = 5000000;

int main()
{

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	ll x, y, z; cin >> x >> y >> z;
	swap(x, y);
	swap(x, z);
	cout << x << " " << y << " " << z << endl;
	return 0;
}


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

int main(){
    int A, B;
    cin >> A >> B;
    int count = 0;
    for (int i = A; i <= B; ++i){
        int top2 = i / 1000;
        int las2 = i % 100;
        if (top2 % 10 == las2 / 10 && top2 / 10 == las2 % 10) ++count;
    }
    cout << count << endl;
}

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

int main() {
  string s; cin >> s;
  int n = s.size();
  int a, z;
  REP(i, n) {
    if (s.at(i) == 'A') {
      a = i;
      break;
    }
  }
  for (int i = n - 1; i >= 0; --i) {
    if (s.at(i) == 'Z') {
      z = i;
      break;
    }
  }
  
  cout << z - a + 1 << endl;
  
  return 0;
}

Measured memory_bytes: 640
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>
 
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
 
using namespace std;
 
#define int long long
//typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;
 
const int INF=1e+9;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int n,a,b,mi,ma;
	cin >> n >> a >> b;
	mi = a * (n - 1) + b;
	ma = b * (n - 1) + a;
	cout << max(0ll,ma - mi + 1) << endl;
	return 0;
}

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

int main( void )
{
    int n, m;
    string input;
    int G[31][31];
    int C[31][31];
    for ( int i = 0; i < 31; i++ )
    {
        for ( int j = 0; j < 31; j++ )
        {
            C[i][j] = 1 << 24;
        }
    }

    cin >> n >> m;
    for ( int i = 0; i < m; i++ )
    {
        cin >> input;
        replace( input.begin(), input.end(), ',', ' ' );
        istringstream is( input );
        int a, b, c, d;
        is >> a >> b >> c >> d;
        C[a][b] = c;
        C[b][a] = d;
    }

    for ( int k = 1; k <= n; k++ ) for ( int i = 1; i <= n; i++ ) for ( int j = 1; j <= n; j++ )
    {
        C[i][j] = min( C[i][j], C[i][k] + C[k][j] );
    }

    int x1, x2, y1, y2;
    cin >> input;
    replace( input.begin(), input.end(), ',', ' ' );
    istringstream is( input );
    is >> x1 >> x2 >> y1 >> y2;
    cout << y1 - y2 - C[x1][x2] - C[x2][x1] << endl;

    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
#define reset(a,b) memset(a,b,sizeof a);
#define ALL(x) x.begin(),x.end()
 
template <typename T>
void cetak(T t){cout << t << ')' << endl;}
template <typename T, typename... V>
void cetak(T t, V... v) {cout << t; if (sizeof...(v)) cerr << ", "; cetak(v...);}
 
#define debug(x...) cout<< '(' << #x << ") = ("; cetak(x) 
#define sz(x) (int)(x.size())
#define lt(x) (int)(x.length())

const int MOD = 1e9 + 7;
const int mx = 1e5 + 10;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int r;
    cin >> r;
    cout << r * r << endl;
}

Measured memory_bytes: 256
N=int(input())
A=[0]*5
count=0
for i in range(N):
    S=input()
    if S[0]=='M':
        A[0]+=1
    if S[0]=='A':
        A[1]+=1
    if S[0]=='R':
        A[2]+=1
    if S[0]=='C':
        A[3]+=1
    if S[0]=='H':
        A[4]+=1

for i in range(5):
    for j in range(i):
        for k in range(j):
            if i!=j and j!=k and k!=i:
                count+=A[i]*A[j]*A[k]
print(count)

Measured memory_bytes: 3064
// AOJ Hakone
#include <iostream>
#include <vector>

using namespace std;
#define int long long

template <uint_fast64_t Modulus> class mint {
    using u64 = uint_fast64_t;
    u64 a;
public:

    constexpr mint(const u64 a = 0) noexcept : a((a % Modulus + Modulus) % Modulus) {}

    constexpr u64& value() noexcept {
        return a;
    }

    constexpr mint& operator +=(const mint& rhs) noexcept {
        a += rhs.a;
        if (a >= Modulus) a -= Modulus;
        return *this;
    }

    constexpr mint& operator -=(const mint& rhs) noexcept {
        a += Modulus - rhs.a;
        if (a >= Modulus) a -= Modulus;
        return *this;
    }

    constexpr mint& operator *=(const mint& rhs) noexcept {
        a = a * rhs.a % Modulus;
        return *this;
    }

    constexpr mint operator +(const mint rhs) const noexcept {
        return mint(*this) += rhs;
    }

    constexpr mint operator -(const mint rhs) const noexcept {
        return mint(*this) -= rhs;
    }

    constexpr mint operator *(const mint &rhs) const noexcept {
        return mint(*this) *= rhs;
    }

    constexpr mint pow(u64 t) const noexcept {
        if (!t) return 1;
        mint<Modulus> ret = pow(t >> 1u);
        ret *= ret;
        if (t & 1) ret *= *this;
        return ret;
    }

    constexpr mint inv() const noexcept {
        return pow(Modulus - 2);
    }

    constexpr mint operator /=(const mint rhs) {
        return (*this) *= rhs.inv();
    }

    constexpr mint operator /(const mint &rhs) const noexcept {
        return mint(*this) /= rhs;
    }
};

const int MOD = 1000000007;
const int MAX_N = 205;
// dp[i][j] = 上からi個のうち、j個のペアを作る場合の数
using mi = mint<MOD>;
mi dp[MAX_N][MAX_N];

signed main() {
    int N;
    cin >> N;
    vector<char> chars(N);
    for (int i = 0; i < N; i++) {
        cin >> chars[i];
    }
    dp[0][0] = 1;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= N; j++) {
            if (chars[i] == 'D') {
                if (j <= i) dp[i+1][j+2] += dp[i][j] * (i-j) * (i-j);
                if (j <= i) dp[i+1][j+1] += dp[i][j] * (i-j);
            } else if (chars[i] == 'U') {
                if (j <= i) dp[i+1][j+1] += dp[i][j] * (i-j);
                dp[i+1][j] += dp[i][j];
            } else {
                dp[i+1][j+1] += dp[i][j];
            }
        }
    }

    cout << dp[N][N].value() << endl;
}


Measured memory_bytes: 3428
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <stdbool.h>
typedef long long LL;
typedef long double Lf;
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
//#define Rep(i,a,n)for(LL i=(LL)(a);i<(LL)(n);i++)
#define rep(i,n)Rep(i,0,n)
#define Repp(i,l,r,k)for(LL i=(LL)(l);i<(LL)(r);i+=(LL)(k))
#define Ma(x,y) ((x)>(y)?(x):(y))
#define mi(x,y) ((x)<(y)?(x):(y))
#define MOD 1000000007//998244353,1000000007,1000000009 
int upi(const void* a, const void* b) { return*(int*)a<*(int*)b ? -1 : *(int*)a> * (int*)b ? 1 : 0; }
int downi(const void* a, const void* b) { return*(int*)a<*(int*)b ? 1 : *(int*)a> * (int*)b ? -1 : 0; }
void sortupi(int* a, int n) { qsort(a, n, sizeof(int), upi); } //1,2,3,4,...
void sortdowni(int* a, int n) { qsort(a, n, sizeof(int), downi); }
int upLL(const void* a, const void* b) { return*(LL*)a<*(LL*)b ? -1 : *(LL*)a> * (LL*)b ? 1 : 0; }
int downLL(const void* a, const void* b) { return*(LL*)a<*(LL*)b ? 1 : *(LL*)a> * (LL*)b ? -1 : 0; }
void sortupLL(LL* a, int n) { qsort(a, n, sizeof(LL), upLL); }
void sortdownLL(LL* a, int n) { qsort(a, n, sizeof(LL), downLL); }
int cmp_char(const void* a, const void* b) { return *(char*)a - *(char*)b; } // a,b,c,d
int cmp_str(const void* a, const void* b) { return strcmp(*(const char**)a, *(const char**)b); } // aaa,aab
LL gcd(LL p, LL q) { while (q) { LL t = p % q; p = q; q = t; }return p; }
LL modpow(LL a,LL n,int m){LL x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
#define invmodpow(b,p)modpow(b,p-2,p)// a/b≡a*b^{-1}(mod p)...return b^{-1}(mod p)
typedef struct fac { LL n, exp; }F;
LL fact(LL n,F*a){LL x,i,j,c=0;x=n;for(i=2;i*i<=x;i++){for(j=1;x%i==0;j++)x/=i;if(j>1){a[c].n=i;a[c++].exp=j-1;}}if(x-1){a[c].n=x;a[c++].exp=1;}return c;}
//snippet
//overflow...char 1e6

#define N 109

int main() {
	char n[N];
	int d[N], K, l;
	scanf("%s%d", n, &K);
	l = strlen(n);
	rep(i, l)d[i] = n[i] - 48;

	LL dp[N][2][5] = { 0 };//dp[桁][未満][0数]
	dp[0][1][0] = 1;
	rep(i, l) {//桁
		rep(k, 4) {//0の数
			rep(j, 10) {//各数字
				if (j < d[i]) {
					if (!j) {
						dp[i + 1][0][k] += dp[i][0][k] + dp[i][1][k];
					}
					else {
						dp[i + 1][0][k + 1] += dp[i][0][k] + dp[i][1][k];
					}
				}
				if (j == d[i]) {
					if (!j) {
						dp[i + 1][1][k] += dp[i][1][k];
						dp[i + 1][0][k] += dp[i][0][k];
					}
					else {
						dp[i + 1][1][k + 1] += dp[i][1][k];
						dp[i + 1][0][k + 1] += dp[i][0][k];
					}
				}
				if (j > d[i]) {
					dp[i + 1][0][k + 1] += dp[i][0][k];
				}
			}
		}
	}
	printf("%lld", dp[l][1][K] + dp[l][0][K]);
	return 0;
}

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

int main(){
	int n;
  	cin >> n;
  	vector<int> a(n);
  	vector<int> b(n);
  	long count=0;
  	for(int i = 0; i <n; i++) {
      	cin >> a[i] >> b[i];
	}
  	
  	for(int i = n-1; i>=0;  i--) {
      	count += b[i] - (((count + a[i])%b[i])==0?b[i]:((count+a[i])%b[i]));
      	
	}
  	cout << count <<endl;
}

Measured memory_bytes: 1024
class UnionFind:
    def __init__(self, N):
        self.N = N
        self.parents = [-1] * N

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return (i for i in range(self.N) if self.find(i) == root)

    def roots(self):
        return (i for i, x in enumerate(self.parents) if x < 0)

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        dic = {}
        for x in range(self.N):
            r = self.find(x)
            dic.setdefault(r, [])
            dic[r].append(x)
        return dic


import sys
sys.stdin.readline

def main():
    N, K, L = map(int, input().split())
    UF1 = UnionFind(N)
    UF2 = UnionFind(N)
    for _ in range(K):
        p, q = map(int, input().split())
        UF1.union(p-1, q-1)
    for _ in range(L):
        r, s = map(int, input().split())
        UF2.union(r-1, s-1)
    P = [None] * N
    D = {}
    for i in range(N):
        T = (UF1.find(i), UF2.find(i))
        P[i] = T
        D.setdefault(T, 0)
        D[T] += 1
    print(*[D[p] for p in P])


if __name__ == "__main__":
    main()

Measured memory_bytes: 43240
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;
typedef long long ll;
const int maxn = 5005;

int main() {
  //freopen("in.cpp","r",stdin);
  int x,y;
  cin>>x>>y;
  if(x==1)x=14;
  if(y==1)y=14;
  if(x==y)cout<<"Draw"<<endl;
  else if(x<y)cout<<"Bob"<<endl;
  else cout<<"Alice"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1e9+7;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

int main(){
    string s;
    cin >> s;
    int n=s.size();
    if (s[0]=='0'||s[n-1]=='1'){
        cout << -1 << endl;
        return 0;
    }
    rep(i,n-2){
        if (s[i]!=s[n-i-2]){
            cout << -1 << endl;
            return 0;
        }
    }
    int base=1;
    rep(i,n-1){
        cout << base << ' ' << i+2 << endl;
        if (s[i]=='1') base=i+2;
    }
}

Measured memory_bytes: 1664
#include <stdio.h>
#include <math.h>
int main (void){
        int N,D,X,A[100],ans=0;
        for (int i = 0; i < 100; i++) {
                A[i]=0;
        }
        scanf("%d",&N);
        scanf("%d",&D);
        scanf("%d",&X);
        for (int i = 0; i < N; i++) {
                scanf("%d",&A[i]);
        }
        for (int i = 0; i < N; i++) {
                ans+=((D-1)/A[i])+1;
        }
        ans+=X;
        printf("%d\n",ans );
        return 0;

}


Measured memory_bytes: 128
from itertools import groupby as gb
mai,sou=map(int,input().split())
cards=[(e,len(list(f))) for e,f in gb(sorted(map(int,input().split())))]
sl=[tuple(list(map(int,input().split()))[::-1]) for a in range(sou)]
l=sorted(sl+cards,reverse=1)
s=0
for v,c in l:
  s+=v*min(mai,c)
  mai-=c
  if mai<=0:break
print(s)

Measured memory_bytes: 30928
#include <iostream>
using namespace std;
int main()
{
    int i;
    string word, text;
    int c=0;
    cin>>word;

    for(i=0; i<word.size(); i++){
        if(word[i]>='A' && word[i]<='Z')
            word[i]=word[i]-'A'+'a';
    }
    while(1){
            cin>>text;
        if(text=="END_OF_TEXT")
            break;
        for(i=0;i<text.size(); i++){
            if(text[i]>='A' && text[i]<='Z')
                text[i]=text[i]-'A'+'a';
        }
        if(word==text)
            c++;

    }
    cout<<c<<endl;
}


Measured memory_bytes: 3184
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;


fn main() {
    input! {
    a:usize,
    b:usize,
    c:[String;a],
  }
    let mut d=Vec::new();
    for i in 0..b+2 {
        d.push('#');
    }
    let d:String=d.iter().collect();
    println!("{}",d);
    for i in 0..a {
        println!("#{}#",c[i])
    }
    println!("{}",d)
}

Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
int n;
int judge(int x)
{
    int u,l=x,ans=1;
    for (u=3;u<=l;u+=2)
        if (l%u==0) ans++;
    return ans;
}
void solve()
{
    int ans=0;
    for (int i=1;i<=n;i+=2)
        if (judge(i)==8) ans++;
    cout<<ans<<endl;
}
int main()
{
    while(cin>>n)
        solve();
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
int n,m,k,ans;
long long a[200010],b[200010];
long long suma[200010],sumb[200010];
int main(){
	scanf("%d%d%d",&n,&m,&k);
	for(int i=1;i<=n;++i){
		scanf("%lld",a+i);
		suma[i]=suma[i-1]+a[i];
	}
	for(int i=1;i<=m;++i){
		scanf("%lld",b+i);
		sumb[i]=sumb[i-1]+b[i];
	}
	for(int i=0;i<=n&&k-suma[i]>=0;++i){
        long long *ans1=lower_bound(sumb+1,sumb+1+m,k-suma[i]);
		ans=max(ans,i+(int)((ans1-(*ans1==k-suma[i]?0:1)-&sumb[0])));
	}
    printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 7976
#include <stdio.h>

int main(void)
{
	int n,x;
	
	scanf("%d%d",&n,&x);
	
	int l[n],i,count = 0;
	
	for(i = 0; i < n; i++){
		scanf("%d",&l[i]);
	}
	
	int d[n+1];
	d[0] = 0;
	
	for(i = 1; i < n + 1; i++){
		d[i] = d[i - 1] + l[i - 1];
	}
	
	for(i = 0; i < n + 1; i++){
		if(x >= d[i]){
			count++;
		}
	}
	
	printf("%d\n",count);
	
	return 0;
}
	
	
	
	

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

int main() {
	int N, M;
	cin >> N >> M;
	int counter = 0;
	int K[30];
	int A[30][30];
	int count[40] = { 0 };

	for (int i = 0; i < N; i++) {
		cin >> K[i];
		for (int j = 0; j < K[i]; j++) {
			cin >> A[i][j];
			count[A[i][j]]++;
		}
	}

	for (int i = 1; i <= 30; i++) {
		if (count[i] >= N) counter++;
	}

	cout << counter << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
typedef pair<string,string> Ps;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct pos{
	// 1 変数を入れる;
	int x,y,sx,sy,cost;
};
int main() {

	int a;
	cin>>a;
	cout<<a+a*a+a*a*a<<endl;


	return 0;
}


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

using namespace std;

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll n, k;
    cin >> n >> k;
    ll ub = (n - 1) * (n - 2) / 2;
    if(k > ub){
        cout << -1 << endl;
        return 0;
    }
    cout << n - 1 + ub - k << endl;
    REP(i, n - 1) cout << 1 << " " << i + 2 << endl;
    ll cnt = ub - k;
    ll i = 2, j = 3;
    while(cnt){
        cout << i << " " << j << endl;
        j++;
        if(j > n){
            i++;
            j = i + 1;
        }
        cnt--;
    }
    return 0;
}

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

using namespace std;

int n;
long long s[111111];
map<pair<long long, long long>, int> mp;
int pr[2555];
vector<int> pp;

int main(){
//	freopen("input.inp", "r", stdin);
	scanf("%d",&n);
	for(int i = 1; i <= n; ++i) scanf("%lld",&s[i]);
	for(int i = 2; i <= 2500; ++i){
		if (!pr[i]){
			pp.push_back(i);
			for(int j = i; i * j <= 2500; ++j){
				pr[i * j] = 1;
			}
		}
	}
	for(int i = 1; i <= n; ++i){
		long long tmp = s[i], dn = 1, up = 1;
		for(int j = 0; j < pp.size(); ++j){
			if (tmp % pp[j]) continue;
			int x = 0;
			while (tmp % pp[j] == 0) tmp /= pp[j], ++x;
			x %= 3;
			if (x == 1){
				dn *= pp[j];
				up *= pp[j] * pp[j];
			}
			else if (x == 2){
				dn *= pp[j] * pp[j];
				up *= pp[j];
			}
		}
		if (tmp > 1){
			long long ss = floor(sqrt(tmp));
			if (ss * ss == tmp){
				dn *= tmp;
				up *= ss;
			}
			else{
				dn *= tmp;
				up *= tmp * tmp;
			}
		}
		++mp[make_pair(dn, up)];
	}
	int an = 0;
	while (!mp.empty()){
		pair<long long, long long> cu = mp.begin()->first;
		if (cu.first == 1){
			++an;
		}
		else{
			pair<long long, long long> cuu = make_pair(cu.second, cu.first);
			an += max(mp[cu], mp[cuu]);
			mp.erase(cuu);
		}
		mp.erase(mp.begin());
	}
	printf("%d",an);
	return 0;
}

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

#define _REP(_1,_2,_3,_4,name,...) name
#define _REP4(i,b,e,s) for(decltype(e) _b=(b),_e=(e),i=_b+(0<(s)?0:(s));(0<(s)?i<_e:_e<=i);i+=(s))
#define _REP3(i,b,e) for(decltype(e) _b=(b),_e=(e),i=(_b<_e?_b:_b-1);(_b<_e?i<_e:_e<=i);(_b<_e?i++:i--))
#define _REP2(i,n) for(decltype(n) i=0,_n=(n);i<_n;i++)
#define _REP1(n) for(decltype(n) _i=0,_n=(n);_i<_n;_i++)
#define REP(...) _REP(__VA_ARGS__,_REP4,_REP3,_REP2,_REP1)(__VA_ARGS__)
#define INT(n) int n;assert(0<scanf("%d",&n))
#define STR(s) string s;cin>>s

int main(){
  INT(n);
  cout << 0 << endl << flush;
  STR(s);
  int l = 0, r = n - 1, prvi = 0;
  string prvs = s;
  REP(19){
    if (prvs == "Vacant"){break;}
    int c = (l + r) / 2;
    if (c == prvi){
      if (c == l){
        c = r;
      } else {
        c = l;
      }
    }
    cout << c << endl << flush;
    cin >> s;
    if (prvi == l){
      if ((s == prvs) == ((c - l) % 2 == 0)){
        l = c;
      } else {
        r = c;
      }
    } else {
      if ((s == prvs) == ((r - c) % 2 == 0)){
        r = c;
      } else {
        l = c;
      }
    }
    prvi = c; prvs = s;
  }
  return 0;
}

Measured memory_bytes: 852
#include<stdio.h>

int main(void)
{
  int x[10000], y[10000];
  int i=0, j;
  int temp;

  while(1)
    {
      scanf("%d %d", &x[i], &y[i]);
      i++;
      if(x[i-1]==0 && y[i-1]==0)
	break;
    }

  for(j=0;j<i-1;j++)
    {
      if(x[j]>y[j])
	{
	  temp=x[j];
	  x[j]=y[j];
	  y[j]=temp;
	    }
      printf("%d %d\n", x[j], y[j]);
    }

  return 0;
}

Measured memory_bytes: 624
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
 
const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

int n;
ll a[400];
ll dp[400][400];
ll sum[400][400];

int main() {
    cin >> n;
    rep(i,n) cin >> a[i];
    rep(i,n) rep(j,n-i) for (int k = j; k <= i+j; k++) sum[j][j+i] += a[k];
    rep(i,n) rep(j,n) dp[i][j] = MOD*MOD;
    rep(i,n) {
        rep(j,n-i) {
            if (i == 0) {
                dp[j][j+i] = 0;
                continue;
            }
            rep(k,i) {
                dp[j][j+i] = min(dp[j][j+i], dp[j][j+k]+dp[j+k+1][j+i]+sum[j][j+k]+sum[j+k+1][j+i]);
            }
        }
    }
    cout << dp[0][n-1] << endl;
}



Measured memory_bytes: 2688
#include <iostream>
#include <cstdio>
#include <cstdlib>
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define REP3(i, f, n) for (int (i) = (f); (i) < (n); (i)++)
using namespace std;

int digit_sum(int i){
    int ret=0;
    string s;
    s=to_string(i);
    REP(k,s.size()){
        ret+=(s[k]-'0');
    }
    // cout<<"s:"<<s<<endl<<"ret:"<<ret<<endl;
    return ret;
}

int main(){
    int n,a,b;
    cin>>n>>a>>b;
    int cnt=0;
    REP3(i,1,n+1){
        int s=digit_sum(i);
        if(s>=a and s<=b){
            cnt+=i;
        }
    }
    cout<<cnt<<endl;
    return 0;
}

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

int main()
{
    int A, B, H, M;
    cin >> A >> B >> H >> M;
    long double PI = 3.14159265358979324;
    long double argA = (PI * (static_cast<long double>(H) * 60.0 + static_cast<long double>(M) * 1.0)) / 360.0;
    long double argB = PI * M / 30.0;
    long double theta = abs(argA - argB);
    if (theta >= PI) theta = 2.0 * PI - theta;
    long double C = sqrtl(A * A + B * B - 2.0 * A * B * cosl(theta));
    printf("%.10Lf\n", C);
    return 0;
}


Measured memory_bytes: 4080
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

a,b,c,x,y = nm()

min_cost = 10**10
for i in range(10**5+1):
  cost=2*i*c+max(0,x-i)*a+max(0,y-i)*b
  min_cost = min(min_cost,cost)
print(min_cost)


Measured memory_bytes: 9176
from collections import deque

s = input()
n = int(input())
query = [0]*n
rev = 0
for i in range(n):
    query[i] = list(map(str, input().split()))
    if query[i][0] == '1':
        rev = rev + 1

begin = deque()
end = deque()
pal = 0

for i in range(n):
    if int(query[i][0]) == 1:
        pal = (pal+1)%2
    else:
        if pal == 0:
            if int(query[i][1]) == 1:
                begin.appendleft(query[i][2])
            else:
                end.append(query[i][2])
        else:
            if int(query[i][1]) == 1:
                end.append(query[i][2])
            else:
                begin.appendleft(query[i][2])
#    print('--------'+str(i+1)+'th try-----')
#    print(begin)
#    print(end)
#    print('pal:'+str(pal))
#print(s)

if rev%2 == 1:
    print(''.join(deque(reversed(end)))+s[::-1]+''.join(deque(reversed(begin))))
else:
    print(''.join(begin)+s+''.join(end))

Measured memory_bytes: 43060
#include<bits/stdc++.h>
using namespace std;
const unsigned int MOD = 1000000007;
#define ll long long
#define PI 3.1416
string day[]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
vector<string>v;
void dfs(string str,string t="",int cnt=0){
    if(cnt==2){
        v.push_back(t);
        return;
    }else{
        for(int i=0;i<str.size();i++){
            dfs(str,t+str[i],cnt+1);
        }
    }
}
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int n;
    while(cin>>n){
        if(n>=2800)cout<<"AGC"<<endl;
        else if(n>=1200)cout<<"ARC"<<endl;
        else cout<<"ABC"<<endl;
    }
    return 0;
}


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

int main() {
	double x, y,i;
	double a, b;
	double s;
	cin >> a >> b >> x >> y;
	s = (a * b) / 2;
	if ((x == a / 2) && (y == b / 2))
		i = 1;
	else
		i = 0;
	cout << s << " " << i << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int main()
{
int a[5],k;
for(int i=0;i<5;i++)
{
cin>>a[i];
}
cin>>k;
sort(a,a+5);
string ans="Yay!";
if(a[4]-a[0]>k)
{
ans=":(";
}
cout<<ans<<endl;
}

Measured memory_bytes: 3576
import numpy as np

N, M, C = map(int, input().split())
B = list(map(int, input().split()))
B.append(C)
B_array = np.array(B).T
A = []
for i in range(N):
    a = list(map(int, input().split()))
    a.append(1)
    A.append(a)
A_array = np.array(A)

result = np.dot(A, B)
print(np.sum(result > 0))


Measured memory_bytes: 12508
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}

int main()
{
        //input->compute->output//
        string S;
        cin >> S;

        S[3] = '8';
        cout << S << endl;

        return 0;
}


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

int main() {
  long X;
  cin >> X;

  long happy = 0;
  if(X <= 0){
    cout << happy << endl;
    return 0;
  }

  happy = int(X / 500) * 1000;
  X %= 500;
  happy += int(X / 5) * 5;
  
  cout << happy << endl;  
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define mod 1000000007

typedef long long ll;

using namespace std;

int main(){
    int n;cin >> n;
    string s;cin >> s;
    int x=0;
    int max=0;
    for(char c:s){
        if(c=='I')x++;
        if(c=='D')x--;
        if(max<x)max=x;
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 256
H, W = list(map(int, input().split()))
M = []
M.append('.'*(W+2))
M += ['.'+input()+'.' for _ in range(H)]
M.append('.'*(W+2))

for h in range(1, H+1):
    for w in range(1,W+1):
        if M[h][w]=='#' and ('....'==M[h][w+1]+M[h][w-1]+M[h+1][w]+M[h-1][w]):
            print('No')
            exit()

print('Yes')

Measured memory_bytes: 3064
from math import gcd
from functools import reduce

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

M = 10**6+1
mp = [0]*M
for a in A:
    mp[a] += 1

pairwise = 1
for i in range(2,M):
    if sum(mp[i::i])>1:
        pairwise = 0
        break

if pairwise:
    print('pairwise coprime')
elif reduce(gcd, A) == 1:
    print('setwise coprime')
else:
    print('not coprime')



Measured memory_bytes: 127784
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		
		int input_num = sc.nextInt();
		int num[] = new int[input_num];
		int even_count = 0;
		
		for(int i=0;i<input_num;i++){
			num[i] = sc.nextInt();
			if(num[i] % 2 == 0) even_count++;
		}
		
		int even_num[] = new int[even_count];
		int even_elements = 0;
		
		for(int i=0;i<input_num;i++){
			if(num[i] % 2 == 0){
				even_num[even_elements] = num[i];
				even_elements++;
			}
		}
		
		boolean judge = true;
		
		for(int i=0;i<even_elements;i++){
			if(even_num[i] % 3 != 0 && even_num[i] % 5 != 0){
				judge = false;
				break;
			}
		}
		
		if(judge){
			System.out.println("APPROVED");
		}else{
			System.out.println("DENIED");
		}
	}
}

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

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;

using namespace std;
#define ll  long long
#define PI  acos(-1)
#define pb  push_back
#define ins insert
#define INF 5000000000000000007 //1e18+7
#define mk  make_pair
#define ff  first
#define ss  second
//#define endl "\n"
#define max3(x,y,z)  max(x,max(y,z))
#define min3(x,y,z)  min(x,min(y,z))
#define sz(a) (ll)a.size()
#define double long double
#define coud(a,b) cout << fixed << setprecision((b)) << (a)
#define mset(x,y)  memset(x,y,sizeof(x))
#define all(x)   (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define bp(n)  __builtin_popcountll(n)
#define mxt(a)  *(max_element(a.begin(),a.end()))
#define mnt(a)  *(min_element(a.begin(),a.end()))
#define unique_sort(c) (sort(all(c)), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define rep(i,a,b) for(ll i=(a);i<=(b);++i)
#define trav(a, x) for(auto &a : x)

const double eps=1e-7;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int d8x[8] = {+1, +1, +1, 0, 0, -1, -1, -1};
int d8y[8] = {+1, 0, -1, +1, -1, +1, 0, -1};
int d4x[4] = {1, 0, 0, -1};
int d4y[4] = {0, -1, 1, 0};
ll power(ll x,ll y){ll fk=1;x=x;while(y>0){if(y&1)fk=(fk*x);y=y>>1;x=(x*x);}return fk;}
ll sqr(ll x) { return x * x;}

template <typename T> T gcd(T a,T b){ if(a==0) return b; return gcd(b%a,a); }
template <class T> inline void chmax(T &x,T y){ x = max((x), (y));}
template <class T> inline void chmin(T &x,T y){ x = min((x), (y));}
template <class T> T abs(T x) { return x>0 ? x : -x;}
template <typename T> T powm(T a,T b, ll m){T cnt=1; while(b>0) { if(b%2==1) cnt=(cnt*a)%m; b/=2; a=(a*a)%m; }return cnt%m;}
typedef pair<int,int>  pii;
typedef pair<ll,ll>  pll;
typedef vector<pll>  vpll;
typedef vector<pii>  vpii;
typedef vector<ll>   vll;
typedef vector<int>  vii;
#define minpq priority_queue<T,vector<T>,greater<T> >;
// #define T int
// #define ordered_set tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>
//*X.find_by_order(k) returns the kth largest element (0-based).
//X.order_of_key(val) returns the no. of values less than val.
ll ncr(ll n,ll r) {ll fk=1;if(r>n)return 0;if(r>n-r)r=n-r;for(ll i=0;i<r;i++){fk*=(n-i);fk/=(i+1);}return fk;}
const int MOD = 998244353;   
const int N = 102;
// 🎲

void solve() {
  int n;
  cin >> n;
  vpii a(n+1);
  rep(i,1,n) {
    cin >> a[i].ff >> a[i].ss;
  }
  int fk = 0;
  rep(i,1,n-2) {
    int ok = 1;
    for (int j=i; j<=i+2; ++j) {
      if(a[j].ff != a[j].ss) ok = 0;
    }
    if(ok) fk = 1;
  }
  if(fk) cout << "Yes";
  else cout << "No";
}

int32_t main() {
  cin.sync_with_stdio(0);cin.tie(0);
  cin.exceptions(cin.failbit);
  
  int tc = 1;
  //cin >> tc;
  for (int i=1; i<=tc; ++i) {
    solve();
  }
  return 0; 
}
/* stuff you should look for
    * int overflow,array bounds.
    * special cases (n=1?).
    * N,MOD value.
*/

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

int main() {
  ll a,b;
  cin >> a >> b;
  for(ll i=1;i<100000;i++) {
    if(i*8/100==a&&i*10/100==b) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}

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

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

typedef pair<int, int> pint;

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front

#define MOD (1000 * 1000 * 1000 + 7)

signed main() {

    int N;
    cin >> N;

    vector<double> xs(N);
    vector<double> ys(N);
    REP(i, N) {
        cin >> xs[i] >> ys[i];
    }

    vector< vector<double>> d(N, vector<double>(N));
    REP(i, N) {
        REP(j, N) {
            d[i][j] = pow(pow(xs[i] - xs[j], 2) + pow(ys[i] - ys[j], 2), 0.5);
        }
    }

    vector<int> fact(10, 1);
    REPS(i, 9) {
        fact[i] = fact[i-1] * i;
    }

    int total = 0;
    REP(i, N-1) {
        total +=  (fact[N-2] / fact[N-2-i]) * fact[N-2-i];
    }

    double ans = 0;
    REP(i, N) {
        REP(j, N) {
            ans += d[i][j] * total / fact[N];
        }
    }

    cout << setprecision(10) << ans << endl;

    return 0;
}

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

typedef long long ll;
const int maxn=50+5;
int n,a[maxn],b[maxn];
bool vis[maxn];
ll ans;

bool dfs(int x,int y,int pos){
	if(x==y)
		return true;
	if(!pos)
		return false;
	if(vis[pos]&&x%pos!=x&&x%pos>=y&&dfs(x%pos,y,pos-1))
		return true;
	return dfs(x,y,pos-1);
}
bool judge(){
	for(int i=1;i<=n;++i)
		if(!dfs(a[i],b[i],50))
			return false;
	return true;
}

int main(){
	cin>>n;
	for(int i=1;i<=n;++i)
		cin>>a[i];
	for(int i=1;i<=n;++i)
		cin>>b[i];
	for(int i=1;i<=50;++i)
		vis[i]=true;
	if(!judge()){
		puts("-1");
		return 0;
	}
	for(int i=50;i;--i){
		vis[i]=false;
		if(!judge())
			vis[i]=true;
	}
	for(int i=1;i<=50;++i)
		if(vis[i])
			ans|=1ll<<i;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(a); i++)
typedef long long ll;
template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////
const ll inf = 1LL<<60;

int main()
{
  string s; cin>>s;
  ll t = 0;
  for (auto c:s) t += (c-'0');

  ll n = stoll(s);
  if (n%t == 0) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int arr[5];
  for(int i=0;i<5;i++)
    	cin>>arr[i];
  int min=10,sum=0;
  for(int i=0;i<5;i++)
  {
		if((arr[i]%10)<min&&(arr[i]%10)!=0)
        {
			min=arr[i]%10;
          //sum+=arr[i]+10-(arr[i]%10);
        }
        sum+=arr[i]+10-(arr[i]%10);
        if(arr[i]%10==0)
            sum-=10;
  }
  cout<<sum-10+min;
}


Measured memory_bytes: 256