akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;

class program
{
    static public int mod = 1000000007;
    static void Main()
    {
        var n = rint();
        var ans = new Dictionary<string, int>()
        {
            {"AC",0 },{"WA",0 },{ "TLE",0},{"RE",0}
        };
        for(int i = 0; i < n; i++)
        {
            string s = rstr();
            ans[s]++;
        }
        WriteLine("AC" + " x " + ans["AC"]);
        WriteLine("WA" + " x " + ans["WA"]);
        WriteLine("TLE" + " x " + ans["TLE"]);
        WriteLine("RE" + " x " + ans["RE"]);
    }
    
    static int pow(int a, int b) { string binary = Convert.ToString(b, 2); int bileng = binary.Length; long a_power = a; long value = 1; for (int i = bileng - 1; i >= 0; i--) { if (binary[i] == '1') { value = value * a_power % mod; } a_power = a_power * a_power % mod; } return (int)value; }
    static string rstr() { return ReadLine(); }
    static int rint() { return int.Parse(ReadLine()); }
    static long rlong() { return long.Parse(ReadLine()); }
    static string[] stra() { return ReadLine().Split(' '); }
    static char[] chara() { string[] a = stra(); string b = ""; for (int i = 0; i < a.Length; i++) { b += a[i]; } return b.ToCharArray(); }
    static int[] inta() { string[] read_str_array = ReadLine().Split(' '); int[] return_int_array = new int[read_str_array.Length]; for (int countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_int_array[countup_i] = int.Parse(read_str_array[countup_i]); } return return_int_array; }
    static long[] longa() { string[] read_str_array = ReadLine().Split(' '); long[] return_long_array = new long[read_str_array.Length]; for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_long_array[countup_i] = long.Parse(read_str_array[countup_i]); } return return_long_array; }
    static double[] doublea() { string[] read_str_array = ReadLine().Split(' '); double[] return_double_array = new double[read_str_array.Length]; for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_double_array[countup_i] = double.Parse(read_str_array[countup_i]); } return return_double_array; }
    static long GCD(long a, long b) { if (a < b) { long temp = a; a = b; b = temp; } if (a % b == 0) { return b; } else { long temp = b; b = a % b; a = temp; return GCD(a, b); } }
    static long LCM(long a, long b) { return a * b / GCD(a, b); }
    static void WriteArray2(int[,] a, int b, int c) { for (int i = 0; i < b; i++) { for (int j = 0; j < c; j++) { if (j != 0) Write(" "); Write(a[i, j]); } WriteLine(); } }
    static void WriteArray(int[] a, int b) { for (int i = 0; i < b; i++) { Write(" "); Write(a[i]); } WriteLine(); }
}


Measured memory_bytes: 30712
#include<stdio.h>

void DFS(int,int);

struct Node
{
  int key;
  int discovered_time;
  int finished_time;
};

int time_from_begin = 0;
int List[101][101];
struct Node node[101];

int main()
{
  int n,i,j,key,k;
  
  scanf("%d",&n);
  for(i = 1 ; i<=n ; i++)  for(j = 0 ;j < n ; j++ )  List[i][j] = 0;
  for(i = 1 ; i<= n ; i++)
    {
      node[i].key =0;
      node[i].discovered_time = 0;
      node[i].finished_time = 0;
    }
  for(i = 1; i<= n;i++)
    {
      scanf("%d %d",&node[i].key,&k);
      
      for(j = 0 ; j < k; j++) scanf("%d",&List[node[i].key][j]);//あやしい
    }

  for(i = 1; i <= n ;i++)DFS(i,0);

  for(i = 1 ; i<=n ; i++)printf("%d %d %d\n",i, node[i].discovered_time , node[i].finished_time);
	

      
  

}

void DFS(int node_index ,int List_index)
{
   if(node[node_index].discovered_time ==0)
  {
  time_from_begin++;
  //printf("arrive:node %d time:%d\n",node[node_index].key,time_from_begin);
  if(node[node_index].discovered_time == 0) node[node_index].discovered_time = time_from_begin;
  while(List[node_index][List_index]!=0 && node[node_index].key !=List[node_index][List_index])
    {
      
      DFS( List[node_index][List_index] , 0);
      List_index++;
    }
   time_from_begin++;
  node[node_index].finished_time = time_from_begin;
  
  }
   //printf("left:node %d time:%d\n",node[node_index].key,time_from_begin);
  return;

}



Measured memory_bytes: 2056
#include "bits/stdc++.h"

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
ll inf = 1e18;

ll a;
int main(){
	cin >> a;
	p(a*a*a);

	return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedReader;

public class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line;

        while((line = br.readLine()) != null){
            String[] input = line.split(" ");
            
            if(input[0].equals("-1") && input[1].equals("-1")){
                break;
            }
            
            if(input[0].equals("-1") || input[1].equals("-1")){
                System.out.println("F");
                continue;
            }

            int score = Integer.parseInt(input[0]) + Integer.parseInt(input[1]);

            if(score < 30){
                System.out.println("F");
            }else if(score >= 80){
                System.out.println("A");
            }else if(score < 50){
                if(Integer.parseInt(input[2]) >= 50) System.out.println("C");
                else System.out.println("D");
            }else if(score < 65){
                System.out.println("C");
            }else{
                System.out.println("B");
            }

        }

    }
}

