akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const ld eps = 1e-9;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  ll n, k; cin >> n >> k;
  ll tmp = n % k;
  cout << min(tmp, k - tmp) << endl;
}


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

int main() {
  int N, count = 0, tmp = 0;

  cin >> N;
  vector<int> cards(N);
  
  for(int i = 0; i < N; i++){
    cin >> cards.at(i);
  }
  
  sort(cards.begin(), cards.end());
  
  for(int i = 0; i < N; i++){
    if(!(cards.at(i) == tmp)){
      count++;
    }
    tmp = cards.at(i);
  }
  
  cout << count << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int 
#define pb push_back
#define mp make_pair
#define ff first
#define se second
#define MAX 1000001
#define MAXN 200001
#define mod 1000000007 
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll k,a,b,ans,x;
    cin>>k>>a>>b;
    x=b-a;
    if(x<=2){
        k=k+1;
        cout<<k;
    }
    else{
        if(k<=a){
            cout<<k+1;
        }
        else{
            ans=a;
            k=k-a+1;
            ans+=(k/2)*1ll*(x);
            ans+=(k%2);
            cout<<ans;
        }
    }
}

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

int main()
{
  int N, dummyN, sum;
  cin >> N;
  dummyN = N;
  for(int i=0; i<8; i++)
  {
    sum += dummyN % 10;
    dummyN /= 10;
    if(dummyN==0)
    {
      break;
    }
  }
  if(N%sum == 0)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.InputStreamReader;

import static java.lang.Math.*;

public class Main {
	public static void main(String[] args) {
		try {
			BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
			String[] line = input.readLine().split(" ");
			String lb = System.getProperty("line.separator");
			int a = Integer.parseInt(line[0]);
			int b = Integer.parseInt(line[1]);
			double c = toRadians(Integer.parseInt(line[2]));
			
			double area = (a * b * sin(c)) / 2;
			double perimeter = a + b + pow(a*a + b*b - 2*a*b*cos(c), 0.5);
			double height = b * sin(c);
			
			System.out.printf("%f%s%f%s%f", area, lb, perimeter, lb, height);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 17132
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)
  

K = int(input())
ans = 0

for a in range(1,K+1):
  for b in range(1,K+1):
    for c in range(1,K+1):
      ans += gcd(a,b,c)
      

print(ans)

Measured memory_bytes: 69624
# include <bits/stdc++.h>
# define sz(x) (int)((x).size())
# define F first
# define S second
# define pb push_back
# define ub upper_bound
# define lb lower_bound
# define all(x) x.begin(), x.end()
# define pqueue priority_queue
# define Speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
# define rep(i,n) for(int i=0;i<n;++i)
# define forn(i,n) for(int i=1;i<=n;++i)
using namespace std;

template<class T> void umin(T &a,T b){a=min(a,b);}
template<class T> void umax(T &a,T b){a=max(a,b);}

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

const int dx[]={1,0,-1,0,-1,-1,1,1},dy[]={0,1,0,-1,-1,1,-1,1}; 
const int mod = 1e9+7;
const ll N = 2e5+5;

void solve(){
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll ans=-1e18;
	vector<ll>v={a,b},r={c,d};
	for(int i=0;i<2;i++){
		for(int j=0;j<2;++j){
			umax(ans,v[i]*r[j]);
		}
	}	
	cout<<ans;
}

int main(){
	Speed();
	int T=1; 
	//cin>>T;	
	while(T--)solve();
}


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

using namespace std;


int main(){
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='?'){
            cout<<'D';
        }else{
            cout<<s[i];
        }
    }
    return 0;
}


Measured memory_bytes: 3748
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>

int N;
std::string s[1000];
int t[1000];
std::string X;

void solve() {
    int i;
    int u = 0;
    for (i = 0; i < N; i++) {
        if (X == s[i]) {
            break;
        }
    }
    for (int j = i + 1; j < N; j++) {
        u += t[j];
    }
    std::cout << u << std::endl;
}

int main() {
    std::cin >> N;
    for (int i = 0; i < N; i++) {
        std::cin >> s[i] >> t[i];
    }
    std::cin >> X;

    solve();

    return 0;

}

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


int main(){
	long i,j,k,z;
	long n,m,l,sum,a[101][101],b[101][101];
	char input[10000],*p=NULL;
	
	fgets(input,sizeof input,stdin);
	sscanf(input,"%ld %ld %ld",&n,&m,&l);
	
	for(i=0;i<n;i++){
		fgets(input,sizeof input,stdin);
		p=strtok(input," ");
		a[i][0]=atol(p);
		
		for(j=1;j<m;j++){
			p=strtok(NULL," ");
			a[i][j]=atol(p);
		}
		
	}
	for(i=0;i<m;i++){
		fgets(input,sizeof input,stdin);
		p=strtok(input," ");
		b[i][0]=atol(p);
		
		for(j=1;j<l;j++){
			p=strtok(NULL," ");
			b[i][j]=atol(p);
		}
		
	}
	
	for(i=0;i<n;i++){
		for(j=0;j<l;j++){
			sum=0;
			for(k=0;k<m;k++){
				sum+=a[i][k]*b[k][j];
			}
			printf("%ld",sum);
			if(j+1!=l){
				printf(" ");
			}
		}
		printf("\n");
	}
	
	return 0;
}

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

#define rep(i,a,b) for(i=(a);i<=(b);++i)
#define rev(i,a,b) for(i=(a);i>=(b);--i)
#define max2(a,b)  ((a)>(b)?(a):(b))
#define min2(a,b)  ((a)<(b)?(a):(b))
#define all(x) x.begin(),x.end()
#define sz(x) (long long)x.size()
#define fi first
#define se second
#define pb emplace_back // push_back
#define mp make_pair
#define endl '\n'

#ifdef Wild4Stone
template<typename T>
void __p(T a) { cout << a << " "; }
template<typename T, typename F>
void __p(pair<T, F> a) { cout << "{ "; __p(a.fi); __p(a.se); cout << "}"; }
template<typename T>
void __f(const char* s, T t) { cout << s << " : "; __p(t); }
template<typename T>
void __t(const char* s, const T &x) { cout << s << " : { "; for (auto it : x) __p(it); cout << "} ";}
template<typename T, typename ... F>
void __f(const char* s, T t, F ... f) {
	int i = 0; for (;; ++i) if (s[i] == ',') break;
	cout.write(s, i) << " : "; __p(t); cout << " | "; __f(s + i + 1, f...);
}
#define trace(...) { cout<<"LINE: "<<__LINE__<<" || "; __f(#__VA_ARGS__,__VA_ARGS__); cout<<"\n\n"; }
#define autra(...) { cout<<"LINE: "<<__LINE__<<" || "; __t(#__VA_ARGS__,__VA_ARGS__); cout<<"\n\n"; }
#else
#define trace(...) {}
#define autra(...) {}
#endif

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

const ll mod = 1000000007;  //998244353;
const ll inf = 0x3f3f3f3f3f3f3f3fLL;
const double eps = 1e-9;
const double PI = acos(-1);

ll i, j, k;
void solve(void);
inline bool equal(double a, double b) { return fabs(a - b) < eps; }
// inline ll gcd(ll a, ll b) { a=abs(a); b=abs(b); while(a>0 && b>0) (a>b?a%=b:b%=a); return (a==0?b:a); }
// inline ll power(ll x, ll n, ll m = LLONG_MAX)
//        {  ll res=1; x = (x%m + m)%m;
//             while(n) { if(n&1) res=(res*x)%m;  x=(x*x)%m;  n >>= 1; }  return res;
//        }

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
	cout << fixed << setprecision(10);
	int t = 1;
	// cin>>t;
	while (t--)  solve();
	return 0;
}

