akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int, int>;
/* ------------------------------------------------ */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ------------------------------------------------ */
int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    vector<int> b = a;
    sort(b.rbegin(), b.rend());
    rep(i, n) {
        if(a[i] == b[0]) {
            cout << b[1] << endl;
        }
        else cout << b[0] << endl;
    }
    return 0;
}


Measured memory_bytes: 4852
/*input
2
1 1

*/ 
#include <iostream>
#include <bits/stdc++.h>
#include <math.h> 
#include <algorithm>
#include <unordered_map>
#include <unordered_set>

using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define gc getchar_unlocked
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
#define int long long
#define si(x)   scanf("%d",&x)
#define sl(x)   scanf("%lld",&x)
#define ss(s)   scanf("%s",s)
#define pi(x)   printf("%d\n",x)
#define pl(x)   printf("%lld\n",x)
#define ps(s)   printf("%s\n",s)
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define ms(a,x) memset(a, x, sizeof(a));
#define endl "\n"
#define trav(a,x) for(auto &a:x)
#define bits(n) __builtin_popcount(n)
int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
typedef pair<int, int>  pii;
typedef vector<int>     vi;
typedef vector<pii>     vpii;
typedef vector<vi>      vvi;
int mpow(int base, int exp); 
void ipgraph(int m);
//void dfs(int u, int par);
const int mod = 1000000007;
const int N = 1000000001;
const int MAX = pow(10,5)+5;
 

//standard input and output template
template<typename... T>
void in(T&... args) {
    ((cin >> args), ...);
}

template<typename... T>
void out(T&&... args) {
    ((cout << args << " "), ...);
}

template<typename... T>
void outl(T&&... args) {
    ((cout << args << endl), ...);
}


int fast_exp(int base, int exp) {
    int res=1;
    while(exp>0) {
       if(exp%2==1) res=(res*base)%mod;
       base=(base*base)%mod;
       exp/=2;
    }
    return res%mod;
}



int32_t main() {
  IOS;

  int n;cin>>n;
  int arr[n];
  // set<int> s;
  for(int i=0;i<n;i++){
    cin>>arr[i];
  }
  int ans = 0;

  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      for(int k=j+1;k<n;k++){
        vector<int> temp;
        temp.push_back(arr[i]);
        temp.push_back(arr[j]);
        temp.push_back(arr[k]);
        sortall(temp);
        if(temp[0]+temp[1]>temp[2] && temp[0]!=temp[1] && temp[2]!=temp[1] && temp[0]!=temp[2]){
          ans++;
          //cout<<i<<" "j<<
        }
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3644
#include <iostream>

using namespace std;
int a,b,c,d;
char s[10];
int main()
{
    cin>>s;
    a=s[0]-'0';
    b=s[1]-'0';
    c=s[2]-'0';
    d=s[3]-'0';
    if(a+b+c+d==7){
        printf("%d+%d+%d+%d=7",a,b,c,d);
        return 0;
    }
    if(a+b+c-d==7){
        printf("%d+%d+%d-%d=7",a,b,c,d);
        return 0;
    }
     if(a+b-c+d==7){
        printf("%d+%d-%d+%d=7",a,b,c,d);;
        return 0;
    }
     if(a+b-c-d==7){
        printf("%d+%d-%d-%d=7",a,b,c,d);
        return 0;
    }
     if(a-b+c+d==7){
        printf("%d-%d+%d+%d=7",a,b,c,d);
        return 0;
    }
     if(a-b+c-d==7){
        printf("%d-%d+%d-%d=7",a,b,c,d);
        return 0;
    }
     if(a-b-c+d==7){
        printf("%d-%d-%d+%d=7",a,b,c,d);
        return 0;
    }
     if(a-b-c-d==7){
        printf("%d-%d-%d-%d=7",a,b,c,d);
        return 0;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define READ() freopen("in.txt","r",stdin)
#define WRITE() freopen("out.txt","w",stdout)
#define  pb(x)  push_back(x)
#define mem(arr,val) memset(arr,val,sizeof(arr));
typedef long long ll;
const int mx=30005;
vector<int>G[mx],cost[mx];
struct data{
    bool ev;
    int val;
};

bool cmp(data a,data b)
{
    if(a.val<b.val)
    {
        return true;
    }
    if(a.val==b.val)
    {
        return a.ev;

    }
    return false;
}
int vis[100][26];

int main()
{
//    READ();
    char arr[55][55];
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            cin>>arr[i][j];
        }
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            if(arr[i][j]=='#')
            {
                if(arr[i+1][j]=='#' || arr[i-1][j]=='#' || arr[i][j+1]=='#' || arr[i][j-1]=='#' )
                {
                    continue;

                }
                else
                {
                    cout<<"No"<<endl;
                    return 0;
                }
            }
        }
    }
    cout<<"Yes"<<endl;






    return 0;
}


Measured memory_bytes: 1664
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

typedef long long ll;

ll rec(ll L, ll X){
  
  if( L == 0){ return 1;}
  
  else{
  ll hight = (1LL << (L + 1)) - 3;
  ll number = ( 1LL << (L) ) - 1;
  
  
  if( X == 1){ return 0;}
  else if( X <= hight + 1){
    return rec( L - 1, X - 1);}
  else if( X == hight + 2){
    return number + 1 ;}
  else if( X <= 2* hight + 2 ){
    return number + rec( L - 1, X - hight - 2) + 1;}
  else if( X == 2 * hight + 3){
    return 2*number + 1;} }
}
      
    


int main(){
ll N,X; cin >> N >> X;
  
  cout << rec(N,X) << endl; return 0;}
    
  


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

using namespace std;

using ll = long long;

int main(){
  ll N;
  cin >> N;
  vector<ll> b;
  while(abs(N) > 0){
    b.push_back(N % 2 != 0);
    if(N % 2 != 0)
      N--;
    N /= -2;
  }
  for(int i=(int)b.size()-1;i>=0;i--){
    cout << b[i];
  }
  if(b.empty())
    cout << 0;
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
room=[[[0]*10 for _ in range(3)] for _ in range(4)]

for _ in range(N):
    b, f, r, v = map(int,input().split())
    room[b-1][f-1][r-1] += v

for i in range(4):
    for j in range(3):
        for k in range(10):
            print(" {}".format(room[i][j][k]), end="")
        print()
    if i!=3:
        print("####################")



Measured memory_bytes: 5624
main :: IO ()
main = do
    [n, a] <- (map read . words) <$> getLine
    ts <- (map read . words) <$> getLine
    print $ solve (n, a) ts

-- |
--
-- >>> solve (2, 4) [0, 3]
-- 7
--
-- >>> solve (2, 4) [0, 5]
-- 8
--
-- >>> solve (9, 10) [0,3,5,7,100,110,200,300,311]
-- 67
--
-- >>> solve (4, 1000000000) [0,1000,1000000,1000000000]
-- 2000000000
solve :: (Int, Int) -> [Int] -> Int
solve (n, a) ts = n * a - snd (foldl f (-a, 0) ts)
  where f (x, acc) y = (y, acc + max 0 (x + a - y))


Measured memory_bytes: 157052
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {

            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);
            int c = int.Parse(input[2]);

            
            if (b-a==c-b)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }

        }
    }
}

