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

int main(){
    int R, G, B, N;
    cin >> R >> G >> B >> N;

    int64_t ans = 0;
    for(int r=0;r<=N;r++){
        for(int g=0;g<=N;g++){
            int ball = N - r*R - g*G;
            if(ball < 0 || ball % B != 0) continue;
            ans++;
        }
    }

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

Measured memory_bytes: 256
using System;
using System.Linq;

namespace AGC010_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Console.WriteLine(A.Where(a => a % 2 == 1).Count() % 2 == 0 ? "YES" : "NO");
        }
    }
}


Measured memory_bytes: 21728
n = gets.to_i
a = gets.split.map(&:to_i)

(n-1).times{|i|
  a[-i-2]-=1 if a[-i-2] > a[-i-1]
}

puts (n-1).times.map{|i|a[i]<=a[i+1]}.all? ? "Yes" : "No"

Measured memory_bytes: 9476
#include <iostream>
using namespace std;
int main(){
    int x,y,z;
    cin >> x>>y;
    if(x>y){
        while(1){
            if(y==0)break;
            z=y;
            y=x%y;
            x=z;
        }cout << x <<endl;
    }
    else{
        while(1){
            if(x==0)break;
            z=x;
            x=y%x;
            y=z;
        }cout<<y<<endl;
    }
}


Measured memory_bytes: 3068
<?php
$natural = explode(" ", trim(fgets(STDIN)));
sort($natural, SORT_NUMERIC);
$x = $natural[1];
$y = $natural[0];

$r = 1;
while ($y > 0) {
	list($x, $y) = array($y, $x % $y);
}
echo $x;
?>

Measured memory_bytes: 15432
#include <iostream>
#include <cstring>

using namespace std;

const int Z = 1e9+7;

int main() {
    int n, m;
    cin >> n >> m;
    bool f[n+1];
    memset(f, true, sizeof(f));
    for (int i = 0; i < m; i++) {
        int a;
        cin >> a;
        f[a] = false;
    }

    int dp[n+1];
    dp[0] = 1;
    dp[1] = f[1];
    for (int i = 2; i <= n; i++) {
        dp[i] = f[i] ? (dp[i-1] + dp[i-2]) % Z : 0;
    }

    cout << dp[n] << endl;

    return 0;
}


Measured memory_bytes: 768
#include"bits/stdc++.h"
//#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define print(x) cout<<x<<endl;
typedef long long ll;

int main() {
	int n, start = 0;
	ll a, b;
	ll x[100002];
	cin >> n >> a >> b;
	ll now = x[0],ans=0;
	rep(i, 0, n) { cin >> x[i]; }
	rep(i, 1, n) {
		if ((x[i] - x[i - 1])*a > b) {
			ans += b;
		}
		else if ((x[i] - x[i - 1])*a <= b) {
			ans += (x[i] - x[i - 1])*a;
		}
		now = x[i];
	}
	print(ans);
}

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

#define pb push_back
#define mp make_pair
#define ft first
#define sc second
#define ull unsigned long long int
#define lli long long int
#define li long int

#define si(n) scanf("%d",&n)
#define sl(n) scanf("%ld",&n)
#define sll(n) scanf("%lld",&n)

#define pi(n) printf("%d",n)
#define pl(n) printf("%ld",n)
#define pll(n) printf("%lld",n)

using namespace std;

const int MAX=2e5+5;