Measured memory_bytes: 24292
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
#define rep(i, n) for(ll i = 0; i < ll(n); ++i)
#define all(v) (v).begin(), (v).end()
const char newl = '\n';

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

  ll n;
  cin >> n;
  vl a(5);
  rep(i, 5) cin >> a[i];
  sort(all(a));
  
  cout << (ll)(n+a[0]-1)/a[0]+4 << newl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>

int main() {
  int N;
  int H[20];
  int i, j;

  std::cin >> N;

  for(i=0; i<N; i++) {
    std::cin >> H[i];
  }

  int sum=0;
  for(i=0; i<N; i++) {
    for(j=0; j<i; j++) {
      if(H[j] > H[i]) break;
    }
    if(j==i) sum++;
  }

  std::cout << sum;

  return 0;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
const ll MOD = 1e9+7;

ll N,Q;
ll value[200001];
queue<ll> edge[200001];
int use[200001];

void bfs(ll x, ll root){
    use[x] = 1;
    if(x!=root){
        value[x] += value[root];
    }
    while(!edge[x].empty()){
        ll next = edge[x].front();
        edge[x].pop();
        if(use[next]){continue;}
        bfs(next,x);
    }
}

int main(){
    cin>>N>>Q;
    FILL(value,N+1,0LL);
    REP(count,N-1){
        ll a,b; cin>>a>>b;
        edge[a].push(b);
        edge[b].push(a);
    }
    REP(count,Q){
        ll p,x; cin>>p>>x;
        value[p] += x;
    }
    
    FILL(use,N+1,0);
    bfs(1,1);
    
    for(int i=1;i<=N;++i){
        if(i<N){ printf("%Ld ",value[i]);}
        else{ printf("%Ld\n",value[i]); }
    }
}


Measured memory_bytes: 148480
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <array>
#include <cassert>
#include <utility>
#include <vector>
// #include <atcoder/all>

template <class InputIterator>
std::ostream& range_output(std::ostream& os_arg, InputIterator first_arg, InputIterator last_arg){ if(first_arg != last_arg){ do{ os_arg << *(first_arg++); if(first_arg == last_arg) break; os_arg << ' '; } while(true); }  return os_arg; }
template <class Tp> std::ostream& operator << (std::ostream& os_arg, const std::vector<Tp>& arr_arg){ return range_output(os_arg, arr_arg.cbegin(), arr_arg.cend()); }
template <class Tp, std::size_t Size> std::ostream& operator << (std::ostream& os_arg, const std::array<Tp, Size>& arr_arg){ return range_output(os_arg, arr_arg.cbegin(), arr_arg.cend()); }
template <class S, class T> std::ostream& operator << (std::ostream& os_arg, const std::pair<S, T>& pair_arg){ return os_arg << '(' << pair_arg.first << ", " << pair_arg.second << ')'; }

#ifndef ONLINE_JUDGE
    template <typename Head> void dump_out(Head head_arg){ std::cerr << head_arg << '\n'; }
    template <typename Head, typename... Tail>
    void dump_out(Head head_arg, Tail... tail_args){ std::cerr << head_arg << ", "; dump_out(tail_args...); }
    #define dump(...) do { std::cerr << "[in line " << __LINE__ << "] " << #__VA_ARGS__ << " : "; dump_out(__VA_ARGS__); } while(false)
#else
    #define dump(...) (void(0))
#endif




int main(void){
    std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); 
    std::cout << std::fixed << std::setprecision(16);
    std::string S; std::cin >> S;
    std::cout << S;
    if(S.back() == 's') std::cout << 'e';
    std::cout << "s\n";


    

    return 0;
}

Measured memory_bytes: 3656
import java.util.*;
import java.util.stream.*;

public class Main {
  public static void main(String[] args) throws Exception {
    Scanner in = new Scanner(System.in);
    long A = in.nextLong(), B = in.nextLong(), C = in.nextLong(), D = in.nextLong();
    System.out.println((B - A + 1) - calc(A, B, C) - calc(A, B, D) + calc(A, B, lcm(C, D)));
  }

  public static long calc(long a, long b, long c) {
    return b / c - (a - 1) / c;
  }