Measured memory_bytes: 13140
#include <iostream>
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define REP(i,n) FOR(i,0,n)
using namespace std;

int main(){
    int m,min,max,gap,gapmax,n;
    while(cin >> m >> min >> max && m != 0){
        int p[m];
        REP(i,m){
            cin >> p[i];
        }
        gapmax = 0;
        FOR(i,min,max+1){
            gap = p[i-1] - p[i];
            if(gap >= gapmax){
                gapmax = gap;
                n = i;
            }
        }
        cout << n << endl;
    }


}

Measured memory_bytes: 1160
import java.util.Scanner;
import java.util.Arrays;
public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
       Scanner scn = new Scanner(System.in);
		String str=scn.nextLine();
		String ori=scn.nextLine();
		int count=0;
		for(int i=0;i<str.length();i++)
		{
			if(str.charAt(i)==ori.charAt(i))
				count++;
		}
		System.out.println(count);
	}

}

Measured memory_bytes: 21844
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <limits.h>
#include <queue>
#include <stack>
#include <set>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iomanip>

#define INF (int)1e9
#define endl "\n"
#define ll long long
#define ull unsigned long long

using namespace std;

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

    vector<string> arr(n);

    for (int i = 0; i < n; i++)
    {
        cin >> arr[i];
    }
    vector<vector<int>> dp(n, vector<int>(m, INF));

    dp[n - 1][m - 1] = arr[n - 1][m - 1] == '#';

    for (int i = n - 1; i >= 0; i--)
    {
        for (int j = m - 1; j >= 0; j--)
        {
            if (i < n - 1)
            {
                dp[i][j] = min(dp[i][j], (arr[i][j] != arr[i + 1][j]) + dp[i + 1][j]);
            }
            if (j < m - 1)
            {
                dp[i][j] = min(dp[i][j], (arr[i][j] != arr[i][j + 1]) + dp[i][j + 1]);
            }
        }
    }

    if (arr[0][0] == '#')
        dp[0][0]++;

    cout << dp[0][0] / 2 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstring>

