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

using namespace std;

int main(void) {
    int n;

    cin >> n;
    if(n==1) {cout << 1 << endl; return 0;}

    vector<pair<int,int>> xy(n);
    for(auto &x: xy) cin >> x.first >> x.second;
    sort(xy.begin(), xy.end());

    auto idx = [&](int x, int y) {
        auto t = pair<int,int>(x,y);
        auto it = lower_bound(xy.begin(), xy.end(), t);
        if(it != xy.end() && *it == t) return it;
        return xy.end();
    };

    auto search = [&](int i, int j) {
        int p = xy[i].first - xy[j].first;
        int q = xy[i].second- xy[j].second;

        vector<bool> b(n);
        auto dfs = [&](auto dfs, auto it) {
            int i = it - xy.begin();
            if(b[i]) return;
            b[i] = true;

            {
                auto itt = idx(it->first-p, it->second-q);
                if(itt != xy.end()) dfs(dfs, itt);
            }
            {
                auto itt = idx(it->first+p, it->second+q);
                if(itt != xy.end()) dfs(dfs, itt);
            }
            return;
        };

        int r = 0;
        for(int i=0; i<n; i++) {
            if(!b[i]) r++;
            dfs(dfs, xy.begin()+i);
        }
        return r;
    };

    int r = 1e9;
    for(int i=0; i<n; i++)
        for(int j=i+1; j<n; j++)
            r = min(r, search(i, j));
    cout << r << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int N;
    cin >> N;
    vector<pair<int,int> > vec(N);
    rep(i,N){
        cin >> vec[i].first;
    }
    rep(i,N){
        vec[i].second = i + 1;
    }
    sort(all(vec));
    rep(i,N - 1){
        cout << vec[i].second <<" ";
    }
    cout << vec[N - 1].second << endl;
}

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