  public static long gcd(long x, long y) {
    return y == 0 ? x : gcd(y, x % y);
  }

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

Measured memory_bytes: 23124
// atcoder/abc126/F/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int m, k;
  while (cin >> m >> k) {
    if (k == 0) {
      for (int i = 0; i < (1 << m); ++i) {
        cout << i << ' ' << i << ' ';
      }
      cout << endl;
      continue;
    }

    vector<lli> v;
    v.push_back(0);
    v.push_back(k);
    v.push_back(0);
    int x = 0;
    for (int i = 1; i < (1 << m); ++i) {
      if (i != k) {
        v.push_back(i);
        x ^= i;
      }
    }
    v.push_back(k);
    for (int i = (1 << m) - 1; 1 <= i; --i) {
      if (i != k) v.push_back(i);
    }

    if (x == k) {
      each (i, v) cout << i << ' ';
      cout << endl;
    } else {
      cout << -1 << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 6128
#include<stdio.h>
int main()
{
	int a, b, c;
	while (scanf("%d %d %d", &a, &b, &c)!=EOF)
	{
		if (a == b)printf("%d", c);
		else {
			if (a == c)printf("%d", b);
			else printf("%d", a);
		}
		
	}
}

Measured memory_bytes: 128
grids = 3.times.map{gets.split(' ').map(&:to_i)}
flag = false

(0..grids.max.max).each do |i|
  a1 = i
  b1 = grids[0][0] - a1
  a2 = grids[1][0] - b1
  a3 = grids[2][0] - b1
  b2 = grids[0][1] - a1
  b3 = grids[0][2] - a1
  if a1 >= 0 && a2 >= 0 && a3 >= 0 && b1 >= 0 && b2 >= 0 && b3 >= 0&&  grids[1][1] == a2 +b2 && grids[1][2] == a2 + b3 && grids[2][1] == a3 +b2 && grids[2][2] == a3 + b3
    flag = true
    puts "Yes"
    break
  end
end


puts "No" unless flag

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

using namespace std;

int main(){
    int N,guzai=0;
    vector<int> kusi(205);

    cin>>N;

    for(int i=0;i<2*N;i++){
        cin>>kusi[i];
    }

    sort(kusi.begin(), kusi.end(),greater<>());




    for(int j=0;j<2*N;j=j+2){
        if(kusi[j]<kusi[j+1]){
            guzai=guzai+kusi[j];
        }else{
            guzai=guzai+kusi[j+1];            
        }

    }

    cout<<guzai<<endl;


}

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

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    if (a < c && c < b){
        cout << "Yes" << endl;
    }else if(b < c && c < a){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

ll solve(){}
int main() {

ll A,B,N;
ll ans=-1e9;
cin>>A>>B>>N;
if(N<=1e9)//1e9
{
  rep(i,N+1)
  { //cout << i<<":"<<((A*i)/B)-A*(i/B)<<endl;
  ans=max(ans,((A*i)/B)-A*(i/B));}
}
else
{P ans2;
 ans2.first=-1e9;
 ans2.second=-1e9;
  for(ll i=0; i<=N; i+=20000)
  {P ans1;ans1.first=((A*i)/B)-A*(i/B);ans1.second=i;
   ans2=max(ans2,ans1);
   //cout<<"flag0 :"<<ans2.first<<endl;
  }
  ll near=ans2.second;
  
  if(near<=20000)
  {
    rep(i,near+20000)
    {
      ans=max(ans,((A*i)/B)-A*(i/B));
      //cout<<"flag1 : "<<((A*i)/B)-A*(i/B)<<endl;
    }

  }
  else
  {
    for(ll i=near-20000;i<=near+20000;i++)
    {
      ans=max(ans,((A*i)/B)-A*(i/B));
      //cout<<"flag2"<<endl;
    }
  }
  
}


cout << ans<<endl;


}
/*vector <int> a(3);
for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }*/

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

int main()
{
    long long INF = 1e5 + 5;
    long long N, M;
    string S;
    cin >> N >> M >> S;

    reverse(S.begin(), S.end());
    vector<int> dp(S.size(), INF);
    int current = 0;
    dp.front() = current;
    queue<int> q;
    q.push(0);
    for (int i = 1; i < S.size(); i++)
    {
        while (q.size() > M)
        {
            q.pop();
        }
        while (q.front() == INF)
        {
            q.pop();
        }
        if (q.empty())
        {
            cout << -1 << endl;
            return 0;
        }
        if (S[i] == '0')
        {
            dp[i] = q.front() + 1;
        }
        q.push(dp[i]);
    }
    reverse(dp.begin(), dp.end());

    current = 0;
    vector<int> ans;
    for (int i = 0; i < dp.size(); i++)
    {
        if (dp[i] == dp[current] - 1)
        {
            ans.push_back(i - current);
            current = i;
        }
    }

    for (int a : ans)
    {
        cout << a << " ";
    }
    cout << endl;
}


Measured memory_bytes: 1528
X = int(input())

Dp = [False for _ in range(X+1)]

Dp[0] = True
for i in range(100, X+1):
    if any([Dp[i - j] == True for j in range(100, 106)]):
        Dp[i] = True
if Dp[X]:
    print(1)
else:
    print(0)

Measured memory_bytes: 79756
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define so sizeof
#define pb push_back
#define vl vector<ll>
#define el endl;cout.flush()
#define be begin()
#define fi first
#define se second
#define br break
#define sz size()
#define en end()
#define ro return 0
#define br break
#define con continue;
#define um unordered_map<ll,ll>
#define ms(x) memset(x , 0, so x)
#define all(x) (x).be , (x).en
#define rall(x) (x).rbegin() , (x).rend()
#define acc(x) accumulate((x).be , (x).en , 0ll)
#define forn(i,a,b) for(ll i=a;i<=b;++i)
#define forr(i,a,b) for(ll i=a;i<b;++i)
#define rng_58 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define plvl pair<pair<ll,ll> ,ll>
#define mp make_pair
int main()
{
    ios;
    long long  n ,  x ;
    cin >> n >>x ;
    ll nos = 2*n - 1;
    vl v ;
    v.pb(-1);
    forn(i , 1 , nos){
       v.pb(i);
    }
    /// 1 2 3 4 5 6 7 8 9
    ll med = (nos / 2) + 1;
    ll val  = v[med] ;
    if(x == 1  or x == nos){
        cout << "No\n";
        ro;
    }
    ll arr[nos+1];
    forn(i ,0 , nos) {
       arr[i] = -1 ;
    }
    if(x >= val) {
        cout << "Yes\n";
        arr[med] = x ;
        forn(i , med +1 , nos){
           arr[i] = arr[i-1] + 1 ;
        }
        for(ll i = med - 1 ; i>=1 ;--i){
             arr[i] = arr[i+1] - 1 ;
        }
        forn(i ,  1,  nos){
           if(arr[i] > nos){
            arr[i] = arr[i] % nos ;
           }
        }
        forn( i , 1 , nos){
           cout << arr[i] << el;
        }
    }
    else if(x < val){
        cout << "Yes\n";
        arr[med ] = x ;
        forn(i , med+1 , nos){
           arr[i] = arr[i-1] + 1 ;
        }
        ll ind = -1 ;
        for(ll i = med - 1 ; i>=1 ; --i){
            if(arr[i+1] > 1){
                arr[i] = arr[i+1] - 1 ;
            }
            else if(arr[i+1] == 1 ){
                ind = i + 1 ;
                br ;
            }
        }
        arr[ind - 1 ] = nos ;
        for(ll i = ind - 2 ; i >= 1 ; --i){
            arr[i] = arr[i+1] - 1 ;
        }
        forn(i , 1 ,  nos){
           cout << arr[i] << " " ;
        }
        cout << el ;
    }

}






















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

#define ll             long long
#define sf             scanf
#define pf             printf
#define nl             printf("\n")
#define TEST           int Test;cin>>Test;for(int _t=1;_t<=Test;_t++)
#define si(n)          scanf("%d",&n)
#define inarr(a,i,n)   for(int i=0; i<n; i++) scanf("%d",&a[i])

using namespace std;


int main()
{
	int n,arr[103];
	si(n);
	inarr(arr,i,n);
	sort(arr,arr+n);
	int cnt = 0;
	for(int i=0; i<n; i++){
		//if(i>0 and arr[i-1]==arr[i]) continue; 
		for(int j=i+1; j<n; j++){
			if(arr[i]==arr[j]) continue;
			for(int k=j+1; k<n; k++){
				if(arr[j]==arr[k]) continue;
				if(arr[i]+arr[j]>arr[k]){
					cnt++;
				}
			}
		}
	}
	pf("%d\n",cnt);
	return 0;
}


Measured memory_bytes: 3760
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        List<Integer> l = IntStream.range(0, n)
                .mapToObj(i -> scanner.nextInt())
                .collect(Collectors.toList());
        int max = l.stream()
                .max(Comparator.comparingInt(Integer::intValue))
                .get();
        l.remove(Integer.valueOf(max));
        System.out.println(max < l.stream().mapToInt(Integer::valueOf).sum() ? "Yes" : "No");
    }
}

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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

template <class T> constexpr T inf = numeric_limits<T>::max() / 2.1;

auto chmax = [](auto&& a, auto b) { return a < b ? a = b, 1 : 0; };

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<long long> a(n);
  for (auto&& e : a) {
    cin >> e;
  }
  vector<int> ord(n);
  iota(begin(ord), end(ord), 0);
  sort(begin(ord), end(ord), [&](int i, int j) {
    return a[i] > a[j];
  });
  vector dp(n + 1, vector(n + 1, -inf<long long>));
  dp[0][0] = 0;
  int sz = 0;
  for (int i : ord) {
    for (int l = 0; l <= sz; ++l) {
      int r = sz - l;
      chmax(dp[l + 1][r], dp[l][r] + a[i] * abs(l - i));
      chmax(dp[l][r + 1], dp[l][r] + a[i] * abs(n - r - 1 - i));
    }
    ++sz;
  }
  auto res = -inf<long long>;
  for (int l = 0; l <= n; ++l) {
    chmax(res, dp[l][n - l]);
  }
  cout << res << '\n';
}


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

using namespace std;

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

int x[100005],y[100005];

int main(){

  int n,w,h;
  cin >> n >> w >> h;
  rep(i,100005){
    x[i]=0; y[i]=0;
  }
  rep(i,n){
    int tx,ty,tw,l,r,t,b;
    cin >> tx >> ty >> tw;
    l = tx-tw;
    r = tx+tw;
    b = ty-tw;
    t = ty+tw;
    if(0<=l&&l<100005)x[l]++;
    else if(l<0)x[0]++;
    if(0<=r&&r<100005)x[r]--;
    if(0<=b&&b<100005)y[b]++;
    else if(b<0)y[0]++;
    if(0<=t&&t<100005)y[t]--;
  }
  int tmp=0,xflag=0,yflag=0;
  rep(i,w){
    tmp += x[i];
    if(tmp==0)xflag=1;
  }
  tmp = 0;
  rep(i,h){
    tmp += y[i];
    if(tmp==0)yflag=1;
  }
  if(xflag&&yflag)cout << "No" << endl;
  else cout << "Yes" << endl;

  return 0;
}



Measured memory_bytes: 3908
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <time.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<28;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

const int M=2000000;

vi f(vi a){
	int S=a.size();
	vi b(M);
	for(int i=0;i<S;i++) for(int j=0;j<i;j++) b[a[i]-a[j]]++;
	return b;
}

int main(){
	while(1){
		int n,m;
		cin>>n>>m;
		if(n==0) return 0;
		vi a(n+1),b(m+1);
		for(int i=0;i<n;i++){
			int A;
			cin>>A;
			a[i+1]=a[i]+A;
		}
		for(int i=0;i<m;i++){
			int B;
			cin>>B;
			b[i+1]=b[i]+B;
		}
		vi c=f(a),d=f(b);
		ll res=0;
		for(int i=0;i<M;i++) res+=c[i]*d[i];
		cout<<res<<endl;
	}
}

Measured memory_bytes: 18524
#include <iostream>

int main() {
    int count;
    std::cin>>count;
    int s[128];
    for(int i=0;i<count;i++)
        std::cin>>s[i];
    int max=0,mini=1000000000;
    for (int i=0;i<count;i++){
        if(max<s[i])
            max=s[i];
    }
    for (int i=0;i<count;i++){
        if(mini>s[i])
            mini=s[i];
    }
    std::cout<<max-mini<<std::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 REP(i,n) for(int i=1;i<=n;i++)
typedef long long ll;

int dist[10][10];


int main(){
	int H,W;
	cin >> H >> W;
	int A[205][205];
	
	rep(i,10){
		rep(j,10){
			cin >> dist[i][j];
		}
	}
	
	vector<int> count(10);
	
	rep(i,10){
		count[i] = 0;
	}
	
	rep(i,H){
		rep(j,W){
			cin >> A[i][j];
			rep(k,10){
				if(A[i][j] == k){
					count[k]++;
				}
			}
		}
	}
	
	rep(k,10){
		rep(i,10){
			rep(j,10){
				dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
			}
		}
	}
	
	int ans = 0;
	
	rep(i,10){
		ans += count[i]*dist[i][1];
	}
	
	cout << ans << endl;
    return 0;
}



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

#define infile "../test/sample-1.in"
#define int long long
// #define INF 2147483647
#define INF 1000000000000000000LL
#define MOD 1000000007LL

// {{{ define basic macro
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)

#define foreach(x,a) for(auto& (x) : (a) )
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)