lli A[MAX];
int main() {
    // freopen("a.in","r",stdin);
    // freopen("a.out","w",stdout);
    lli N;
    cin >> N;
    for(lli i=0; i<N; i++) {
        cin >> A[i]; A[i] -= (i+1);
    }

    sort(A,A+N);

    lli val = A[(N>>1)];
    lli ans = 0;
    for(int i=0; i<N; i++) {
        ans += abs(A[i]-val);
    }

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<map>
#include<queue>
#include<set>
#include<bitset>
#include<stdio.h>
#include<deque>
#include<iomanip>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;

int main()
{
    int s;
    cin >> s;
    set<int> data;
    data.insert(s);
    int ans = 2;
    while(1){
        if(s % 2 == 0){
            s /= 2;
        }
        else{
            s = s*3+1;
        }
        if(!data.count(s)){
            data.insert(s);
            ans++;
        }
        else{
            cout << ans << endl;
            return 0;
        }
    }
}

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

 int main() {
   int N, D;
   int X[20][20];
   cin >> N >> D;
   for (int i = 0; i < N; i++) {
     for (int j = 0; j < D; j++) {
       cin >> X[i][j];
     }
   }

   int res = 0;
   for (int i = 0; i < N; i++) {
     for (int j = i+1 ; j < N; j++) {
       int a = 0;

       for (int k = 0; k < D; k++) {
         int diff =  abs(X[j][k] - X [i][k]);
         a += diff * diff;
       }
       bool flag = false;
       for (int k = 0; k <= a; k++) {
         if (k * k == a) {
           flag = true;
         }
       }
       if (flag) res++;
     }
   }
   cout << res << '\n';
 }


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
# define PI           3.14159265358979323846
int main(){
  int r,a;
  cin>>r>>a;
  int k=0;
  int ass=0;
for(int i=0;i<a;i++){
  cin>>k;
  ass+=k;
}
if( ass >r )
cout<<"-1";
else
cout<<(r-ass);

}


Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
//using System.Text;
//using System.Text.RegularExpressions;
//using System.Globalization;
//using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;
//using pair = Pair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;


    void solve()
    {
        int N = cin.nextint;
        int X = cin.nextint;
        int sum = 0;
        int min = int.MaxValue;
        for (int i = 0; i < N; i++)
        {
            int m = cin.nextint;
            sum += m;
            min = Math.Min(min, m);
        }
        WriteLine(N + Math.Max(0, X - sum) / min);
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin>>a.at(i);
    }
    int b,c;
    b = a.at(0);
    c = b;
    for(int i=0;i<n;i++){
        c = max(c, a.at(i));
        if(c-1>a.at(i)){
            cout<< "No" <<endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cmath>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <complex>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <unordered_map>

using namespace std;
typedef long long ll;

int main() {
	int n, a, b;
	cin >> n;
	cin >> a;
	cin >> b;
	vector<int> p((int)n);

	int score[3] = {0,0,0};
	for (int i = 0; i < n; ++i)
	{
		cin >> p[i];
		if (p[i] <= a) ++score[0];
		if (p[i] <= b && p[i] >a) ++score[1];
		if (p[i] >b) ++score[2];
	}

	int ans = 0;
	ans = min(score[0], min(score[1], score[2]));

	std::cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
//============================================================================
// Name        : AOL.cpp
// Author      : Akari Fujii
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cctype>
#include <string>
#include<algorithm>

using namespace std;



int main(){


	char a,b;

	cin>>a>>b;

	if(a=='H'&&b=='H'){
		cout<<"H"<<endl;
	}
	if(a=='H'&&b=='D'){
		cout<<"D"<<endl;
	}
	if(a=='D'&&b=='H'){
		cout<<"D"<<endl;
	}
	if(a=='D'&&b=='D'){
		cout<<"H"<<endl;
	}

	return 0;



}


Measured memory_bytes: 256
from collections import defaultdict,deque
from sys import stdin,setrecursionlimit
import heapq,bisect,math,itertools,string,queue,datetime,copy
setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, stdin.readline().split()))

x,y = inpl()

xx = (4*x-y)
yy = (y-2*x)

if xx >=0 and yy>=0 and xx%2==0 and yy%2==0:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 10740
import sys
import itertools
import bisect

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


n = ni()

li = make_divisors(n)
#print(li)
res = 10 ** 12 + 1
m = len(li)
for i in range(m//2 + 1):
    res = min(li[i] - 1 + li[-(i + 1)] - 1, res)
    # print(res, li[i] - 1 + li[-i] - 1)
print(res)





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

int main(){
    int d,n;
    cin>>d>>n;
    int ans=1;
    for(int i=0;i<d;i++){
        ans*=100;
    }
    if(n==100)cout<<ans*(n+1)<<endl;
    else cout<<ans*n<<endl;
    return 0;
}

Measured memory_bytes: 3520
#def main():
#    N = int(input())
#    S = input()
#    R = []
#    G = []
#    B = []
#    for i, s in enumerate(S):
#        if s == "R":
#            R.append(i)
#        elif s == "G":
#            G.append(i)
#        else:
#            B.append(i)
#    s = 0
#    for i in R:
#        for j in G:
#            for k in B:
#                if abs(i-j) != abs(j-k) and abs(i-j) != abs(k-i) and abs(j-k) != abs(k-i):
#                    s += 1
#    print(s)
#if __name__ == '__main__':
#    main()
N = int(input())
S = input()
r = S.count("R")
g = S.count("G")
b = S.count("B")
ans = r*g*b
for i in range(N):
    for j in range(i+1, N):
        k = 2*j -i
        if k >= N:
            continue
        if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
            ans -=1
print(ans)


Measured memory_bytes: 73728
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
    ll a,x;cin>>a>>x;
    if(a*500>=x){
                 cout<<"Yes"<<endl;
                 }
    else{cout<<"No"<<endl;}
}



Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;
int main(){
  int N,K;
  cin >> N >> K;
  map<int,int> mp;
  for(int i = 0;i < N;i++){
    int A;
    cin >> A;
    mp[A]++;
  }

  vector<pair<int,int>> balls;

  for(auto itr : mp){
    int num = itr.first;
    int num_of_balls = itr.second;

    balls.push_back(make_pair(num_of_balls,num));
  }


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

  int ans = 0;
  int deleted_kind = 0;

  for(int i = 0;i < balls.size();i++){
    if(balls.size() - deleted_kind > K){
      ans += balls[i].first;
      deleted_kind++;
    }
    else break;
  }

  cout << ans << endl;
}


Measured memory_bytes: 11768
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <iostream>
#include <queue>
#include <list>
#include <stack>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;

string pat[4] = {"..", ".#", "#.", "##"};

void dump(const string& s){
  for(int i=0; i<s.size(); i+=2){
    cout << s[i];
  }
  cout << endl;
  for(int i=1; i<s.size(); i+=2){
    cout << s[i];
  }
  cout << endl;
}

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

  string res;
  string st = "";
  bool back = true;
  while(true){
    bool flg = false;
    rep(i,4){
      string tmp;
      if(back) tmp = st + pat[i];
      else tmp = pat[i] + st;
      dump(tmp);
      cin >> res;
      if(res == "end") return 0;
      if(res == "T"){
        st = tmp;
        flg = true;
        break;
      }
    }
    if(!flg){
      back = false;
    }
  }

  return 0;
}



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

int main() {
  int Z, N;
  int enable = 0;
  cin >> N;

  for(int i = 0; i < N; i++) {
    cin >> Z;
    for(int y = 1; y * y < Z; y++) {
      if(((Z - y) % (2 * y + 1)) == 0) {
        enable++;
        break;
      }
    }
  }
  cout << (N - enable) << endl;
  return 0;
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    ll h,w,n;cin >>h>>w>>n;
    n--;
    ll ans=min(n/h,n/w);
    ans++;
    cout <<ans <<endl;
    return 0;
}

Measured memory_bytes: 256
#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++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

bool G[50][50];
vector<bool> seen;

void dfs(int v, int N){
  seen[v] = true;
  REP(v1, N){
    if(G[v][v1]==false || seen[v1]==true) continue; 
	dfs(v1, N);
  }
}
    
int main()
{
  int N,M;
  cin >> N >> M;
  vector<int> a(M),b(M);
  REP(i,M){
    cin >> a[i] >> b[i];
	a[i]--;
    b[i]--;
    G[a[i]][b[i]] = true;
    G[b[i]][a[i]] = true;
  }
  int ans = 0;
  REP(i,M){
    G[a[i]][b[i]] = false;
    G[b[i]][a[i]] = false;
    seen.assign(N, false);
    dfs(0, N);
  	REP(n,N){
      if(seen[n]==false){
        ans++;
        break;
      }
    }
    G[a[i]][b[i]] = true;
    G[b[i]][a[i]] = true;
  }
  cout << ans << '\n';
  return 0;
}

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

int main(){
    int n;
    cin>>n;
    vector<int>a(n);
    rep(i,n)cin>>a[i];
    ll ans=1000;
    rep(i,n-1){
        if(a[i]<a[i+1]){
            ll x=(ans/a[i])*a[i];
            ans-=x;
            ans+=(x/a[i])*a[i+1];
        }
    }
    cout<<ans<<endl;
}

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

int main(){
  int r,c;
  cin>>r>>c;
  int a[r][c],b[r],d[c],e=0;
  for(int s=0;s<c;s++){
    d[s]=0;
  }
  for(int i=0;i<r;i++){
    b[i]=0;
    for(int j=0;j<c;j++){
	cin>>a[i][j];
	b[i]+=a[i][j];
	d[j]+=a[i][j];
    }
  }
  for(int k=0;k<r;k++){
    for(int l=0;l<c;l++){
      cout<<a[k][l]<<" ";
    }
    cout<<b[k]<<endl;
  }
  for(int o=0;o<c;o++){
    cout<<d[o]<<" ";
    e+=d[o];
  }
  cout<<e<<endl;
  
  return 0;
}


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;
// vector<vector<int>> data(3, vector<int>(4));

void solve(long long N, long long K, vector<long long> A, vector<long long> B){
	set<ll> mask;
	ll now = 0;
	for(ll i = 30; i > 0; i--) {
		if (K&(1<<(i-1))) {
			mask.insert(now+(1<<(i-1))-1);
			now += 1<<(i-1);
		}
	}
	mask.insert(now);
	map<ll, ll> m;
	rep(i, N) {
		for (auto x : mask) {
			if ((A[i] | x) == x) m[x] += B[i]; 
		}
	}
	ll res = 0;
	for (auto x : mask) {
		// cout << x << " " << m[x] << endl;
		res = max(res, m[x]); 
	}
	cout << res << endl;
}

int main(){	
	long long N;
	long long K;
	scanf("%lld",&N);
	vector<long long> B(N-1+1);
	vector<long long> A(N-1+1);
	scanf("%lld",&K);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&A[i]);
		scanf("%lld",&B[i]);
	}
	solve(N, K, A, B);
	return 0;
}



