akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;
int read();

int N, x[200005], st[200005], a[200005];
int work() {
    int m = N / 2 + 1, res = a[m], l = m, r = m;
    a[0] = a[1], a[N + 1] = a[N];
    for (; l >= 1 && a[l] != a[l - 1] && a[r] != a[r + 1]; --l, ++r) res ^= 1;
    return res;
}

int main() {

    N = read() * 2 - 1;
    for (int i = 1; i <= N; ++i) st[i] = x[i] = read();
    sort(st + 1, st + 1 + N);
    int l = 1, r = N, res = r;
    while (l <= r) {
        int mid = l + r >> 1;
        for (int i = 1; i <= N; ++i) a[i] = x[i] > st[mid];
        if (!work())
            r = mid - 1, res = mid;
        else
            l = mid + 1;
    }
    printf("%d\n", st[res]);
    return 0;
}
int read() {
    int x = 0, f = 1;
    char c = getchar();
    while (!isdigit(c)) f = (c == '-') ? -1 : f, c = getchar();
    while (isdigit(c)) x = x * 10 + c - '0', c = getchar();
    return x * f;
}

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

#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
// constexpr ll mod = 1e9 + 7;

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

    vector<int> A(N);
    rep(i,N) cin >> A[i];

    int longest = 0;
    rep(i,N-1){
        longest = max(longest, A[i+1]-A[i]);
    }
    longest = max(longest, K-A[N-1]+A[0]);
    int ans = K - longest;

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


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

int main()
{
    int r, d, x_i;

    cin >> r >> d >> x_i;

    for (size_t i = 0; i < 10; i++)
    {
        int x_i_1 = r * x_i - d;
        x_i = x_i_1;

        cout << x_i_1 << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;class Main{final static int LEN = 105;public static void main(String args[]){int[][] graph = new int[LEN][LEN];int[] minCost = new int[LEN];int count=0;int v;boolean[] used = new boolean[LEN];Scanner in = new Scanner(System.in);int n = in.nextInt();int nodeNumber;int k;for(int i=0; i<n; i++){for(int j=0; j<n; j++){graph[i][j]=2000000; }}for(int i=0; i<n; i++){ nodeNumber = in.nextInt(); k = in.nextInt();for(int j=0; j<k; j++){graph[nodeNumber][in.nextInt()]=in.nextInt(); }}for(int i=0; i<n; i++){ minCost[i]=999999;used[i]=false;}minCost[0]=0;while(true){ v = -1;for(int i=0; i<n; i++){if(!used[i] && (v==-1 || minCost[i] < minCost[v]))v=i;} if(v==-1)break; used[v]=true; count+=minCost[v]; for(int i=0; i<n; i++){minCost[i]=Math.min(minCost[i], graph[v][i]+minCost[v]); }}for(int i=0; i<n; i++)System.out.println(i+" "+minCost[i]);}}

Measured memory_bytes: 13000
first = sorted(input(''))
second = sorted(input(''), reverse=True)
result = False
check_equal = False
for (f, s) in zip(first, second):
  check_equal = (s == f)
  if not check_equal:
    result = (f < s)
    break
if (len(first) < len(second) and check_equal) or result:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
//#define mp make_pair
#define pb push_back
#define int long long
#define pi 3.141592653589793238462643383279502
#define M 998244353
#define F first
#define S second
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
bool isPowerOfTwo(int n)
{
   if(n==0)
   return false;

   return (ceil(log2(n)) == floor(log2(n)));
}
int power(int x, unsigned int y)
{
    int res = 1;

    x = x;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x)%M;

        y = y>>1;
        x = (x*x)%M;
    }
    return res%M;
}
bool isprime(int x)
{
      if(x<2)
        return false;
    for(int i=2;i*i<=x;i++)
     {
        if (x%i==0)
            return false;
    }
    return true;
}
vector<pair<int,int>>primeFactors(int n)
{
    vector<pair<int,int>>v;
    int x=0;
    while (n % 2 == 0)
    {
        x++;
        n = n/2;
    }
    if(x>0)
    v.pb({2,x});
    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        int y=0;
        while (n % i == 0)
        {
            y++;
            n = n/i;
        }
        if(y>0)
        v.pb({i,y});
    }
    if (n > 2)
        v.pb({n,1});
    return v;
}
int maxSubArraySum(int a[], int size)
{
    int max_so_far = INT_MIN, max_ending_here = 0;

    for (int i = 0; i < size; i++)
    {
        max_ending_here = max_ending_here + a[i];
        if (max_so_far < max_ending_here)
            max_so_far = max_ending_here;

        if (max_ending_here < 0)
            max_ending_here = 0;
    }
    return max_so_far;
}

void solve()
{
int n;
cin>>n;
int a[n];

for(int i=0;i<n;i++)
    {cin>>a[i];
    if(a[i]==0)
    {
        cout<<0<<endl;
        return ;
    }
    }

int ans=a[0];
for(int i=1;i<n;i++)
{
    int x=1e18;
    int y;
    //cout<<a[i]*ans-x<<endl;
    if(x%a[i]==0)
    {

    y=x/a[i];

    if(ans>(y))
    {

        cout<<-1<<endl;
        return ;
    }
    else
    {
        ans*=a[i];
    }
    }
    else
    {
        y=x/a[i];
        y++;
        if(ans>=y)
        {
            cout<<-1<<endl;
            return ;
        }
        else
            ans*=a[i];
    }
}
cout<<ans<<endl;
}
signed main()
{ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int t;
//cin>>t;
t=1;
while(t--)
{

solve();

}
}


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

