akhauriyash/Code-Regression huggingface dataset:
using Yorukatsu021.Questions;
using Yorukatsu021.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Yorukatsu021.Questions
{
    /// <summary>
    /// ABC087 A
    /// </summary>
    public class QuestionA : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var x = inputStream.ReadInt();
            var a = inputStream.ReadInt();
            var b = inputStream.ReadInt();

            x -= a;
            var donutCount = x / b;
            yield return x - b * donutCount;
        }
    }
}


namespace Yorukatsu021
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionA();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace Yorukatsu021.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace Yorukatsu021.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 11092
#include <stdio.h>
#include <string.h>

int field[10][10];

void explosion(int x,int y);

int main(void) {

  int n;

  int bomb_x,bomb_y;

  char buf[100];

  int i,j,k;


  scanf("%d",&n);

  for(i=0;i<n;i++) {

    getchar();

    fgets(buf,sizeof(buf),stdin);
    
    for(j=0;j<8;j++) {

      fgets(buf,sizeof(buf),stdin);

      buf[strlen(buf)-1]='\0';

      for(k=0;k<8;k++) {

	field[j][k]=buf[k]-'0';

      }

    }

    scanf("%d\n%d",&bomb_x,&bomb_y);
    
    //printf("%d %d\n",bomb_x,bomb_y);
    printf("Data %d:\n",i+1);

    explosion(bomb_x-1,bomb_y-1);

    for(j=0;j<8;j++) {

      for(k=0;k<8;k++) printf("%d",field[j][k]);

      puts("");

    }

  }

  return 0;

}

void explosion(int x,int y) {

  int i;

  field[y][x]=0;

  for(i=-3;i<=3;i++) {

    if(y+i<0 || y+i>=8) continue;

    else if(field[y+i][x]==1) {

      explosion(x,y+i);

    }

  }

  for(i=-3;i<=3;i++) {

    if(x+i<0 || x+i>=8) continue;

    if(field[y][x+i]==1) {

      explosion(x+i,y);

    }

  }

  return;

}

Measured memory_bytes: 0
import std.stdio;
import std.conv;
import std.container;
import std.algorithm;
import std.array;

void main() {
    int n; readf("%d\n", &n);
    int[string] data;
    foreach (_; 0 .. n) {
        string key; int value;
        readf("%s %d\n", &key, &value);
        data[key] = data.get(key, 0) + value;
    }
    static bool compare(string a, string b) {
        if (a.length == b.length) {
            return a < b;
        } else {
            return a.length < b.length;
        }
    }
    auto keys = data.keys.array;
    keys.sort!compare.array;
    foreach (k; keys) {
        writeln(k, " ", data[k]);
    }
}

Measured memory_bytes: 1512
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
using namespace std;
ll INF = 1000000007;
using Graph = vector<vector<ll>>;

// 0 false, 1 true 


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

    rep(i,1000){

        if((x >= (i+1)*100) && (x <= (i+1)*105)){
            cout << 1 << endl;
            return 0;
        }

    }
    
    cout << 0 << endl;


}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
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(a > b){ a = b; return 1; } return 0; }
typedef long long ll;
int main()
{
  ll n,m; cin >> n >> m;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];

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

  auto bins = [&](auto isok, ll x, ll maxi)-> ll{
		ll lb = -1, ub = maxi;
		while(ub - lb > 1) {
		  ll mid = (ub + lb) / 2;
		  (isok(mid, x) ? ub : lb) = mid;
		}
		return ub;
	      };

  auto comp1 = [&](ll mid, ll x)-> bool{
		 return x <= a[mid];
	       };

  auto comp2 = [&](ll mid, ll x)-> bool{
		 ll cnt = 0;
		 rep(i,n) {
		   cnt += bins(comp1, mid - a[i], n);
		 }
		 return n*n - m <= cnt;
	       };

  ll bor = bins(comp2, 0, 1e+10+1);

  vector<ll> sum(n+1);
  sum[0] = 0;
  rep(i,n) sum[i+1] = sum[i] + a[i];
  
  ll cnt = 0;
  ll res = 0;
  rep(i,n) {
    ll tmp = bins(comp1, bor - a[i], n);
    cnt += n - tmp;
    res += (sum[n] - sum[tmp]) + a[i] * (n - tmp);
  }

  res += (m - cnt) * (bor - 1);
  cout << res << "\n";
  
  return 0;
}


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

struct UnionFind {
    vector<int> Parent;
    vector<int> Size;

    explicit UnionFind(int N) : Parent(N), Size(N,1){
        for(int i = 0; i < N; i++) Parent[i] = i;
    }

    int root(int A) {
        if (Parent[A] == A) return A;
        return Parent[A] = root(Parent[A]);
    }

    bool merge(int A, int B) {
        A = root(A);
        B = root(B);
        if (A == B) return false;

        if (Size[A] < Size[B]) swap(A, B);

        Size[A] += Size[B];
        Parent[B] = A;
        return true;
    }

    bool issame(int A, int B) { //
        return root(A) == root(B);
    }

    int findsize(int A) {
        return Size[root(A)];
    }
};

struct edge {
    int u, v, cost;
};

bool comp(const edge& e1, const edge& e2){
    return e1.cost < e2.cost;
}

const int MAX_E = 100010;

edge es[MAX_E];
int V,E;

int kruskal(){
    sort(es, es + E, comp);
    UnionFind Tree(V);
    int res = 0;
    for(int i = 0; i < E; i++){
        edge e = es[i];
        if(!Tree.issame(e.u, e.v)){
            Tree.merge(e.u, e.v);
            res += e.cost;
        }
    }
    return res;
}