#define all(x) (x).begin(),(x).end()
#define sum(v) accumulate(all(v), 0)
#define sz(x) ((int)(x).size())
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
#define fill(x,y) memset(x,y,sizeof(x))
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)

template <class T = int>
T in() {T x; cin>>x; return (x);}

struct Fast {
  Fast(){
    std::cin.tie(0);
    ios::sync_with_stdio(false);
  }
} fast;
// }}}
//{{{ dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}
//{{{ others
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;

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


int solve(){
  int n,k;cin>>n>>k;
  int x[n]; rep(i, n){ cin>>x[i]; }

  int res = INF;

  rep(i, n){
    if (i+k-1 > n-1) continue;
    chmin(res, abs(x[i]) + (x[i+k-1]-x[i]));
    chmin(res, abs(x[i+k-1]) + (x[i+k-1]-x[i]));
  }

  cout << res << endl;

  return 0;
}

int test(){ //{{{
  return 0;
}
//}}}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
#ifdef PCM
  test();
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>
#include <cstdint>



#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rrep(i, n) for(ll i = (ll)(n-1); i >= 0; i--)
#define repi(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rrepi(i,a,b) for(ll i=(ll)(b-1);i>=(ll)(a);i--)

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

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; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll h,w,n;cin>>h>>w>>n;
  ll res=1e9;
  rep(i,h+1)rep(j,w+1){
    if(h*j+w*i-i*j>=n)chmin(res,i+j);
  }
  cout<<res<<endl;
  return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main(){
    string s;
    cin >> s;
    int K;
    cin >> K;
    vector<int> dis(s.size());
    for(int i = 0; i < s.size(); i++){
        if('a' + 26 - s[i] == 26) dis[i] = K + 1;
        else dis[i] = 'a' + 26 - s[i];
    }
    for(int i = 0; i < s.size(); i++){
        if(dis[i] <= K){
            s[i] = 'a';
            K -= dis[i];
        }
    }
    if(K > 0){
        s[s.size() - 1] = 'a' + (s[s.size() - 1] - 'a' + K % 26) % 26; 
    }
    cout << s << endl;
}