int main(){
  int ans,tmp,tmp2;
  int m,n;

  cin >> m >> n;
  ans = 0;
  for(int i=0;i<m;i++){
    tmp = 0;
    for(int j=0;j<n;j++){
      cin >> tmp2;
      tmp += tmp2;
    }
    if(tmp>ans)ans = tmp;
  }

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

Measured memory_bytes: 0
#include <iostream>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cmath>
using namespace std;
int main() {
  double x, y, walk, deg, rad = M_PI_2;
  char c;
  while (cin >> walk >> c >> deg) {
    if (walk == 0 && deg == 0) break;
    x += walk * cos(rad);
    y += walk * sin(rad);
    rad -= deg * M_PI / 180;
  }
  cout << (int) x << endl << (int) y << endl;
}

Measured memory_bytes: 1232
import sys


atoe = []
for i in range(5):
    atoe.append(int(sys.stdin.readline()))

fastest_meal = 0
fastest_meal_num = 99
for i in range(5):
    temp = str(atoe[i])
    if int(temp[-1:]) > 0 and int(temp[-1:]) < fastest_meal:
        fastest_meal = int(temp[-1:])
        fastest_meal_num = i
    if i == 0:
        fastest_meal = int(temp[-1:])
        fastest_meal_num = i

total_time = 0
for i in range(5):
    if i == fastest_meal_num:
        continue
    temp = str(atoe[i])
    total_time += atoe[i]
    str_total_time = str(total_time)
    if int(temp[-1:]) > 0 and len(str_total_time) > 1:
        upper = int(str_total_time[:-1])
        upper += 1
        total_time = int(str(upper) + "0")
    elif int(temp[-1:]) > 0:
        total_time = 10

total_time += atoe[fastest_meal_num]

print(total_time)

Measured memory_bytes: 3064
r,c=[int(k) for k in input().split()]
arr=[[]]*r
for i in range(r):
    arr[i]=[int(k) for k in input().split()]
arr+=[[0]*c]
for i in range(r):
    arr[i].append(sum(arr[i]))
    arr[r]=[arr[r][k]+arr[i][k] for k in range(c)]
arr[r].append(0)
for v in arr[r]:
    arr[r][c]+=v
arr[r][c]//=2
for i in range(r+1):
    for j in range(c+1):
        arr[i][j]=str(arr[i][j])
for x in arr:
    print(' '.join(x))
    



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

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

        long n = sc.NextLong();
        string s = sc.Next();
        int k = sc.NextInt();

        char c = s[k - 1];

        string answer = string.Join("", s.Select(w => w == c ? 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: 28296
#define DEBUGGING  // Enables DEBUG macro.
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifndef DEBUGGING
#define debug(...)
#define DEBUG(...)
#else
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                     \
  do {                                 \
    cerr << " (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ": ";      \
    _debug(__VA_ARGS__);               \
    cerr << endl;                      \
  } while (0)
#endif
// auto mod int

const i64 MOD = 1'000'000'007;

namespace {
long long ext_gcd(long long a, long long b, long long& x, long long& y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  }
  long long d = ext_gcd(b, a % b, y, x);
  y -= a / b * x;
  return d;
}
}  // namespace

struct mint {
  long long x;
  mint(long long x = 0) : x((x % MOD + MOD) % MOD) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD - a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(long long t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // Inverse by Extended Euclidean algorithm.
  // MOD doesn't need to be prime, but x and MOD must be coprime.
  mint inv() const {
    assert(x != 0);
    long long a, b;
    int g = ext_gcd(x, MOD, a, b);
    assert(g == 1);  // gcd(x, MOD) must be 1.
    return a;
  }

  mint& operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int> a(100001, -1);
  int k1 = -1, k2 = -1;
  REP(i, n + 1) {
    int x;
    cin >> x;
    if (a[x] != -1) {
      k1 = a[x];
      k2 = i;
      break;
    }
    a[x] = i;
  }

  mint num = n + 1;
  mint dinv = mint(1).inv();
  mint num2 = 1;
  mint dinv2 = mint(1).inv();
  REP(i, n + 1) {
    mint allc = num * dinv;  // comb(n+1, i+1)
    mint dupc = num2 * dinv2;
    cout << (allc - dupc) << '\n';
    num *= (n - i);
    num2 *= (n + k1 - k2 - i);
    dinv *= mint(i + 2).inv();
    dinv2 *= mint(i + 1).inv();
  }
}

Measured memory_bytes: 3656
#include<cstdio>
#include<algorithm>
using namespace std;

int main() {
	int a, b, k, cnt = 0;
	scanf("%d%d%d", &a, &b, &k);
	for(int i=min(a, b);i>0;i--) {
		if (a%i==0 && b%i==0) {
			cnt++;
			if (cnt==k) {
				printf("%d\n", i);
				return 0;
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(void)
{
	int n,a;
	scanf("%d",&n);
	a=n%10;
	if(a==2||a==4||a==5||a==7||a==9){
		printf("hon\n");
	}
	if(a==0||a==1||a==6||a==8){
		printf("pon\n");
	}
	if(a==3){
		printf("bon\n");
	}
	return 0;
}

Measured memory_bytes: 1636
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define NUM 1000000007
#define MAX 100001
#define INF LLONG_MAX
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    if(n==0)
        cout<<1<<endl;
    else
        cout<<0<<endl;
    return 0;
}


Measured memory_bytes: 3644
#include<stdio.h>
int main()
{
    long long int n,k,i;
    static long long int ara[200005];
    scanf("%lld%lld",&n,&k);
    for(i=1;i<=n;i++)
        scanf("%lld",&ara[i]);
    for(i=1;i<=n-k;i++)
    {
        if(ara[i]<ara[i+k])
            printf("Yes\n");
        else
            printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 3208
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		long N = long.Parse(Console.ReadLine());
		var list = PrimeFactors(N);
		var dic = new Dictionary<long,int>();
		for(var i=0;i<list.Count;i++){
			long a1 = list[i];
			if(a1>=2){
			if(dic.ContainsKey(a1)){
				dic[a1]++;
			} else {
				dic[a1] = 1;
			}
			}
		}
		long ans = 0;
		foreach(var i in dic.Keys){
			int c1 = dic[i];
			long c = 0;
			while(true){
				c++;
				if(c1 < c*(c+1)/2){
					c--;
					break;
				}
			}
			ans += c;
		}
		Console.WriteLine(ans);
	}
	
	public static List<long> PrimeFactors(long n){
		long i = 2;
		long tmp = n;
		var list = new List<long>();
		while(i*i<=n){
			if(tmp%i==0){
				tmp /= i;
				list.Add(i);
			} else {
				i++;
			}
		}
		if(tmp != 1){
			list.Add(tmp);
		}
		return list;
	}
}

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

int main(){
    int n;
    cin>>n;
    bool ans[4][13]={};
    char ans_[4]={'S','H','C','D'};
    for(int i=0;i<n;i++){
        char mark;
        int m;
        cin>>mark>>m;
        if(mark=='S')ans[0][m-1]=1;
        if(mark=='H')ans[1][m-1]=1;
        if(mark=='C')ans[2][m-1]=1;
        if(mark=='D')ans[3][m-1]=1;
    }
    for(int j=0;j<4;j++){
        for(int k=0;k<13;k++){
            if(ans[j][k]==false){
                cout<<ans_[j]<<' '<<(k+1)<<endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3108
#include <iostream>

namespace {
// 色々設定
enum {
	MaxSize =1000	// 地図の大きさの最大値
};

enum {
	EmptySymbol = '.',	// 空白を示すシンボル
};

typedef unsigned int ScoreType; // 空白数を保持するための型, MaxSize*MaSizeに連動して変える

// 色々定義
template <class T>
T max(const T& A, const T& B){
	return (A > B) ? A : B;
}

template <class T>
T min(const T& A, const T& B){
	return (A < B) ? A : B;
}

template <class T>
T min(const T& A, const T& B, const T& C){
	return min(min(A, B), C);
}

// 空白か？
char isEmpty(const char& ch) {
	return (ch == EmptySymbol) ?  1 : 0;
}

} // unnamed namespace 

int main()
{
	unsigned char _map[MaxSize][MaxSize];
	const unsigned char (&map)[MaxSize][MaxSize] = _map; // なんとなく入力をconstにしたかった...
	ScoreType score[MaxSize][MaxSize];

	while (1) {
		int n;
		// データサイズ読み取り
		std::cin >> n;
		if (n == 0) { break; } // n==0ならば終了
		
		// データを読み取り
		for (int i=0; i<n; ++i) {
			std::cin >> _map[i];
		}

		// 一応, Width, Height
		const int Width  = n;
		const int Height = n;

		ScoreType max_score =0;
		// スコア計算(境界)
		for (int i=0; i<Height; ++i) {
			score[i][0] = isEmpty(map[i][0]);
			// 最大値を覚えておく
			max_score = max(max_score, score[i][0]);
		}
		for (int j=0; j<Width; ++j) {
			score[0][j] = isEmpty(map[0][j]);
			// 最大値を覚えておく
			max_score = max(max_score, score[0][j]);
		}
		
		// スコア計算(境界以外)
		for (int i=1; i<Height; ++i) {
			for (int j=1; j<Width; ++j) {
				// 更新ルール
				if (isEmpty(map[i][j])) {
					score[i][j] = min(score[i-1][j-1], score[i-1][j  ],
									  score[i  ][j-1]				   )+1;
				}else{
					score[i][j] = 0;
				}
				// 最大値を覚えておく
				max_score = max(max_score, score[i][j]);
			} // for (int j...)
		} // for (int i...)
		// 結果を出力
		std::cout << max_score << std::endl;
	} // while(1)
	return 0;
}

Measured memory_bytes: 6040
# -*- coding: utf-8 -*-
"""
Created on Sat Sep  7 21:12:15 2019

@author: doppe
"""

N = int(input())

B = list(map(int, input().split()))

sum = B[0]
for i in range(0, len(B) - 1):
    sum += min([B[i], B[i + 1]])
sum += B[len(B) - 1]
print (sum)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
string a;
int main()
{
	cin>>a;
    if(a[0]=='a'||a[0]=='e'||a[0]=='i'||a[0]=='o'||a[0]=='u') cout<<"vowel"<<endl;
    else cout<<"consonant"<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define For(i, a, b) for (int i = (a); i <= (b); ++i)
#define Ford(i, a, b) for(int i = (a); i >=(b); --i)
#define endl '\n'
#define debug(a) cout << a << endl
using namespace std;
 
typedef long long ll;
typedef pair <ll, ll> pll;
typedef vector <ll> vll;
 
const ll maxN = 1e18;
const ll minN = -1e18;
const ll MOD = 1e9 + 7;
 
const ll limit = 2e5 + 5;
const ll limit1 = 1e6 + 5;
const ll limit2 = 1e3 + 5;

ll test;
ll k, n;
ll r, g, b;
string s;
ll res = 0, sum = 0, ans = 0, kd, hkd;


void FastIn(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}

ll Solve(){
    
    For(i, 0, n - 1){
        if(s[i] == 'R') r++;
        if(s[i] == 'G') g++;
        if(s[i] == 'B') b++;
    }
    res = r * g * b;
    For(i, 0, n - 1)
        For(j, i + 1, n - 1){
            if(s[i] != s[j] && s[j] != s[2 * j - i] && s[2 * j - i] != s[i] && 2 * j - i <= n - 1)
                res--;
        }
    
    return res;
}

void ReadIn(){
    cin >> n;
    cin >> s;
    cout << Solve();
}
int main(){
    FastIn();
    ReadIn();
}
    

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

using namespace std;

#define int long long

void solve() {
    int x;
    cin >> x;
    cout << 1 - x;
}

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


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

long long gcd(long long x,long long y) {
    if(y == 0) return x;
    return gcd(y, x%y);
}

long long lcm(long long x,long long y) {
    return x*y/gcd(x,y);
}

int main() {
    int a[3],m[3];
    while(cin>>a[0]>>m[0]>>a[1]>>m[1]>>a[2]>>m[2], a[0]) {
        int res[3];
        for(int i=0; i<3; ++i) {
            int p = a[i]%m[i], cc = 1;
            while(p != 1) {
                p = (a[i]*p)%m[i];
                cc++;
            }
            res[i] = cc;
        }
        cout<<lcm(res[0], lcm(res[1], res[2]))<<endl;
    }
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner stdIn = new Scanner(System.in);
		long X = Math.abs(stdIn.nextLong());
		long K = stdIn.nextLong();
		long D = stdIn.nextLong();
		
		long ans = X;
		
		if(K <= X / D) {
			ans = X - D * K;
		}else {
			K -= X / D;
			if(X % D <= Math.abs(X % D - D)) {
				if(K % 2 == 0) {
					ans = X % D;
				}else {
					ans = Math.abs(X % D - D);
				}
			}else if(Math.abs(X % D - D) < X % D) {
				K -= 1;
				if(K % 2 == 0) {
					ans = Math.abs(X % D - D);
				}else {
					ans = X % D;
				}
			}
		}
		
		System.out.println(ans);
	}
}

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

using namespace std;

#define ALL(x) (x).begin(), (x).end()

typedef long long int lld;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(15);
    cout << fixed;

    int n = 0;
    cin >> n;
    cout << n * n * n << '\n';

    return 0;
}

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

int n, m, ans[1009][1009];
char x;
bool a[1009][1009];
queue <pair<int, int> > asd;

int main()
{
	cin >> n >> m;
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < m; j++)
		{
			ans[i][j] = INT_MAX;
		}
	}
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < m; j++)
		{
			cin >> x;
			if(x == '#')
			{
				a[i][j] = 1;
				asd.push(make_pair(i, j));
				ans[i][j] = 0;
			}else {
				a[i][j] = 0;
			}
		}
	}
	while(!asd.empty())
	{
		pair <int, int> temp = asd.front();
		asd.pop();
		int x = temp.first, y = temp.second;
		
		if(x > 0)
		{
			if(ans[x-1][y] > ans[x][y] + 1)
			{
				ans[x-1][y] = ans[x][y] + 1;
				asd.push(make_pair(x-1, y));
			}
		}
		if(x < n-1)
		{
			if(ans[x+1][y] > ans[x][y] + 1)
			{
				ans[x+1][y] = ans[x][y] + 1;
				asd.push(make_pair(x+1, y));
			}
		}
		if(y > 0)
		{
			if(ans[x][y-1] > ans[x][y] + 1)
			{
				ans[x][y-1] = ans[x][y] + 1;
				asd.push(make_pair(x, y-1));
			}
		}
		if(y < m-1)
		{
			if(ans[x][y+1] > ans[x][y] + 1)
			{
				ans[x][y+1] = ans[x][y] + 1;
				asd.push(make_pair(x, y+1));
			}
		}
	}
	int maks = 0;
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < m; j++)
		{
			maks = max(maks, ans[i][j]);
		}
	}
	cout << maks;
}

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

#define faster      ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi          acos(-1.0)
#define nl          '\n'

///Library
#define mem(a,b)    memset(a,b,sizeof(a))
#define all(a)      a.begin(),a.end()
#define Sort(x)     sort(x.begin(),x.end())
#define Reverse(x)  reverse(x.begin(),x.end())
#define SortA(ar,s) sort(ar,ar+s)
#define SortD(ar,s) sort(ar,ar+s,greater<int>())
#define gcd(a,b)    __gcd(a,b)
#define lcm(a,b)    (a*(b/gcd(a,b)))
#define sq(x)       (x)*(x)

#define min3(a,b,c)        min(a,min(b,c))
#define min4(a,b,c,d)      min(a,min(b,min(c,d)))
#define max3(a,b,c)        max(a,max(b,c))
#define max4(a,b,c,d)      max(a,max(b,max(c,d)))
#define ABS(x)             ((x)<0?-(x):(x))
#define pb                 push_back
#define mod                1000000007
#define end                printf("\n")
#define yes                printf("YES\n")
#define no                 printf("NO\n")

///data type
typedef long long int ll;
typedef unsigned long long int  llu;

int main()
{
    faster
    ll n,sum=0;
    cin>>n;
    int A[n+n];
    for(int i=0; i<(n+n); i++)
        cin>>A[i];

    sort(A,A+n+n);
    for(int i=0; i<n+n; i=i+2)
    {
        sum+=A[i];
    }
    cout<<sum<<nl;
    return 0;
}


Measured memory_bytes: 3620
S=gets.chomp
T=gets.chomp
s = S.chars.map {|c| c == '?' ? '.' : c}
l=T.length

(S.length - l).downto(0) do |i|
    if T.match(/#{s[i...i+l].join}/)
        s = S
        s[i...i+l] = T
        puts s.tr('?','a')
        exit 0
    end
end

puts 'UNRESTORABLE'

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

using namespace std;
const int maxn=3010;
int dp[maxn][maxn];

int main()
{
    string s,t;
    cin >> s >> t;
    for(int i=0;i<3010;i++)
    {
        dp[i][0]=0;
        dp[0][i]=0;
    }
    for(int i=1;i<=s.size();i++)
    {
        for(int j=1;j<=t.size();j++)
        {
            if(s[i-1]==t[j-1])
            {
                dp[i][j]= dp[i-1][j-1]+1;
            }
            else
            dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    string ans;
    int i=s.size(),j=t.size();
    while(i>0 && j>0)
    {
        if(s[i-1]==t[j-1])
        {
            ans+=s[i-1];
            i--;
            j--;
        }
        else if(dp[i][j]==dp[i][j-1])
        {
            j--;
        }
        else if(dp[i][j]==dp[i-1][j])
        {
            i--;
        }
    }
    reverse(ans.begin(),ans.end());
    cout << ans;
    return 0;
}


Measured memory_bytes: 35584
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#define LL long long
using namespace std;
LL n,k,ans=0;
LL get(LL c)
{
	if(c==0) return (n/k)*(n/k);
	return ((n-c)/k+1)*((n-c)/k+1);
}
int main()
{
	scanf("%lld %lld",&n,&k);
	if(k%2==1) for(LL i=k;i<=n;i+=k) ans+=get(i%k);
	else for(LL i=k/2;i<=n;i+=k/2) ans+=get(i%k);
	printf("%lld",ans);
}

Measured memory_bytes: 256
/*
  Contest 091
  B - Two Colors Card Game
  Rakesh Kumar --> 21/09/2020
 */

#include <bits/stdc++.h>

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

    std::unordered_map<std::string, int> dict;
    int n = 0;
    std::cin >> n;
    std::cin.ignore();
    while (n--) {
        std::string s;
        std::getline(std::cin, s);
        ++dict[s];
    }
    std::cin >> n;
    std::cin.ignore();
    while (n--) {
        std::string s;
        std::getline(std::cin, s);
        --dict[s];
    }

    int max = 0;
    for (auto it : dict)
        max = std::max(max, it.second);
    std::cout << max << std::endl;

    return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

int main(){
  ll n, m;
  cin >> n >> m;
  m /= 2;
  ll ans = min(n, m);
  m -= n;
  if(m > 0) ans += m / 2;
  cout << ans << endl;
}

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

int main() {
  int N;
  cin >> N;
  
  if (N<11) cout << "Yes";
  else {
    int sum = (N%10)+((N/10)%10)+((N/100)%10)
      +((N/1000)%10)+((N/10000)%10)+((N/100000)%10)
      +((N/1000000)%10)+((N/10000000)%10);    
    if(N % sum == 0) cout << "Yes";
    else cout << "No";
  }
}


Measured memory_bytes: 256
H, W, K = [int(n) for n in input().split(" ")]
M = []
for _ in range(H):
    a = [n for n in input()]
    assert(len(a) == W)
    M.append(a)

import copy
import itertools
"""
M = [[".", ".", "#"],
     ["#", "#", "#"]
]
W = len(M[0])
H = len(M)
K = 2
"""


def makeCombination(candidate, n, lessFlag):
    if len(candidate) <= 0:
        return [[]]
    _candidate = [n for n in candidate]
    _candidate = sorted(_candidate)
    result = []
    if lessFlag is False:
        tmp = list(set(list(itertools.combinations(_candidate, n))))
        for t in tmp:
            result.append(list(t))
    else:
        for i in range(n):
            result += makeCombination(candidate, i + 1, False)
        result += [[]]
    return result


def check(m, h, w):
    MM = copy.deepcopy(m)
    for a in h:
        for i in range(W):
            MM[a][i] = "R"
    for a in w:
        for i in range(H):
            MM[i][a] = "R"

    count = 0
    for i in range(len(MM)):
        for j in range(len(MM[i])):
            if MM[i][j] == "#":
                count += 1
    return count


HHH = makeCombination([n for n in range(H)], H, True)
WWW = makeCombination([n for n in range(W)], W, True)

OK = 0

for i in range(len(HHH)):
    for j in range(len(WWW)):
        if check(M, HHH[i], WWW[j]) == K:
            OK += 1
print(OK)



Measured memory_bytes: 9284
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;
const int MOD = 1000000007;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
void inline swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
void inline swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }

int n;
string s;
vvi nxt;

void init()
{
	cin >> n >> s;

	nxt.resize(n + 1, vi(26, n));

	RREP(i, n)
	{
		REP(j, 26)
			nxt[i][j] = nxt[i + 1][j];
		nxt[i][s[i] - 'a'] = i;
	}

}

void print()
{
	REP(i, SZ(nxt))
	{
		REP(j, 26)
			cout << nxt[i][j] << " ";
		cout << endl;
	}

}

int main()
{
	init();

	int ans = 0;

	REP(c, 26)
	{
		int left = nxt[0][c];
		int right = n;

		if (left < n)
			right = nxt[left + 1][c];

		while (left < n && right < n)
		{
			int len;
			if (ans)
				len = ans;
			else
				len = 1;

			if ((right + len - 1 < n) && ((left + len - 1) < right))
			{
				bool flag = true;
				REP(i, len)
				{
					if (s[left + i] != s[right + i])
					{
						flag = false;
						break;
					}
				}
				if (flag)
				{
					while ((s[left + len - 1] == s[right + len - 1]) && (right + len - 1 < n) && ((left + len - 1) < right))
					{
						chmax(ans, len);
						++len;
					}
				}
			}

			right = nxt[right + 1][c];

			if (right == n)
			{
				left = nxt[left + 1][c];

				if (left < n)
					right = nxt[left + 1][c];
				else
					right = n;
			}
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 896
import java.util.*;
public class Main{
	
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		String s=sc.next();
		String t=sc.next();

		int count=0;
		for(int i=0;i<s.length();i++){

			if(s.charAt(i)==t.charAt(i)){
				count++;
			}
		}
		System.out.println(count);
	}

}

Measured memory_bytes: 21844
#pragma GCC optimize("Ofast")

#include <queue>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <time.h>
using namespace std;
typedef long long int ll;

#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(int i=0;i<n;i++)

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

ll beki(ll a, ll b) {
	ll tmp = 1;
	REP(i, b) tmp *= a;
	return tmp;
}

int H, W;
int A, B;

int main() {
	cin >> H >> W >> A >> B;
	int a;
	REP(i, H) {
		if (i < B) {
			a = 0;
		}
		else {
			a = 1;
		}
		REP(j, W) {
			//とりあえずj < Aのとき0を出力
			//それ以外のとき 1を出力
			if (j < A) {
				cout << a;
			}
			else {
				cout << 1 - a;
			}
		}
		cout << endl;
	}
}

/*
4 3 1 2
*/

Measured memory_bytes: 1280
/*
author: Apoorv Singh
*/

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

typedef vector <long long> vi;
typedef pair <long long, long long> pii;
#define pb push_back   
#define aint(c) c.begin(), c.end()
#define watch(x) cout << (#x) << " " << (x) << endl;
#define FOR(i, a, b) for (long long i = a; i < b; ++i)
#define FORR(i, a, b) for (long long i = a; i > b; --i)
#define um unordered_map
#define F first
#define S second
#define int long long
#define inf LLONG_MAX

int modulo = 1e9 + 7;

template <class X>

void printarr(X arr[], int n)
{
    for (int i = 0; i < n; ++i)
        cout << arr[i] << " ";
    cout << endl;
}

int fpow(int a, int n)
{
    int ans = 1;
    while (n)
    {
        if (n&1)
            ans = (ans * a)%modulo;
        a = (a*a)%modulo;
        n = n >> 1;
    }
    return ans;
}

/*
const int M = 1e6 + 10;
int composite[M] = {0};

void sieve()
{
    FOR(i,2,M)
    {
        if (!composite[i])
        {
            for (int j = 2*i; j < M; j += i)
                composite[j] = max(composite[j], i);
        }
    }
}
*/

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,k; cin >> n >> k;
    string s; cin >> s;
    FOR(i,0,n)
    {
    	if (k-1 == i)
    	{
    		if (s[i] == 'A')
    			cout << 'a';
    		else if (s[i] == 'B')
    			cout << 'b';
    		else
    			cout << 'c';
    	}
    	else
    		cout << s[i];
    }
    cout << 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 pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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; }



int main(int argc, char const *argv[]) {
  string s;
  int w;
  cin >> s >> w;
  w;
  for(int i=0; i<sz(s); i++){
    if(i%w==0) cout << s[i];

  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
// C - Welcome to AtCoder
#include <bits/stdc++.h>
using namespace std;

int wa_count[100000];

int main(){
	int n,m,p,ac=0,wa=0;
	char s[3];
	scanf("%d%d",&n,&m);
	while(m--){
		scanf("%d%s",&p,s);
		if(wa_count[p] < 0) continue;// ac
		else{//not ac
			if(s[0] == 'W') wa_count[p]++;
			else{
				ac++;
				wa += wa_count[p];
				wa_count[p] = -1;// ac flag on
			}
		}
	}
	printf("%d %d\n",ac,wa);
}

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

int main(){
    int c[3][3];
    for (int i=0;i<3;i++){
        cin >> c[i][0] >> c[i][1] >> c[i][2];
    }
    bool flag = true;
    if(c[0][0]-c[0][1]!=c[1][0]-c[1][1] || c[1][0]-c[1][1] != c[2][0]-c[2][1]) flag = false;
    if(c[0][0]-c[1][0]!=c[0][1]-c[1][1] || c[0][1]-c[1][1] != c[0][2]-c[1][2]) flag = false;
    if(c[0][1]-c[0][2]!=c[1][1]-c[1][2] || c[1][1]-c[1][2] != c[2][1]-c[2][2]) flag = false;
    if(c[1][0]-c[2][0]!=c[1][1]-c[2][1] || c[1][1]-c[2][1] != c[1][2]-c[2][2]) flag = false;
    if(flag){cout << "Yes" << endl;}
    else{cout << "No" << endl;}
    return 0;
}

Measured memory_bytes: 256
S="753"
ans = 0

N = int(input())
keta = len(str(N))

def dfs(s):
  global ans
  if len(s) == keta:
    if int(s) <= N and ('7' in s and '5' in s and '3' in s):
      ans += 1
    return
  elif len(s) < keta:
    if int(s) <= N and ('7' in s and '5' in s and '3' in s):
      ans += 1
  for c in S:
    dfs(s+c)

dfs('3')
dfs('5')
dfs('7')

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
using ll = int64_t;
using P = pair<ll,ll>;
int64_t INF = 10010010010;
// int64_t INF = 1000000007;
// int64_t INF = 9223372036854775807;
// int64_t INF = 998244353;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    ll sx,sy,tx,ty;
    cin >> sx >> sy >> tx >> ty;
    string res = "";
    rep(i,tx-sx) res += "R";
    rep(i,ty-sy) res += "U";
    rep(i,tx-sx) res += "L";
    rep(i,ty-sy) res += "D";
    res += "D";
    rep(i,tx-sx+1) res += "R";
    rep(i,ty-sy+1) res += "U";
    res += "L";
    res += "U";
    rep(i,tx-sx+1) res += "L";
    rep(i,ty-sy+1) res += "D";
    res += "R";
    cout << res << endl;
}


Measured memory_bytes: 3596
INF = 10 ** 20

(h, n) = map(int, raw_input().split())

dp = [INF for i in xrange(h + 1)]
dp[0] = 0

for i in xrange(n):
    (a, b) = map(int, raw_input().split())
    for j in xrange(h + 1):
        if dp[j] >= INF:
            continue
        nxt = min(j + a, h)
        dp[nxt] = min(dp[nxt], dp[j] + b)
print dp[h]


Measured memory_bytes: 33512
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include<random>
#include<math.h>
#include<limits.h>
#include<iterator>
#include<queue>
#include<functional>
#define rep(i,a) for(int i=0;i<a;i++)
#define nrep(i,a,b) for(int i=a;i<b;i++)
#define mrep(i,a) for(int i=a;i>=0;i--)
#define ll long long
#define vl vector<ll> 
#define vvl vector<vector<ll> > 
#define vb vector<bool> 
#define vvb vector<vector<bool> > 
#define INF 11234567890123456789
using namespace std;


int main(){
	string s; cin >> s;
	rep(i, s.size() - 1){
		if (s[i] == 'A'&&s[i + 1] == 'C'){
			cout << "Yes" << std::endl;
			return 0;
		}
	}cout << "No" << endl;
	return 0;
}

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

using namespace std;

const int MAXN = 330;
const int MOD = 1000000007;

int add(int x, int y) {
   x += y;
   if (x >= MOD) x -= MOD;
   return x;
}

void sadd(int &x, int y) {
   x = add(x, y);
}

int N, M;
int dp[MAXN][MAXN][MAXN];
vector<pair<int, int>> qs[MAXN];

int main() {
   ios_base::sync_with_stdio(false);
   cin >> N >> M;
   for (int i = 0; i < M; ++i) {
      int l, r, x;
      cin >> l >> r >> x;
      qs[r].emplace_back(l, x);
   }
   dp[0][0][0] = 1;
   int ans = 0;
   for (int lr = 0; lr <= N; ++lr) {
      for (int lg = 0; lg <= N; ++lg) {
         for (int lb = 0; lb <= N; ++lb) {
            if (!dp[lr][lg][lb]) continue;
            int r = max({lr, lg, lb});
            for (auto z : qs[r]) {
               int l, x; tie(l, x) = z;
               int __x = (lr >= l) + (lg >= l) + (lb >= l);
               if (__x != x) dp[lr][lg][lb] = 0;
            }
            if (r < N) {
               sadd(dp[r + 1][lg][lb], dp[lr][lg][lb]);
               sadd(dp[lr][r + 1][lb], dp[lr][lg][lb]);
               sadd(dp[lr][lg][r + 1], dp[lr][lg][lb]);
            } else {
               sadd(ans, dp[lr][lg][lb]);
            }
         }
      }
   }
   cout << ans << "\n";
   return 0;
}


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


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n = sc.nextInt();

		int[] d = new int[n];
		Set<Integer> hs = new HashSet<>();
		for (int i = 0; i < n; i++) {
			d[i] = sc.nextInt();
			hs.add(d[i]);
		}

		pr.println(hs.size());
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 22996
# C
N, M = map(int, input().split())

G = dict()
G2 = dict()
for i in range(1, N+1):
    G[i] = []
    G2[i] = []
    
for _ in range(M):
    a, b = map(int, input().split())
    G[a].append(b)
    G[b].append(a)


pre_list = [0]*(N+1)
low_list = [0]*(N+1)
par_list = [0]*(N+1)

res = 0

que = [1]
pre_no = 0


while len(que) > 0:
    p = que.pop()
    if pre_list[p] == 0:
        pre_no += 1
        pre_list[p] = pre_no
        low_list[p] = pre_no
    
    for q in G[p]:
        if pre_list[q] == 0:
            par_list[q] = p
            que.append(q)
            G2[q].append(p)
        elif par_list[p] != q:
            G2[q].append(p)
            
que = list(range(1, N+1))
while len(que) > 0:
    p = que.pop()
    for q in G2[p]:
        if low_list[q] > low_list[p]:
            low_list[q] = low_list[p]
            que.append(q)
            
res = -2
for i in range(N+1):
    if pre_list[i] == low_list[i]:
        res += 1
        
print(res)

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

int main(){
  int N, M;
  cin >> N;
  vector <string> b_str(N);
  for (int i = 0; i < N; ++i){
    cin >> b_str.at(i);
  }
  cin >> M;
  vector <string> r_str(M);
  vector <string> merge_str_vec(N + M);
  for (int i = 0; i < M; ++i){
    cin >> r_str.at(i);
  }
  for(int i = 0; i < N; ++i){
    merge_str_vec.at(i) = b_str.at(i);
  }
  for(int i = 0; i < M; ++i){
    merge_str_vec.at(N + i) = r_str.at(i);
  }
  sort(merge_str_vec.begin(), merge_str_vec.end());
  merge_str_vec.erase(unique(merge_str_vec.begin(), merge_str_vec.end()), merge_str_vec.end());
  vector<int> point(merge_str_vec.size());

  for(int i = 0; i < merge_str_vec.size(); ++i){
    for(int j = 0; j < N; ++j){
      if (merge_str_vec.at(i) == b_str.at(j)){
	++point.at(i);
      }
    }
    for(int j = 0; j < M; ++j){
      if (merge_str_vec.at(i) == r_str.at(j)){
	--point.at(i);
      }
    }
  }
  if(*max_element(point.begin(), point.end()) > 0)
    cout << *max_element(point.begin(), point.end()) << endl;
  else
    cout << 0 << endl;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
//macros
using namespace std;
typedef long long ll;
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)

int main(){
    double N, T,A;
    cin >> N >> T >> A;
    vector<double> h(N);
    double res = 99999999;
    int index = 0;
    rep(i,0,N){
        cin >> h[i];
        double diff = fabs(A - (T - 0.006*h[i]));
        if(min(res, diff) == diff){
            res = diff;
            index = i+1;
        }
    }
    cout << index << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
typedef long long int lint;
using namespace std;

int main() {
    lint mod = 1e+9 + 7;
    int n;
    string s;
    cin >> n >> s;
    vector<lint> abc(26, 1);
    for (int i = 0; i < n; i++) {
        abc[s[i] - 'a']++;
    }
    lint ans = 1;
    for (int i = 0; i < 26; i++) {
        ans *= abc[i];
        ans %= mod;
    }
    cout << ans - 1 << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=998244353;
signed main(){
    ll n;cin>>n;
    multiset<ll>st;
    rep(i,1<<n){
        ll a;cin>>a;
        st.insert(-a);
    }
    ll s=*st.upper_bound(-inf);
    st.erase(st.find(s));
    vector<ll>a(0);
    a.pb(s);
    bool f=1;
    rep(i,n){
        vector<ll>b(0);
        rep(j,a.size()){
            auto itr=st.upper_bound(a[j]);
            if(itr==st.end())f=0;
            else{
                b.pb(*itr);
                st.erase(itr);
            }
        }
        rep(j,b.size()){
            a.pb(b[j]);
        }
        sort(all(a));
        /* cout<<i<<' ';
        rep(j,a.size())cout<<a[j]<<' ';
        cout<<endl;*/
    }
    if(f)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 15432
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;

#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 1000000007;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),* $(,)*) => {
        #[cfg(debug_assertions)]
        eprintln!(concat!($("| ", stringify!($a), "={:?} "),*, "|"), $(&$a),*);
    };
}

fn main() {
    input! {
        n: usize,
        xy: [(isize, isize); n],
    }

    let x_max = xy.iter().map(|&(xi, yi)| xi + yi).max().unwrap();
    let x_min = xy.iter().map(|&(xi, yi)| xi + yi).min().unwrap();
    let y_max = xy.iter().map(|&(xi, yi)| xi - yi).max().unwrap();
    let y_min = xy.iter().map(|&(xi, yi)| xi - yi).min().unwrap();

    println!("{}", max(x_max - x_min, y_max - y_min));
}


Measured memory_bytes: 8928
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <math.h>

using namespace std;

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }

    int numcount = 1;
    int breakcount = 0;

    for(int i = 0; i < n; i++){
        if(numcount == a[i]){
            numcount++;
        } else {
            breakcount++;
        }
    }

    cout << (breakcount != n? breakcount:-1) << endl;
}

int main() {
    solve();
    return 0;
}

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

using namespace std;

typedef long long ll;

ll MOD = 1000000007;

ll find(ll n, vector<ll> &memo)
{
	if(n == 0)
		return 1;

	if(n < 0)
		return 0;

	if(memo[n] != -1)
		return memo[n];

	ll w = 0;
	for(int i = 3; i <= n; i++)
	{
		w = (w + find(n - i, memo)) % MOD;
	}

	memo[n] = w;
	return w;
}

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

	vector<ll> memo(n + 1, -1);
	cout << find(n, memo) << endl;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n;
int main(){
	cin >> n;
	ll res= n / 500;
	ll hyy = n % 500;
	ll ans = res * 1000 + hyy / 5 *5;
	cout <<ans <<endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#solve
def solve():
    n, a, b = LI()
    ab = a + b
    print(n // ab * a + min(n % ab, a))
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 39024
r = 1
t = 0
m = 0
N = int(input())
txy = []

for i in range(N):
    txy.append([int(x) for x in input().split()])


for i in txy:
    t = i[0] - t
    m = abs((i[1] + i[2]) - m)
    
    if t < m:
        print("No")
        break
    elif (t - m) % 2 != 0:
        print("No")
        break
    
    
    
    if r == N and t >= m:
        print("Yes")
        
    r += 1
    
    
    
            

Measured memory_bytes: 21156
import numpy as np
n = int(input())
a = np.array([int(i) for i in input().split(" ")])
b = [int(i) for i in input().split(" ")]
c = np.array([int(i) for i in input().split(" ")])

ans = sum(b)
diff = np.diff(a)
mask = diff == 1
mask2 = a[mask]-1
ans += np.sum(c[mask2])
print(ans)

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

using namespace std;

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

#define reps(i,f,n) for(int i = int(f); i <= int(n); i++)
#define rep(i,n) reps(i,0,int(n)-1)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)

#define all(x) (x).begin(),(x).end()
#define X first
#define Y second

#define sz size()
#define eb emplace_back

char str[12][6] ={"",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
int mod[12] = {0,5,3,3,3,3,3,4,3,4};

int main(void){
  int n;
  cin >> n;
  rep(test,n){
    string s;
    cin >> s;
    int num = -1;
    int cnt = -1;
    rep(i,s.sz){
      if(s[i] == '0'){
        if(num != -1){
          printf("%c", str[num][cnt%mod[num]]);
          num = -1;
          cnt = -1;
        }
      }else{
        num = s[i] - '0';
        cnt++;
      }
    }
    puts("");
  }
  return 0;
}

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

int main() {
  int R, G, B, N;
  cin >> R >> G >> B >> N;
  int ans = 0;
  for (int r = 0; r <= 3000; ++r) {
    for (int g = 0; g <= 3000; ++g) {
      int rest = N - R * r - G * g;
      if (rest >= 0 && rest % B == 0) ++ans;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3584
n=int(input())
s=[input() for i in range(n)]
ans=0
c=[0,0,0]
for i in range(n):
    ans+=s[i].count('AB')
    if s[i][0]=='B'and s[i][-1]=='A':
        c[0]+=1
    elif s[i][0]=='B':
        c[1]+=1
    elif s[i][-1]=='A':
        c[2]+=1

if c[0]==0:
    ans+=min(c[1:3])
elif sum(c[1:3])==0:
    ans+=c[0]-1
elif sum(c[1:3])>0:
    ans+=c[0]+min(c[1:3])


print(ans)

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

int a[105];

int main(){
	int n, l, r, p, cnt1, cnt2, cnt3, ans;
	scanf("%d",&n);
	scanf("%d %d",&l,&r);
	cnt1 = cnt2 = cnt3 = 0;
	for (int i = 1; i <= n; i++){
		scanf("%d",&p);
		if (p <= l) cnt1++;
		else if (p > r) cnt3++;
		else cnt2++;
	}
	ans = min(cnt1, cnt2);
	ans = min(ans, cnt3);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256