signed main() {
    cin >> V >> E;
    for(int i = 0; i < E; i++){
        int u, v, cost;
        cin >> u >> v >> cost;
        edge e = {u, v, cost};
        es[i] = e;
    }

    cout << kruskal() << endl;
}




Measured memory_bytes: 5568
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		int[] A = new int[N];

		int min = 0;

		for(int i=0; i<N; i++) {
			A[i] = sc.nextInt();
			min = i==0 || min > A[i] ? A[i] : min;
		}

		int count = 0;
		for(int i=0; i<Math.log(min)/Math.log(2); i++) {
			boolean flag = false;
			for(int j=0; j<N; j++) {
				if(A[j]%2 != 0) flag = true;
				A[j] = A[j]/2;
			}
			if(flag) {
				break;
			}else {
				count++;
			}
		}

		System.out.println(count);
	}

	public static void print(Object o) {
		System.out.print(o);
	}

	public static void println(Object o) {
		System.out.println(o);
	}
}

Measured memory_bytes: 21844
using System;
using System.Collections.Generic;
using System.Linq;
public class Program
{
    public static void Main()
    {
        int[] n = Console.ReadLine().ToCharArray().Select(num => int.Parse(num.ToString())).ToArray();
        int a, b, c;
        string a_, b_, c_;
        int box = 0;
        for (int i = 0; i < 2; i++)
        {
            if (i == 1) { a = -1 * n[1]; a_ = "-"; }
            else { a = n[1]; a_ = "+"; }
            for (int j = 0; j < 2; j++)
            {
                if (j == 1) { b = -1 * n[2]; b_ = "-"; }
                else { b = n[2]; b_ = "+"; }
                for (int k = 0; k < 2; k++)
                {
                    if (k == 1) { c = -1 * n[3]; c_ = "-"; }
                    else { c = n[3]; c_ = "+"; }
                    box = a + b + c;
                    if (box + n[0] == 7)
                    {
                        Console.WriteLine(n[0] + a_ + n[1] + b_ + n[2] + c_ + n[3] + "=7");
                        return;
                    }
                }
            }
        }
    }
}


Measured memory_bytes: 13396
N,Q = (int(i) for i in input().split())
S = input()
acl = [0 for i in range(N)]
cnt = 0

for j in range(1,N):
  if S[j-1] == 'A' and S[j] == 'C':
    cnt += 1
  acl[j] = cnt
      
for k in range(Q):
  x,y = (int(i)-1 for i in input().split())
  print(acl[y]-acl[x])

Measured memory_bytes: 6104
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N,T;
  cin>>N>>T;
  vector<pair<int,int> > C;
  REP(i,N){
    int A,B;
    cin>>A>>B;
    C.push_back(make_pair(A,B));
  }
  sort(ALL(C));
  vector<int> B(N+1);
  REP(i,N)B[i]=C[i].second;
  vector<map<int,int> > dp(N+1);
  int ans=0;
  REP(i,N){
    if(i==0){
      dp[i][0]=0;
      if(C[i].first<T)dp[i][C[i].first]=B[i];
    }else{
      for(auto e:dp[i-1]){
        dp[i][e.first]=max(dp[i][e.first],e.second);
        if(e.first+C[i].first<T)dp[i][e.first+C[i].first]=max(dp[i][e.first+C[i].first],e.second+B[i]);
      }
    }
    // cerr<<i<<": ";
    // for(auto e:dp[i])cerr<<e.first<<":"<<e.second<<" ";
    // cerr<<endl;
    int ma=0;
    for(auto e:dp[i])ma=max(ma,e.second);
    ans=max(ans,ma+*max_element(B.begin()+(i+1),B.end()));
    // cerr<<ans<<endl;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 406912
n, k, q = gets.chomp.split(' ').map(&:to_i)
scores = Array.new(n, k-q)
winners = readlines.map(&:chomp).map(&:to_i)
winners.each{|winner| scores[winner - 1] +=1 }
scores.each{|score| puts(score > 0 ? 'Yes' : 'No' ) }

Measured memory_bytes: 18556
#include<iostream>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
#define SZ(v) ((int)(v).size())
#define rep(i,n) for(int i=0;i<(n);i++)
#define foreach(it,c) for(__typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define all(v) (v).begin(),(v).end()
typedef long long ll;
typedef unsigned uint;
const int INF=0x3f3f3f3f;
int inline in(){int x=0,c;for(;(uint)((c=getchar())-'0')>=10;)
{if(c=='-')return -in();if(!~c)throw ~0;}do{x=(x<<3)+(x<<1)+(c-'0');}
while((uint)((c=getchar())-'0')<10);return x;}
bool is_prime[1005];
vector<int>p;
void make(){
	for(int i=0;i<=1000;i++)is_prime[i]=true;
	is_prime[0]=is_prime[1]=false;
	for(int i=2;i<=1000;i++){
		if(!is_prime[i])continue;
		for(int j=i+i;j<=1000;j+=i){
			is_prime[j]=false;
		}
	}
	for(int i=0;i<=1000;i++){
		if(is_prime[i]){
			p.push_back(i);
		}
	}
}
int n;
int A[10005];
int f[10005][200];
int mx[200];
const int mod=1e9+7;
int mod_pow(int w,int r){
	int x=w,ans=1;
	while(r){
		if(r&1){
			ans=ll(ans)*x%mod;
		}
		x=ll(x)*x%mod;
		r>>=1;
	}
	return ans;
}
int v[10005];
int tpp[10005];
pair<int,int> tp[10005];
int extra[10005];
int main(){
	make();
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>A[i];
	}
	for(int j=1;j<=n;j++){
		int tmp=A[j];
		rep(i,SZ(p)){
			int bgr=p[i],cnt=0;
			while(tmp%bgr==0){
				tmp/=bgr;
				cnt++;
			}
			f[j][i]=cnt;
		}
		if(tmp>1000){
			v[j]=tmp;
		}else{
			v[j]=-1;
		}
	}
//	for(int i=1;i<=n;i++)cout<<v[i]<<' ';cout<<endl;
	for(int i=1;i<=n;i++)tpp[i]=v[i];
	for(int i=1;i<=n;i++)tp[i]=make_pair(v[i],i);
	sort(tp+1,tp+n+1);
	for(int i=2;i<=n;i++){
		if(tp[i-1].first==tp[i].first){
			v[tp[i-1].second]=-1;
		}
	}
	for(int i=1;i<=n;i++){
		rep(j,SZ(p)){
			mx[j]=max(mx[j],f[i][j]);
		}
	}
	for(int i=1;i<=n;i++)extra[i]=1;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(v[j]!=-1&&i!=j&&tpp[i]!=v[j]){
//				cout<<j<<' ';
				extra[i]=ll(extra[i])*v[j]%mod;
			}
		}