Measured memory_bytes: 1024
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

using namespace std;

int my_abs(int num) {
    if (num > 0)
        return num;
    else
        return -num;
}

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

long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

int main() {
    int N;
    cin >> N;
    vector<int> P(N);
    for (int i = 0; i < N; i++) {
        cin >> P.at(i);
    }
    sort(P.begin(), P.end());
    reverse(P.begin(), P.end());

    cout << P.at(N / 2 - 1) - P.at(N / 2) << endl;



    
    
}

Measured memory_bytes: 640
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int [] in = new int [a];
        int [] ans = new int [a];
        for(int i=0;i<a;i++){
                             in[i] = sc.nextInt();
                            }
		for(int i=0;i<a;i++){ans[in[i]-1] = i+1;}
		for(int i=0;i<a;i++){System.out.println(ans[i]);}
	}
}


Measured memory_bytes: 63312
#include <cmath>
#include <iostream>

using namespace std;

int main()
{
    int x[4], y[4];
    cin >> x[0] >> y[0] >> x[1] >> y[1];
    int disX = x[0] - x[1], disY = y[0] - y[1];
    x[2] = x[1] + disY;
    y[2] = y[1] - disX;
    x[3] = x[2] + disX;
    y[3] = y[2] + disY;

    cout << x[2] << " " << y[2] << " " << x[3] << " " << y[3] << endl;
    return 0;
}


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

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