int main() {
  char s[4];
  rep(i, 4) cin >> s[i];
  if(s[0] == s[1] && s[2] == s[3] && s[1] != s[2])
    puts("Yes");
  else if ( s[0] == s[2] && s[1] == s[3] && s[2] != s[1])
    puts("Yes");
  else if( s[0] == s[3] && s[1] == s[2] && s[3] != s[1])
    puts("Yes");
  else 
    puts("No");
  return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
	int n;cin>>n;
	vl a(n),b(n);
	vll c(n);
	rep(i,n){
		cin>>a[i]>>b[i];
		c[i].F=b[i];
		c[i].S=a[i];
	}
	sort(all(c));
	ll sum=0;
	rep(i,n){
		sum+=c[i].S;
		if(sum>c[i].F){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
}

Measured memory_bytes: 6528
use v5.18; # strict say state
use warnings;
use List::Util qw(reduce first max min sum0);

chomp (my $n = <STDIN>);
chomp (my @p = split / /, <STDIN>);
chomp (my @q = split / /, <STDIN>);
my $next_perm = sub {
  my $t = shift;
  my $f = -1;
  for my $i (0..length($t)-1) {
    if (ord(substr($t, length($t)-1-$i, 1)) > ord(substr($t, length($t)-2-$i, 1))) {
      $f = length($t) - 2 - $i;
      last;
    }
  }
  return -1 if $f == -1;
  my @w = split '', substr($t, $f+1);
  my @x = sort {$a cmp $b} grep {ord($_) > ord(substr($t, $f, 1))} @w;
  my $r = shift @x;
  push @w, substr($t, $f, 1);
  @w = sort {$a cmp $b} grep {ord($_) != ord($r)} @w;
  return substr($t, 0, $f).$r.join('', @w);
};
my $x = join('', @p);
my $y = join('', @q);
if ($x gt $y) {
  ($x, $y) = ($y, $x);
}
my $ans = 0;
while ($x ne $y) {
  $x = $next_perm->($x);
  $ans++;
}
say $ans;

Measured memory_bytes: 896
#include <bits/stdc++.h>
#include <sys/types.h>
#include <unistd.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

template<typename T> vector<T> make_vector(size_t sz){
	return vector<T>(sz);
}

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

template<typename T,typename U,typename... V> 
typename enable_if<is_same<T, U>::value!=0>::type 
fill_value(U &u, const V... v){
	u=U(v...);
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_value(U &u, const V... v){
	for(auto &e:u){
		fill_value<T>(e,v...);
	}
}

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

const pid_t pid = getpid();
// Problem Specific Parameter:

int main(void){
	ll n, a, b;
	cin >> n >> a >> b;
	const ll d = abs(a - b);
	if(d % 2 == 0) {
		cout << d / 2 << endl;
	} else {
		const ll head_a = a - 1LL;
		const ll head = head_a + (b - head_a + 1) / 2;
		const ll tail_b = n - b;
		const ll tail = tail_b + (n - a - tail_b + 1) / 2;
		cout << min(head, tail) << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AizuGCDLCM solver = new AizuGCDLCM();
        solver.solve(1, in, out);
        out.close();
    }

    static class AizuGCDLCM {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            while (in.hasNext()) {
                int x = in.nextInt();
                int y = in.nextInt();

                int g = gcd(x, y);
                long p = (long) x * y;
                long l = p / g;

                out.printf("%d %d\n", g, l);
            }
        }

        private int gcd(int x, int y) {
            while (y != 0) {
                int t = x % y;
                x = y;
                y = t;
            }

            return x;
        }

    }
}




Measured memory_bytes: 26428
{-# LANGUAGE BangPatterns      #-} --引数に!

import Data.Bits
import Data.Foldable (foldlM,foldrM)
import Data.Maybe (fromJust)
import Data.List
import qualified Data.Vector.Unboxed.Mutable as V
import Control.Monad
import qualified Data.ByteString.Lazy.Char8 as BS
import Debug.Trace

main :: IO ()
main = do
  n <- readLn :: IO Int
  as <- forM [1..n] $ \i -> do
    [s,p] <- words <$> getLine :: IO [String]
    return (i,(s,(read p :: Int)))
  let as' = concat $ map (sortOn (\x -> (0-) $ (snd.snd) x)) $ groupBy (\x y -> (fst.snd) x == (fst.snd) y) $ sortOn (fst.snd) as
  forM_ as' $ \(i,_) -> do
    print (i :: Int)


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

int main() {
  cout << setprecision(15);
  int a;
  string s;
  cin >> a;
  cin >> s;
  if (a < 3200) {
    cout << "red" << endl;
  } else {
    cout << s << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX_N = 1e6 + 5;
int arr[MAX_N];
 
void solve()
{
}
 
int main()
{
    char d;
    cin >> d;
    if (d - 'A' < 26)
    {
        cout << 'A' << "\n";
    }
    else
    {
        cout << 'a' << "\n";
    }
}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <string>
#include <queue>
using namespace std;
#define INF 100000000
int main(void){
    int h,w,n,ans=0;
    pair<int,int> start;
    cin>>h>>w>>n;
    vector<string>field(h+2,string(w+2,'X'));
    vector<vector<int>>d(h+2,vector<int>(w+2,0));
    vector<pair<int,int>>goal(n);
    int dx[4]={1,0,-1,0};
    int dy[4]={0,1,0,-1};

    for(int i=1;i<h+1;i++){
        for(int j=1;j<w+1;j++){
            cin>>field[i][j];
            if(field[i][j]=='S'){
                start.first=j;
                start.second=i;
            }else if(field[i][j]!='.'&&field[i][j]!='X'){
                goal[(int)(field[i][j]-'1')].first=j;
                goal[(int)(field[i][j]-'1')].second=i;
            }
        }
    }
    for(int i=0;i<n;i++){
        queue<pair<int,int>> que;
        for(int j=0;j<h+2;j++){
            for(int k=0;k<w+2;k++){
                d[j][k]=INF;
            }
        }
        que.push(pair<int,int>(start.first,start.second));
        d[start.second][start.first]=0;
        while(que.size()){
            pair<int,int> p=que.front();
            que.pop();
            if((p.first==goal[i].first)&&(p.second==goal[i].second)){
                break;
            }
            for(int j=0;j<4;j++){
                int nx=p.first+dx[j];
                int ny=p.second+dy[j];
                if(field[ny][nx]!='X'&&d[ny][nx]==INF){
                    que.push(pair<int,int>(nx,ny));
                    d[ny][nx]=d[p.second][p.first]+1;
                }
            }
        }
        ans+=d[goal[i].second][goal[i].first];
        start.first=goal[i].first;
        start.second=goal[i].second;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 7924
program main
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: tobig = ichar('A') - ichar('a')
    character(10):: a,b,c
    read*, a,b,c
    print'(a)', char(ichar(a(1:1))+tobig) // char(ichar(b(1:1))+tobig) // char(ichar(c(1:1))+tobig)
end program main

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

# 1行目
N,L = map(int,input().split())
mylist = []
for i in range(N):
  val = input()
  if val:
    mylist.append(val)
  else:
    break
    
s = ""  
mylist.sort()
for a in mylist:
  s += a
print(s)

Measured memory_bytes: 3060
//#include<iostream>
//#include<algorithm>
//#include<string>
//#include <cmath>
//#include <vector>
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define REP(x,n) for(int x=0;x<n;x++)

//vector//
#define vei vector<int> 
#define velli vector<long long int> 
#define pb(x) push_back(x) // 末尾にxを加える
#define pb2 pop_back() // 末尾削除
#define all(x) (x).begin(),(x).end() //イテレーター
#define be(x) (x).begin()
//auto  auto begin = v.begin()とか

typedef pair<int,int> P;  //q(p.first,p.second)

///////sortされたsを使う/////////
int BinarySearch(vector<int> &s, int key,int n){
    int left = 0;
    int right = n;
    while(left < right){
        int mid = (left + right)/2;
        if(s[mid]==key){
            return mid;
        }
        else if(key < s[mid]){
            right = mid;
        }
        else{
            left = mid+1;
        }
    }
    return -100;
}

int main (){
    int n,q;
    cin >> n;
    vector<int> s(n);
    REP(i,n){
        cin >> s[i];
    }
    cin >> q;
    vector<int> t(q);
    REP(i,q){
        cin >> t[i];
    }

    int ans = 0;
    REP(i,q){
        if(BinarySearch(s,t[i],n)!= -100){
            ans++;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3360
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

int n, m;
vector<int> es[100000];

int ved[100000];

bool dfs(int v, int ev) {
	ved[v] = ev;
	ev = (ev == 1 ? 2 : 1);
	bool res = false;
	REP(i, es[v].size()) {
		int u = es[v][i];
		res |= (ved[u] != 0 && ved[u] != ev);
		if (ved[u] == 0) res |= dfs(u, ev);
	}
	return res;
}

int main(int argc, char **argv) {
	cin >> n >> m;
	REP(i, m) {
		int u, v;
		cin >> u >> v;
		--u; --v;
		es[u].push_back(v);
		es[v].push_back(u);
	}

	CLEAR(ved);
	ll tp[3] = {};
	REP(i, n) {
		if (ved[i] != 0) continue;
		if (es[i].size() == 0) ++tp[0];
		else ++tp[dfs(i, 1) ? 2 : 1];
	}

	ll res = 0;
	res += 2 * tp[0] * n - tp[0] * tp[0];
	res += tp[1] * 2 + tp[2];
	res += 2 * tp[1] * tp[2];
	res += 2 * tp[1] * (tp[1] - 1);
	res += tp[2] * (tp[2] - 1);

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 10880
#include<stdio.h>
#include<algorithm>

using namespace std;

int main(){
	int n,a,b,c;
	int m=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		int a[3];
		for(int j=0;j<3;j++)scanf("%d",&a[j]);
		std::sort(a,a+3);
		
		int d = 32;
		if(a[0]>d || a[1]>d || a[2]>d)puts("hogehogehoge");
		
		if(a[0]*a[0]+a[1]*a[1] == a[2]*a[2]){
			puts("YES");
		}else{
			puts("NO");
		}
	}
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  long long n,m,ans=1,a=1000000007;
  cin >> n >> m;
  if(abs(n-m)>1) {
    cout << 0 << endl;
    return 0;
  }
  for(long long i=2; i<=n; i++) {
    ans*=i;
    ans%=a;
  }
  for(long long i=2; i<=m; i++) {
    ans*=i;
    ans%=a;
  }
  if(n==m) {
    ans=ans*2%a;
  }
  cout << ans << endl;
}

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

int main() {
    int a,b,c,d,e,f;
    cin>>a>>b>>c>>d>>e>>f;
    a*=100;
    b*=100;
    int mx=0;
    int g=a,h=0;
    for (int i=0;i<=f;i+=a)
        for (int j=0;i+j<=f;j+=b)
            for (int k=0;i+j+k<=f;k+=c)
                for (int l=0;i+j+k+l<=f;l+=d)
                    if (i+j+k+l!=0&&(i+j)/100*e>=k+l&&(k+l)*10000/(i+j+k+l)>mx)
                        mx=(k+l)*10000/(i+j+k+l),g=i+j+k+l,h=k+l;
    cout<<g<<' '<<h<<endl;
    return 0;
}

Measured memory_bytes: 256
s = str(input())
s = ''.join(list(reversed(s)))

t = 0
while t <= len(s):
    if s[t:t+5] == 'maerd':
        t += 5
        continue
    elif s[t:t+7] == 'remaerd':
        t += 7
        continue
    elif s[t:t+5] == 'esare':
        t += 5
        continue
    elif s[t:t+6] == 'resare':
        t += 6
        continue
    elif t == len(s):
        print('YES')
        quit()
    else:
        break
print('NO')

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

#define NMAX 200100
#define INF 2000000000

#define MOD 1000000007

typedef unsigned long long ull;

using namespace std;

int main()
{
    char str[110];

    cin >> str;

    int n = strlen(str);

    for(int i = 0; i < n; i++)
    {
        if((i+1) % 2 == 0)
        {
            if(str[i] == 'R')
            {
                cout << "No\n";
                exit(0);
            }
        }
        else if((i+1) % 2 == 1 && str[i] == 'L')
        {
            cout << "No\n";
            exit(0);
        }
    }

    cout << "Yes\n";

    return 0;
}


Measured memory_bytes: 256
pp = list(map(int, input().split()))
n = int(input())

def project(bb, p=pp):
    ans = []
    a = (p[2]-p[0], p[3]-p[1])
    b = (bb[0]-p[0], bb[1]-p[1])
    if dot(a,b)<0:
        a = (-a[0], -a[1])
    c = dot(a,b)/length(a)**2
    ans += [c*v+p[i] for i, v in enumerate(a)] 
    return ans
    
def length(vector):
    ans = 0
    for i in vector:
        ans += i**2
    return ans**(1/2)
    
def dot(a, b):
    n = len(a)
    if n != len(b):
        return None
    ans = 0
    for i, j in zip(a, b):
        ans += i*j
    return ans
    
def reflection(b, p = pp):
    a = project(b)
    ans = (b[0]+2*(a[0]-b[0]), b[1]+2*(a[1]-b[1]))
    print(f'{ans[0]:.8f} {ans[1]:.8f}')
    
for i in range(n):
    b = list(map(int, input().split()))
    reflection(b)


Measured memory_bytes: 5680
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef long long ll;
typedef vector<ll> vl;
int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  cout << fixed << setprecision(10);
  /*--------------------------------*/
  ll q;cin>>q;
  vl a(q),b(q);
  rep(i,q)cin>>a[i]>>b[i];
  rep(i,q){
    ll x=min(a[i],b[i]);
    ll y=max(a[i],b[i]);
    ll ans=x-1;
    long double k=sqrt(x*y-0.75)-x+0.5;
    ll lk=k;
    ans+=k+(x*y-1)/(x+k);
    if(a[i]==b[i])cout<<ans<<endl;
    else cout<<ans-1<<endl;
  }
}


Measured memory_bytes: 3636
s = input()
t = input()
tlen = len(t)
anslist = []
n = len(s)
'''
当てはまる文字列を全列挙してソート
'''
def mojiretu(a):
    global anslist
    a = list(a)
    for i in range(len(a)):
        if a[i] == '?':
            a[i] = 'a'
    anslist.append(''.join(a))

def hantei(ss):
    for i in range(len(ss)):
        if ss[i] != t[i] and ss[i] != '?':
            return False
    else:return True

for i in range(n+1-tlen):
    if s[i] == t[0] or s[i] == '?':
        if hantei(s[i:i+tlen]):
            mojiretu(s[:i] + t + s[i+tlen:])
anslist.sort()
if anslist:
    print(anslist[0])
else:
    print('UNRESTORABLE')




Measured memory_bytes: 3064
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;


class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;
    

    void calc()
    {
        cin = new Scanner();
        string S = cin.next();
        if (S.Length % 2 == (S[0] == S[S.Length - 1] ? 0 : 1)) Console.WriteLine("First");
        else Console.WriteLine("Second");
    }


}

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

Measured memory_bytes: 13140
/*input

*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define REP(i,j,k)     for(int i = j ; i < k ; ++i)
#define RREP(i,j,k)    for(int i = j ; i >=k ; --i)
#define A    first
#define B    second
#define mp   make_pair
#define pb   emplace_back
#define PII pair<int , int>
#define MEM(i,j)   memset(i , j , sizeof i)
#define ALL(i)     i.begin() , i.end()
#define DBGG(i,j)     cout << i << " " << j << endl
#define DB4(i,j,k,l)  cout << i << " " << j << " " << k << " " << l << endl
#define IOS cin.tie(0) , cout.sync_with_stdio(0)
#define endl "\n"
///------------------------------------------------------------
#define MAX 
#define INF 0x3f3f3f3f


int a , b , c;
int32_t main(){
	IOS;
	cin >> a >> b >> c;
	cout << ((a + b >= c) ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
from sys import stdin, stdout
import math
import bisect
import queue

N,H,W = map(int,stdin.readline().strip().split())

ans = 0

for i in range(N):
    A, B = map(int, stdin.readline().strip().split())
    ans += min(A // H, B // W)

stdout.writelines(str(ans) + '\n')


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

int main() {
  string S;
  cin >> S;
  
  if( S.at(0) != 'A' ){ //先頭が大文字のAかどうか
    cout << "WA" << endl;
    return 0;
  }else if( S.at(1) == 'C' || S.back() == 'C' ){ //2文字目もしくは最後の文字がCかどうか
    cout << "WA" << endl;
    return 0;
  }
  int count = 0; //ここからCが0個または2個以上か調べる
  for( int i = 2; i < S.size() - 1; i++ ){
    if( S.at(i) == 'C' ) count++;
    if( count > 1 ){
      cout << "WA" << endl;
      return 0;
    }
  }
  if( count == 0 ){ //Cが0個のとき
    cout << "WA" << endl;
    return 0;
  }
  //ここまで
  
  for( int i = 1; i < S.size(); i++ ){ //大文字がないか調べる
    if( S.at(i) >= 'A' && S.at(i) <= 'Z' && S.at(i) != 'C' ){
      cout << "WA" << endl;
      return 0;
    }
  }
  cout << "AC" << endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int N;
  cin >> N;
  vi A(N);
  rep(i,N) {
    cin >> A[i];
  }
  vi maxL(N),maxR(N);
  maxL[0] = A[0];
  srep(i,1,N){
    maxL[i] = max(maxL[i-1],A[i]);
  }
  maxR[N-1] = A[N-1];
  for(int i = N-2;i >= 0;i--) {
    maxR[i] = max(maxR[i+1],A[i]);
  }
  vi ans(N);
  ans[0] = maxR[1];
  ans[N-1] = maxL[N-2];
  srep(i,1,N-1) {
    ans[i] = max(maxL[i-1],maxR[i+1]);
  }
  rep(i,N) {
    cout << ans[i] <<endl;
  }
  return 0;
}

Measured memory_bytes: 4736
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextInt()
  val a = (1..n).map { sc.nextLong() }


  var ans = 0L
  for (ai in a) {
    ans += ai - 1L
  }
  println(ans)

}


Measured memory_bytes: 32792
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> data(n);
  for(int i=0;i<n;i++)cin>>data[i];
  int tot=0;
  for(int i=0;i<n;i++)tot+=data[i];
  int ans=20000;
  for(int i=0;i<n;i++){
    int sum=0;
    for(int j=0;j<i;j++)sum+=data[j];
    int dif=max(tot-2*sum,2*sum-tot);
    if(dif<ans)ans=dif;
  }
  cout<<ans<<endl;
}

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 K;
  string S;
  cin >> K;
  cin >> S;
  if(S.size() <= K) cout << S << endl;
  else{
    string S1;
    rep(i,K) S1 += S[i];
    S1 += "...";
    cout << S1 << endl;
  }
  return 0;
}

Measured memory_bytes: 3584
'use strict';
process.stdin.on('data', function(chunk) {
    var inputs = chunk.toString().trim();
  var expressions = inputs.split('\n');
  for (var i = 0; i < expressions.length; i++) {
    if (expressions[i] === '0 ? 0') {
    	break;
    }
    var expression = expressions[i].split(' ');
    var left = Number(expression[0]);
    var right = Number(expression[2]);
    var op = expression[1];

    switch(op) {
    	case '+':
    	console.log(left + right);
    	break;
    	case '-':
    	console.log(left - right);
    	break;
    	case '*':
    	console.log(left * right);
    	break;
    	case '/':
    	console.log(Math.floor(left / right));
    	break;

    }

    }
});
process.stdin.resume();
process.stdin.setEncoding('utf8');

Measured memory_bytes: 16068
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD=1000000007;
ll INF=300000;

int main(){
    ll N;
    cin>>N;
    string S;
    cin>>S;
    int Max=0;
    for(int i=0; i<N-1; i++){
        vector<pair<bool, bool>>  Jd(26);
        int Cou=0;
        for(int i=0; i<26; i++){
            Jd.at(i).first=false;
            Jd.at(i).second=false;
        }
        for(int j=0; j<=i; j++){
            Jd.at(S.at(j)-'a').first=true;
        }
        for(int j=i+1; j<N; j++){
            Jd.at(S.at(j)-'a').second=true;
        }
        for(int i=0; i<26; i++){
            if(Jd.at(i).first&&Jd.at(i).second){
                Cou ++;
            }
        }
        Max=max(Max, Cou);
    }
  	cout<<Max<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fst first
#define snd second
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define repeat_reverse_from_to(i, m, n) for(lint i = (m); (i) >= (lint)(n); --(i))
#define el cout<<endl
#define dump(x) cout<<" "<<#x<<"="<<x
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std;
using lint = long long;
using ld = long double;

int main(void) {
    int n; cin >> n;
    vector<int> t(n+1), x(n+1), y(n+1); repeat(i, n) cin >> t[i+1] >> x[i+1] >> y[i+1];
    t[0] = x[0] = y[0] = 0;
    
    auto dist = [](int x1, int y1, int x2, int y2) -> int {
        return abs(x1-x2) + abs(y1-y2);
    };
    
    auto parity = [](int m, int n) -> bool {
        if (m % 2 == n % 2) return true;
        else return false;
    };
    
    repeat (i, n) {
        int d = dist(x[i], y[i], x[i+1], y[i+1]);
        int dt = t[i+1] - t[i];
        if (parity(dt, d) and d <= dt) {
            continue;
        }
        else {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
int main() {
    int n;
    cin >> n;
    vector<pair<pair<string,int>,int>>p(n);
    string s;
    int t;
    for (int i = 0; i < n; i++) {
        cin >> s >> t;
        p[i].first.first = s;
        p[i].first.second = (-1) * t;
        p[i].second = i + 1;
    }
    sort(p.begin(), p.end());
    for (auto id : p) {
        cout << id.second << endl;
    }
    return 0;
}

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

int main() {
  int s,s1,s2,s3,p;
  cin >> s;
  s1 = int (s / 100);
  s2 = int ((s - s1 * 100) / 10);
  s3 = s - s1 * 100 - s2 * 10;
  p = s1 + s2 + s3;
  cout << p << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string result = "";
            for (int i = 0; i < s.Length; i++)
            {
                if (s.Substring(i, 1) == "0")
                {
                    result += "0";
                }
                else if (s.Substring(i, 1) == "1")
                {
                    result += "1";
                }
                else if (s.Substring(i, 1) == "B")
                {
                    if (result != "")
                    {
                        result = result.Substring(0, result.Length - 1);
                    }
                }
            }
            Console.WriteLine(result);
        }
    }
}
// 文字列の入力
//string s = Console.ReadLine();

// 整数の入力
//long n = long.Parse(Console.ReadLine());

// 文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');

// 整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();


//Console.WriteLine(ans);


Measured memory_bytes: 25880
#include<bits/stdc++.h>
using namespace std;
/*2 100*/
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b; cin>>a>>b;
    if((b-2*a)%2==0)
    {
        int x=(b-2*a)/2;
        int y=a-x;
        if(x>=0 && y>=0)
        {
            cout<<"Yes"<<endl;
        }
        else
        cout<<"No"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 3640
import sys
from math import sqrt, ceil
from collections import deque, Counter, defaultdict #すべてのkeyが用意されてる defaultdict(int)で初期化
input=lambda: sys.stdin.readline().strip()
sys.setrecursionlimit(11451419)
from decimal import ROUND_HALF_UP,Decimal  #変換後の末尾桁を0や0.01で指定
  #Decimal((str(0.5)).quantize(Decimal('0'), rounding=ROUND_HALF_UP))
from functools import lru_cache
from bisect import bisect_left as bileft, bisect_right as biright
from fractions import Fraction as frac  #frac(a,b)で正確なa/b
#メモ化再帰defの冒頭に毎回 @lru_cache(maxsize=10**10)
#引数にlistはだめ
#######ここまでテンプレ#######
#ソート、"a"+"b"、再帰ならPython3の方がいい
#######ここから天ぷら########

n,a,b=map(int,input().split())
A=sorted(list(map(int,input().split())))
print(sum(A[n-a:])/a)
q=A[n-a]
cnt=A.count(A[n-a])
kaku= n- biright(A,q)

def C(n, r ,mod=2**62):
    if n-r<r: r=n-r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k]) %mod

    return result % mod
ans=0
if cnt==1:
    print(1);exit()

if kaku==0:
    for i in range( a-kaku,min(b-kaku,cnt)+1 ):
        ans+=C(cnt,i)

else:
    ans=C(cnt,a-kaku)
print(ans)

Measured memory_bytes: 72848
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
#define INF 1e9
#define showVector(v) rep(i,0,v.size()){p(v[i]);p(" ")} pl("")
#define p(s) std::cout << s ;
#define pl(s)  std::cout << s << endl;
using namespace std;

// 素数判定 O(√n)
bool is_prime(int n){
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0) return false;
    }
    return true;
}

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

}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {
    ll H, N;
    cin >> H >> N;

    rep(i, 0, N) {
        ll A;
        cin >> A;
        H -= A;
        if (H <= 0) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

const int INF = 1001001001;

vector<int> to[100005];

int main() {
  int n,m;
  cin >> n >>m;
  
  for (int i = 0; i < m; i++) {
    int a,b;
    cin >> a >> b;
    a--; b--;
    to[a].push_back(b);
    to[b].push_back(a);    
  }
  queue<int>que;
  vector<int>dist(n,INF);
  vector<int>pre(n,-1);
  dist[0] = 0;
  que.push(0);

  while(!que.empty()) {
    int v = que.front(); que.pop();

    for (int u : to[v]) {
      if (dist[u] != INF) continue;

      dist[u] = dist[v] + 1;
      pre[u] = v;
      que.push(u);
    }
  }  
  cout << "Yes" << endl;
  for (int i = 0; i < n; i++) {
    if (i == 0) continue;
    int ans = pre[i];
    ans++;
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 10660
import java.io.*;

public class Main {

    public static void main(String[] args) throws IOException {
        PrintWriter prnt = new PrintWriter(System.out);
        BufferedReader read = new BufferedReader(new InputStreamReader(System.in));

        String s = read.readLine();
        int res = 0;
        if (s.charAt(0) == 'R' && s.charAt(1) == 'R' && s.charAt(2) == 'R') {
            res = 3;
        } else if (s.charAt(0) == 'R' && s.charAt(1) == 'R') {
            res = 2;
        } else if (s.charAt(1) == 'R' && s.charAt(2) == 'R') {
            res = 2;
        } else if (s.charAt(0) == 'S' && s.charAt(1) == 'S' && s.charAt(2) == 'S') {
            res = 0;
        } else {
            res = 1;
        }

        prnt.println(res);
        prnt.close();
    }
}

Measured memory_bytes: 32680
MOD = 1000000007

N, K = map(int, input().split())

facts = [1] * (N + 1)
for i in range(1, N + 1):
    facts[i] = facts[i - 1] * i
    facts[i] %= MOD
invfacts = [1] * (N + 1)
for i, v in enumerate(facts):
    invfacts[i] = pow(v, MOD - 2, MOD)

for i in range(1, K + 1):
    if i > N - K + 1:
        print(0)
        continue
    ans = facts[K - 1] * facts[N - K + 1] * invfacts[K - i] * \
        invfacts[N - K - i + 1] * invfacts[i] * invfacts[i - 1]
    print(ans % MOD)


Measured memory_bytes: 3444
n = int(input())
S = input()
res = 0
for i in range(1000) :
    T = str(i).zfill(3)
    a = 0
    b = 0
    f1 = 0
    f2 = 0
    f = 0
    for j,t in enumerate(T) :
        if f :
            break
        for k,s in enumerate(S) :
            if t == s :
                if not f1 :
                    f1 = 1
                    a = k
                    break
                elif f1 and not f2 and a < k :
                    f2 = 1
                    b = k
                    break
                elif f1 and f2 and b < k :
                    res += 1
                    f = 1
                    break
print(res)


Measured memory_bytes: 44636
#include<bits/stdc++.h>
using namespace std;
const int N=6e5+10,p=1e9+7;
void update(int &x,int y){x+=y;if (x>=p) x-=p;}
int n,m,k,U,must[30],state[30],lowbit[N];
int dp[30][N];
void trans(int *x,int *y){
    static int dp[30][N];
    for (int i=0;i<n;i++)
    for (int S=0;S<U;S++)
        dp[i][S]=0;
    for (int S=0;S<U;S++) dp[0][S]=x[S];
    for (int i=0;i<n-1;i++)
    for (int S=0;S<U;S++){
        int v=dp[i][S];
        update(dp[i+1][S],v);
        if (!(S>>i&1)){
            int T=S;
            T^=lowbit[T>>i]<<i;
            T^=1<<i;
            T&=(U-1);
            update(dp[i+1][T],v);
        }
    }
    for (int S=0;S<U;S++) y[S]=dp[n-1][S];
}
int main()
{
	scanf("%d%d%d",&n,&m,&k);
	for (int i=1;i<=k;i++){
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);b--;
		must[a]|=(1<<b);
		state[a]|=(c<<b);
	}
	U=1<<(n-1);
	for (int S=0;S<U;S++) lowbit[S]=S&-S;
	dp[0][0]=1;
	for (int i=1;i<=m;i++){
        trans(dp[i-1],dp[i]);
        for (int S=0;S<U;S++)
        if (must[i]&S^state[i]) dp[i][S]=0;
	}
	int ans=0;
	for (int S=0;S<U;S++) update(ans,dp[m][S]);
	printf("%d\n",ans);
	return 0;
}


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

using namespace std;

#define N 100005

int n, a[N], ans, now;

inline int read();

int main() {
	n = read();
	for(int i = 1; i <= n; ++i) a[i] = read();
	for(int i = 2; i <= n; ++i) {
		if(a[i] <= a[i - 1]) now++;
		else {
			ans = max(ans, now);
			now = 0;
		}
	}
	printf("%d\n", max(ans, now));
	return 0;
}

inline int read() {
	int x = 0, t = 1; char ch = getchar();
	while(ch < '0' || ch > '9') (ch == '-') && (t = -1), ch = getchar();
	while(ch >= '0' && ch <= '9') x = x * 10 + (ch ^ 48), ch = getchar();
	return x * t;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll m;cin>>m;
  ll ans=0;
  vi A;
  for(int i=0;i<m;i++){
    ll a,b;cin>>a>>b;
    vi hogg;
    for(ll i=BITLE(50);i>0;i/=2){
      if(b>=i){
	ll num=a;
	ll cnt=i;
	ll plus=0;
	
	while(cnt>1){
	  num*=2;
	  if(num>=10){
	    num=num/10+num%10;
	    plus+=cnt;
	    cnt/=2;
	  }else{
	    plus+=cnt/2;
	    cnt/=2;
	    
	  }
	}
	hogg.pb(num);
	ans+=plus;
	b-=i;
      }
    }
    if(hogg.size() == 0){
      A.pb(a);
    }else{
      ll noww=hogg[0];
      for(ll ii=1;ii<hogg.size();ii++){
	noww+=hogg[ii];
	if(noww>=10){
	  noww=noww/10+noww%10;
	  ans+=2;
	}else{
	  ans++;
	}
      }
      A.pb(noww);
    }
  }
  ll now=A[0];
  for(int i=1;i<A.size();i++){
    now+=A[i];
    if(now>=10){
      now=now/10+now%10;
      ans+=2;
    }else{
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 2420
n,w = (int(i) for i in input().split())
x = [[int(i) for i in input().split()] for i in range(n)]
x,y,z,num,ans = sorted(x)[::-1],[0,0,0,0],[[0] for i in range(4)],x[0][0],0
for i,j in x:
	y[i-num] += 1
	z[i-num].append(z[i-num][-1]+j)
for i1 in range(y[0]+1):
	for i2 in range(y[1]+1):
		for i3 in range(y[2]+1):
			for i4 in range(y[3]+1):
				if (i1+i2+i3+i4)*num+i2+2*i3+3*i4>w: break
				else: ans = max(ans,z[0][i1]+z[1][i2]+z[2][i3]+z[3][i4])
print(ans)

Measured memory_bytes: 3064
# coding: utf-8

w, h, N = list(map(int, input().split()))

rect = [0, w, 0, h]
for i in range(N):
    x, y, a = list(map(int, input().split()))
    rect[a - 1] = (lambda c, r, p: [r, c][p * (c - r) < 0])([x, y][a > 2], rect[a - 1], [1, -1][a % 2])

length = lambda x: [x, 0][x < 0]
print(length(rect[1] - rect[0]) * length(rect[3] - rect[2]))

Measured memory_bytes: 3064
#include <bits/stdc++.h>  // clang-format off
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef _MY_DEBUG
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sat Apr  4 21:00:23 JST 2020
 **/

signed main() {
    Int x, y, z;
    std::cin >> x >> y >> z;
    std::cout << z << " " << x << " " << y << std::endl;
}


Measured memory_bytes: 256
sx,sy,tx,ty=map(int,input().split())
dx=tx-sx
dy=ty-sy
s=''
route=['U' for i in range(dy)]
for i in range(dx):
    route.append('R')
for i in range(dy):
    route.append('D')
for i in range(dx+1):
    route.append('L')
for i in range(dy+1):
    route.append('U')
for i in range(dx+1):
    route.append('R')
route.append('D')
route.append('R')
for i in range(dy+1):
    route.append('D')
for i in range(dx+1):
    route.append('L')
route.append('U')
for i in range(len(route)):
    s+=route[i]
print(s)


Measured memory_bytes: 3188
# -*- coding: utf-8 -*-
"""
Created on Tue Apr 28 22:12:42 2020
"""

import sys
#import numpy as np

sys.setrecursionlimit(10 ** 9)
#def input():
#    return sys.stdin.readline()[:-1]
mod = 10**9+7

#N = int(input())
X, Y, A, B, C = map(int,input().split())
r = list(map(int,input().split()))
g = list(map(int,input().split()))
n = list(map(int,input().split()))

r.sort()
g.sort()
n.sort()

x, y = A-X, B-Y
z = C-1
ans = 0
ans += sum(r[x:])
ans += sum(g[y:])
g.append(10**10)
#print(x,y,z,r[x],g[y],n[z],ans)
while z >= 0:
#    print(x,y,z,r[x],g[y],n[z],ans)
    flg = True
    if x < A and r[x] < n[z] and r[x] < g[y]:
        ans += (n[z] - r[x])
        x += 1
        z -= 1
        flg = False
    elif y < B and g[y] < n[z]:
        ans += (n[z] - g[y])
        y += 1
        z -= 1
        flg = False
    if flg:
        break
#print(x,y,z,r[x],g[y],n[z],ans)
print(ans)



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


using ll = long long;
const int MaxN = 2e5;
int N, P;
string S;
int powten[MaxN];
int cnt[MaxN];


void solve2()
{
    ll ans = 0;
    for (int i = 0; i < N; i++) {
        int d = S[N - 1 - i] - '0';
        if (d % 2 == 0) ans += N - i;
    }
    cout << ans << endl;
}


void solve5()
{
    ll ans = 0;
    for (int i = 0; i < N; i++) {
        int d = S[N - 1 - i] - '0';
        if (d % 5 == 0) ans += N - i;
    }
    cout << ans << endl;
}


void solvep()
{
    powten[0] = 1;
    for (int i = 1; i < MaxN; i++) powten[i] = powten[i - 1] * 10 % P;    

    ll ans = 0;
    int x = 0;
    for (int i = 0; i < N; i++) {
        int d = S[N - 1 - i] - '0';
        x = (x + d * powten[i]) % P;
        ans += cnt[x];
        if (x == 0) ans++;
        cnt[x]++;
    }    
    cout << ans << endl;
}


int main()
{
    cin >> N >> P;
    cin >> S;
    if (P == 2) solve2();
    else if (P == 5) solve5();
    else solvep();
    return 0;
}


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

using namespace std;

typedef long long ll;

int main() {
	
	ll N, W;
	cin>>N>>W;
	ll dp[N+1][W+1];
	ll w[N+1], v[N+1];

	for (int i = 0;i <= N;++i) {
		for (int j = 0;j <= W;++j) {
			dp[i][j] = 0;
		}
	}
	
	for (int i = 1;i <= N;++i) {
		cin>>w[i]>>v[i];
	}
	
	for (int i = 1;i <= N;++i)  {
		for (int j = 1;j <= W;++j) {
			if (w[i] > j) {
				dp[i][j] = dp[i-1][j];
			}
			else {
				dp[i][j] = max(dp[i-1][j-w[i]] + v[i], dp[i-1][j]);
			}
		}
	}
	
	cout<<dp[N][W];
	return 0;
}


Measured memory_bytes: 82436
#include<iostream>
#include<string>
#include<utility>
#include<cmath>
#include<algorithm>
using namespace std;
int main (){
	int n,k,h[100000],ans=1000000000;
	cin>>n>>k;
	for(int a=0;a<n;a++)cin>>h[a];
	sort(h,h+n);
	for(int i=n-1;i>=k-1;i--){
		if(h[i]-h[i-k+1]<ans){
			ans=h[i]-h[i-k+1];
			}
		}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
//#define int long long

int f(int a, int b) {
    if (a % b == 0)
        return a / b;
    else
        return a / b + 1;
}

signed main() {
    int n, t, x;
    cin >> n >> x >> t;
    cout << f(n, x) * t << endl;
}

Measured memory_bytes: 3628
#include<iostream>
#define rep(i,n) for(int i=0;i<n;i++)
#define MAX 1000000007
using namespace std;

int main(void){
	int N,M;
	cin>>N>>M;
	int a[M];
	rep(i,M)cin>>a[i];
	long long int x=1,y=0;
	int cnt=0;
	rep(i,N){
		long long int tmp=x;
		if(i+1 == a[cnt] && cnt<M){
			y = x%MAX;
			x = 0;
			cnt++;
		}
		else{
			x = (x+y)%MAX;
			y = tmp;
		}
		//cout<<i+1<<":"<<"x="<<x<<","<<"y="<<y<<endl;	
	}
	cout<<x%MAX<<endl;
	return 0;

}

Measured memory_bytes: 640
import java.util.*; 
import java.io.*;

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

        int A = nextInt();
        long B = nextLong();
        long N = nextLong();

        // if Y = n*B + x, 
        // Y/B = n +x/B
        // Y and x answer is same
        // x=B, then = 0
        // let 0<=x<=B-1//a non-negative integer x
        // A × floor(x/B) = 0
        // floor(Ax/B) is increasing

        long low = Math.min(B-1, N);

        System.out.println(A*low/B);
    }
    
      
    public static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    public static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    public static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    static String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine().trim());
        return st.nextToken();
    }
}

Measured memory_bytes: 32776
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
#define MOD (1000000007ll)
#define l_ength size
#define EPS (1e-10)

vector<int> x[22];

int main(void){
	int a[225816],n,i,j,cnt,p;
	ll ans=0ll;
	cin >> n;
	for(i=0; i<n; ++i){
		cin >> a[i];
		for(j=0; j<20; ++j){
			if(a[i]&(1<<j)){
				x[j].push_back(i);
			}
		}
	}
	for(j=0; j<20; ++j){
		x[j].push_back(n);
		x[j].push_back(n+1);
		sort(x[j].begin(),x[j].end());
	}
	for(i=0; i<n; ++i){
		cnt=n;
		for(j=0; j<20; ++j){
			if(!x[j].size()){ continue; }
			p = i;
			if(a[i]&(1<<j)){--p;}
			p = x[j][(int)(upper_bound(x[j].begin(),x[j].end(),p)-x[j].begin())];
			p = x[j][(int)(upper_bound(x[j].begin(),x[j].end(),p)-x[j].begin())];
			p = min(n,p);
			cnt = min(cnt,p);
		}
		ans += (cnt-i);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 9024