Measured memory_bytes: 3456
#include<cstdio>
#include<cstdlib>
#define MAX 10000

int main(){
        int n;
        int *a, *b, *c;
        scanf("%d", &n);
        a = (int *) malloc(sizeof(int)*n);
        b = (int *) malloc(sizeof(int)*n);
        c = (int *) malloc(sizeof(int)*MAX);
        for(int i=0;i<n;i++) scanf("%d", &a[i]);
        for(int i=0;i<MAX;i++) c[i] = 0;

        for(int i=0;i<n;i++) c[a[i]] += 1;
        for(int i=0;i<MAX-1;i++) c[i+1] += c[i];
        for(int i=n-1;i>=0;i--){
                b[c[a[i]]-1] = a[i];
                c[a[i]] -= 1;
        }

        for(int i=0;i<n;i++)
                if(i<n-1) printf("%d ", b[i]);
                else  printf("%d\n", b[i]);
        return 0;
}


Measured memory_bytes: 18432
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define ms(x, n) memset(x, n, sizeof(x));
typedef vector<int> VI;
typedef long long ll;
typedef pair<int, int> PII;
const ll mod = 1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    string S, T;
    ll s, t;
    cin >> s >> t;
    cin >> S >> T;
    ll c = s/gcd(s, t)*t;
    ll a = c/s, b = c/t;
    bool ok = true;
    rep(i, 0, t) {
        if(b*i%a == 0 && S[b*i/a] != T[i]) {
            ok = false;
            break;
        }
    }
    if(ok) cout << c << endl;
    else cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 640
{-# LANGUAGE BangPatterns #-}
import           Control.Exception           (assert)
import           Control.Monad
import           Control.Monad.Primitive
import qualified Control.Monad.ST            as ST
import qualified Data.Array.IO               as IO
import qualified Data.Array.ST               as ST
import qualified Data.Array.Unboxed          as A
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Foldable
import           Data.List
import           Data.Maybe
import qualified Data.Sequence               as Seq
import qualified Data.Set                    as Set
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM
import           Debug.Trace

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

readInteger = fst . fromJust . BS.readInteger
readIntegerList = map readInteger . BS.words
getInteger = readInteger <$> BS.getLine
getIntegerList = readIntegerList <$> BS.getLine

inf :: Int
inf = 10^18

main = do
  [a, b, c, d] <- getIntList


  let game turn hpt hpa
        | turn == 0 = {- takahashi's turn -}
            let hpa' = hpa - b
            in if hpa' <= 0
               then 0
               else game 1 hpt hpa'
        | otherwise = {- aoki's turn -}
            let hpt' = hpt - d
            in if hpt' <= 0
               then 1
               else game 0 hpt' hpa

      res = game 0 a c

      ans = if res == 0 then "Yes" else "No"

  putStrLn ans

Measured memory_bytes: 3784
n,k,q = map(int,input().split())
start = [k-q]*n
answerlist = [int(input()) for _ in range(q)]
for i in tuple(answerlist):
  start[i-1] = start[i-1]+1
for i in range(n):
  if start[i]<=0:
    print("No")
  else:
    print("Yes")



Measured memory_bytes: 10476
#ifdef LOCAL_BUILD
#include "pch.h"
#define DLOG(msg) cout << "#" << __LINE__ << ":" << msg << endl;
#else
#include <bits/stdc++.h>
#define DLOG(msg)
#endif
using namespace std;

int main() {
  string s;
  cin >> s;
  stack<size_t> descends;
  size_t total = 0;
  size_t d = 0;
  vector<pair<size_t, size_t>> areas;
  for (size_t i = 0; i < s.size(); ++i) {
    auto c = s[i];
    if (c == '\\') {
      descends.push(i);
    } else if (c == '/') {
      if (!descends.empty()) {
        d = descends.top();
        descends.pop();
        total += i - d;
        size_t cur = 0;
        for (auto it = areas.begin(); it != areas.end();) {
          if (it->first > d) {
            cur += it->second;
            it = areas.erase(it);
          } else {
            ++it;
          }
        }
        areas.push_back(make_pair(d, cur + i - d));
      }
    }
  }

  cout << total << endl;
  cout << areas.size();
  for (auto&& area : areas) {
    cout << " " << area.second;
  }
  cout << endl;
}

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

using namespace std;

int kq;

void    init()
{
    freopen("a.inp","r",stdin);
    freopen("a.out","w",stdout);
}

void    xuly()
{
    char x,y,z;
    cin>>x>>y>>z;
    kq=700;
    if (x=='o') kq+=100;
    if (y=='o') kq+=100;
    if (z=='o') kq+=100;
    cout<<kq;
}

int     main()
{
    //init();
    xuly();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    int a,b,x;
    cin>>a>>b>>x;
    double ans;
    if(a*a*b>=2*x){
        ans=atan2(a*b*b,2.0*x)*(180.0/M_PI);
    }
    else{
        ans=atan2(2.0*(a*a*b-x),a*a*a)*(180.0/M_PI);
    }
    cout<<fixed<<setprecision(10)<<ans<<endl;
}

Measured memory_bytes: 384
import java.util.*;

public class Main
{
	public static void main(String[] args)
	{
		Scanner s=new Scanner(System.in);
		
		int n=s.nextInt();
		int[] a=new int[n];
		
		for(int i=0;i<n;i++)
		{
			a[i]=s.nextInt();
		}
		
		int count=0;
		int num=1;
		
		for(int i=0;i<n;i++)
		{
			if(a[i]==num)
			{
				count++;
				num++;
			}
		}
		
		if(count==0)
		{
			count=-1;
		}
		else
		{
			count=n-count;
		}
		System.out.println(count);
		
		s.close();
		
	}
}


Measured memory_bytes: 74164
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int N;
	cin >> N;

	int P[100001];
	rep1(i, N) {
		int p;
		cin >> p;
		P[p] = i;
	}
	set<int> ST;
	ST.insert(N + 1);
	ST.insert(0);
	ll kotae = 0;
	for (int i = N; i >= 1; i--) {
		int p = P[i];

		auto itr1 = ST.lower_bound(p);
		auto itr2 = itr1--;

		int l = *itr1;
		int r = *itr2;

		int kari = 0;
		if (r != N + 1) {
			int r2 = *(++itr2);
			kari += (ll)(p - l) * (r2 - r);
		}
		if (l != 0) {
			int l2 = *(--itr1);
			kari += (ll)(r - p) * (l - l2);
		}
		kotae += (ll)kari * i;
		ST.insert(p);
	}

	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REP(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define rep1(i,x,n) for(int (i)=(x);(i)<(int)(n);(i)++)
#define REP1(i,x,n) for(int (i)=(x);(i)<=(int)(n);(i)++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using Int = long long;

//INT_MAX = 2147483647;
//LLONG_MAX = 9223372036854775807;
//ULLONG_MAX = 18446744073709551615;
const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;
typedef pair<int,int> P;
typedef std::priority_queue<int> IntPrioQueue;
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue;

//少数点表示
//cout << std::fixed << std::setprecision(14) << 値

int main(){
    cin.tie( 0 ); ios::sync_with_stdio( false );
    int n,k;
    cin >> n >> k;
    int ans=0;
    vector<int> p;

    rep(i,n){
        int a;
        cin >> a;
        p.push_back(a);
    }

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

    rep(i,k){
        ans += p[i];
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3612
import java.util.Scanner;

// https://atcoder.jp/contests/abc144/tasks/abc144_c
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		sc.close();

		for(long i=(long) Math.sqrt(N);i>=1;i--) {
			if(N%i==0) {
				System.out.println(i+N/i-2);
				break;
			}
		}
	}
}

Measured memory_bytes: 21844
n = gets.to_i
sum = 0.0
n.times do 
  a = gets.split(" ").map!{|i| i.to_s}
  if a[1] == "JPY"
    sum += a[0].to_f
  else sum += 380000.0*a[0].to_f
  end
end
puts sum


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

double d[8][8];
double ans;
int n;

void foreach_permutation(int n, std::function<void(int *)> f) {
  int indexes[n];
  for (int i = 0; i < n; i++) indexes[i] = i;
  do {
    f(indexes);
  } while (std::next_permutation(indexes, indexes + n));
}

int f(int n){
	if (n >1){
		return n*f(n-1);
	}
	else{
		return 1;
	}
}

int main(){
	int z,y;
	cin >> n;
	vector<P> x(n);
	for (int i = 0;i < n;i++){
		cin >> z >> y;
		x[i].fs = z;
		x[i].sc = y;
	}
	for(int i = 0;i < n;i++){
		for(int j = 0;j<n;j++){
			d[i][j]=sqrt(double((x[j].fs - x[i].fs)*(x[j].fs - x[i].fs) +(x[j].sc - x[i].sc)*(x[j].sc - x[i].sc)));
		}
	}
	foreach_permutation(n, [](int *indexes) {
    for(int i = 0;i < n -1;i++){
		ans +=d[indexes[i]][indexes[i+1]];
	}
  });
	ans /=double(f(n));
	cout << fixed << setprecision(10)<< ans <<endl;





	return 0;
}

Measured memory_bytes: 256
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r#"1
24 30"# => r#"7"#,
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        n: usize,
        lr: [(usize, usize); n],
    }

    let mut ans = 0;
    for i in 0..n {
        ans += 1 + lr[i].1 - lr[i].0;
    }
    ans.to_string()
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ld long double
#define dd double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;
typedef vector<pll> vplll;
ll mod = 1e9+7;
const ld PI = 2 * acos(0.0);
const vector<ll> dx = {1, -1, 0, 0};
const vector<ll> dy = {0, 0, 1, -1};
#define round(x, y) ((x + y - 1) / y)
#define ce(x, y) ((x + y - 1) / y)
#define amax(x, y) \
    if (y > x)     \
        x = y;
#define amin(x, y) \
    if (y < x)     \
        x = y;
#define lcm(x, y) ((x) * (y) / __gcd(x, y))
#define len(x) (ll) x.length()
#define sq(x) ((x) * (x))
#define cb(x) ((x) * (x) * (x))
const int N = 1e5+1;
ll dp[101][N];
ll ar[101][2];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,c,t,n,m,k,q,w; 
    t = 1;
    // cin>>t;
    while(t--)
    {
    	memset(dp,0,sizeof(dp));
    	ll n;
    	cin>>n>>w;
    	for(int i=1;i<=n;i++)
    		cin>>ar[i][0]>>ar[i][1];
    	for(int i=1;i<=n;i++)
    	{
    		for(int j=1;j<=w;j++)
    		{
    			if(j>=ar[i][0])
    				dp[i][j] = max(dp[i-1][j],dp[i-1][j-ar[i][0]]+ar[i][1]);
                else 
                    dp[i][j] = dp[i-1][j];
    		}
    	}
    		cout<<dp[n][w]<<endl;
    }
    return 0;
}

Measured memory_bytes: 79232
#include<stdio.h>
int gcd(int a,int b){
	int r=a>b?a%b:b%a;
	if(!r)return a>b?b:a;
	else gcd(r,a>b?b:a);
}
int main(){
	int a,b;
	while(~scanf("%d %d",&a,&b)){
		int AnsGcd=gcd(a,b);
		printf("%d %d\n",AnsGcd,a/AnsGcd*b);
	}
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<vector>
#include<utility>
#include<cmath>
using namespace std;
#define pb push_back
typedef long long ll;
#define rep(i, a, b) for(ll i=(a); i<(b); i++)

ll a[100000];
int main(){
  ll N,div=0,sum = 0, adjust=0;
  vector<pair<ll, ll> > res;
  vector<ll> later;
  cin >> N;
  rep(i,0,N){
    cin>> a[i];
    sum += abs(a[i]);
  }
  sort(a,a+N);
  if(N == 2){
    cout<< a[1]-a[0]<<endl;
    cout << a[1] <<" " <<a[0]<<endl;
    return 0;
  }

  
  if(a[0] < 0 && a[N-1] >= 0){ 
    rep(i,1,N-1){
      if(a[i] > 0){
	res.pb(make_pair(a[0],a[i]));
	a[0] -= a[i];
      }else later.pb(i);
    }
    later.pb(0);
    rep(i,0,later.size()){
      res.pb(make_pair(a[N-1],a[later[i]]));
      a[N-1] -= a[later[i]];
    }
  }

  
  if(a[0]<0 && a[N-1] < 0){
    sum = abs(sum);
    sum += a[N-1] * 2;
    rep(i,0,N-1){
      res.pb(make_pair(a[N-1],a[i]));
      a[N-1] -= a[i];
    }
  } 
  if(a[0]>=0 && a[N-1] >=0){
 
    sum -= (a[0] * 2);
    rep(i,1,N-1){
      res.pb(make_pair(a[0],a[i]));
      a[0] -= a[i];
    }
    res.pb(make_pair(a[N-1],a[0]));
    a[N-1] -=a[0];
  }

  cout<< sum << endl;
  rep(i,0,res.size()){
    cout << res[i].first << " " << res[i].second << endl;
  }
}

Measured memory_bytes: 5104
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, k, x, y;
    cin >> n >> k >> x >> y;
    if (n <= k) cout << n * x;
    else cout << k * x + (n - k) * y;
}


Measured memory_bytes: 256
x[100],y[100];i,j,k;
float p[101],s,P=2*acos(-1);
c(a,b)float*a,*b;{return*a<*b?-1:*a>*b;}
main(n){
	for(scanf("%d",&n);~scanf("%d%d",x+j++,y+j););
	for(;i<n;i++){
		for(k=j=0;j<n;j++)i-j&&(p[k++]=atan2(y[j]-y[i],x[j]-x[i]));
		qsort(p,k,4,c);
		for(p[k]=p[j=s=0]+P;++j<n;)s=fmax(s,(p[j]-p[j-1])/P-.5);
		printf("%.6f\n",s);
	}
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
#include <utility>
#include <stack>
using namespace std;
using ll = long long;
int main()
{
	ll a, b, c=0, d;
	cin >> a;
	cin >> b;
	ll x[10000];
	for (int i = 0; i < a; i++)
	{
		cin >> x[i];
	}
	sort(x,x+a, greater<ll>());
	for (int i = 0; i < b; i++)
	{
		c += x[i];
	}

		cout << c << endl;

	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
Ans = list(map(int, input().split()))
Ans = Ans[1:]
Ans = set(Ans)

for _ in range(N-1):
    A = list(map(int, input().split()))
    A = set(A[1:])
    Ans = Ans & A
print(len(Ans))

Measured memory_bytes: 62324
#include <stdio.h>

int grid[14][14] = {0};

int main(void)
{
	int x, y, s;
	int count = 0;
	int max = 0;
	int i, j;

	while (scanf("%d,%d,%d", &x, &y, &s) != EOF) {		
		x += 2;
		y += 2;

		switch (s) {
		case 3:
			grid[x][y + 2]++;
			grid[x][y - 2]++;
			grid[x + 2][y]++;
			grid[x - 2][y]++;
				
		case 2:
			grid[x + 1][y + 1]++;
			grid[x - 1][y + 1]++;
			grid[x + 1][y - 1]++;
			grid[x - 1][y - 1]++;

		case 1:
			grid[x][y + 1]++;
			grid[x][y - 1]++;
			grid[x + 1][y]++;
			grid[x - 1][y]++;
			grid[x][y]++;
			break;
		default:
			break;
		}
	}

	for (i = 2; i < 12; i++) {
		for (j = 2; j < 12; j++) {
			if (grid[i][j] == 0) {
				count++;
				continue;
			}
			if (grid[i][j] > max) {
				max = grid[i][j];
			}
		}
	}

	printf("%d\n%d\n", count, max);
	
	return 0;
}

Measured memory_bytes: 600
n=int(input())
v=list(input().split())
v0={}
v1={}
for i in range(0,n,2):
    if v[i] in v0:
        v0[v[i]]+=1
    else:
        v0[v[i]]=1
for i in range(1,n,2):
    if v[i] in v1:
        v1[v[i]]+=1
    else:
        v1[v[i]]=1
v0=sorted(v0.items(), key=lambda x:x[1], reverse=True)
v1=sorted(v1.items(), key=lambda x:x[1], reverse=True)
if v0[0][0]==v1[0][0]:
    if len(v0)==1:
        print(int(n/2))
    else:
        print(n-v0[0][1]-(v0[1][1] if v0[1][1]>v1[1][1] else v1[1][1] ))
else:
    print(n-v0[0][1]-v1[0][1])

Measured memory_bytes: 19892
import java.util.Scanner;

/**
 * コンソールテスト用Main クラス
 *
 * @author RisaTozawa
 */
public class Main {

	/* コンストラクタ */
	Main() {
	//何もしない
	}

	/**
	 * Atcorder 提出
	 * @return
	 *
	 */

	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int A;
		String B = "";
		int C;
		int result = 0;

		A = scanner.nextInt();
		B = scanner.next();
		C = scanner.nextInt();

		if (B.equals("+")) {

			result = A + C;
		} else {
			result = A - C;
		}
		System.out.println(result);
	}
}


Measured memory_bytes: 26864
s=raw_input().strip()
t=raw_input().strip()
n=len(s)
m=len(t)
z=[[0]*(m+1) for _ in xrange(n+1)]
for i in xrange(n):
    for j in xrange(m):
        if s[i]==t[j]:
            z[i+1][j+1]=z[i][j]+1
        else:
            z[i+1][j+1]=max(z[i+1][j],z[i][j+1])
i=n-1
j=m-1
a=[]
while i>=0 and j>=0:
    if s[i]==t[j]:
        a.append(s[i])
        i-=1
        j-=1
    elif z[i][j+1]>z[i+1][j]:
        i-=1
    else:
        j-=1
print ''.join(a[::-1])

Measured memory_bytes: 102428
open Scanf
open Printf

let flip f x y = f y x

let rec range a b = if a >= b then [] else a :: range (a+1) b

let read_int () = scanf " %d" (fun x -> x)
let rec read_ints n = if n = 0 then [] else let i = read_int () in i :: read_ints (n-1)

let rec for_iter a b f = if a >= b then [] else let x = f a in x :: for_iter (a+1) b f
let rec for_iter_ a b f = if a >= b then () else (f a; for_iter_ (a+1) b f)

let list_of_string str =
  let len = String.length str in
  let rec f i = if i >= len then [] else str.[i] :: f (i+1) in
  f 0

let lim_width = 16006
let cp = lim_width / 2

type axis = X | Y

let swt ax = match ax with X -> Y | Y -> X

let rec parse ax acc xs =
  match xs with
  | [] -> if acc = 0 then [] else [(acc, ax)]
  | (x::xs') ->
      if x = 'T' then
        if acc = 0 then parse (swt ax) 0 xs'
        else (acc, ax) :: parse (swt ax) 0 xs'
      else parse ax (acc+1) xs'

let () =
  let s0::_ as s = read_line () |> list_of_string in
  let [xp; yp] = read_ints 2 in
  let f_first = s0 = 'F' in
  let steps = parse X 0 s in
  let xs' = steps |> List.filter (fun z -> snd z = X) |> List.map fst in
  let (x0, xs) = match xs' with
  | (z::zs) when f_first -> (z, zs)
  | _                    -> (0, xs') in
  let ys = steps |> List.filter (fun z -> snd z = Y) |> List.map fst in

  let dp = Array.make lim_width 0 in
  let bak = Array.make lim_width 0 in

  let result = List.for_all (fun (ss, src, dst) ->
    Array.fill dp 0 lim_width 0; dp.(src) <- 1;
    List.iter (fun s ->
      Array.fill bak 0 lim_width 0;
      for_iter_ 0 lim_width (fun i ->
        if dp.(i) = 1 then (
          if i-s >= 0        then bak.(i-s) <- 1;
          if i+s < lim_width then bak.(i+s) <- 1));
      for_iter_ 0 lim_width (fun i ->
        dp.(i) <- bak.(i));
    ) ss;
    dp.(dst) = 1) [(xs, cp+x0, cp+xp); (ys, cp, cp+yp)] in

  print_endline @@ if result then "Yes" else "No"


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

template<typename T>
istream& operator >> (istream& istr, vector<T>& v){
    for(T& x: v) istr >> x;
    return istr;
}

template<typename T, typename U>
istream& operator >> (istream& istr, pair<T,U>& p){
    istr >> p.first >> p.second;
    return istr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<T>& v){
    if(!v.empty()){
        ostr << v.front();
        for(auto itr = ++v.begin(); itr != v.end(); itr++)
            // ostr << *itr;
            ostr << " " << *itr;
    }
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, pair<T,U>& p){
    // ostr << p.first << p.second;
    ostr << p.first << ", " << p.second;
    return ostr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<vector<T>>& vv){
    if(!vv.empty()){
        ostr << vv.front();
        for(auto itr = ++vv.begin(); itr != vv.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, vector<pair<T,U>>& vp){
    if(!vp.empty()){
        ostr << vp.front();
        for(auto itr = ++vp.begin(); itr != vp.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

typedef long long ll;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<double> vd;
// vll x(n); x[i]=a;
typedef vector<vll> vvll;
typedef vector<vc> vvc;
typedef vector<vd> vvd;
// vvll x(m,vi(n)); x[i][j]=a;
typedef pair<ll,ll> pll;
typedef pair<double,double> pd;
typedef vector<pll> vpll;
typedef vector<pd> vpd;
// vpll x(n); x[i]={a,b}; x[i].first/second;

#define PI 3.1415926535897932
#define EPS 1e-12
#define INF (ll)1e12
#define REP(i,n) for(ll i=0; i<(n); i++)
#define RREP(i,n) for(ll i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORR(i,a,b) for(ll i=(b)-1; i>=(a); i--)
#define fix(x) cout << fixed << setprecision(x)
#define dump(x) cout << #x << " = " << (x) << endl
#define all(x) (x).begin(),(x).end()

template<typename T> T sum(vector<T>& v) {return accumulate(all(v), (T)0LL);}
template<typename T> inline void sort(vector<T>& v){sort(all(v));}
template<typename T> inline void rsort(vector<T>& v){sort(all(v), greater<T>());}
template<typename T> inline void chmin(T& a, T b){if(a>b) a=b;}
template<typename T> inline void chmax(T& a, T b){if(a<b) a=b;}

int main(){
    ll n, ans=0;
    cin >> n;
    vll a(n), b(n), c(n);
    vvll dp(n, vll(3, 0));
    REP(i,n) cin >> a[i] >> b[i] >> c[i];

    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];
    FOR(i,1,n){
        chmax(dp[i][0], dp[i-1][1]+a[i]);
        chmax(dp[i][0], dp[i-1][2]+a[i]);
        chmax(dp[i][1], dp[i-1][2]+b[i]);
        chmax(dp[i][1], dp[i-1][0]+b[i]);
        chmax(dp[i][2], dp[i-1][0]+c[i]);
        chmax(dp[i][2], dp[i-1][1]+c[i]);
    }
    REP(i,3) chmax(ans, dp[n-1][i]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8064
#include<iostream>
#include<algorithm>
#include<climits>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define scan(arg) cin>>arg
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){//ユークリッドの互除法
  if(b==0) return a;
  else return gcd(b,a%b);
}
ll lcd(ll a,ll b){
  ll c=a/gcd(a,b);
  return b*c;
}

int n;
ll t[110];

int main(){
  cin>>n;
  rep(i,n){
    cin>>t[i];
  }
  ll res=t[0];
  rep1(i,n-1){
    res=lcd(res,t[i]);
  }

  prin(res);


  

  return 0;
}


Measured memory_bytes: 256
#ifdef __GNUC__
#pragma GCC target("avx2")
#pragma GCC optimize ("O20")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC optimize("unroll-loops")
#define iss std::cin
#endif
#include "bits/stdc++.h"
#define rep(i, times) for(ll i = 0; i < (times); ++i)
#define p(x) (cout << x << "\n")
using ll = uint16_t; using ld = long double; using namespace std;

#ifndef __GNUC__
string text =
R"X(
8
7 3 5 4 2 1 6 8
3 8 2 5 4 6 7 1
)X";
stringstream iss{text};
#endif

class CountOrder
{
	ll N{0};
	vector<ll> p, q;
	void inp( ) {
		iss >> N; p.resize(N); q.resize(N);
		rep(n, N) { iss >> p[n]; }
		rep(n, N) { iss >> q[n]; }
		//for_each(begin(p), end(p), [](auto x) { cout << x << "\n"; });
	}
	void change( ) {
		long long sa{0};
		if (p > q) swap(p, q);
		do {
			if (p == q) p(sa);
			++sa;
		} while (next_permutation(begin(p), end(p)));
	}
public:
	void procedures( ) {
		inp( );
		change( );
	}
};
//https://atcoder.jp/contests/abc145/tasks/abc145_c
int main( ) {
	cin.tie(0);	ios::sync_with_stdio(0);
	cout << fixed << setprecision(15);
	class CountOrder a; a.procedures( );
}

Measured memory_bytes: 3660
#include<iostream>
#include<algorithm>
#include<map>
#include<unordered_map>
#include<math.h>
#include<set>
#include<string.h>
#include<vector>
using namespace std;

#define int long long

void fastio()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
}

int32_t main()
{
  fastio();
  int a, b;
  cin >> a >> b;
  cout << a*b;
  return 0;
}

Measured memory_bytes: 3168
#include <bits/stdc++.h> 
#define pb push_back
#define sp " "
#define sl "\n"
#define fi first
#define se second
#define mp make_pair
#define sz(a) ((int)a.size())
#define all(a) a.begin(),a.end()
#define rev(a) reverse(a.begin(),a.end())
#define PI 3.141592

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
const int N=500,mod=1000000007;
int x,y;
int main() { 
	cin.tie(0); cout.tie(0); 
	ios_base::sync_with_stdio();
	cin>>x>>y;
	int c=0;
	for (int i=0;i<=x;i++) if (i*2+(x-i)*4==y) { cout<<"Yes"; return 0; }
	cout<<"No";
	return 0;
}
// Recuerda limites 
// Recuerda casos especiales


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

using namespace std;

void solve()
{
    string s;
    cin >> s;
    int ans = 0, cnt = 0;
    for (int i = 0; i < 3; i++)
    {
        if (s[i] == 'R') cnt++;
        else cnt = 0;
        ans = max(ans, cnt);
    }
    cout << ans << endl;
}

int main()
{
    ios::sync_with_stdio(false);
    int tt = 1;
    //cin >> tt;
    while (tt--) solve();
}


Measured memory_bytes: 3552
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int n,p, k;
  cin>>n>>k;
  p=n;
  if(n<k)
  {
      if(k-n<n)
      cout<<k-n<<endl;
      else
       cout<<n<<endl;
  }
 
      
  
  else
  {
  long long int l=n%k;
  //cout<<l<<endl;
  long long int m=k-l;
  //cout<<m<<l<<endl;
  if(m<l)
    cout<<m<<endl;
  else
    cout<<l<<endl;
  }
}

Measured memory_bytes: 384
from sys import stdin


def gcd(x, y):
    if x % y == 0:
        return y
    return gcd(y, x % y)


def fact(x):
    if x == 1:
        return x
    return x * fact(x - 1)


def main():
    k = int(stdin.readline())

    ans = 0

    for a in range(1, k + 1):
        for b in range(a, k + 1):
            d = gcd(a, b)
            for c in range(b, k + 1):
                e = gcd(d, c)
                ans += e * fact(3) // fact(3 - len(set([a, b, c])) + 1)

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 72156
N, A, B = map(int, input().split())
if A % 2 == B % 2:
  print((B - A) // 2)
else:
  print(min(A - 1 + (B - A + 1) // 2, B - 1, N - A, N - B + (B - A + 1) // 2))

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

int dp[6][2]={{0,9},{9,12},{12,15},{15,18},{18,21},{21,30}};
int n;
int p[30];

void turn(int x){
    if (x==0) {
        swap(p[6],p[21]);
        swap(p[7],p[22]);
        swap(p[8],p[23]);
        swap(p[9],p[11]);
        swap(p[17],p[12]);
    }
    else if (x==1){
        swap(p[8],p[27]);
        swap(p[5],p[24]);
        swap(p[2],p[21]);
        swap(p[12],p[14]);
        swap(p[11],p[18]);
    }
    else if (x==2){
        swap(p[0],p[27]);
        swap(p[1],p[28]);
        swap(p[2],p[29]);
        swap(p[18],p[20]);
        swap(p[14],p[15]);
    }
    else if (x==3){
        swap(p[0],p[23]);
        swap(p[3],p[26]);
        swap(p[6],p[29]);
        swap(p[15],p[17]);
        swap(p[9],p[20]);
    }
}

int check(){
    for (int i=0; i<6; i++) {
        for (int j=dp[i][0]; j<dp[i][1]; j++) {
            if(p[dp[i][0]]!=p[j])return false;
        }
    }
    return true;
}

int solve(int num){
    if(num==8||check())return num;
    int res=8;
    for (int i=0; i<4; i++) {
        turn(i);
        res=min(res, solve(num+1));
        turn(i);
    }
    return res;
}

int main(){
    cin>>n;
    for (int i=0; i<n; i++) {
        for (int j=0; j<30; j++) {
            cin>>p[j];
        }
        cout<<solve(0)<<endl;
    }
    return 0;
}

Measured memory_bytes: 3088
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    
    int money = 700;
    
    for ( int i = 0; i < 3; ++i ) {
        char S;
        cin >> S;
        
        if ( S == 'o' ){
            money = money + 100;
        }
    }

    cout << money << endl;
}


Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int D = sc.nextInt();
    int[][] X = new int[N][D];
    for (int i = 0; i < N; i++)
      for (int j = 0; j < D; j++)
        X[i][j] = sc.nextInt();
    int count = 0;
    int tmp;
    for (int i = 0; i < N - 1; i++)
      for (int j = i + 1; j < N; j++) {
        tmp = 0;
        for (int k = 0; k < D; k++)
          tmp += (int) Math.pow(X[i][k] - X[j][k], 2);
        if (Math.sqrt(tmp) == (int) Math.sqrt(tmp))
          count++;
      }
    System.out.println(count);
  }
}

Measured memory_bytes: 23764