//***************** Code Starts Here *******************//

void solve()
{
	ll k, n; cin >> k >> n;
	ll a[n + 1] = {0}; rep(i, 1, n) cin >> a[i];

	vector<ll> v;
	rep(i, 2, n) v.pb(a[i] - a[i - 1]); v.pb(k - a[n] + a[1]);

	ll sum = 0;
	rep(i, 0, sz(v) - 2) sum += v[i];

	ll ans = sum;
	rep(i, 0, sz(v) - 1)
	{
		sum += v[(i + n - 1) % n] - v[i];
		ans = min2(ans, sum);
	}
	cout << ans << endl;

}

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

#define fast                     \
    ios::sync_with_stdio(false); \
    cin.tie(NULL);               \
    cout.tie(NULL)
#define int long long
#define endl '\n'
#define all(a)                   (a).begin(),(a).end()

#define Unique(A)                (A).resize(distance((A).begin(),unique(all((A)))))

using namespace std;

const int N = 2e5 + 77;

string s ;
int n ; 
int32_t main()
{
    fast;
    cin >> s;
    bool ok = true;
    
    regex R ("(dream|erase|dreamer|eraser)*");

    ok = (regex_match(s,R));
    if(ok) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 28236
def sweep(field, i, j)
  return field unless i.between?(0, 7)
  return field unless j.between?(0, 7)

  if field[j][i] == '1'
    field[j][i] = '0'
    1.upto(3) do |l|
      field = sweep(field, i + l, j)
      field = sweep(field, i - l, j)
      field = sweep(field, i, j + l)
      field = sweep(field, i, j - l)
    end
  end
  field
end
gets.to_i.times do |num|
  gets
  field = []
  8.times do
    field << gets.strip.split('')
  end
  i = gets.to_i - 1
  j = gets.to_i - 1
  field = sweep(field, i, j)
  puts "Data #{num + 1}:"
  field.each do |line|
    puts line.join
  end
end



Measured memory_bytes: 6968
#include <algorithm>
#include <iostream>
#include <vector>
#include <bitset>
using namespace std;

const int MAX_ROW = 2600; // to be set appropriately
const int MAX_COL = 2600; // to be set appropriately
struct BitMatrix {
    int H, W;
    bitset<MAX_COL> val[MAX_ROW];
    BitMatrix(int m = 1, int n = 1) : H(m), W(n) { }
    bitset<MAX_COL>& operator[] (int i) { return val[i]; }
};
int GaussJordan(BitMatrix &A, bool is_extended = false) {
    int rank = 0;
    for (int col = 0; col < A.W; ++col) {
        if (is_extended && col == A.W - 1) break;
        int pivot = -1;
        for (int row = rank; row < A.H; ++row) {
            if (A[row][col]) { pivot = row; break; }
        }
        if (pivot == -1) continue;
        swap(A[pivot], A[rank]);
        for (int row = 0; row < A.H; ++row) {
            if (row != rank && A[row][col]) A[row] ^= A[rank];
        }
        ++rank;
    }
    return rank;
}
int linear_equation(BitMatrix A, vector<int> b, vector<int> &res) {
    int m = A.H, n = A.W;
    BitMatrix M(m, n + 1);          // augmented matrix (A|B)
    for (int i = 0; i < m; ++i) {
        for (int j = 0; j < n; ++j) M[i][j] = A[i][j];
        M[i][n] = b[i];
    }
    int rank = GaussJordan(M, true);
    // check if it has no solution
    for (int row = rank; row < m; ++row) if (M[row][n]) return -1;
    // answer
    res.assign(n, 0);
    for (int i = 0; i < rank; ++i) res[i] = M[i][n];
    return rank;
};

long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n) {
		if (n & 1) (res *= a) %= mod;
		(a *= a) %= mod;
		n >>= 1;
	}
	return res;
}

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