//		cout<<endl;
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		int B=extra[i];
		rep(j,SZ(p)){
			B=ll(B)*mod_pow(p[j],mx[j]-f[i][j])%mod;
		}
		ans=(ll(ans)+B)%mod;
	}
	cout<<ans<<endl;
//	for(int i=1;i<=n;i++)cout<<extra[i]<<endl;
	return 0;
}

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

#ifndef DEBUG
#define endl '\n'
#define debug(...)
#else
#define debug(...) __VA_ARGS__
#endif
#define debugf(...) debug(printf(__VA_ARGS__);)

const int N = 1e5 + 5;
using ll = long long;


int (((((main)))))() <%
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    string s; cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
%>

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B, C; cin >> A >> B >> C;
  int s = ((A % B) ? A % B : A), t = max(A, B);
  while(true) {
    if(max(s, t) % min(s, t) == 0) {
      s = min(s, t);
      break;
    } else {
      int x = max(s, t) % min(s, t);
      t = min(s, t); s = x;
    }
  }
  cout << ((C % s == 0) ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for (int i = 0; i < (n); ++i)
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;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;cin >> n;
    vector<ll> a(n+1);
    rep(i,n+1){
        cin >> a[i];
    }
    if(n==0){
        if(a[0]==1){
            cout << 1 << endl;
        }
        else{
            cout << -1 << endl;
        }
        return 0;
    }
    if(a[0]){
        cout << -1 << endl;
        return 0;
    }
    vector<ll> l(n+1,INF);
    l[0]=1;
    for(int i=1;i<=n;i++){
        chmin(l[i],(l[i-1]-a[i-1])*2);
        if(l[i]<=0){
            cout << -1 << endl;
            return 0;
        }
    }
    vector<ll> v(n+1);
    v[n]=a[n];
    if(v[n]>l[n]){
        cout << -1 << endl;
        return 0;
    }
    for(int i=n-1;i>=0;i--){
        v[i]=min(l[i],v[i+1]+a[i]);
    }
    ll ans=0;
    rep(i,n+1){
        ans+=v[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 5580
while True:
    m, f, r = [int(i) for i in input().split()]
 
    if m == f == r == -1:
        break
 
    total = m + f
    if m == -1 or f == -1 or total < 30:
        print('F')
 
    elif total < 50 and r < 50:
        print('D')
 
    elif total < 65:
        print('C')
 
    elif total < 80:
        print('B')
         
    else:
        print('A')

Measured memory_bytes: 7628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

// http://noshi91.hatenablog.com/entry/2019/03/31/174006
template <uint_fast64_t Mod = 1'000'000'007>
struct modint {
  using u64 = uint_fast64_t;

  u64 n;

  modint(const u64 x = 0) : n(x % Mod) {}
  modint operator+(const modint r) const { return modint(*this) += r; }
  modint operator-(const modint r) const { return modint(*this) -= r; }
  modint operator*(const modint r) const { return modint(*this) *= r; }
  modint operator/(const modint r) const { return modint(*this) /= r; }
  modint &operator+=(const modint r) {
    n += r.n;
    if (n >= Mod) n -= Mod;
    return *this;
  }
  modint &operator-=(const modint r) {
    if (n < r.n) n += Mod;
    n -= r.n;
    return *this;
  }
  modint &operator*=(const modint r) {
    n = n * r.n % Mod;
    return *this;
  }
  modint &operator/=(modint r) {
    n = n * inv();
    return *this;
  }
  modint pow(u64 x) const {
    modint<Mod> ret(1), tmp(*this);
    while (x) {
      if (x&1) ret *= tmp;
      tmp *= tmp;
      x >>= 1;
    }
    return ret;
  }
  modint inv() const {
    return pow(Mod-2);
  }
};
using mint = modint<1'000'000'007>;

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

  ll n;
  cin >> n;
  vl a(n);
  rep(i, n) {
    cin >> a[i];
  }
  sort(all(a));
  vector<mint> c(n);
  rep(i, n) {
    c[i] = mint(a[i]);
  }

  vector<mint> pow_2(n+1);
  pow_2[0] = 1;
  rep(i, n) {
    pow_2[i+1] = pow_2[i]*2;
  }

  mint ans(0);
  rep(i, n) {
    ll l = i;
    ll r = n-1-i;
    mint cnt = pow_2[r];
    if (r != 0) cnt += pow_2[r-1]*r;
    cnt *= pow_2[l];
    cnt *= c[i];
    ans += cnt;
  }
  ans *= pow_2[n];

  cout << ans.n << endl;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<ll, ll, ll> T;

string s;

int main(void){
    
    cin >> s;
    
    for(int i = 0; i < s.size(); ++i){
        if(s[i] == ',') s[i] = ' ';
    }
    cout << s << endl;
    
    return 0;
}

Measured memory_bytes: 256
#coding: utf-8

l = range(0, 1001)
l[1] = 0
for i in range(0, 50):
    if l[i] != 0:
        for k in range(i + i, 1001, i):
            l[k] = 0
        continue
l = [x for x in l if x]
while True:
    l2 = map(int,raw_input().split())
    if l2 == [0,0,0]:
        break
    a = l2[0]
    d = l2[1]
    n = l2[2]
    c = 0
    ch = 0
    while True:
        for p in l:
            if (a != p and a % p == 0) or a == 1:#?´???°???????????????
                ch = 1
                break
        if ch == 1:
            a = a + d
            ch = 0
            continue
        c = c + 1
        if c == n:
            break
        a = a + d
    print a

Measured memory_bytes: 6416
#include<stdio.h>
int main(void){
    int W,H;
    int x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    if(((x>=r)&&(x<=W-r))&&((y>=r)&&(y<=H-r)))
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}

Measured memory_bytes: 584
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
using ll = long long;
using VI = vector<int>;

int main(){
  int n;cin >> n;
  vector<int> a(n);
  int ans =-1;
  for(auto &i:a) cin >> i;
  for(int i=0;i<n-1;i++){
    for(int j=i;j<n;j++){
      ans = max(ans,abs(a[i]-a[j]));
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define sim template < class c
#define int long long
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << '\n'; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef tree< pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 2e5 + 10 ;
const ll INF = 1e18 + 10 ;
signed main(){
    fastio
    int n , m ; 
    cin >> n >> m ; 
    vector<set<int> > g(n) ; 
    vector<int> H(n) ; 
    for(int i = 0; i < n; i++){
        cin >> H[i] ; 
    }
    for(int i = 0; i < m; i++){
        int x , y ;
        cin >> x >> y ; 
        x--, y-- ;
        g[x].insert(y) ;
        g[y].insert(x) ;
    }
    int ans = 0 ;
    for(int i = 0; i < n; i++){
        bool ok = true ;
        for(int c : g[i]){
            debug() << imie(c) ;
            if ( H[c] >= H[i] ) {
                ok = false ;
                break ; 
            }
        }
        if ( ok ) ans++ ;
    }
    cout << ans << endl;
    return 0; 
}

Measured memory_bytes: 17988
l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(l[int(input())-1])    

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

using namespace std;

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

  vector<int> A(N);

  for(int i = 0; i < N; i++)
    cin >> A[i];

  int min_so_far = A[0];

  vector<int> B(N);

  B[0] = 0;

  for(int i = 1; i < N; i++) {
    B[i] = A[i] - min_so_far;
    min_so_far = min(min_so_far, A[i]);
  }

  int max_in_B = B[0];

  for(int i = 0; i < N; i++) {
    max_in_B = max(B[i], max_in_B);
  }

  int count = 0;

  for(int i = 0; i < N; i++) {
    if(B[i] == max_in_B) {
      count += 1;
    }
  }

  cout << count << endl;

}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws IOException {
        PrintWriter pw = new PrintWriter(System.out);
        Scanner sc = new Scanner();
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());
        if (a + +b + 1 >= c) {
            System.out.println(c + b);
        } else {
            System.out.println(b + Math.min(a + b, c) + 1);
        }

    }

    static class Scanner {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");
        int spaces = 0;

        public String nextLine() throws IOException {
            if (spaces-- > 0) {
                return "";
            } else if (st.hasMoreTokens()) {
                return new StringBuilder(st.nextToken("\n")).toString();
            }
            return br.readLine();
        }

        public String next() throws IOException {
            spaces = 0;
            while (!st.hasMoreTokens()) {
                st = new StringTokenizer(br.readLine());
            }
            return st.nextToken();
        }

        public boolean hasNext() throws IOException {
            while (!st.hasMoreTokens()) {
                String line = br.readLine();
                if (line == null) {
                    return false;
                }
                if (line.equals("")) {
                    spaces = Math.max(spaces, 0) + 1;
                }
                st = new StringTokenizer(line);
            }
            return true;
        }
    }
}


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

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    int l; cin >> l;
    int r; cin >> r;
    if (r - l >= 2019){
        cout << 0 << endl;
        return 0;
    }
    l -= (l / 2019) * 2019;
    r -= (r / 2019) * 2019;
    if (l >= r){
        r += 2019;
    }
    int ans = 2018;
    for (int i=l; i<r; i++){
        for (int j=i+1; j<=r; j++){
            ans = min(ans, i*j % 2019);
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define ll long long
#define mtv(kit) cout<<#kit<<" - "<<kit<<"\n";
#define ff first
#define ss second
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define pii pair<ll , ll>
#define all(x) x.begin(),x.end()
#define nl "\n"
#define ump unordered_map

void doit(){
    ll x;
    cin >> x;
    cout << 1 - x << nl;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1;
   //  cin >> t;
    for(ll i = 1; i <= t; i++){
        doit();
    }
}


Measured memory_bytes: 3644
#include <stdio.h>
#include <stdlib.h>
#define int long long

signed main(){
	int N, s, t, i, j, k, ans = 0;
	scanf("%lld", &N);
	int *a = (int *)malloc(sizeof(int) * N);
	int *b = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		scanf("%lld", &a[i]);
	}
	for(i = 0; i < N; i++){
		scanf("%lld", &b[i]);
	}
	int **dis = (int **)malloc(sizeof(int *) * 51);
	for(i = 0; i <= 50; i++){
		dis[i] = (int *)malloc(sizeof(int) * 51);
	}

/*	for(i = 0; i <= 50; i++){
		dis[i] = (int *)malloc(sizeof(int) * 51);
		for(j = 0; j <= 50; j++){
			dis[i][j] = i == j ? 1 : 0;
		}
	}
	for(i = 0; i <= 50; i++){
		for(j = 1; j <= 50; j++){
			dis[i][i % j] = 1;
		}
	}
	for(k = 0; k <= 50; k++){
		for(i = 0; i <= 50; i++){
			for(j = 0; j <= 50; j++){
				dis[i][j] = dis[i][j] | (dis[i][k] & dis[k][j]);
			}
		}
	}
	for(i = 0; i < N; i++){
		if(dis[a[i]][b[i]] == 0){
			printf("-1\n");
			return 0;
		}
	}
*/
	for(s = 50; s >= 0; s--){
		for(t = 0; t <= s; t++){

			for(i = 0; i <= 50; i++){
				for(j = 0; j <= 50; j++){
					dis[i][j] = i == j ? 1 : 0;
				}
			}
			for(i = 0; i <= 50; i++){
				for(j = 1; j <= 50; j++){
					if((ans & ((int)1 << j)) != 0 || j <= t){
						dis[i][i % j] = 1;
					}
				}
			}
			for(k = 0; k <= 50; k++){
				for(i = 0; i <= 50; i++){
					for(j = 0; j <= 50; j++){
						dis[i][j] = dis[i][j] | (dis[i][k] & dis[k][j]);
					}
				}
			}
			int f = 1;
			for(i = 0; i < N; i++){
				if(dis[a[i]][b[i]] == 0){
					f = 0;
					break;
				}
			}
			if(f == 1){
				ans |= (int)1 << t;
				break;
			}

		}
	}

	printf("%lld\n", ans - 1);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll gcd(ll a,ll b);

int main(){
  int n;
  cin>>n;
  ll ans=1;
  for(int i=0;i<n;i++){
    ll t;
    cin>>t;
    ll a=max(ans,t);
    ll b=min(ans,t);
    ans=a/gcd(a,b)*b;
  }
  cout<<ans<<endl;
  return(0);
}

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


Measured memory_bytes: 256
var rl, i = 1, end = false;

process.stdin.setEncoding('ascii');
rl = require('readline').createInterface({
	input: process.stdin, output: process.stdout});
rl.on('line', function (line) {
	if (end) return;
	if (line === '0') {
		end = true;
		return;
	}
	console.log("Case %d: %s", i, line);
	i++;
});

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

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  string s;
  cin>>s;
  char c[30];
  for(int i=0;i<s.length();i++){
     c[i]=s[i];
  }
  sort(c,c+s.length());
  int f=0;
  for(int i=0;i<s.length()-1;i++){
    if(c[i]==c[i+1]){
      f++;
    }
  }
  if(f){
    cout<<"no";
  }else{
    cout<<"yes";
  }
}



Measured memory_bytes: 256
def is_prime(n):
	# 対象の数(n)が素数かどうかを判定する	

	if n < 2:
		# 0,1 は素数ではない
		return False
	elif n == 2 or n == 3 or n == 5:
		return True
	elif n % 2 == 0 or n % 3 == 0 or n % 5 == 0:
		return False
	else:
		# nの平方根以下の素数候補ですべて試し割りする
		import math
		sqrt_ = math.floor(math.sqrt(n))
		
		primes = [7, 11, 13, 17, 19, 23, 29, 31]
		i = 0
			
		while True:
			for p in primes:
				if p + i <= sqrt_:
					if n % (p + i) == 0:
						return False
				else:
					return True
						
			i += 30


# C - Next Prime
x = int(input())

while True:
	if is_prime(x):
		print(x)
		break
	else:
		x += 1

Measured memory_bytes: 3064
from sys import stdin
from collections import defaultdict
readline = stdin.readline
read = stdin.buffer.read
def r_map(): return map(int, readline().rstrip().split())
def r_list(): return list(r_map())

MOD = 10 ** 9 + 7
# import numpy as np
# from numba import jit
# stdin = open('sample.txt')

def main():
    N = int(readline().rstrip())
    A = r_list()
    A.sort()
    ans = 0
    a_dic = defaultdict(lambda: 0)
    for j, a in enumerate(A[:0:-1]):
        i = N - 2 - j
        a_dic[i] += a
        if i > 0:
            a_dic[i - 1] = a_dic[i]
    for i, a in enumerate(A[:-1]):
        ans += a * a_dic[i]
    print(ans % MOD)

if __name__ == "__main__":
    main()


Measured memory_bytes: 133660
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
// const int MOD = 1e9 + 7;

int main() {
    int a, b;
    cin >> a >> b;
    if (a * b % 2 == 0) {
        cout << "Even\n";
    } else {
        cout << "Odd\n";
    }
}


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

#define watch(x) cout << (#x) << " is " << (x) << endl
#define fr(i,n) for(int i=0; i<n; i++)
#define rep(i, st, en) for(int i=st; i<=en; i++)
#define repn(i, st, en) for(int i=st; i>=en; i--)
#define sq(a) (a*a)
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
int mod = 1e9+7;

vector<vector<int>> g;
vector<pii> dp;
int n;

void add_self(int &a, int b){
    a += b;
    if(a >= mod) a -= mod;
}

void mul_self(int &a, int b){
    ll z = 1ll*a*1ll*b;
    if(z >= mod) z %= mod;
    a = z;
}

void dfs(int v, int p){
    pii &z = dp[v];

    int cnt = 0;
    int sum[2] = {0};
    int prod[2] = {1, 1};
    for(auto u: g[v]){
        if(u == p) continue;
        dfs(u, v);
        cnt++;  /// child count
        mul_self(prod[0], dp[u].second);
        mul_self(prod[1], dp[u].first + dp[u].second);
    }

    if(!cnt){
        /// leaf node
        z = make_pair(1, 1);
        return;
    }

    z.first = prod[0];
    z.second = prod[1];
}

void solve(){
    int u, v;
    cin>>n;
    g.resize(n);
    dp.resize(n, {0, 0});
    /// dp[i].first = no. of valid subtrees with vertex i set to black
    /// dp[i].second = no. of valid subtrees with vertex i set to white

    fr(i, n-1){
        cin>>u>>v;
        u--, v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }

    auto sum = [&](pii z){
        add_self(z.first, z.second);
        return z.first;
    };

    dfs(0, 0);
    cout<<sum(dp[0]);
}

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

    ll t = 1;
    //  cin>>t;
    while(t--){
        solve();
    }

    return 0;
}


Measured memory_bytes: 13440
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	string s; cin >> s;
	if (s[2] == s[3] and s[4] == s[5]) {
		cout << "Yes";
		return 0;
	}
	cout << "No";
}


Measured memory_bytes: 256
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A;
ll B;
ll C;
ll N;
ll M;
ll K;

ll ltmp;
string stmp;
double dtmp;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> A;
    cout << A*A << endl;
    

}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;



int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int l = a+b;
  int r = c+d;
  if(l>r) cout << "Left" << endl;
  else if(l == r) cout << "Balanced" << endl;
  else cout << "Right" << endl;
  return 0;
}