int main()
{
	std::string r, a;
	while( std::cin >> r >> a, r != "0" || a != "0" )
	{
		bool fr[10], fa[10];
		int hit = 0, blow = 0;
		memset( fr, false, sizeof( fr ) );
		memset( fa, false, sizeof( fa ) );

		for( int i = 0; i != r.size(); ++i )
		{
			if( r[i] == a[i] )
				++hit;
			else
			{
				fr[r[i]-'0'] = true;
				fa[a[i]-'0'] = true;
			}
		}

		for( int i = 0; i != 10; ++i )
			if( fr[i] & fa[i] )
				++blow;

		std::cout << hit << ' ' << blow << std::endl;
	}

	return 0;
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
using namespace std;
#define R(i,n) for(int i=0;i<n;i++)
main(){int n,a=1e9,c[2][20];cin>>n;R(i,n)cin>>c[0][i];R(i,n)cin>>c[1][i];vector<vector<int>>p(1<<n,vector<int>(51,1e9));p[0][0]=0;R(B,1<<n){int o=0,d[n];R(i,n)if(!(B&1<<i))d[i]=o++;R(i,n){int k=c[abs(i-n+o)%2][i];R(j,k+1)p[B|1<<i][k]=min(p[B|1<<i][k],p[B][j]+d[i]);}}R(i,51)a=min(a,p[(1<<n)-1][i]);cout<<(a>1e8?-1:a);}

Measured memory_bytes: 63744
n = int(input())
a = list(map(int,input().split()))

ans = [0] * n
for i in range(n, 0, -1):
    k = 0
    j = 2
    l = j * i
    while l <= n:
        if ans[l-1] == 1:
            k += 1
        j += 1
        l = j * i
    if k % 2 != a[i-1]:
        ans[i-1] = 1

m = sum(ans)
s = ""
for i in range(n):
    if ans[i] == 1 and s == "":
        s += str(i+1)
    elif ans[i] == 1:
        s += " "+str(i+1)

if m == 0:
    print(m)
else:
    print(m)
    print(s)
    




Measured memory_bytes: 9144
#include<stdio.h>
void alg();
int n,data[100][100];
int main(){
    int i,j,x,z;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            scanf("%d",&x);
            if(x==-1)data[i][j]=100000;
            else data[i][j]=x;
        }
    }
    alg();
    return 0;
}
void alg(){
    int i,flag[100],y[100],x[100],min,k,j,sum=0;
    for(i=0;i<n;i++){
       flag[i]=0;
       x[i]=100000;
       y[i]=-1;
    }
    x[0]=0;
    while(1){
        min=100000;
        k=-1;
        for(i=0;i<n;i++){
            if(min>x[i] && flag[i]!=2){
                min=x[i];
                k=i;
            }
        }
        if(k==-1)break;
        flag[k]=2;
        for(i=0;i<n;i++){
            if(data[k][i]!=100000 && flag[i]!=2){
                if(data[k][i]<x[i]){
                    flag[i]=1;
                    x[i]=data[k][i];
                    y[i]=k;
                }
            }
        }
    }   
    for(i=0;i<n;i++){
        if(y[i]!=-1)sum=sum+data[i][y[i]];
    }
    printf("%d\n",sum);

}