int main() {
    int r, c; cin >> r >> c;
    BitMatrix A(r * c, r * c);
    vector<int> b(r * c), res;
    for (int i = 0; i < r; i++) {
        for (int j = 0; j < c; j++) cin >> b[i*c + j];
    }
    for (int i = 0; i < r; i++) {
        for (int j = 0; j < c; j++) {
            int cur = i*c + j;
            A[cur][cur] = 1;
            for (int k = 0; k < 8; k++) {
                for (int l = 1; l < 50; l++) {
                    int ni = i + dx[k]*l, nj = j + dy[k]*l;
                    if (ni < 0 || ni >= r || nj < 0 || nj >= c) break;
                    A[ni*c + nj][cur] = 1;
                }
            }
        }
    }
    int rank = linear_equation(A, b, res);
    if (rank == -1) cout << 0 << endl;
    else cout << modpow(2LL, r*c - rank, (int)1e9 + 9) << endl;
    return 0;
}


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

int volume[6] = { 200, 300, 500, 1000, 1200, 1500 };
int value[6]  = { 380, 550, 850, 1520, 1870, 2244 };
int n;
int dp[7][51];

int main()
{
	while (cin >> n, n)
	{
		for (int i = 0; i < 7; i++)
		{
			for (int j = 0; j < 51; j++)
			{
				dp[i][j] = 99999999;
			}
		}

		dp[0][0] = 0;
		for (int i = 1; i < 7; i++)
		{
			for (int j = 0; j < 51; j++)
			{
				int vol = volume[i - 1] / 100;
				int val = value[i - 1];
				if (j - vol < 0)
				{
					dp[i][j] = dp[i - 1][j];
				}
				else
				{
					dp[i][j] = min(dp[i - 1][j], dp[i][j - vol] + val);
				}
			}
		}

		cout << dp[6][n / 100] << endl;
	}

	return 0;
}

Measured memory_bytes: 2968
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define ALL(a)  (a).begin(),(a).end()
#define MOD 1000000007
 
int main(){
    int ABCD; cin >> ABCD;
    int A[4]; rep(i, 4) A[i] = (ABCD % (int)pow(10,4-i)) / pow(10,3-i);
    int N = 4;

    for(int bit = 0; bit < (1<<(N-1)); bit++){
        int sum = A[0];
        for(int i = 0; i<(N-1); i++){
            if(bit & (1<<i)) sum = sum + A[i+1];
            else sum = sum - A[i+1];
        }
        if(sum == 7){
            for(int i = 0; i<(N-1); i++){
                cout << A[i];
                if(bit & (1<<i)) cout << "+";
                else cout << "-";
            }
            cout << A[N-1] << "=7";
          	break;
        }
    }
}


Measured memory_bytes: 512
import java.util.Scanner;

/**
 * Created by srikanth on 04-02-2017.
 */
public class Main {
    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        int even=0,odd=0;
        int N=scan.nextInt();
        while(N-->0){
            int i=scan.nextInt();
            if(i%2==0){
                even++;

            }
            else{
                odd++;
            }
        }
        if(odd%2==1 && even>0)
            System.out.println("NO");
        else{
            System.out.println("YES");
        }
    }
}


Measured memory_bytes: 32212
[n, x] = list(map(int, input().strip().split(" ")))
a = list(map(int, input().strip().split(" ")))
sa = [0] * (n + 1)
sa[0] = 0
 
def calc(num):
    res = 0
    k = 0
    now = n - 1
    while (now >= 0):
        right = now
        left = max(0, now - num + 1)
        if (k == 0):
            res += 5 * (sa[right + 1] - sa[left])
        else:
            res += (2 * k + 3) * (sa[right + 1] - sa[left])
        k += 1
        now -= num
    return res + x * (num + n)
 
for i in range(n):
    sa[i+1] = sa[i]+a[i]
 
ans = 1000000000000000000000000000000000
for i in range(n):
    ans = min(ans, calc(i+1))
 
print(ans)

Measured memory_bytes: 26132
def main():
    K = int(input())
    mod = 7 % K
    mods = set([mod])
    if mod == 0:
        print(1)
        exit()
    ans = 1
    while True:
        ans += 1
        mod = (mod * 10 + 7) % K
        if mod == 0:
            print(ans)
            exit()
        elif mod in mods:
            print(-1)
            exit()
        else:
            mods.add(mod)


if __name__ == '__main__':
    main()


Measured memory_bytes: 200072
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
    long ans = 0;
    for (int i = 1; i <= K; i++) {
      for (int j = 1; j <= K; j++) {
        for (int k = 1; k <= K; k++) {
          ans += gcd(i, j, k);
        }
      }
    }
    System.out.println(ans);
  }

  static int gcd(int i, int j, int k) {
    return gcd(gcd(i, j), k); // i < j
  }

  static int gcd(int i, int j) {
    if (i > j) {
      return gcd(j, i);
    }
    if (i == 0) return j;
    return gcd(j % i, i);
  }
}


Measured memory_bytes: 35772
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int n=in.nextInt(),M[][]=new int[n][n];
		
		
		for(int i=0;i<n;i++) {
			int u=Integer.parseInt(in.next()),k=Integer.parseInt(in.next());
			for(int j=0;j<k;j++) {
				M[u-1][Integer.parseInt(in.next())-1]=1;
			}
		}
		
		for(int i=0;i<n;i++) {
			for(int j=0;j<n;j++) {
				if(j==n-1)System.out.println(M[i][j]);
				else System.out.print(M[i][j]+" ");
			}
		}
	}

}



Measured memory_bytes: 32220
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int x = (b-a) * (b-a+1) / 2 - b;
		System.out.println(x);
	}
}


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

#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define INFINITO 1000000000
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define vvi vector<vi>
#define all(x) x.begin(), x.end()
#define fo(i, n) for( int i = 0; i < n; i++ )