Measured memory_bytes: 3604
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <numeric>
#include <bitset>

using namespace std;
using ll = long long;
using ld = long double;
const ll mod =  1000000007;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (ll i = (j); i < (n); ++i)
#define all(x) (x).begin(),(x).end()

ll power(ll base, ll exponent, ll module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ ll root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2, mod);}
ll gcd(ll a, ll b) {if(a < b) gcd(b, a);ll r;while(r=a%b) {a=b;b=r;}return b;}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

int bsearch(const vector<ll>& a, ll x){
  int lft = 0;
  int rgt = a.size();
  while (rgt - lft > 1) {
    int mid = (lft + rgt) / 2;
    if(a[mid] < x) {
      lft = mid;
    }
    else {
      rgt = mid;
    }
  }
  return lft;
}


signed main() {
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  vector<ll> a(2*n);
  REP(i, 2*n) {
      cin >> a[i];
  }
  sort(all(a), greater<ll>());
  ll ans = 0;
  REP(i, n) {
    ans += a[2*i+1];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
  public static void main(String args[]){
    Scanner scan;
    String S;
    String T;
    int Ss;
    String Sc;
    
    scan = new Scanner(System.in);
    S = scan.next();
    T = scan.next();

    Ss = S.length();
    Sc = T.substring(0, Ss);

    if (Sc.equals(S)){
        System.out.println("Yes");
    }else{
        System.out.println("No");
    }
  }
}


Measured memory_bytes: 35688
S = input()
S = S[::-1]
while True:
  if S[0:5] == "maerd":
    S = S[5::]
  elif S[0:7] == "remaerd":
    S = S[7::]
  elif S[0:5] == "esare":
    S = S[5::]
  elif S[0:6] == "resare":
    S = S[6::]
  else:
    break
if len(S) == 0:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 3188
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

signed main() {
    int N; cin >> N;
    vector<int> a(N), b(N);
    for(int i=0; i<N; i++) {
        cin >> a[i];
    }
    for(int i=0; i<N; i++) {
        cin >> b[i];
    }

    int ans = 0;
    for(int k=28; k>=0; k--) {
        int i1 = 0, i2 = 0, i3 = 0;
        int T = 1 << k, ad = 0;
        for(int i=0; i<N; i++) {
            a[i] %= 2*T, b[i] %= 2*T;
        }
        sort(a.begin(), a.end(), greater<int>());
        sort(b.begin(), b.end());
        for(int i=0; i<N; i++) {
            while(i1 < N && a[i] + b[i1] <   T) i1++;
            while(i2 < N && a[i] + b[i2] < 2*T) i2++;
            while(i3 < N && a[i] + b[i3] < 3*T) i3++;
            ad += (i2 - i1) + (N - i3);
        }
        if(ad % 2) ans += T;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define P 1000000007
#define in(x, a, b) (a <= x && x < b)

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
const ll inf = 1000000001, INF = (ll)1e18 + 1;

void solve() {
	int x, y, z, k;
	cin >> x >> y >> z >> k;
	
	vector<ll> a(x), b(y), c(z);
	for(int i = 0; i < x; i++) cin >> a[i];
	for(int i = 0; i < y; i++) cin >> b[i];
	for(int i = 0; i < z; i++) cin >> c[i];
	
	vector<ll> ab;
	for(int i = 0; i < x; i++)
		for(int j = 0; j < y; j++)
			ab.pub(a[i] + b[j]);
			
	sort(all(ab));
	reverse(all(ab));
	sort(all(c));
	reverse(all(c));
	
	priority_queue<pair<ll, ii>> q;
	for(int i = 0; i < ab.size(); i++) {
		q.push({ab[i] + c[0], {i, 0}});
	}
	
	int taken = 0;
	while(!q.empty() && taken < k) {
		cout << q.top().ff << endl;
		taken++;
		ii state = q.top().ss;
		q.pop();
		if(state.ss + 1 < z) {
			q.push({ab[state.ff] + c[state.ss + 1], {state.ff, state.ss + 1}});
		}
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	solve();
    return 0;
}

Measured memory_bytes: 27636
/**
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡀⠀⠀⠀⠀⢀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⡖⠁⠀⠀⠀⠀⠀⠀⠈⢲⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⣼⡏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢹⣧⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⣸⣿⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⣿⣇⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⣿⣿⡇⠀⢀⣀⣤⣤⣤⣤⣀⡀⠀⢸⣿⣿⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⢻⣿⣿⣔⢿⡿⠟⠛⠛⠻⢿⡿⣢⣿⣿⡟⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣀⣤⣶⣾⣿⣿⣿⣷⣤⣀⡀⢀⣀⣤⣾⣿⣿⣿⣷⣶⣤⡀⠀⠀⠀⠀
⠀⠀⢠⣾⣿⡿⠿⠿⠿⣿⣿⣿⣿⡿⠏⠻⢿⣿⣿⣿⣿⠿⠿⠿⢿⣿⣷⡀⠀⠀
⠀⢠⡿⠋⠁⠀⠀⢸⣿⡇⠉⠻⣿⠇⠀⠀⠸⣿⡿⠋⢰⣿⡇⠀⠀⠈⠙⢿⡄⠀
⠀⡿⠁⠀⠀⠀⠀⠘⣿⣷⡀⠀⠰⣿⣶⣶⣿⡎⠀⢀⣾⣿⠇⠀⠀⠀⠀⠈⢿⠀
⠀⡇⠀⠀⠀⠀⠀⠀⠹⣿⣷⣄⠀⣿⣿⣿⣿⠀⣠⣾⣿⠏⠀⠀⠀⠀⠀⠀⢸⠀
⠀⠁⠀⠀⠀⠀⠀⠀⠀⠈⠻⢿⢇⣿⣿⣿⣿⡸⣿⠟⠁⠀⠀⠀⠀⠀⠀⠀⠈⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣼⣿⣿⣿⣿⣧⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠐⢤⣀⣀⢀⣀⣠⣴⣿⣿⠿⠋⠙⠿⣿⣿⣦⣄⣀⠀⠀⣀⡠⠂⠀⠀⠀
⠀⠀⠀⠀⠀⠈⠉⠛⠛⠛⠛⠉⠀⠀⠀⠀⠀⠈⠉⠛⠛⠛⠛⠋⠁⠀⠀
 *    author:  Daredevil666
 *    institution: IIT Patna
**/
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define nl cout<<"\n";
#define ll long long int
#define REP(i,a,n) for(i=a;i<=n;i++)
#define F(i,a,b) for(i=a;i<b;i++)
#define RF(i,b,a) for(i=b;i>=a;i--)
#define IOS  ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
const ll mod=1e16;
const ll MAXN=1000200;
ll i,j,mask,test;
int main()
{
IOS
/*#ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin);
   freopen("output.txt","w",stdout);
#endif // ONLINE_JUDGE*/
ll a,b,c,d;
cin>>a>>b>>c>>d;
cout<<max(max(a*c,a*d),max(b*c,b*d));
return 0;
}


Measured memory_bytes: 3644
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.System.*;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

    static void solve() throws Exception {
        int n = scanInt();
        String c = scanString();
        int 赤石の数 = c.replace("W", "").length();
        int 移動しないといけない白石の数 = c.substring(0, 赤石の数). replace("R", "").length();
        out.print(移動しないといけない白石の数);
    }

    static int scanInt() throws IOException {
        return parseInt(scanString());
    }

    static long scanLong() throws IOException {
        return parseLong(scanString());
    }

    static String scanString() throws IOException {
        while (tok == null || !tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    }

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    public static void main(String[] args) {
        try {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
            solve();
            in.close();
            out.close();
        }
        catch (Throwable e) {
            e.printStackTrace();
            exit(1);
        }
    }
}

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

using ll = long long;
using namespace std;

#define FOR(i,a,b) for(int i = (int)(a); i <= (int)(b); i++)
#define FORR(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define REPR(i,n) FORR(i,(int)(n)-1,0)

#define LFOR(i,a,b) for(ll i = (ll)(a); i <= (ll)(b); i++)
#define LFORR(i,a,b) for(ll i = (int)(a); i >= (ll)(b); i--)
// #define LREP(i,n) LFOR(i,0,(ll)(n)-1)
// #define LREPR(i,n) LFORR(i,(ll)(n)-1,0)

#define SIZ(v) int(v.size())
const int INF = 1e8;
const ll LINF = 1e15;
const int MOD = 1e9+7;



int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c=1,d=0;
  cin >> a >> b;
  while(c<b){
    d++;  c+=a-1;
  }
  cout << d << endl;
}

Measured memory_bytes: 256
#%%
n = int(input())
s = [0] * (n + 1)

print(0)
a = input()
if a == 'Vacant':
    exit()
s[0], s[n] = a, a
l, r = 0, n
while True:
    m = (r + l) // 2
    print(m)
    a = input()
    if a == 'Vacant':
        exit()
    s[m] = a
    if s[l] == s[m]:
        if (l - m) % 2 == 1:
            r = m
        else:
            l = m
    else:
        if (l - m) % 2 == 1:
            l = m
        else:
            r = m


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


#define ll long long int
#define ld long double
#define mod 998244353
#define big 1e18+100000000
#define small -big
#define pb push_back



template <typename T>

void prarr(T a)
{
     cerr << "[ ";
     
     for(auto i : a){
         cerr << i << " ";
     }
     
     cerr << "]" << endl;
}


#define trace(...) _er(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>

void _er(const char* name, Arg1&& arg1){
	cerr << "[" << name << " : " << arg1 << "]" << endl;
}

template <typename Arg1, typename... Args>

void _er(const char* names, Arg1&& arg1, Args&&... args){
    
	const char* comma = strchr(names + 1, ',');
	cerr << "[" ; cerr.write(names, comma - names) << " : " << arg1 << "] ";
	_er(comma+2, args...);
}


map<ll, ll> g;

void solve() {
        
         ll n, x, m;
         cin >> n >> x >> m;
         
         if(n == 1) {
                cout << x << endl;
                return;
         }
         
         ll sum = 0;
         
         ll arr[m + 1] = {0};
         
         
         arr[1] = x;
         g[x] = 1;
         ll point = 0;
         ll loop = 0;
         
         for(ll i = 2; i <= m + 3; i++) {
                ll c = arr[i - 1];
                c *= c;
                c %= m;
                if(g[c]) {
                        loop = (i - g[c]);
                        point  = g[c];
                        break;
                }
                g[c] = i;
                arr[i] = c;
         }
         
         for(ll i = 1; i < point; i++) {
                sum += arr[i];
         }
         
         ll er = 0;
         
         for(ll i = point; i < (point + loop); i++) {
             er += arr[i];
         }
         
         n -= (point - 1);
         
         ll d = (n / loop);
         
         sum += (d * er);
         
         n %= loop;
         
         for(ll i = point; i < point + n; i++) {
                sum += arr[i];
         }
         
         cout << sum << endl;
}




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

    int t=1;
   // cin >> t;

    for(int i = 1; i <= t; i++) {  
   
         solve();
    }


    return 0;
        
}


Measured memory_bytes: 7484
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int cnt = 0;
	for(int i = 1; i <= n / 2; ++i){
		int x = n - i;
		if(x != i)cnt++;
	}
	cout<<cnt<<endl;	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
map<int,int> Mark;
const int MAXN=200010;
int A[MAXN];
bool Solve()
{
	int N;
	cin>>N;
	for (int i=1;i<=N;++i)
	{
		scanf("%d",&A[i]);
		if (Mark[A[i]]) return false;
		Mark[A[i]]=true;
	}
	return true;
}
int main()
{
	if (Solve()) printf("YES\n");
	else printf("NO\n");
}

Measured memory_bytes: 10368
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
using namespace std;

int main(void) {
	int N;
	while (cin >> N, N) {
		int W, H, S, T;
		cin >> W >> H;
		vector< vector<bool> > area(H, vector<bool>(W, false) );
		for (int i = 0; i < N; i++) {
			int x, y;
			cin >> x >> y;
			area[--y][--x] = true;
		}
		cin >> S >> T;

		int maxGet = 0;
		for (int x1 = 0; x1 <= W - S; x1++) {
			for (int y1 = 0; y1 <= H - T; y1++) {
				int nowGet = 0;
				for (int x2 = 0; x2 < S; x2++) {
					for (int y2 = 0; y2 < T; y2++) {
						if (area[y1 + y2][x1 + x2]) {
							nowGet++;
						}
					}
				}
				maxGet = max(maxGet, nowGet);
			}
		}

		cout << maxGet << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1224
local function getgcd(x, y)
  while(0 < x and 0 < y) do
    if(x < y) then y = y % x else x = x % y end
  end
  return math.max(x, y)
end
local n = io.read("*n")
local gcd = io.read("*n")
for i = 2, n do
  local a = io.read("*n")
  gcd = getgcd(gcd, a)
end
print(gcd)


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

int main() 
{
    int N;
    cin >> N;
    vector<pair<int, int>> v(N);
    for (int i = 0; i < N; i++) 
    {
        int t;
        cin >> t;
        v[i] = make_pair(t, i+1);
    }
    sort(v.begin(), v.end());
    for (int i = 0; i < N; i++) 
    {
        if (i) cout << " ";
        cout << v[i].second;
    }
    cout << endl;
}

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

int main() {
  ll n; cin >> n;
  vector<ll>v(n);
  rep(i,n) cin >> v[i];
  sort(v.begin(),v.end());
  ll sum = 0;
  rep(i,n-1) sum+=v[i];
  sum+=v[n-1]/2;
  cout << sum << endl;
    
  return 0;
}

Measured memory_bytes: 3572