Measured memory_bytes: 1996
#include <iostream>
using namespace std;
int main()
{
	int a = 0;
	int kazu = 0;
	int b = 0;
	int c = 0;
	cin >> kazu;
	for (int i = 0; i < kazu; i++)
	{
		cin >> a;
		cin >> b;
		cin >> c;
		if (a * a + b * b == c * c)
		{
			cout << "YES" << endl;
		}
		else if (a * a + c * c == b * b)
		{
			cout << "YES" << endl;
		}
		else if (c * c + b * b == a * a)
		{
			cout << "YES" << endl;
		}
		else
		{
			cout << "NO" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1156
#![allow(non_snake_case)]
use proconio::input;
// use std::collections::HashMap;

fn main() {
    input! {
        N: i64,
        D: i64,
    }

    // let mut Xs = Vec::new();
    // let mut Ys = Vec::new();
    // Xs.resize(0, N);
    // Ys.resize(0, N);

    let mut ans: i64 = 0;

    for _ in 0..N {
        input! {
            X: i64,
            Y: i64,
        }
        // Xs[n as usize] = X;
        // Ys[n as usize] = Y;

        if X * X + Y * Y <= D * D {
            ans += 1;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 4880
#include <iostream>
#include <cmath>
#include <vector>
#include <map>

using namespace std;

int main(int argc, char* argv[]) {
  long long N;
  cin >> N;

  long long tmp = N;
  vector<long long> a;
  for (long long i = 2; i * i <= tmp; ++i) {
    if (tmp % i == 0) {
      a.push_back(i);
      tmp /= i;
      while (tmp % i == 0) {
        a.push_back(i);
        tmp /= i;
      }
    }
  }
  if (tmp > 1) {
    a.push_back(tmp);
  }

  long long ret = 10000000000000LL;
  long long l = pow(2, a.size());
  for (long long i = 0; i < l; ++i) {
    long long cur = 1;
    for (long long j = 0; j < a.size(); ++j) {
      if (((i >> j) & 1) == 1)
        cur *= a[j];
    }
    ret = min(ret, (long long)log10(max(N / cur, cur)) + 1);
  }

  cout << ret << endl;

  return 0;
}

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

int main() {
  ll n;
  cin >> n;
  string s;
  
  while (n > 0) {
    n--;
    int m = n % 26;
    //if (m == 0)
    //  s.push_back('z');
    //else
    s.push_back('a' + m);
    n /= 26;
  }
  string s2(s.rbegin(), s.rend());
  cout << s2 << endl;
  return 0;
}


Measured memory_bytes: 3628
#include<stdio.h>

int main(){
	int A, B, C, D;
	scanf("%d %d %d %d", &A, &B, &C, &D);
	while(1){
		C = C - B;
		if(C <= 0){
			printf("Yes\n");
			break;
		}
		A = A - D;
		if(A <= 0){
			printf("No\n");
			break;
		}
	}
	return 0;
}

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

class Tramp{
 public:
  char suit;
  int num;

  bool operator ==(const Tramp T){
    if(this->suit == T.suit && this->num == T.num)return true;
    else return false;
  }
  bool operator !=(Tramp T){
    return !(*this == T);
  }
};

void printAll(Tramp a[],int N){
  rep(i,N-1) cout << a[i].suit << a[i].num << " ";
  cout << a[N-1].suit << a[N-1].num << endl;
}

void bubbleSort(Tramp A[],int N){
  bool flag = true;
  while(flag){
    flag = false;
    for(int i=N-1;i>0;i--){
      if(A[i].num < A[i-1].num){
        swap(A[i],A[i-1]);
        flag = true;
      }
    }
  }
}

void selectionSort(Tramp A[],int N){
  for(int i=0;i<N;i++){
    int min_j = i;

    for(int j=i;j<N;j++){
      if(A[j].num < A[min_j].num)swap(min_j,j);
    }

    if(i != min_j)swap(A[i],A[min_j]);
  }
}

bool isStable(Tramp A[],Tramp c[],int N){
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      for(int a=0;a<N;a++){
        for(int b=a+1;b<N;b++){
          if(A[i].num == A[j].num && A[i] == c[b] && A[j] == c[a]){
            return false;
            }
        }
      }
    }
  }
  return true;
}

int main(){
  int N;
  cin >> N;
  string c[N];
  rep(i,N)cin >> c[i];

  Tramp cards[N],bubbleT[N],selectT[N];
  rep(i,N){
    cards[i].suit = c[i].at(0);
    cards[i].num = c[i].at(1) - '0';
    selectT[i] = cards[i];
    bubbleT[i] = cards[i];
  }

  bubbleSort(bubbleT,N);
  printAll(bubbleT,N);
  //if(isStable(bubbleT,c))cout << "Stable" << endl;
  //else cout << "Not Stable" << endl;
  cout << "Stable" << endl;

  selectionSort(selectT,N);
  printAll(selectT,N);
  if(isStable(selectT,bubbleT,N))cout << "Stable" << endl;
  else cout << "Not stable" << endl;
  
}


Measured memory_bytes: 3168
import java.util.Scanner;

class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int d = sc.nextInt();
		int t = sc.nextInt();
		int s = sc.nextInt();

		if(s * t >= d)
			System.out.println("Yes");
		else
			System.out.println("No");
	}

}


Measured memory_bytes: 35736
#include <bits/stdc++.h>
using namespace std;
int main() {
  int64_t N;
  cin >> N;
  vector<int64_t> vec(N+1);
  vec.at(0)=2;
  vec.at(1)=1;
  for(int i=0;i<N-1;i++){
    vec.at(i+2)=vec.at(i+1)+vec.at(i);
  }
  cout << vec.at(N);
}


Measured memory_bytes: 384
/*
  Contest 082
  A - Round Up the Mean
  Rakesh Kumar --> 15/09/2020
 */

#include <bits/stdc++.h>

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

    int a = 0, b = 0;
    std::cin >> a >> b;
    std::cout << std::round((a + b) / static_cast<double>(2)) << std::endl;

    return 0;
}


Measured memory_bytes: 3828
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>

using namespace std;

long long int combination(long long int n, long long int r){
    if (n == r || r == 0)  return 1;
    else  return combination(n, r - 1) * (n - r + 1) / r;
}

int main(void){
    
   int n;
   cin>>n;
    vector<double> v(n);
    double sum = 0.0;
    for(int i=0;i<n;i++){
        double a;
        cin>>a;
        v[i] = a;
        sum += a;
    }
    sort(v.begin(), v.end());
    // for(int i=0;i<n;i++){
    //     cout<<v[i]<<endl;
    // }

    for(int i=0;i<n-1;i++){
        v[i+1] = (v[i] + v[i+1]) / 2.0;
        //cout<<v[i+1]<<endl;
    }

    cout<<setprecision(10)<<v[n-1]<<endl;


    return 0;

}

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

//Function Macros:
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

//Type Definitions:
typedef long long ll;
typedef unsigned long long ull;

//Constants:
const int INF = 2e9;
const int MOD = 1e9 + 7;

//Global Variables:

//Prototype Declarations:
int gcd(int, int);

//================ Main Loop ================
int main()
{
    int A, B;
    cin >> A >> B;

    int tap = 1;
    int ans = 0;
    while(tap<B){
        ans++;
        tap += A-1;
    }
    cout << ans << endl;
    return 0;
}
//===========================================

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

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt(), b = sc.nextInt();
        StringBuilder a_str = new StringBuilder();
        StringBuilder b_str = new StringBuilder();
        for(int i = 0; i < a; i++) {
            a_str.append(b);
        }
        for(int i = 0; i < b; i++) {
            b_str.append(a);
        }
        System.out.println(a_str.toString().compareTo(b_str.toString()) < 0? a_str.toString():b_str.toString());
    }
}

Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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


int main() {
    int N, X, T;
    while (cin >> N >> X >> T) {
        cout << (N + X-1) / X * T << endl;
    }
}

















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