int main() {
    string s;
    double long m,n,x;
    cin>>m>>n>>x;
    double long xx=m/x;
   if(xx<=n)
 
    
    
    cout<<"Yes";
  else
    cout<<"No";
	return 0;
}

Measured memory_bytes: 3752
import java.util.*

fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }
    val graph = Array(n) {
        ArrayList<Int>()
    }
    repeat(m) {
        val (ai, bi) = readLine()!!.split(" ").map { it.toInt()-1 }
        graph[ai].add(bi)
        graph[bi].add(ai)
    }
    val sirube = Array(n) { -1 }
    val queue = ArrayDeque<QueueData>()
    queue.add(QueueData(0, 0))
    while (queue.isNotEmpty()) {
        val now = queue.poll()!!
        if (sirube[now.next] != -1) continue
        sirube[now.next] = now.from
        graph[now.next].forEach { i: Int ->
            queue.add(QueueData(i, now.next))
        }
    }
    println("Yes")
    sirube.drop(1).forEach {
        println(it + 1)
    }
}

data class QueueData(val next: Int, val from: Int)

Measured memory_bytes: 83000
#include<stdio.h>

#define INFINITY 2000000001
#define N 500000

int merge(int *, int ,int ,int);
void mergeSort (int *,int ,int);

int cnt=0;

int main(){
  int Merge[N];
  int num,i;
  int right,left,mid;

  scanf("%d",&num);
  for(i=0;i<num;i++) scanf("%d",&Merge[i]);

  right = num;
  left = 0;
  mid = (right + left) / 2;

  mergeSort(Merge,left,right);

  //printf("num: %d\n",num);
  
  for(i=0;i<num;i++){
    if(i) printf(" ");
    printf("%d",Merge[i]);
  }
  printf("\n");
  printf("%d\n",cnt);
  
  return 0;

}

int merge(int A[],int left,int mid,int right){
  int i,j,k,n1,n2;
  int R[N],L[N];

  //printf("wa-i\n");
  
  n1 = mid - left;
  n2 = right - mid;
  //L[0...n1], R[0...n2] を生成
  for (i = 0;i<= n1-1;i++)
    L[i] = A[left + i];
  for (i = 0;i<= n2-1;i++)
    R[i] = A[mid + i];
  // printf("aaaa\n");
  L[n1] = INFINITY;
  R[n2] = INFINITY;
  i = 0;
  j = 0;
  for (k = left;k<=right-1;k++){
    cnt++;
    if (L[i] <= R[j]){
      A[k] = L[i];
      i = i + 1;
    }
    else {
      A[k] = R[j];
      j = j + 1;
    }
  }
}

void mergeSort(int A[],int left,int right){
  int mid;
  int i;
  //printf("%d  %d\n",left,right);
  if (left+1 < right){
    mid = (left + right)/2;
    mergeSort(A, left, mid);
    //printf("wa-iwa-i%d  %d\n",left,right);
    mergeSort(A, mid, right);
    //printf("wa-iwa-iwa-i\n");
    merge(A, left, mid, right);
  }
}




Measured memory_bytes: 6508
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'

int main() {
    long long n,rta,fallos=0;
    vector<int> R,G,B;
    string s;
    cin >> n >> s;
    for(int i=0;i<n;i++){
        for(int j=1;j<n;j++){
            if(((i+j)<(n) && (i+(j*2))<(n)) && (s[i]!=s[i+j] && s[i]!=s[i+(2*j)] && s[i+j]!=s[i+(2*j)])) fallos++;
        }
    }
    for(int i=1;i<=n;i++){
        if(s[i-1]=='R'){
            R.push_back(i);
        }
        if(s[i-1]=='G'){
            G.push_back(i);
        }
        if(s[i-1]=='B'){
            B.push_back(i);
        }
    }
    rta=(R.size()*G.size()*B.size())-fallos;
    cout << rta << endl;
    return 0;
}


Measured memory_bytes: 3556
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long int pos,n,a[200009],i;
cin>>n;
for(i=0;i<n;i++)
cin>>a[i];
pos=max_element(a,a+n)-a;
sort(a,a+n,greater<long long int>());

for(i=0;i<n;i++)
{
if(i==pos)	
cout<<a[1]<<endl;
else
cout<<a[0]<<endl;
}
return 0;
}


Measured memory_bytes: 3200
//#include <cstdio>
#include <iostream>

#include <cstring>

#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
//#include <queue>
//#include <stack>
#include <cassert>

using namespace std;

#define SZ(a) int((a).size())
#define REP(i,n) for(int i=0,_n=(n);i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)

#define DEBUG(x) cerr << #x << ": " << x << endl

typedef long long llong;
typedef vector<int> VI;
typedef vector<VI> VVI;

int H, W;
char B[24][24];

int dr[] = {-1, 0, 0, 1};
int dc[] = {0, -1, 1, 0};