int main() {

    int n;
    cin >> n;
    vi h(n);

    fo(i, n) cin >> h[i];

    int cont = 0;
    int ans = 0;
    for ( int i = n - 2; i >= 0; i-- ) {
        if ( h[i] >= h[i + 1] ) {
            cont++;
            ans = max(ans, cont);
        } else {
            cont = 0;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
//s配列に格納した単語を、辞書順にソートする
//  sort(s.begin(), s.end());
//  string t = "keyence";//で文字列入力ができる
//s.empty() //emptyなら1を出力 入っていれば0を出力
/*//ABC018-B 部分的にreverseをかける解法
int main() {
  string s;
  cin >> s;
  int n;
  cin >> n;
  vector<int>a(n);
  vector<int>b(n);
  rep(i,n) cin>>a.at(i)>>b.at(i);
  rep(i,n)a.at(i)--;
  rep(i,n)b.at(i)--;
  string t;
  rep(i,n){
    t = s;
    for(int k=0;k<=b.at(i)-a.at(i);k++){
      t.at(a.at(i)+k) = s.at(b.at(i)-k);
    }
    s = t;
  }
  cout << s << endl;
}
*///ABC018-B
//  string s;
//  cin >> s;
//  cout << s.at(0) <<endl;
//  cout << s.at(0)-'0' <<endl;
//  Aが16？
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int kan_hyaku(int n){
  int kurai = 0;
  for(int i=0;i<3;i++){
    kurai = n%10;
    n /=10;
  }
  return kurai;
}
int kan_ju(int n){
  int kurai = 0;
  for(int i=0;i<2;i++){
    kurai = n%10;
    n /=10;
  }
  return kurai;
}
int kan_ichi(int n){
  int kurai = 0;
  for(int i=0;i<1;i++){
    kurai = n%10;
    n /=10;
  }
  return kurai;
}
int main() {
  ll n,m;
  cin >> n >> m;
  vector<ll>x(m);
  rep(i,m) cin >> x.at(i);
  if(n > m ){
    n = m;
  }
  if(m==1){
    cout << 0 << endl;
    return 0;
  }
  vector<ll>b(m-1);
  sort(x.begin(),x.end());
  for(int i=0;i<m-1;i++){
    b.at(i) = x.at(i+1) - x.at(i);
  }
  sort(b.begin(),b.end());
  reverse(b.begin(),b.end());
  for(int i=0;i<n-1;i++){
    b.at(i) = 0;
  }
  ll sum = 0;
  rep(i,m-1) sum += b.at(i);
  cout << sum << endl;
}

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

using namespace std;
using ll = long long;

void pr(int x) { cout << x; }
void pr(ll x) { cout << x; }
void pr(size_t x) { cout << x; }
void pr(const char* s) { cout << s; }
void pr(string& s) { cout << s; }
void pr(bool x) { cout << (x ? "true" : "false"); }

template <typename T1, typename T2>
void pr(const pair<T1, T2>& p) {
    pr("{ "); pr(p.first); pr(", "); pr(p.second); pr(" }");
}

template <typename T> 
void pr(T& v) {
    cout << "{";
    bool f = true; for (const auto& x : v) cout << (!f ? ", " : ""), f = false, pr(x);
    cout << "}";
}

void pd() { cout << "]" << endl; }

template <typename T, typename... U>
void pd(T first, U... rest) {
    pr(first); if (sizeof...(rest)) cout << ", "; pd(rest...);
}

#ifdef TESTING
#define dbg(x...) cout << "[" << #x << "] = [", pd(x)
#else
#define dbg(...)
#endif

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n, m; cin >> n >> m;
    int d[n];
    for (int i = 0; i < n; i++)
        d[i] = -1;
    for (int i = 0; i < m; i++) {
        int s, c; cin >> s >> c;
        if (d[s - 1] != -1 && d[s - 1] != c) {
            cout << -1 << endl;
            return 0;
        }
        d[s - 1] = c;
    }

    if (n == 1) {
        cout << max(0, d[0]) << endl;
        return 0;
    }

    if (d[0] == 0) {
        cout << -1 << endl;
        return 0;
    }

    string ans = "";
    bool trail = true;
    for (int i = 0; i < n; i++) {
        if (d[i] != -1) {
            ans += to_string(d[i]);
            trail = false;
        } else if (trail) {
            ans += "1";
            trail = false;
        } else {
            ans += "0";
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  ll N, cnt = 1;
  cin >> N;
  vector<string> S(N);
  for(ll i = 0; i < N; i++) cin >> S.at(i);
  sort(S.begin(), S.end());
  for(ll i = 1; i < N; i++) {
    if(S.at(i) != S.at(i - 1)) cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 9528
#include <bits/stdc++.h>
using namespace std;
int main(){
	
	int x=0,y=0,z=0;
	cin>>x>> y;
  if(x>=0&&y>=0){
	
	if(x+y>=24)
	 z=(x+y)-24;
	else
	 z=x+y;
}  
	  cout<<z;
	
}

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

int main() {
  int n;
  cin >> n;
  double ans = 0;
  rep(i,n){
    double a;
    string b;
    cin >> a >> b;
    if(b == "JPY") ans += a;
    else ans += a * 380000;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
typedef pair<int,int> pii;
const int NSIZ=1000010;
const int MSIZ=1000010;
const int mxint=-1u/2;
int n, m, o, re=0;
int a[NSIZ], b[NSIZ];
bool chk[NSIZ];
int main(){
	int i, j, k, l;
	scanf("%d", &n);
	for(i=1; i<=n; i++){
		scanf("%d", &a[i]);
	}
	sort(a+1,a+n+1,greater<int>());
	for(i=1; i<=n; i++){
		if(a[i]<i)break;
	}
	i--;
	bool ch=0;
	// printf("=%d\n", i);
	for(j=i; j<=n && a[j]>=i; j++);
	if((j-i-1)&1)ch=1;
	if((a[i]-i)&1)ch=1;
	if(ch)printf("First\n");
	else printf("Second\n");
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
int main(void){
    char a[20],b[20],i,j,k;
    scanf("%s",a);
    for(i=0;i<20;i++){
        if(a[i]=='\0'){
            break;
        }
        j++;
    }for(k=j-1;k>-1;k--){
        printf("%c",a[k]);
    }printf("\n");

return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  double l;
  cin >> l;

  double ans = (l / 3) * (l / 3) * (l / 3);
  cout << setprecision(10);
  cout << ans << ln;

  return 0;
}

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


#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;
typedef double ld;

ll mod = 1e9 + 7ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll inf = 1ll << 60;


int main() {
    string s;
    cin >> s;
    s.push_back('R');
    bool flag1 = true;
    bool flag2 = true;
    int point = 0;
    int start = 0;
    int change = 0;
    while(point < s.size()){
        if(flag1){
            if(s[point+1] == 'R') printf("%d ", 0);
            else{
                flag1 = false;
                change = point;
            }
        } else if(flag2){
            if(s[point+1] == 'R'){
                if((change-start)%2 == 1){
                    printf("%d ", (point - start + 1)/2);
                    printf("%d ", (point - start + 1)/2 + (point - start + 1)%2);
                } else {
                    printf("%d ", (point - start + 1)/2 + (point - start + 1)%2);
                    printf("%d ", (point - start + 1)/2);
                }
                rp(j, 0, point - change - 1) printf("%d ", 0);
                start = point + 1;
                flag1 = true;
                flag2 = true;
            }
        }
        point ++;
    }
    
}



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

typedef long long ll;

ll maxSubarrayXOR(ll a[], int n) {
    int index = 0;
    for(int i = 60; i >= 0; i--) {
        int pos = index;
        int f = 0;
        for(int j = index; j < n; j++) {
            if(a[j] & (1LL << i)) f = 1, pos = j;
        }
        if(!f) continue;
        swap(a[index], a[pos]);
        for(int j = 0; j < n; j++) {
            if(j != index && (a[j] & (1LL << i))) a[j] ^= a[index];
        }
        index++;
    }
    ll res = 0;
    for(int i = 0; i < n; i++) res ^= a[i];
    return res;
}

int n;
ll a[100010], ans = 0;
int main() {
    cin >> n;
    for(int i = 0; i < n; i++) {
        scanf("%lld", a+i);
        ans ^= a[i];
    }
    for(int i = 0; i < n; i++) a[i] &= ~ans;
    cout << ans + 2*maxSubarrayXOR(a, n);
}

Measured memory_bytes: 1024
import java.util.HashMap;
import java.util.Scanner;

class Main{

	static Scanner scanner = new Scanner(System.in);
	static HashMap<Integer, Integer> map;

	public static void main(String args[]){
		while(true){
			int n = scanner.nextInt();
			if(n == 0) break;
			map = new HashMap<Integer, Integer>();
			System.out.println(solve(n));
		}
	}

	static String solve(int n){
		int i = 0;
		Integer m;
		Integer num;
		String result = "NO COLOR";
		for(i = 0; i < n; i++){
			m = scanner.nextInt();
			num = map.get(m);
			if(num != null){
				num++;
				map.put(m, num);
				if(num > n/2) result = m + "";
			}else{
				map.put(m, 1);
				num = 1;
				if(num > n/2) result = m + "";
			}
			if(i % 50000 == 0) System.gc();
		}
		return result;
	}
}

Measured memory_bytes: 76648
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vl vector<ll>
#define vi vector<ll>
#define pi pair<ll,ll>
#define TC int t;cin>>t;while(t--)
#define in(n) ll n;cin>>n;
#define inarr(n) ll n;cin>>n;int arr[n];
int main(void){
    ll a,b;
    cin>>a>>b;
    char c;cin>>c;
    int d;cin>>d;
    b*=100;b+=d;
    cout<<(a*b)/100<<endl;
    return 0;
}

Measured memory_bytes: 3640
n = int(input())
s = list(input())
s2 = s[::-1]

pass_list = [ [ [ 0 for k in range(10) ] for j in range(10) ] for i in range(10) ]
lindex_list, rindex_list = [], []
for i in range(10):
    lindex = n
    si = str(i)
    for j in range(n):
        if s[j] == si:
            lindex = j
            break
    lindex_list.append(lindex)

    rindex = -1
    for j in range(n-1,-1,-1):
        if s[j] == si:
            rindex = j
            break
    rindex_list.append(rindex)

ans = 0
for i in range(10):
    for j in range(10):
        if lindex_list[i] != n and rindex_list[j] != -1:
            a_set = set([])
            for k in range(lindex_list[i]+1,rindex_list[j]):
                a_set.add(s[k])
            ans += len(a_set)
print(ans)

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

int a[51];
int n, m;

int main()
{
	cin >> n >> m;
	for(int i = 1; i <= n; i++) cin >> a[i];
	sort(a + 1, a + n + 1);
	int ans = 0;
	for(int i = n; i >= n - m + 1; i--) ans += a[i];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
// #define int ll
using PII = pair<int, int>;
 
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
 
template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
 
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); }
 
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}
 
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<40;
const ll MOD = 1000000007;

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

  ll n;
  cin >> n;
  n = 2*n-1;
  vector<ll> a(n);
  REP(i, n) cin >> a[i];
  
  //         0
  //       1,0,0
  //     1,0,1,0,0
  //   1,0,1,0,1,0,0
  // 1,0,1,0,1,0,1,0,0

  auto check = [&](ll mid) -> bool {
    vector<ll> v(n);
    REP(i, n) v[i] = a[i] >= mid;

    ll prev = 0;
    FOR(i, 1, n) {
      if(v[i] == v[i-1]) {
        if(prev < i-1) {
          if(v[prev] == v[i-1]) {
            FOR(j, prev, i) v[j] = v[prev];
          } else {
            ll x = (prev+i)/2;
            FOR(j, prev, x) v[j] = v[prev];
            FOR(j, x, i) v[j] = v[i];
          }
        }
        prev = i;
      }
    }
    if(prev < n-1) {
      if(v[prev] == v[n-1]) {
        FOR(j, prev, n) v[j] = v[prev];
      } else {
        ll x = (prev+n)/2;
        FOR(j, prev, x) v[j] = v[prev];
        FOR(j, x, n) v[j] = v[n-1];
      }
    }
    return v[n/2];

    // ll l = n/2, r = n/2;
    // while(l>0 && v[l] != v[l-1]) l--;
    // while(r<n-1 && v[r] != v[r+1]) r++;
    // if(v[l] != v[r]) {
    //   if(l+1 <= n/2) l++;
    //   else r--;
    // }
    // // cout << l << " " << r << endl;
    // if(n/2 < (l+r)/2) return v[l-1];
    // if((l+r)/2 < n/2) return v[r+1];
    // return v[l];
  };

  ll lb = 1, ub = n+1;
  while(ub-lb > 1) {
    ll mid = (lb+ub)/2;
    if(check(mid)) lb = mid;
    else ub = mid;
  }

  cout << lb << endl;

  return 0;
}


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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repp(i, n, m) for(int (i) = (n); (i) < (m); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define ldou long double
#define fi first
#define se second
#define setpre(x) std::cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ std::cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 5000*5000+5;

/* ...o(^-^)o... */

lint dp[MAX];

int main(){
    lint n, ga, sa, ba, gb, sb, bb;
    cin>>n>>ga>>sa>>ba>>gb>>sb>>bb;
    
    rep(i, n+1) dp[i] = 0;
    repn(i, n){
        dp[i] = dp[i-1];
        if(i >= ga) dp[i] = max(dp[i], dp[i-ga]+gb-ga);
        if(i >= sa) dp[i] = max(dp[i], dp[i-sa]+sb-sa);
        if(i >= ba) dp[i] = max(dp[i], dp[i-ba]+bb-ba);
    }
    lint m = dp[n] + n;

    rep(i, m+1) dp[i] = 0;
    repn(i, m){
        dp[i] = dp[i-1];
        if(i >= gb) dp[i] = max(dp[i], dp[i-gb]+ga-gb);
        if(i >= sb) dp[i] = max(dp[i], dp[i-sb]+sa-sb);
        if(i >= bb) dp[i] = max(dp[i], dp[i-bb]+ba-bb);
    }
    out(dp[m] + m);
}

Measured memory_bytes: 195584
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int xt, yt;
vector<int> x, y;
bool fx = 1;
string s;

bool check(vector<int> mv, int t) {
	vector<int> pos;
	pos.push_back(0);
	for (int i = 0; i < mv.size(); i++) {
		vector<int> nw;
		for (int j = 0; j < pos.size(); j++) {
			nw.push_back(pos[j] + mv[i]);
			nw.push_back(pos[j] - mv[i]);
		}
		sort(nw.begin(), nw.end());
		nw.resize(unique(nw.begin(), nw.end()) - nw.begin());
		pos = nw;
	}
	for (int i = 0; i < pos.size(); i++)
		if (pos[i] == t)
			return 1;
	return 0;
}

int main() {
	cin >> s >> xt >> yt;
	for (int i = 0; i < s.size();) {
		int cnt = 0, st = i;
		while (i < s.size() && s[i] == 'F')
			cnt++, i++;
		i++;
		if (st == 0)
			xt -= cnt;
		else if (fx)
			x.push_back(cnt);
		else
			y.push_back(cnt);
		fx = !fx;
	}
	if (check(x, xt) && check(y, yt))
		cout << "Yes";
	else
		cout << "No";
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
#define watch(x) cout << (#x) << " is " << (x) << endl
#define pb push_back
const int N=1e18;



int32_t main()
{

	
    IOS;
	

	int n;
	cin>>n;
	int A[n+1],B[n+1],C[n+1],a[n+1],b[n+1],c[n+1];
	
	for(int i=1;i<=n;i++)
	{
		cin>>a[i]>>b[i]>>c[i];
	}
	A[1]=a[1];
	B[1]=b[1];
	C[1]=c[1];
	for(int i=2;i<=n;i++)
	{
		A[i]=max(B[i-1],C[i-1])+a[i];
		B[i]=max(A[i-1],C[i-1])+b[i];
		C[i]=max(A[i-1],B[i-1])+c[i];
	}
	cout<<max(A[n],max(B[n],C[n]))<<endl;
	return 0;
}

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//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 SZ(a) int((a).size())
#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())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int main(int argc, char const* argv[])
{
    int N,M,Q;
    cin >> N >> M >> Q;
    VI L(M),R(M);
    VVI sum(N+1,VI(N+1.0));
    for (int i = 0; i < M; i++) {
        cin >> L[i] >> R[i];
        sum[L[i]][R[i]]++;
    }

    // 累積和のテーブル作成
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N; j++) {
            sum[i][j] += sum[i-1][j];
            sum[i][j] += sum[i][j-1];
            sum[i][j] -= sum[i-1][j-1];
        }
    }

    VI p(Q),q(Q);
    for (int i = 0; i < Q; i++) {
        cin >> p[i] >> q[i];
    }

    for (int i = 0; i < Q; i++) {
        int ans;
        int l = p[i],r = q[i];
        ans = sum[r][r] - sum[l-1][r] - sum[r][l-1] + sum[l-1][l-1];
        cout << ans << endl;
    }
    return 0;
}


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

using usize = ::std::size_t;
using u64 = ::std::int_least64_t;
//using u64 = int;
static constexpr u64 Inf = ::std::numeric_limits<u64>::max() / 2;

u64 n, E;
u64 H, W;
u64 d[310][310], w[310][310], A[310][310];
bool negative_cycle = false;


int main(int argc, char *argv[])
{
    
 
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> n;
    u64 total = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            cin >> A[i][j];
            total += A[i][j];
        }
    }
    
    
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= n; j++){
            d[i][j] = A[i][j];
        }
    }
    
    int overlap[310][310];
    memset(overlap, 0, sizeof(overlap));
    
    for (int k = 1; k <= n; k++){
        for (int i = 1; i <= n; i++){
            for (int j = 1; j <= n; j++){
                if(d[i][k] == Inf || d[k][j] == Inf) continue;
                if (d[i][j] > d[i][k] + d[k][j]) {
                    cout << -1 << endl;
                    return 0;
                } else if (d[i][j] == d[i][k] + d[k][j]){
                    if (!overlap[i][j] && (i != k) && (j != k)) {
                        total -= d[i][j];
                        overlap[i][j] = 1;
                    }
                }
            }
        }
    }
    
    cout << total / 2 << endl;
    
    return 0;
}


Measured memory_bytes: 5404
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
int n,m;
int num[1001];
int sum[1001*501+1];
int main(void){
  scanf("%d%d",&n,&m);
  while(n!=0){
    memset(sum,0,sizeof(sum));
    memset(num,0,sizeof(num));
    int i,j,cnt=0;
    num[0]=0;
    for(i=1;i<=n;i++){
      scanf("%d",&(num[i]));
    }
    for(i=0;i<=n;i++){
      for(j=i;j<=n;j++){
	sum[cnt]=num[i]+num[j];cnt++;
      }
    }
    sort(sum,sum+cnt);
       
    int ans=0;
    for(i=0;i<cnt;i++){
      if(sum[i]<=m){
	int mi,hi,tyu,tai;
	tai=m-sum[i];
	mi=0;hi=cnt-1;
	while(hi-mi>1){
	  tyu=(hi+mi)/2;
	  if(sum[tyu]<=tai){
	    mi=tyu;
	  }
	  else{
	    hi=tyu;
	  }
	}
	//printf("%d %d\n",sum[i],sum[mi]);
	if(tai-sum[mi]<m-ans){
	  ans=sum[mi]+sum[i];
	}
      }
      else break;
    }
    printf("%d\n",ans);
    scanf("%d%d",&n,&m);
  }
  return 0;
}

Measured memory_bytes: 3008
#include<cstdio>
#include<algorithm>
#define MN 101
using namespace std;
int n,m,w1,w,v[4][MN];
long long mmh=0,q[4][MN];
bool cmp(int a,int b){return a>b;}
int main(){
	register int i;
	scanf("%d%d",&n,&m);scanf("%d",&w1);
	v[0][0]=1;scanf("%d",&v[0][1]);
	for (i=1;i<n;i++){
		scanf("%d",&w);
		scanf("%d",&v[w-w1][++v[w-w1][0]]);
	}
	sort(v[0]+1,v[0]+v[0][0]+1,cmp);
	sort(v[1]+1,v[1]+v[1][0]+1,cmp);
	sort(v[2]+1,v[2]+v[2][0]+1,cmp);
	sort(v[3]+1,v[3]+v[3][0]+1,cmp);
	for (i=0;i<4;i++)
	for (int j=1;j<=v[i][0];j++) q[i][j]=q[i][j-1]+v[i][j];
	for (int i=0;i<=v[0][0];i++)
	for (int j=0;j<=v[1][0];j++)
	for (int k=0;k<=v[2][0];k++)
	for (int l=0;l<=v[3][0];l++)
	if (1LL*i*w1+1LL*j*(w1+1)+1LL*k*(w1+2)+1LL*l*(w1+3)<=m)
	if (q[0][i]+q[1][j]+q[2][k]+q[3][l]>mmh) mmh=q[0][i]+q[1][j]+q[2][k]+q[3][l];
	printf("%lld",mmh);
}

Measured memory_bytes: 128
let abcd = readLine()!.split(separator: " ").map { Int($0)! }
let (a, b, c, d) = (abcd[0], abcd[1], abcd[2], abcd[3])

var v0 = c / b
if c % b != 0 { v0 += 1 }
var v1 = a / d
if a % d != 0 { v1 += 1 }

if v0 <= v1 {
  print("Yes")
} else {
  print("No")
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

string S;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>S;
	int mi=101010;
	FOR(i,26) {
		int ma=0;
		x=0;
		FORR(c,S) {
			if(c=='a'+i) x=0;
			else x++;
			ma=max(ma,x);
		}
		mi=min(mi,ma);
	}
	cout<<mi<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,m,n) for(int i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())
#define de cout << "debug" << endl;
#define pb push_back
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    cin.tie(0);    
	ios::sync_with_stdio(false);
    int N;
    cin >> N;
    if(N == 0){
        cout << 0 << endl;
        return 0;
    }
    string S = "";
    int m;
    while(N){
        m = abs(N) % 2;
        S += to_string(m);
        N -= abs(N) % 2;
        N /= -2;
    }
    for(int i = S.size()-1;i >= 0;i--){
        cout << S[i];
    }
  cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
 
int main(void){
    ll n, m, p[1000010];
    while(cin>>n>>m){
        if(n+m==0) break;
        p[0]=0;
        ll maxp=0;
        for(ll i=1; i<=n; i++){
            cin >> p[i];
        }
        ll now=n+1;
        for(ll i=0; i<=n; i++){
            for(ll j=i; j<=n; j++){
                p[now++]=p[i]+p[j];
            }
        }
        sort(p, p+now);
        ll ans=0;
        for(int i=0; i<now; i++){
        ll maxa=m-p[i];
        if(maxa<0) continue;
        ll under=0, upper=now;
        while(upper-under>0){
            ll mid=(under+upper)/2;
            if(maxa>p[mid]){
                under=mid+1;
            }
            else if(maxa==p[mid]){
                break;
            }
            else{
                upper=mid;
            }
        }
        ans=max(ans, p[i]+p[upper-1]);
        }
        cout << ans << "\n";
         
    }
    return 0;
}


Measured memory_bytes: 6944
// Harlequin.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
using namespace std;

int n, x;
bool pos = true;

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x;
		if (x % 2 == 1) {
			pos = false;
		}
	}
	if (pos) {
		cout << "second" << endl;
	}

	else {
		cout << "first" << endl;
	}

	return 0;
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file


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

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

  vector<pair<int, int>> ab(N), cd(M);
  rep(i, N) {
    int a, b;
    cin >> a >> b;
    ab[i] = make_pair(a, b);
  }
  rep(i, M) {
    int c, d;
    cin >> c >> d;
    cd[i] = make_pair(c, d);
  }

  rep(i, N) {
    int point = 1;
    int dist = 1000000000;
    rep(j, M) {
      int d = abs(ab[i].first - cd[j].first) + abs(ab[i].second - cd[j].second);
      if (d < dist) {
        dist = d;
        point = j + 1;
      }
    }
    cout << point << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
/*
 * https://algo-logic.info/combination/
 */
const int MOD = 1000000007;


long long r_seq(long long x, long long p) {
  if(p==0)
    return 1;
  if(p % 2 == 0) {
    long long partial = r_seq(x, p/2);
    return ((partial % MOD) * (partial % MOD)) % MOD;
  }
  long long a = r_seq(x, p-1) % MOD;
  return ((x % MOD) * a) % MOD;
}

long long fact(long long start, long long end) {
  long long temp = 1;
  for (long long i= start;i<=end;i++) {
    temp *= i;
    temp %= MOD;
  }
  return temp % MOD;
}
long long qpow(long long a, long  long b, long long res){ //a^b
    while(b){
        if(b & 1) res = res * a % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return res;
};
long long getC(long long n, long long x) {
	if (x > n) return 0;
	long long res1 = 1, res2 = 1;
	for (long long i = n; i >= n - x + 1; i--) res1 = res1 * i % MOD;
	for (long long i = x; i >= 1; i--) res2 = res2 * i % MOD;
	return res1 * qpow(res2, MOD - 2, 1) % MOD;
};

long long bouquet(long long n, int a, int b) {
  // n種類のはなが1本ずつ
  long long all = (r_seq(2, n) - 1) % MOD;
  // cout << "all: " << all << endl; 
  long long nac = fact(n-a+1, n);
  // cout << "nac: " << nac << endl; 
  long long ac = fact(1, a);
//  cout << "ac: " << ac << endl; 
  long long comb_a = (nac * r_seq(ac, MOD-2)) % MOD;
//  cout << "comb_a: " << comb_a << endl;

  long long nbc = fact(n-b+1, n);
//  cout << "nac: " << nac << endl; 
  long long bc = fact(1, b);
 // cout << "bc: " << bc << endl; 
  long long comb_b = (nbc * r_seq(bc, MOD-2)) % MOD;
//  cout << "comb_b: " << comb_b << endl;
  long long sum = (comb_a + comb_b) % MOD;
  return ((all - sum) % MOD + MOD) % MOD;
}

int main() {
  long long n;
  int a, b;
  cin >> n;
  cin >> a;
  cin >> b;
  cout << bouquet(n, a, b);
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    
    int count = 0;

    for(int i = 1; i <= n; ++i){
      
      count += i;

    }
    
    System.out.println(count);
        
  }
}

Measured memory_bytes: 35820
using System;

namespace Make_Purse_Light
{
    class Program
    {
        private static void Main(string[] args)
        {
            int n, k, i = 0, q, j;
            int[] m, x = new int[4], y = new int[4], p = new int[] { 10, 50, 100, 500 };

            while (true)
            {
                n = int.Parse(Console.ReadLine());
                if (n==0) { break; }
                if (i!=0) { Console.WriteLine(); }
                i++;
                k = 0;
                m = Array.ConvertAll(Console.ReadLine().Trim().Split(' '), int.Parse);
                for (j = 3; j >= 0; j--)
                {
                    k += m[j] * p[j];
                }
                q = k - n;

                for (j = 3; j >= 0; j--)
                {
                    x[j] = q / p[j]; q -= x[j] * p[j];
                    y[j] = Math.Max(0, m[j] - x[j]);
                }

                for (j = 0; j < 4; j++)
                {
                    if (y[j]!=0) { Console.WriteLine("{0} {1}", p[j], y[j]); }
                }
            }
        }
    }
}


Measured memory_bytes: 9228
#include<bits/stdc++.h>
// __builtin_ctz : no of trailing zeros
#define int long long
#define ll long long
#define pp pair<int,int>
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;
int max(int x, int y)
{
    return x>y ? x : y;
}
int min(int x, int y)
{
    return x<y ? x : y;
}
void _(int&a , int b)
{
    a=(a%mod+b%mod)%mod;
    a=(a+mod)%mod;
}
ll cl(ll a,ll b)
{
    return (a/b)+(!(!(a%b)));
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;cin >> n;ll a[n];long double ans=1;
    for (int i = 0; i < n; ++i)
    {
    	cin >> a[i];if(a[i]==0){cout << 0;return 0;}
    }
    for (int i = 0; i < n; ++i)
    {
    	ans*=a[i];
    	if(ans>1000000000000000000){cout << -1;return 0;}
    }
    cout << setprecision(30) << ans;
    }

Measured memory_bytes: 4504