template<typename T>
void fin (T a){
    cout<<a<<endl;
    exit(0);
}
template<typename S>
void print(S a){
    cout<<a<<endl;
}


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

    int k;
    cin>>k;
    queue<ll> a;
    for(int i=1;i<10;i++){
        a.push(i);
    }
    ll tmp;
    int cnt=0;
    while(cnt<k){
        tmp = a.front();
        a.pop();
        int t = tmp%10;
        switch(t){
            case 0:
                a.push(tmp*10+t);
                a.push(tmp*10+t+1);
                break;
            case 9:
                a.push(tmp*10+t-1);
                a.push(tmp*10+t);
                break;
            default:
                a.push(tmp*10+t-1);
                a.push(tmp*10+t);
                a.push(tmp*10+t+1);
                break;
        }
        cnt++;
    }
    fin(tmp);

}


Measured memory_bytes: 5160
import bisect
n=int(input())
l=list(map(int, input().split()))
l.sort()
ans=0
for i in range(n-2):
  for j in range(i+1,n-1):
    ans+=bisect.bisect_left(l[j+1:], l[i]+l[j]) #n未満の個数を数える
print(ans)
    
  

Measured memory_bytes: 74984
N,M=map(int,input().split())
wh=[None for _ in range(N)]
flag=0
ans=0
for i in range(M):
    s,c=map(int,input().split())
    if wh[s-1] == None:
        wh[s-1]=c
    elif wh[s-1] == c :
        continue
    else :
        flag=1
        break
if N == 1:
    if wh[0]==None:
        wh[0]=0
else:
    if wh[0]==None:
        wh[0]=1
    elif wh[0]==0:
        flag=1
    if wh[1]==None:
        wh[1]=0
    if N ==3 and wh[2]==None:
        wh[2]=0
if flag==1:
    print(-1)
else:
    for i in range(N):
        ans+=int(wh[i])*(10**(N-i-1))
    print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <string>
using namespace std;

int main()
{
	long a;
	cin >> a;
	int x_500 = a / 500;
	a -= x_500 * 500;
	int x_5 = a / 5;
	cout << x_500 * 1000 + x_5 * 5 << endl;



}

Measured memory_bytes: 256
N, A, B = map(int, input().split())
S = list(input())

acnt = 0
bcnt = 0
for s in S:
  if s == "a":
    if (acnt + bcnt) < (A + B):
      print("Yes")
      acnt += 1
    else:
      print("No")    
  elif s== "b":
    if (acnt + bcnt) < (A + B) and bcnt < B:
      print("Yes")
      bcnt += 1
    else:
      print("No")
  else:
    print("No")
    

Measured memory_bytes: 4712
#include <bits/stdc++.h>
#define HAIRETU(N,A) for(int i=0;i<N;i++) cin >>A[i]
using namespace std;