const int INF = 1000000000;
int A[20*20][20*20];
inline int IDX(int r, int c) {
   return r*W + c;
}

int main(int argc, char* argv[]) {
   ios_base::sync_with_stdio(false); 
   cin.tie(nullptr);

   cin >> H >> W;
   REP(r, H)
      cin >> B[r];

   const int NN = H*W;
   REP(i, NN) {
      REP(j, NN)
         A[i][j] = INF;
      A[i][i] = 0;
   }

   REP(r, H) REP(c, W) {
      if (B[r][c] != '.') continue;
      REP(k, 4) {
         int nr = r + dr[k], nc = c + dc[k];
         if (nr < 0 || nr >= H || nc < 0 || nc >= W) continue;
         if (B[nr][nc] != '.') continue;
         A[IDX(r, c)][IDX(nr, nc)] = 1;
      }
   }

   REP(k, NN) REP(i, NN) REP(j, NN)
      A[i][j] = min(A[i][j], A[i][k] + A[k][j]);

   int res = 0;
   REP(i, NN) REP(j, NN) {
      if (A[i][j] < INF)
         res = max(res, A[i][j]);
   }
   
   cout << res << endl;

   return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long;
#define div 1000000007
 
int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b;
  int sum = 0;
  
  rep(i,n){
    cin >> a[i];
    sum = (sum + a[i]) % div;;
    b.emplace_back(sum);
  }
  
  int ans = 0;
  rep(i,n-1){
      ans = (ans + (ll)a[i+1]*b[i]) % div;
  }
  cout << ans << endl;
  return 0;
}

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

sys.setrecursionlimit(1000000)


memo = [0]*(10**5+1)
def count(n):
    if n < 2:
        return 1
    if memo[n] != 0:
        return memo[n]
    memo[n] = count(n-1) + count(n-2)
    return memo[n]


n, m, *a = map(int, open(0).read().split())
if sum(a[i + 1] == a[i] + 1 for i in range(m - 1)) > 0:
    print(0)
    exit()

a.append(n + 1)
c = -1
ans = 1
for i in a:
    ans = ans * count(i - c - 2) % (10**9 + 7)
    c = i
print(ans)


Measured memory_bytes: 572840
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repr(i,n) for (int i = (n); i >= 0; --i)
#define FOR(i,m,n) for (int i = (m); i < (n); ++i)
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int mod2 = 998244353;

int main() {
  string s;
  cin >> s;
  rep(i,s.size()-1) {
    if (s[i] == s[i+1]) {
      cout << "Bad" << endl;
      return 0;
    }
  }
  cout << "Good" << endl;
}

Measured memory_bytes: 256
N,X = list(map(int, input().split()))
a = list(map(int, input().split()))
a = sorted(a)
m = sum(a)
count = 0
S=0
if m == X:
    print(N)
elif m < X:
    print(N-1)
elif a[0] > X:
    print(0)