int main(){
    int N, A, B, sum = 0;
    int a, b, c, d, e;

    cin >> N >> A >> B;
    for (int i = 0; i <= N; i++) {
        a = i / 10000;
        b = (i - a * 10000) / 1000;
        c = (i - a * 10000 - b * 1000) / 100;
        d = (i - a * 10000 - b * 1000 - c * 100) / 10;
        e = (i - a * 10000 - b * 1000 - c * 100 - d * 10) / 1;
        
        if (A <= a + b + c + d + e && a + b + c + d + e <= B) {
            sum += a*10000 + b*1000 + c*100 + d*10 + e;

        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int n, k, x, a;

    scanf("%d%d", &n, &k);

    a = k;
    x = 1;

    while (n>=a) {
        x++;
        a *= k;
    }

    printf("%d\n", x);

    return 0;
}

Measured memory_bytes: 128
use proconio::*;

fn main() {
    input! {
        n: usize,
        a: [i64; n]
    }

    for &i in &a {
        if i == 0 {
            println!("0");
            return;
        }
    }

    let mut ans: i64 = 1;
    for &i in &a {
        if 1000000000000000000 / i < ans {
            println!("-1");
            return;
        }
        ans *= i;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4404
#include <iostream>
using namespace std;
int main(void){
    int a, b;
    cin >> a >> b;
    if (a < b) {
        cout << "a" << " < " << "b" << endl;
    } else if (a > b) {
        cout << "a" << " > " << "b" << endl;
    } else {
        cout << "a" << " == " << "b" << endl;
    }
    return 0;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  int a, b;
  cin >> a >> b;

  bool ans = false;
  for (int i = 1; i <= 3; i++){
    if (a * b * i % 2 == 1) ans = true;
  }

  if (ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
const double PI = acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;

int main() {
  Graph board(3, vector<int>(3)),last(3, vector<int>(3));
  rep(i,3) {
    rep(j,3) cin >> board[i][j];
  }

  last = {
    {1,2,3},
    {4,5,6},
    {7,8,0}
  };

  map<Graph, int> m;
  m[board] = 0;
  queue <Graph> que;
  que.push(board);

  const vector<int> dy = {-1,0,0,1};
  const vector<int> dx = {0,-1,1,0};

  while(!que.empty()) {
    Graph v = que.front();
    int count = m[v];
    que.pop();
    int y,x;
    rep(i,3) {
      rep(j,3) {
        if (v[i][j] == 0) {
          y = i;
          x = j;
        }
      }
    }

    rep(i,4) {
      int yy = y + dy[i];
      int xx = x + dx[i];
      if (yy < 0 || yy >= 3 || xx < 0 || xx >= 3) continue;
      swap(v[y][x],v[yy][xx]);
      if (!m.count(v)) {
        que.push(v);
        m[v] = count + 1;
        if (m.count(last)) goto OUT;
      }
      swap(v[y][x],v[yy][xx]);
    }
  }

  OUT:

  cout << m[last] << endl;
}


Measured memory_bytes: 49264
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) { 
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

inline ll f(ll A, ll B, ll X)  {
  return (A*X/B) - A*(X/B);
}

int main() {
  ll A, B, N; cin>>A>>B>>N;
  ll ans = f(A, B, N);
  if(B-1LL <= N) {
    ll work = f(A, B, B-1);
    ans = max(ans, work);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3168
# coding: utf-8
# Your code here!

N = input()
p = list("abcdefghijklmnopqrstuvwxyz")

if len(N) != 26:
    for i in N:
        p.pop(p.index(i))
    if p == []:
        print(-1)
        exit()
    print(N+p[0])
else:
    tmp = 0
    a = list("zyxwvutsrqponmlkjihgfedcba")
    if a == list(N):
        print("-1")
        exit()
    for i in range(24,-1,-1):
        for c in p:
            if c not in N[:i] and c > N[i]:
                print(N[:i]+c)
                exit()

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

int main(){
    int N; cin>>N;
    vector<int> A(N, 0);
    for(int i=0; i<N; i++) cin>>A.at(i);
    string ans = "APPROVED";
    for(auto x:A){
        if(x%2==0){
            if(x%3==0 || x%5==0) continue;
            else ans = "DENIED";
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
const double pi = 3.141592653589793238462643383279;
using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
 
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
 
//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
 
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

const long double EPS = 1e-6, PI = acos((long double)-1);

//ここから編集
template<typename T = int> struct SegmentTree{

  vector<T> node;
  int N;

  SegmentTree(int n){
    N = 1;
    while(N < n) N*=2;
    node.resize(2*N-1, INT_MAX);
  }

  void update(int x, int val){
    x += N-1;
    
    node[x] = val;
    while(x > 0){
      x = (x-1)/2;
      node[x] = min(node[2*x+1], node[2*x+2]);
    }
  }

  // [a, b)について求める
  T getmin(int a, int b, int k=0, int l=0, int r=-1){

    if(r < 0) r = N;
    if(r <= a || b <= l) return INT_MAX;
    if(a <= l && r <= b) return node[k];
    
    T vl = getmin(a, b, 2*k+1, l, (l+r)/2);
    T vr = getmin(a, b, 2*k+2, (l+r)/2, r);
    return min(vl, vr);
  }


};
vector<int> g(201010);
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(4);

  int N; cin >> N;
  vector<pair<ll,ll>> vp;
  vector<ll> vx, vy;
  vector<int> x(N), y(N);
  REP(i,N){
    cin >> x[i] >> y[i];
    vp.push_back({x[i], y[i]});
    vx.push_back(x[i]+y[i]);
    vy.push_back(x[i]-y[i]);
  }
  sort(all(vx));
  sort(all(vy));

  cout << max(abs(vx[N-1]-vx[0]), abs(vy[N-1]-vy[0])) << endl;

}

Measured memory_bytes: 13872
N = int(input())
A = tuple(map(int, input().split()))

from itertools import accumulate
CA = list(accumulate(A))

mindiff = CA[-1]
left = 0
right = 2
for c in range(1,N-1):
    # left side
    p = CA[left]
    q = CA[c] - CA[left]
    while True:
        pi = CA[left+1]
        qi = CA[c] - CA[left+1]
        if abs(pi- qi) >= abs(p - q):
            break
        p = pi; q = qi
        left += 1

    # right side
    r = CA[right] - CA[c]
    s = CA[-1] - CA[right]
    while True:
        ri = CA[right+1] - CA[c]
        si = CA[-1] - CA[right+1]
        if abs(ri- si) >= abs(r - s):
            break
        r = ri; s = si
        right += 1

    mindiff = min(mindiff, max(p, q, r, s) - min(p, q, r, s))
print(mindiff)

Measured memory_bytes: 24940
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iterator>
#include<sstream>
#include<iomanip>
#include<map>
#include<queue>
#include<deque>

#define rep(i, n) for (ll i = 0; i < n; i++) 
#define rrep(i, n) for(ll i = n-1; i>=0; i--)
#define range(i, n, m) for (ll i = n; i < m; i++) 
#define rrange(i, n, m) for (ll i = n - 1; i => m; i--) 
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vp vector<pair<ll, ll> >
#define vvp vector<vector<pair<ll, ll> > >
//#define MOD 998244353

typedef long long int ll;
typedef unsigned long long int ull;

using namespace std;

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

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

	ll N, A, B, C, D;
	cin >> N >> A >> B >> C >> D;

	string S;
	cin >> S;


	if (C < D) {
		range(i, A - 1, C - 1) {
			if (S[i] == '#' && S[i + 1] == '#') {
				cout << "No" << endl;
				return 0;
			}
		}
		range(i, B - 1, D - 1) {
			if (S[i] == '#' && S[i + 1] == '#') {
				cout << "No" << endl;
				return 0;
			}
		}
		cout << "Yes" << endl;
	}
	else {
		range(i, A - 1, C - 1) {
			if (S[i] == '#' && S[i + 1] == '#') {
				cout << "No" << endl;
				return 0;
			}
		}
		if(A)

		range(i, B - 2, D - 1) {
			if (S[i] == '.' && S[i + 1] == '.' && S[i + 2] == '.') {
				cout << "Yes" << endl;
				return 0;
			}
		}
		cout << "No" << endl;
	}





	return 0;
}



Measured memory_bytes: 640
//  ____            _                  _                       _       _
// |  _ \ _   _ ___| |_    ___ _ __   | |_ ___ _ __ ___  _ __ | | __ _| |_ ___
// | |_) | | | / __| __|  / __| '_ \  | __/ _ \ '_ ` _ \| '_ \| |/ _` | __/ _ \
// |  _ <| |_| \__ \ |_  | (__| |_) | | ||  __/ | | | | | |_) | | (_| | ||  __/
// |_| \_\\__,_|___/\__|  \___| .__/___\__\___|_| |_| |_| .__/|_|\__,_|\__\___|
//                            |_| |_____|               |_|

//https://github.com/manta1130/Competitive_Programming_Template_Rust

#[macro_use]
mod input {

    use std;
    use std::io;

    const SPLIT_DELIMITER: char = ' ';

    #[macro_export]
    #[allow(unused_macros)]
    macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

    #[allow(dead_code)]
    pub fn input_line_str() -> String {
        let mut s = String::new();
        io::stdin().read_line(&mut s).unwrap();
        s.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn p<T>(t: T)
    where
        T: std::fmt::Display,
    {
        println!("{}", t);
    }

    #[allow(dead_code)]
    pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<Vec<T>> = Vec::new();

        for _ in 0..line {
            let vec_line = input_vector();
            v.push(vec_line);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector<T>() -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<T> = Vec::new();

        let s = input_line_str();
        let split_result = s.split(SPLIT_DELIMITER);
        for z in split_result {
            let buf = match z.parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector_row<T>(n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v = Vec::with_capacity(n);
        for _ in 0..n {
            let buf = match input_line_str().parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    pub trait ToCharVec {
        fn to_charvec(&self) -> Vec<char>;
    }

    impl ToCharVec for String {
        fn to_charvec(&self) -> Vec<char> {
            self.to_string().chars().collect::<Vec<_>>()
        }
    }
}

use input::*;

fn main() {
    let (h, w, n): (usize, usize, usize);
    input!(h);
    input!(w);
    input!(n);
    let bg = std::cmp::max(h, w);
    if n % bg == 0 {
        println!("{}", n / bg);
    } else {
        println!("{}", n / bg + 1);
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define EPS 1e-9
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

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


signed main(void) {
    string s;
    cin >> s;
    int n = s.size();
    s += "R";
    vi a;
    a.push_back(0);
    rep(i,n)if(s[i] == 'L' && s[i+1] == 'R'){
        a.push_back(i+1);
    }
    //[a[i],a[i+1])
    vi ans(n,0);
    rep(i,a.size()-1){
        //cout << " " << a[i];cout << endl;
        //cout << "!" << a[i] << " " << a[i+1] << endl;
        int j = a[i];
        while(s[j] == 'R')j++;
        //Rは j-a[i] 個, Lは a[i+1]-j 個
        int r = j - a[i];
        int l = a[i+1] - j;
        int cnt1 = r/2 + (l - l/2);//偶数回後にLに到達
        int cnt2 = l/2 + (r - r/2);//偶数回後にRに到達
        //cout << l << " " << r << " " << cnt1 << " " << cnt2 << endl;
        ans[j-1] = cnt2;//R
        ans[j] = cnt1;//L
    }
    rep(i,n)cout << ans[i] << " \n"[i == n-1];
}


Measured memory_bytes: 1912
#!/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 = 1e10

#solve
def solve():
    n = II()
    a = LI()
    ans = 1
    t = -1
    for i in range(n - 1):
        if a[i] < a[i + 1]:
            if t == 1:
                continue
            elif t == -1:
                t = 1
            else:
                t = -1
                ans += 1
        elif a[i + 1] < a[i]:
            if t == 0:
                continue
            elif t == -1:
                t = 0
            else:
                t = -1
                ans += 1
    print(ans)
    return


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


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

using namespace std;

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

  string s;
  cin >> s;
  string t;
  for (size_t i = 0; i < s.size(); ++i) {
    if (i % 2 == 0) {
      t.push_back(s[i]);
    }
  }
  cout << t << "\n";
}


Measured memory_bytes: 592
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <map>
#include <set>
#include <list>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <limits>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;

struct edge {
    i64 from, to, cost;
    edge(i64 from, i64 to) : from(from), to(to), cost(1) {}
    edge(i64 from, i64 to, i64 cost) : from(from), to(to), cost(cost) {}
};
using Graph = vector<vector<edge>>;

constexpr i64 INF = std::numeric_limits<i64>::max();
constexpr i64 SINF = std::numeric_limits<i64>::max() / 10;
const i64 dx[4] = { 0,1,0,-1 }, dy[4] = { -1,0,1,0 };
//const i64 dx[5] = {-1,0,0,0,1}, dy[5] = {0,-1,0,1,0};
//const i64 dx[8] = {-1,0,1,1,1,0,-1,-1}, dy[8] = {1,1,1,0,-1,-1,-1,0};
//const i64 dx[9] = {-1,0,1,1,1,0,-1,-1,0}, dy[9] = {1,1,1,0,-1,-1,-1,0,0};

// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
    for (auto& e : t) fill_v(e, v);
}

struct IoSetup {
    IoSetup() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

int main() {
    i64 a;
    string s;
    cin >> a >> s;
    if(a >=3200) cout << s;
    else cout << "red" << endl;
}


Measured memory_bytes: 256
"""
author : halo2halo
date : 4, Feb, 2020
"""

import sys

import itertools

# import math
# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, K, *P = map(int, read().split())
R = list(itertools.accumulate(P))
ans = 0
for i in range(K - 1, N):
    if i - K >= 0:
        s = ((R[i] - R[i - K]) + K) / 2
    else:
        s = (R[i] + K) / 2
    ans = max(s, ans)
print('{:.6f}'.format(ans))


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

int main() {

    int n; cin >> n;
    int t; cin >> t;
    int a; cin >> a;

    vector<double> h(n);

    for (int i = 0; i < n; i++) {
        cin >> h.at(i);

        h.at(i) = abs( (t - h.at(i) * 0.006) - a );
    }

    double min = 1000;
    int ans;

    for (int i = 0; i < n; i++) {
        
        if (h.at(i) < min) {
            min = h.at(i);
            ans = i + 1;
        }
    }

    cout << ans;

    return 0;

}

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

struct Edge {
  int u, v, c;
  Edge() {}
  Edge(int u, int v, int c) :
    u(u), v(v), c(c) {}
  bool operator < (const Edge& e) const {
    return c < e.c;    
  }
};

struct UnionFind {
  int n;
  vector<int> r, p;
  UnionFind() {}
  UnionFind(int sz) : n(sz), r(sz, 1), p(sz, 0) {
    iota(p.begin(), p.end(), 0);    
  }
  int find(int x) {
    return (x==p[x] ? x : p[x]=find(p[x]));    
  }
  bool same(int x, int y) {
    return find(x) == find(y);    
  }
  void unite(int x, int y) {
    x = find(x); y = find(y);
    if ( x == y ) return;
    if ( r[x] < r[y] ) swap(x, y);
    r[x] += r[y];
    p[y] = x;    
  }
};

int main() {
  int N, M;
  cin >> N >> M;
  
  vector<Edge> es(M);  
  for ( int i = 0; i < M; i++ ) {
    int u, v, c;
    cin >> u >> v >> c;
    u--; v--;
    es[i] = Edge{u, v, c};    
  }

  sort(es.begin(), es.end());  

  vector<int> use;
  int cost = 0;
  {
    UnionFind uf(N);
    int cnt = 0;
    for ( int i = 0; i < M; i++ ) {
      int u = es[i].u, v = es[i].v, c = es[i].c;
      if ( uf.same(u, v) ) continue;
      cost += c;
      uf.unite(u, v);
      use.emplace_back(i);
      cnt++;
      if ( cnt == N-1 ) continue;    
    }
  }

  int ans = 0, anscost = 0;  
  for ( int i = 0; i < N-1; i++ ) {
    UnionFind uf(N);
    int ncost = 0;
    int ncnt = 0;    
    for ( int j = 0; j < M; j++ ) {
      if ( use[i] == j ) continue;
      int u = es[j].u, v = es[j].v, c = es[j].c;
      if ( uf.same(u, v) ) continue;
      ncost += c;
      uf.unite(u, v);
      ncnt++;
      if ( ncnt == N-1 ) continue;      
    }

    if ( ncost > cost || ncnt < N-1 ) {
      ans++;
      anscost += es[use[i]].c;      
    }
  }

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



Measured memory_bytes: 3360
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')


def c(r, l):
    cnt = r - l +1

    if cnt<2:
        return 0
    return cnt * (cnt-1)//2

def solve():
    n = f()[0]
    a = f()

    add_sum = 0
    xor_sum = 0
    ans = n

    l = 0
    r = 0
    while r<=n-1:
        add_sum += a[r]
        xor_sum ^= a[r]

        r+= 1

        if r == n and add_sum == xor_sum:
            ans += c(n-1, l)
            break

        if add_sum != xor_sum:
            nl = l
            while add_sum != xor_sum:
                add_sum -= a[nl]
                xor_sum ^= a[nl]
                nl += 1
            
            ans += c( nl-1, l)

            ans += (nl - l)*(r - nl-1)

            l = nl

        if r == n:
            ans += c(n-1, l)




    print(ans)

solve()


Measured memory_bytes: 25556
#include<stdio.h>
int main()
{
    int A,B,C,x;
    scanf("%d %d %d",&A,&B,&C);
    x=A-B;
    if(x<C)
    {
        printf("%d\n",C-x);
    }
    else
       printf("0\n");
    return 0;
}


Measured memory_bytes: 1652