else: 
    for i in a:
        if S <= X:
            S = S + i
            count = count + 1
    else:
        print(count-1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()

using namespace std;

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

    int ans = 0;

    for(int i = 1; i <= 33; i++){
        for(int j = 2; j <= 10; j++){
            double di = (double)i;
            double dj = (double)j;
            int tmp = round(pow(di, dj));

            if(tmp <= x) ans = max(ans, tmp);
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

long long int i,j,k,x[3];
char tax[127],a[3][127];

int main(){
	while(scanf("%s",tax)!=EOF){
		sscanf(tax,"%[0123456789X]+%[0123456789X]=%[0123456789X]",a[0],a[1],a[2]);
		for(i=0;i<10;i++){
			for(j=0;j<3;j++){
				x[j]=0;
				for(k=0;k<(signed int)strlen(a[j]);k++){
					if(a[j][k]=='X'){
						if(i==0 && k==0 && strlen(a[j])>1)goto exit;
						else x[j]=x[j]*10+i;
					}
					else x[j]=x[j]*10+a[j][k]-'0';
				}
			}
			if(x[0]+x[1]==x[2])break;
			exit:;
		}

		if(i>9)printf("NA\n");else printf("%d\n",i);

	}
	return 0;
}

Measured memory_bytes: 564
while line = gets do
  a, b, c, d, e, f = line.chop.split(/\s+/).map { |s| s.to_f }
  x = (e*c - b*f)/(a*e - b*d) + 0.0
  y = (d*c - a*f)/(d*b - a*e) + 0.0
  printf("%.3f %.3f\n", x, y)
end



Measured memory_bytes: 6896
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <string>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	int a,b,c; cin>>a>>b>>c;
	if(a+b+c>=22) cout << "bust";
	else cout << "win";


  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 rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
#define CININIT cin.tie(0),ios::sync_with_stdio(false)
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

int main(){
    int N,K;
    cin>>N>>K;
    vi P(26,0);
    rep(i,N){
        string p;cin>>p;
        P[p[0]-'A']++;
    }
    sort(ALL(P));
    auto Po = P;
    int ul=0,ur=10001;
    while(ur-ul>1){
        debug2(ul,ur);
        int mid = (ul+ur)/2;
        debug(mid);
        bool f=true;
        Po = P;

        for(int i=0;i<mid;i++){
            int cnt=0;
            sort(ALL(Po));
            reverse(ALL(Po));
            for(int j='A';j<='Z';j++){
                int jj=j-'A';
                if(Po[jj]>0){
                    //cerr << "check" << endl;
                    Po[jj]--;
                    cnt++;
                }
                if(cnt==K) break;
            }
            if(cnt<K){
                debug(cnt);
                f=false;
                break;
            }
        }
        if(f){
            cerr << "OK" << endl;
            ul = mid;
        }else{
            cerr << "NG" << endl;
            ur = mid;
        }
    }
    cout << ul << endl;
}


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

typedef pair<int, int> pii;
typedef long long ll;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os<<"("<<p.first<<","<<p.second<<")";
    return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os<<"{";
    rep(i, v.size()) {
        if (i) os<<",";
        os<<v[i];
    }
    os<<"}";
    return os;
}

int main() {
    string s; cin >> s;
    bool ok = 1;
    rep(i, s.size()) {
        char c = s[i];
        if (c == 'R') {
            if (i % 2 == 1) {
                ok = 0;
            }
        } else if (c == 'L') {
            if (i % 2 == 0) {
                ok = 0;
            }
        }
    }
    puts(ok ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	h := getNextInt(scanner)
	w := getNextInt(scanner)
	n := getNextInt(scanner)
	sr := getNextInt(scanner)
	sc := getNextInt(scanner)
	s := getNextString(scanner)
	t := getNextString(scanner)

	ysp48 := [2]int{
		1,
		w,
	}
	rng58 := [2]int{
		1,
		h,
	}
	for i := n - 1; i >= 0 && ysp48[0] <= ysp48[1]; i-- {
		if t[i] == 'R' && ysp48[0] > 1 {
			ysp48[0]--
		}
		if t[i] == 'L' && ysp48[1] < w {
			ysp48[1]++
		}
		if s[i] == 'R' {
			ysp48[1]--
		}
		if s[i] == 'L' {
			ysp48[0]++
		}
	}
	if ysp48[0] > sc || ysp48[1] < sc {
		fmt.Println("NO")
		return
	}
	for i := n - 1; i >= 0 && rng58[0] <= rng58[1]; i-- {
		if t[i] == 'D' && rng58[0] > 1 {
			rng58[0]--
		}
		if t[i] == 'U' && rng58[1] < h {
			rng58[1]++
		}
		if s[i] == 'D' {
			rng58[1]--
		}
		if s[i] == 'U' {
			rng58[0]++
		}
	}
	if rng58[0] > sr || rng58[1] < sr {
		fmt.Println("NO")
		return
	}

	fmt.Println("YES")
	writer.Flush()
}


Measured memory_bytes: 1408
import java.util.*;
public class Main{
	public static void main(String[] args){
      	Scanner sc = new Scanner(System.in);
    	int h = sc.nextInt();
      	int w = sc.nextInt();
        String[] eng = {"A","B","C","D","E","F","G","H","I","J","K","L","M",
                        "N","O","P","Q","R","S","T","U","V","W","X","Y","Z"};
      	int hitH=0;
      	int hitW=0;
      	String[][] s = new String[h][w];
      	for(int i = 0; i < h; i++){
        	for(int j = 0; j < w; j++){
            	s[i][j] = sc.next();
              	if(s[i][j].equals("snuke")){
                	hitH = i;
                  	hitW = j;
                  	break;
                }
            }
        }
      	System.out.println(eng[hitW] + (hitH+1));
      	
    }
}

Measured memory_bytes: 39296
#include <bits/stdc++.h>
#define ll          long long
#define int 		long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define ff           first
#define ss           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;

void solve(){
	//write here
	ll n,k;
	cin>>n>>k;
	vector<ll>arr(n);
	rep(i,0,n)cin>>arr[i];
	rep(i,k,n){
		if (arr[i]>arr[i-k])cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	return;
}

int32_t main(){
	cin.tie(NULL);
	ios::sync_with_stdio(false);
	//insert code
		solve();
	return 0;
}

Measured memory_bytes: 4780
import           Control.Applicative
import           Control.Monad
import           Data.List

main :: IO ()
main = do
  [x1,y1,x2,y2] <- map (read::String->Double) . words <$> getLine
  print $ sqrt ((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2))



Measured memory_bytes: 3952
import sys
import math

X, K, D = [int(i) for i in input().split()]

x = (abs(X) - K * D)
if x >= 0:
  print(x)
  sys.exit()

a = X // D if X > 0 else math.ceil(X / D)
k = K - a
k = k % 2

print(abs(X - D * a - k * D if X > 0 else X - D * a + k * D))


Measured memory_bytes: 8984
#include <iostream>
#include <string>

using namespace std;

int main() {
  int l, m, n;
  ios::sync_with_stdio(false);
  
    
  while (1) {
    cin >> l;
    //cout << "aa" << l << endl;
    if(l!=0){
      int i;
      int month=0;
      for(i=1;i<=12;i++){
	cin >> m >> n;
	//cout << i << m << n << endl;
	
	l = l - (m-n);
	if(l<=0 && month==0)
	  {month = i;}
      }

      //cout << "bb" << l << endl;

      if(month==0)
	cout << "NA" <<endl;
      else
	cout << month << endl;
    }
    else
      break;
  }
    
    return 0;
}

Measured memory_bytes: 3128