akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using ll=long long;
using ld=long double;
#define inf INT_MAX  
const ll infll=1ll*inf*inf;
#define mode 998244353
#define mod 1000000007
const long double PI=3.141592653589793238462643383279502884197169399375105820974944;
#define pb push_back
#define mp make_pair
#define ub upper_bound 
#define lb lower_bound 
#define far(i,a,b) for (ll i = a; i <= b; i++)
#define rev(i,a,b) for (ll i = a; i >= b; i--)
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define sz(a) int((a).size())
#define ftr(c,i) for(auto i = begin(c); i != end(c); i++)
#define rtr(c,i) for(auto i = rbegin(c); i != rend(c); i++)
#define pre(c,x) ((c).find(x) != (c).end())
#define cpre(c,x) (find(all(c),x) != (c).end())
#define mii map<int,int>
#define mll map<ll,ll>
#define vs vector<string>
#define vi vector<int>
#define vl vector<ll>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define vii vector<pii >
#define vll vector<pll >
#define vvl vector<vector<ll> >
#define vvi vector< vector<int > >
#define W(t) while(t --)
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout <<(ll)(it-arr.begin()) << ')' <<  *it << ' '; cout << endl;
#define printii(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << it->ff<<' '<<it->ss << endl; cout << endl;
#define MID(i,j) ((i)+(j))/2
#define nl '\n' 
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
ll max(ll a,ll b) {return (a>b? a:b);}
ll min(ll a,ll b) {return (a>b? b:a);}
ll gcd(ll a,ll b) {return (b==0)? a:gcd(b,a%b); }
ll gcd(ll a,ll b,ll & x,ll & y) {
    if (a == 0) {
        x = 0;
        y = 1;
        return b;
    }
    ll x1, y1;
    ll d = gcd(b % a, a, x1, y1);
    x = y1 - (b / a) * x1;
    y = x1;
    return d;
}
ll modinv(ll a,ll b){
	ll x,y;
	gcd(a, b, x, y);
	return (x%b + b)%b;
}
ll ceiling(ll a,ll b){ 
        if(a%b==0) return a/b;
        else return a/b+1;
}
ll bpow(ll a,ll b,ll m){
	a%=m;
	ll res=1;
	while(b>0){
		if(b&1) res=(res*a)%m;
		b>>=1;
		a=a*a%m;
	}
	return res;
}
vvl mat_mul(vvl mat1,vvl mat2,ll mod1){
        vvl res(sz(mat1),vl(sz(mat2[0]),0));
        far(i,0,sz(mat1)-1){
                far(j,0,sz(mat2[0])-1){
                        far(k,0,sz(mat1[0])-1){
                                res[i][j]=(res[i][j]+(mat1[i][k]*mat2[k][j])%mod1)%mod1;          
                        }   
        }   
        }   
        return res;
}
vvl mat_exp(vvl mat,ll p,ll mod1){ 
        vvl res(sz(mat),vl(sz(mat[0]),0));
        far(i,0,sz(mat)-1) res[i][i]=1;
        while(p>0){
                if(p&1) res=mat_mul(res,mat,mod1);   
                mat=mat_mul(mat,mat,mod1);
                p>>=1;
        }   
        return res;
}
const int N=1e6+5;
ll n,m,q,t,k,x,y,z,ans;

int main()
{
	double a,b,c,d;
	cin >> a >> b >> c >> d;
	if(a==c*2 && b==d*2) z=1;
	cout << a*b*1.0/2  << ' ' << z << nl;
}


Measured memory_bytes: 256
class Main
  def self.run
    house = OfficialHouse.new
    tenants = read_inputs
    tenants.each {|t| house.move_into(*t)}
    puts house.description
  end

  private

  def self.read_inputs
    n = gets.to_i
    (1..n).map {gets.split(" ").map(&:to_i)}
  end
end

class OfficialHouse
  def initialize
    @sections = (1..4).map{|n| Section.new(n)}
  end

  def description
    @sections.map {|s| s.description}.join("\n#{"#" * 20}\n")
  end

  def move_into(section, floor, room, number)
    @sections.select{|s| s.number == section}.first.move_into(floor, room, number)
  end
end

class Section
  def initialize(number)
    @number = number
    @floors = (1..3).map{|n| Floor.new(n)}
  end

  def description
    @floors.map {|f| f.description}.join("\n")
  end

  def move_into(floor, room, number)
    @floors.select{|f| f.number == floor}.first.move_into(room, number)
  end

  attr_reader :number
end

class Floor
  def initialize(number)
    @number = number
    @rooms = (1..10).map{|n| Room.new(n)}
  end

  def description
    " " << @rooms.map {|r| r.description}.join(" ")
  end

  def move_into(room, number)
    @rooms.select{|r| r.number == room}.first.move_into(number)
  end

  attr_reader :number
end

class Room
  def initialize(number)
    @number = number
    @tenant = 0
  end

  def description
    @tenant.to_s
  end

  def move_into(number)
    @tenant += number
  end

  attr_reader :number
end

Main.run

Measured memory_bytes: 8760
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<string>

int main() {
	int D;
	std::cin >> D;

	std::string s = "Christmas";

	for (int i = 0; i < 25 - D; ++i) {
		s += " Eve";
	}

	std::cout << s << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
#define vsort(v) sort(v.begin(), v.end());
#define vunique(v) unique(v.begin(), v.end());
#define mp make_pair
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;


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

	int N, A;
	cin >> N >> A;
	int r = N % 500;
	if(r <= A) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
// 5_abc144_e
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
#define MOD (1000000007)
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    vector<ll> f(n);
    ll sa = 0;
    ll m = 0;
    rep(i, n){
        cin >> a[i];
        sa += a[i];
    }
    rep(i, n){
        cin >> f[i];
        m = max(m, a[i] * f[i]);
    }

    if(sa <= k){
        cout << 0 << endl;
        return 0;
    }
    sort(a.begin(), a.end(), greater<int>());
    sort(f.begin(), f.end());

    ll ans = m;
    ll l = 1;
    ll r = m;
    ll c = (l + r) / 2;
    while(1){
        if(l >= r){
            ll cnt = 0;
            rep(i, n){
                if(a[i] * f[i] <= c) continue;
                else cnt += a[i] - c / f[i];
            }
            if(k >= cnt) ans = min(ans, r);

            break;
        }
        ll cnt = 0;
        rep(i, n){
            if(a[i] * f[i] <= c) continue;
            else cnt += a[i] - c / f[i];
        }
        if(k >= cnt){
            ans = min(ans, c);
            r = c - 1;
            c = (l + r) / 2;
        }else{
            l = c + 1;
            c = (l + r) / 2 ;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3456
#include<cstdio>


int main(void){
  int n;

  scanf("%d",&n);

  bool ans = true;

  for(int i=0;i<n;i++){
    int t,a,b;
    scanf("%d %d %d",&t,&a,&b);
    if(t<a+b)
      ans = false;
    if((a+b)%2==0&&t%2!=0)
      ans = false;
    if((a+b)%2!=0&&t%2==0)
      ans = false;
  }

  if(ans)
    printf("Yes\n");
  else
    printf("No\n");

  return 0;
}



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

int main() {
  int x,y,z;
  cin >> x >> y >> z;
  if(x==y&&x!=z){
    cout << "Yes" << endl;
  }
  else if(z==y&&x!=z){
    cout << "Yes" << endl;
  }
  else if(x==z&&x!=y){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;

}

Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <bitset>

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define INF 2000000000
#define rep(i,n) for(int i=0;i<(n);i++)
typedef pair<int, int> P;
const ll MOD=1000000007;
using Graph = vector<vector<int>>;

int cut(int a, int b) {//切り捨て
    return (a - a % b) / b;
}
int up(int a, int b) {
    return (a + a % b) / b;
}

int x, y, a, b, c;


int main() {
    
    cin >> x >> y >> a >> b >> c;
    vector<int> p(a);
    deque<int> q(b);
    deque<int> r(c);
    deque<int> d(x + y);
    for (int i = 0; i < a; i++) {
        cin >> p[i];
    }
    for (int i = 0; i < b; i++) {
        cin >> q[i];
    }
    for (int i = 0; i < c; i++) {
        cin >> r[i];
    }
    
    sort(p.rbegin(), p.rend());
    sort(q.rbegin(), q.rend());
    rep(i, x) d.push_back(p[i]);
    rep(i, y) d.push_back(q[i]);
    rep(i, c) d.push_back(r[i]);
    sort(d.rbegin(), d.rend());
    ll ans = 0;
    rep(i, x + y) {
        ans += d[i];
    }
    cout << ans << endl;
   
    return 0;
}

Measured memory_bytes: 3328
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String str = sc.nextLine();
    String[] x = str.split(" ");
    int a = Integer.parseInt(x[0]);
    int b = Integer.parseInt(x[1]);
    int d = a/b;
    int r = a%b;
    double n = (double)a/b;
    String f = String.format("%.8f", n);
    System.out.println(d + " " + r + " " + f);
  }
}


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

typedef long long int   ll;
#define cases           int t;cin>>t;while(t--)
#define FIO             ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define scan(n)         scanf("%d",&n)
#define pb              push_back
#define mod             1000000007
#define maxsz           200001
#define int             ll

using namespace std;

signed main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(d<=a){
        cout<<d<<endl;
    }else {
        if(d<=(a+b)){
            cout<<a<<endl;
        } else {
            cout<<a-(d-a-b)<<endl;
        }
    }
}


Measured memory_bytes: 3632
import sys
n, k = map(int, input().split())

if (n - 1)*(n - 2) / 2 < k:
    print(-1)
    sys.exit()

li = []

for i in range(1, n+1):
    for j in range(i+1, n+1):
        li.append([i, j])

max_k = int(n * (n - 1) / 2)

M = max_k - k

print(M)

for i in range(M):
    print(li[i][0], li[i][1])


Measured memory_bytes: 4120
A, B, K = map(int, input().split())

for i in range(K):
    if(i%2 == 0):
        if(A%2 != 0):
            A = (A-1)//2
            B = A+B
        else:
            A = A//2
            B += A
    else:
        if(B%2 != 0):
            B = (B-1)//2
            A += B
        else:
            B = B//2
            A += B
print(A, end=' ')
print(B)

Measured memory_bytes: 3064
#include <map>
  #include <set>
  #include <list>
  #include <cmath>
  #include <queue>
  #include <stack>
  #include <cstdio>
  #include <string>
  #include <vector>
  #include <complex>
  #include <cstdlib>
  #include <cstring>
  #include <numeric>
  #include <sstream>
  #include <iostream>
  #include <algorithm>
  #include <functional>
    
  #define mp       make_pair
  #define pb       push_back
  #define all(x)   (x).begin(),(x).end()
  #define rep(i,n) for(int i=0;i<(n);i++)
    
  using namespace std;
    
  typedef    long long          ll;
  typedef    unsigned long long ull;
  typedef    vector<bool>       vb;
  typedef    vector<int>        vi;
  typedef    vector<vb>         vvb;
  typedef    vector<vi>         vvi;
  typedef    pair<int,int>      pii;
    
  const int INF=1<<29;
  const double EPS=1e-9;
    
  const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


  int main() {
    int N, K;
    cin >> N >> K;
    int ans = K;
    for(int i = 1; i < N; i++) {
      ans *= (K - 1);
    }
    cout << ans << endl;
    return 0;
  }

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

int main()
{
    int n, k, count{};
    std::map<int, int> kind;
    std::vector<int> table;
    scanf("%d%d", &n, &k);
    for (int i = 0; i < n; i++)
    {
        int a;
        scanf("%d", &a);
        kind[a]++;
    }
    for (const auto & e : kind)
        table.push_back(e.second);
    std::sort(table.rbegin(), table.rend());
    for (int i = k; i < table.size(); i++)
        count += table[i];
    printf("%d\n", count);
    return 0;
}

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

int main(){

  double a[10000],n,a_max=0,a_min=1.79769e+308;
  int i=0;

  while(cin >> n){

    a_max = max(a_max,n);
    a_min = min(a_min,n);

  }

  a_max -= a_min;

  cout << a_max << endl;

}

Measured memory_bytes: 1284
#include <iostream>
#include <cstdlib>
#include <cmath>

using namespace std;

int main()
{
	int N, i;
	long long A[100] = { 0 }, max=1, min=1000000000;

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

	for (i = 0; i < N; i++) {
		if (max < A[i])
			max = A[i];
		if (min > A[i])
			min = A[i];
	}

	cout << max-min << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <queue>
#include <functional>
#include <map>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using pii  = pair<int,int>;
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main(){
    ll N,M,ans=0;cin >> N   >> M;
    ll A,B;
    vector<vector<ll>> job(M); 
    rep(i,N){
        cin >> A >> B;
        if(M >= A){
            job[M-A].push_back(B);
        }
    }
    priority_queue<ll> PQ;
    for(ll i=M-1;i>=0;i--){
        rep(j,job[i].size()){
            PQ.push(job[i][j]);
        }
        if(PQ.empty()==0){
            ans+=PQ.top();
            PQ.pop();
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 5632
n = int(input())
h = [int(i) for i in input().split()]
pre_ans = []
idx = 0

for i in range(n):
  if i>0 and i<n-1:
    if h[i]>h[i-1]:
      pre_ans.append(i-idx-1)
      idx = i
  elif i==n-1:
    if h[i]>h[i-1]:
      pre_ans.append(i-idx-1)
      idx = i
    else:
      pre_ans.append(i-idx)
    

if len(pre_ans)==0:
  print(0)
else:
  ans = max(0, max(pre_ans))
  print(ans)
    
    
    

Measured memory_bytes: 14252
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    W, H, N = il()
    w, h = 0, 0
    for _ in range(N):
        x, y, a = il()
        if a == 1 and w <= x:
            w = x
        if a == 2 and W >= x:
            W = x
        if a == 3 and h <= y:
            h = y
        if a == 4 and H >= y:
            H = y

    if h >= H or w >= W:
        print(0)
    else:
        print((H - h) * (W - w))


if __name__ == '__main__':
    main()


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

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

  bool ans = 0;
  for (int i = 1; i <= 9; i++) {
    for (int j = 1; j <= 9; j++) {
      if (i * j == N) ans = 1;
    }
  }
  cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
import sys
 
S = list(raw_input())
pos = 0
while (pos < len(S)):
	if (''.join([S[x] for x in range(pos, min(pos+11, len(S)), 1)]) == "dreameraser"):
		pos += 11
	elif (''.join([S[x] for x in range(pos, min(pos+10, len(S)), 1)]) == "dreamerase"):
		pos += 10
	elif (''.join([S[x] for x in range(pos, min(pos+7, len(S)), 1)]) == "dreamer"):
		pos += 7
	elif (''.join([S[x] for x in range(pos, min(pos+6, len(S)), 1)]) == "eraser"):
		pos += 6
	elif (''.join([S[x] for x in range(pos, min(pos+5, len(S)), 1)]) == "erase"):
		pos += 5
	elif (''.join([S[x] for x in range(pos, min(pos+5, len(S)), 1)]) == "dream"):
		pos += 5
	else:
		print "NO"
		sys.exit()
print "YES"

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) a.begin(), a.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

template<const long long mod = 1000000007>
struct mint{ //modint
    long long x;
    mint(long long x = 0): x(((x % mod) + mod) % mod) {}
    friend istream& operator >> (istream &s, mint& m){ return s >> m.x; }
    friend ostream& operator << (ostream &s, mint m){ return s << m.x; }
    inline mint& operator += (mint a){ if((x += a.x) >= mod)x -= mod; return *this; }
    inline mint& operator -= (mint a){ if((x += mod - a.x) >= mod)x -= mod; return *this; }
    inline mint& operator *= (mint a){ (x *= a.x) %= mod; return *this; }
    inline mint& operator /= (mint a){ return (*this) *= a.inv(); }
    inline mint operator + (mint a){ mint res(*this); return res += a; }
    inline mint operator - (mint a){ mint res(*this); return res -= a; }
    inline mint operator * (mint a){ mint res(*this); return res *= a; }
    inline mint operator / (mint a){ mint res(*this); return res /= a; }
    inline void takemod(){ x = ((x % mod) + mod) % mod; }
    mint inv(){ return pow(mod - 2); }
    mint pow(long long p){
        mint res(1), tmp(x);
        for(; p; p >>= 1){ if(p & 1)res *= tmp; tmp *= tmp; }
        return res;
    }
};

string K;
int sz, D;
mint<> dp[2][10005][105];

int main(){
    
    cin >> K >> D;
    sz = (int)K.size();
    rep(i, sz)K[i] = K[i] - '0';

    dp[0][0][0] = 1;
    rep(i, sz)rep(j, D){
        rep(k, 10)dp[1][i + 1][(j + k) % D] += dp[1][i][j];
        rep(k, K[i])dp[1][i + 1][(j + k) % D] += dp[0][i][j];
        dp[0][i + 1][(j + K[i]) % D] += dp[0][i][j];
    }

    cout << dp[0][sz][0] + dp[1][sz][0] - mint<>(1) << endl;
    return 0;

}

Measured memory_bytes: 16640
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b)for(int i=(a);i<=(b);i++)
#define repR(i,n) for(int i=n;i>=0;i--)
#define P pair<int, int>
#define sz(x) x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<int>
#define COUT(x) cout<<(x)<<endl
#define MA map<int,int>
#define SE set<int>
#define PQ priority_queue
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

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

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

const long long MOD = 1000000007;
const long long INF = 1LL << 50;
// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int h, w, a, b; cin >> h >> w >> a >> b;
	vector<VE>c(h, VE(w, 0));
	rep(i, b)rep(j, a)c[i][j] = 1;
	for (int i = h - 1; i >= b; i--) {
		for (int j = w - 1; j >= a; j--) {
			c[i][j] = 1;
		}
	}
	rep(i, h) {
		rep(j, w) {
			cout << c[i][j];
		}
		cout << endl;
	}
	return 0;
}

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

// why am I so weak

int n, x;
int a[100055];

int main() {
	scanf("%d %d", &n, &x);

	for (int i = 0; i < n; i++) scanf("%d", &a[i]);

	long long res = 0ll;

	for (int i = 0; i + 1 < n; i++) {
		if (a[i] + a[i + 1] > x) {
			// a[i] + a[i + 1] = x
			// a[i + 1] = x - a[i]

			if (x - a[i] >= 0) {
				res += 1ll * a[i + 1] - (x - a[i]);
				a[i + 1] = x - a[i];
			} else {
				res += a[i + 1];
				a[i + 1] = 0;

				res += a[i] - x;
			}
		}
	}

	printf("%lld\n", res);

	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999999
#define MOD 10007
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef vector<llong> LV;

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


// bool gousei(llong *x,llong *y){
//     if(*x<*y){
//         *y=x+y
//     }
// }

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


    cout << (double)N/M << endl;





}


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

int main(){
  int x, a, b;
  cin >> x >> a >> b;
  if(b-a <= 0){
    cout << "delicious" << endl;
  }else if(b-a <= x){
    cout << "safe" << endl;
  }else{
    cout << "dangerous" << endl;
  }
  return 0;
}

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

const ll mod = 998244353;
const double eps = 1e-8;

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

class mint {
public:
    ll x;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}
    ll get() const { return x; }
    mint& operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; }
    mint& operator-=(const mint a) { if ((x += mod-a.x) >= mod) x -= mod; return *this; }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const { if (!t) return 1; mint a = pow(t>>1); return (t & 1) ? a*a*(*this) : a*a; }
    operator ll () const { return x; }
    operator string () const { return to_string(x); }
    friend istream& operator>>(istream& is, mint& a) { is>>a.x; return is; }

    // for prime mod
    mint inv() const { return pow(mod-2); }
    mint& operator/=(const mint a) { return (*this) *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};

mint dp[3001][3001];

int main() {
    int N, S;
    cin >> N >> S;
    vector<ll> A(N);
    for (int i=0; i<N; ++i) cin >> A[i];

    mint res(0);
    for (int i=0; i<N; ++i) {
        dp[i][A[i]] += mint(i+1);
        for (int j=0; j<=S; ++j) {
            if (0 < i) {
                dp[i][j] += dp[i-1][j];
                if (j+A[i] <= S) dp[i][j+A[i]] += dp[i-1][j];
            }
        }
        res += dp[i][S];
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 70656
#include <stdio.h>
#include <string.h>
#define unknown (-1)

int len(int i, int j); //??¨????????¢????±???????
int min3(int x, int y, int z); //3????????°???????°????????±???????
int M(int i, int j); //0???1???

int PD[10000][10000]; //??????
char s1[1000];
char s2[1000];

int main(void)
{
	unsigned int i, j;
	scanf("%s", s1);
	scanf("%s", s2);
	for (i = 0; i <= strlen(s1); ++i) {
		for (j = 0; j <= strlen(s2); ++j) {
			PD[i][j] = unknown;
		}
	}
	printf("%d\n", len(strlen(s1), strlen(s2)));


    return 0;
}

int len(int i, int j) { //?????°???????????????????¨????????????¨?????????
	int t;
	if (i == 0) {
		PD[0][j] = j;
		return j;
	}
	else if (j == 0) {
		PD[i][0] = i;
		return i;
	}
	if (PD[i][j] != unknown) return PD[i][j];
	t = min3((len(i - 1, j - 1) + M(i-1, j-1)), (len(i - 1, j) + 1), (len(i, j - 1) + 1));
	PD[i][j] = t;
	return t;
}


int min3(int x, int y, int z) {
	int i;
	int num[3];
	num[0] = x;
	num[1] = y;
	num[2] = z;
	int min = x;
	for (i = 0; i < 3; ++i) {
		if (num[i] <= min) {
			min = num[i];
		}
	}
	return min;
}

int M(int i, int j) {
	if (s1[i] == s2[j]) return 0;
	else return 1;
}

Measured memory_bytes: 39988
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793

int main(){
  int a,b,h;
  cin >> a >> b >> h ;
  int ans=(a+b)*h;
  ans/=2;
  cout << ans << endl;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30);
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr double eps = 1e-9;
constexpr ll MOD = 1000000007LL;
template <typename T>
bool chmin(T& a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for(int i = 0; i < v.size(); i++) {
        os << v[i] << (i + 1 == v.size() ? "\n" : " ");
    }
    return os;
}
template <typename T>
vector<T> make_v(size_t a) {
    return vector<T>(a);
}
template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T& t, const V& v) {
    t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T& t, const V& v) {
    for(auto& e : t) {
        fill_v(e, v);
    }
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, k;
    cin >> a >> b >> k;
    int t = 0;
    while(k--) {
        if(t == 0) {
            if(a % 2) {
                a--;
            }
            b += a / 2;
            a /= 2;
        } else {
            if(b % 2) {
                b--;
            }
            a += b / 2;
            b /= 2;
        }
        t ^= 1;
    }
    cout << a << " " << b << endl;
}


Measured memory_bytes: 256
import math
N = int(input())

m = float('inf')
pair = [0,0]
for i in range(1,int(math.sqrt(N))+1):
    if N % i == 0:
        if int(N/i) - i < m:
            m = int(N/i) - i
            pair = [int(N/i),i]

t = pair[0] + pair[1] - 2
print(t)

Measured memory_bytes: 40300
#include<stdio.h>
#include<string.h>
main()
{
   int n, m, i, j;
   char a[101][105];
   while(scanf("%d%d",&n,&m)!=EOF)
   {
       getchar();
       for(i=0;i<n;i++)
       {
           scanf("%s",&a[i]);
       }
       getchar();
       for(j=0;j<m+2;j++)
       printf("#");
       printf("\n");
       for(i=0;i<n;i++)
       {
           printf("#%s#\n",a[i]);
       }
       for(i=0;i<m+2;i++)
       printf("#");
       printf("\n");
   }
}


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


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


vector<int> ans = {};
int l = 9999;

void solve() {
	int n, m; cin >> n >> m;
	vector<int> b[1000];
	rep(i, m) {
		int A, B; cin >> A >> B;
		b[A - 1].push_back(B - 1);
	}
	// distance, previous
	pair<int, int> d[1001];
	rep(i, n) {
		rep(p, 1001) d[p] = make_pair(9999, -1);
		// previous, present
		queue<pair<int, int>> q; q.push(make_pair(1000, i));
		while (!q.empty()) {
			pair<int, int> p = q.front(); q.pop();
			if (p.second == i && d[p.first].first < l) {
				l = d[p.first].first;
				ans.clear();
				for (int t = p.first; t != 1000; t = d[t].second) {
					ans.push_back(t + 1);
				}
			}

			if (d[p.second].first != 9999) continue;
			rep(j, b[p.second].size()) {
				q.push(make_pair(p.second, b[p.second][j]));
			}
			if (p.first == 1000) d[p.second].first = 0;
			else d[p.second].first = d[p.first].first + 1;
			d[p.second].second = p.first;
		}
	}

	if (l == 9999) { cout << -1 << endl; return; }

	cout << ans.size() << endl;
	rep(i, ans.size()) {
		cout << ans[i] << endl;
	}
}

int main() {


	solve();


	return 0;
}

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

int main() {
  string C ;
  cin >> C ;
  if(C == "a")cout << "b" << endl;
  if(C == "b")cout << "c" << endl;
  if(C == "c")cout << "d" << endl;
  if(C == "d")cout << "e" << endl;
  if(C == "e")cout << "f" << endl;
  if(C == "f")cout << "g" << endl;
  if(C == "g")cout << "h" << endl;
  if(C == "h")cout << "i" << endl;
  if(C == "i")cout << "j" << endl;
  if(C == "j")cout << "k" << endl;
  if(C == "k")cout << "l" << endl;
  if(C == "l")cout << "m" << endl;
  if(C == "m")cout << "n" << endl;
  if(C == "n")cout << "o" << endl;
  if(C == "o")cout << "p" << endl;
  if(C == "p")cout << "q" << endl;
  if(C == "q")cout << "r" << endl;
  if(C == "r")cout << "s" << endl;
  if(C == "s")cout << "t" << endl;
  if(C == "t")cout << "u" << endl;
  if(C == "u")cout << "v" << endl;
  if(C == "v")cout << "w" << endl;
  if(C == "w")cout << "x" << endl;
  if(C == "x")cout << "y" << endl;
  if(C == "y")cout << "z" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
#include <numeric>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<Pll> vp;
typedef vector<bool> vb;
#define rep(i, a, n) for (ll i = (a); i < (n); ++i)
#define rrep(i, a, n) for (ll i = (a); i > (n); --i)
#define erep(i, a, n) for (ll i = (a); i <= (n); ++i)
#define rerep(i, a, n) for (ll i = (a); i >= (n); --i)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define vec_max(V) *max_element(all(V))
#define vec_min(V) *min_element(all(V))
#define vec_sum(V) accumulate(all(V), 0LL)
#define print(X) cout << (X) << "\n"
#define _ << " " <<
#define Yes print("Yes")
#define No print("No")
static const int INF = 1e+9+7;

int main(){
  ll N,M;
  cin >> N >> M;
  vp AB(N);
  rep(i,0,N){
    ll a,b;
    cin >> a >> b;
    AB[i] = mp(a,b);
  }

  sort(all(AB));

  ll count = 0;
  ll ans = 0;
  rep(i,0,N){
    if(count + AB[i].second <= M){
      ans += AB[i].first * AB[i].second;
      count += AB[i].second;
    }
    else{
      ans += AB[i].first * (M - count);
      break;
    }
  }

  print(ans);

 return 0;
}


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

using namespace std;

typedef long long ll;

const ll MOD = 1e9 + 7;

int main(){
    int s,w;
    cin >> s >> w;
    if(w >= s) cout << "unsafe" << endl;
    else cout << "safe" << endl;
    return 0;
}


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

int main(){
	int n;
	cin >> n;
	
	int w[110];
	for(int i=0; i<n; i++) cin >> w[i];
	
	int ans=100000;
	for(int i=0; i<n-1; i++){
      	int s1=0, s2=0, d=0;
		for(int j=0; j<=i; j++){
			s1 += w[j];
		}
		for(int j=i+1; j<n; j++){
			s2 += w[j];
		}
	d = s1-s2;
	d = sqrt(d*d);
	if(d<ans) ans=d;
      //out << s1 << " " << s2 << " " << d << " " << ans << endl;
    }
      cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int A[1000];
int N;
int sub;
int ans;

int main(){
	cin>>N;
  	for (int i=1;i<=N;++i)cin>>A[i];
  ans = 1000000000;
  	for (int x=-100;x<=100;++x){
    	sub=0;
      	for (int i=1;i<=N;++i)sub += (A[i] - x)*(A[i]-x);
      	ans = min(ans,sub);
    }
  cout<<ans;
}


Measured memory_bytes: 256
import java.util.*;

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

      int N = sc.nextInt();
      if(N%10==2||N%10==4||N%10==5||N%10==7||N%10==9){
         System.out.println("hon");
      }
      if(N%10==0||N%10==1||N%10==6||N%10==8){
         System.out.println("pon");
      }
      if(N%10==3){
         System.out.println("bon");
      }
   }
}

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

using namespace std;

int main() {
    int n;
    cin >> n;
    while (n--) {
        double x1, y1, r1, x2, y2, r2, d;
        cin >> x1 >> y1 >> r1 >> x2 >> y2 >> r2;
        d = sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));
        
        if (r1 - r2 > d) {
            cout << 2 << endl;
        }
        else if (r2 - r1 > d){
            cout << -2 << endl;
        }
        else if (r1 + r2 < d) {
            cout << 0 << endl;
        }
        else {
            cout << 1 << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1232
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int digit_sum(int n){
  if(n==0) return 0;
  else return n%10 + digit_sum(n/10);
}
int main(){
  int n;
  cin >> n;
  if(n%digit_sum(n)==0) cout << "Yes" <<endl;
  else cout << "No" <<endl;
  

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<long long ,long long>pll;

ll gcd(ll a, ll b) {return (!b ? a : gcd(b, a % b));}
ll lcm(ll a, ll b) {return ((a*b)/gcd(a,b));}
bool cmp(int a,int b){return a>b;}

const ll mod = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;
const ld pi = 3.141592653589793;

unsigned long long modpow(unsigned long long n, unsigned long long k, unsigned long long mod)
{
if (k == 0) return 1;
long long r = modpow(n * n % mod, k >> 1, mod);
if (k & 1) r = r * n % mod;
return r;
}

void solve(){
     int n;cin >> n;
     vector<ld>a(n+1);
     vector<vector<ld>>dp(n+2,vector<ld>(n+2,0.00));
     for(int i = 1;i<=n;i++)
        cin >> a[i];
     dp[0][0] = 1.00;
     for(int i = 1;i<=n;i++){
        for(int j = 0;j<=i;j++){
            int x = j;int y = i-j;
            if(x) dp[x][y] += dp[x-1][y]*a[i];
            if(y) dp[x][y] += dp[x][y-1]*(1.00-a[i]);
        }
     }
     int l = n,r = 0;ld ans = 0;
     while(l>r){
        ans += dp[l][r];
        l--;r++;
     }
     cout << fixed << setprecision(20) << ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 144160
#include <iostream>

using namespace std;

int N;

int main(void)
{
	cin >> N;
	int l, r;
	int ans = 0;
	
	for(int i = 0; i < N; i++){
		cin >> l >> r;
		ans += r - l + 1;
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/***********************************************/
/* Dear online judge:
 * I've read the problem, and tried to solve it.
 * Even if you don't accept my solution, you should respect my effort.
 * I hope my code compiles and gets accepted.
 *  ___  __     _______    _______      
 * |\  \|\  \  |\  ___ \  |\  ___ \     
 * \ \  \/  /|_\ \   __/| \ \   __/|    
 *  \ \   ___  \\ \  \_|/__\ \  \_|/__  
 *   \ \  \\ \  \\ \  \_|\ \\ \  \_|\ \ 
 *    \ \__\\ \__\\ \_______\\ \_______\
 *     \|__| \|__| \|_______| \|_______|
 */
const long long mod = 1000000007;


long long A[(1<<18)];


bool cmp(int a,int b) {
	return A[a] > A[b];
}

struct got{
	vector<int> in;
	void mrg(got & g) {
		in.insert(in.end(),g.in.begin(),g.in.end());
		
		sort(in.begin(),in.end());
		in.erase(unique(in.begin(),in.end()),in.end());
		
		sort(in.begin(),in.end(),cmp);
		in.resize(2);
	}
};
got MX[(1<<18)];

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

	int N,M;
	cin>>M;
	N = (1<<M);
	for(int i = 0;i < N;i++) cin>>A[i];
	for(int i = 0;i < N;i++) {
		MX[i].in.push_back(i);
		for(int j = 0;j < M;j++) {
			if(!(i&(1<<j))) continue;
			MX[i].mrg(MX[i^(1<<j)]);
		}
	}
	long long cur = 0;
	for(int i = 1;i < N;i++) {
		cur = max(cur,A[MX[i].in[0]] + A[MX[i].in[1]]);
		cout<<cur<<'\n';
	}
	return 0;
}


Measured memory_bytes: 19456
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
using V = vector<int>;
using VV = vector<vector<int>>;
int Inf = (1<<30);
ll inf = (1LL<<60);
int main() {
	int n, m;
	cin >> n >> m;
	int i;
	V box(n, 1);
	vector<bool> red(n, false);
	red[0] = true;
	for (i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		box[a]--;
		box[b]++;
		if (red[a]) red[b] = true;
		if (!box[a]) red[a] = false;
	}
	int ans = 0;
	for (i = 0; i < n; i++) if (red[i]) ans++;
	cout << ans;
	return 0;
}

Measured memory_bytes: 640
import Control.Applicative
import Text.Printf
main = solve

solve = do
    n <- fmap (read :: String -> Int) . words <$> getLine
    let a = n !! 0
        b = n !! 1
    printf "%d %d " (a `div` b) (a `mod` b)
    printf "%f\n" ((fromIntegral a :: Double) / (fromIntegral b :: Double))

Measured memory_bytes: 4016
#include <iostream>
#include <string>
using namespace std;
char temp[30]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
int main()
{
	  int k; cin>>k;
   string t;cin>>t;
     for(int i=0;i<(int)t.size();i++)
	 {
	 	 cout<<temp[((t[i]-'A')+k)%26];
	 }
    return 0;
}


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

using namespace std;

#define ll long long
#define ss stringstream
#define rep(i,n) for(int i=1;i<=(n);i++)
#define rep0(i,n) for(int i=0;i<(n);i++)

const ll INF=1e9+7;

int main()
{
	/*freopen("input.txt","r",stdin);
	freopen("outcout<<put.txt","w",stdin);*/
	int n;
	cin>>n;
	ll h=0;
	rep(i,n){
		ll t;
		cin>>t;
		h+=t-1;
	} 
	cout<<h;
	return 0;
}

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

int maxOfArray(int arr[], int limit, int N){
  int max=0;
  for(int i=0;i<N;i++){
    if(arr[i]<limit){
      if(max<arr[i]){
        max=arr[i];
      }
    }
  }
  return max;
}

int main() {
  int N;
  int d[128];
  int pile;
  int c=101;
  cin >> N;
  for(int i=0;i<N;i++){
    cin >>d[i];
  }
  for(int j=0;c!=0;j++){
    c=maxOfArray(d,c,N);
    pile=j;
  }
  
  cout <<pile <<endl;
  return 0;
}


Measured memory_bytes: 256
#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;
lint p=2019;

int main(){
  string S,SR;
  cin>>S;
  SR=string(S.rbegin(),S.rend());
  int N=S.size();
  map<int,int> m;
  lint x=0;
  lint pow10=1;
  m[0]++;
  for(auto c:SR){
    x+=((c-'0')*pow10);
    x%=p;
    m[x]++;
    pow10*=10;
    pow10%=p;
    // cerr<<x<<endl;
  }
  lint ans=0;
  for(auto e:m){
    // cerr<<e.first<<" "<<e.second<<endl;
    lint y=e.second;
    ans+=y*(y-1)/2;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3868
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <map>
#include <queue>
#include <cmath>
#include <iomanip>

#define MOD (1000000007)

using namespace std;

typedef long long ll;
typedef pair<ll, ll> tup;
const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];


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


// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


// int main() {
//     int H1, M1, H2, M2, K;
//     cin >> H1 >> M1 >> H2 >> M2 >> K;
//     int all = (60*H2 + M2) - (60*H1 + M2);




//     cout << all - K << endl;


//     return 0;
// }


int main() {
    string T;
    cin >> T;

    for(int i = 0; i < T.size(); i++) {
        if(T[i] == '?') T[i] = 'D';
    }

    cout << T << endl;
    return 0;
}

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

int main(){
  
  long long int a;
  long long int b;
  cin>>a>>b;
  
  if(a==1&&b==2){
    cout<<"3"<<endl;
  }
  else if(a==1&&b==3){
    cout<<"2"<<endl;
  }
  else if (a==2&&b==1){
    cout<<"3"<<endl;
  }
  else if(a==2&&b==3){
    cout<<"1"<<endl;
  }
  else if(a==3&&b==1)
    cout<<"2"<<endl;
  else cout<<"1"<<endl;
  
  return 0;
}

Measured memory_bytes: 888
/**
 *    author        : Sudipta Banik Trisha 
 *    created       : August 21, 2020 12:28 PM
 *    Problem Name  : A - Password
 *    Problem Limit : 2000 ms , 1024 MB
 *    Problem Url   : https://atcoder.jp/contests/abc140/tasks/abc140_a
 *    @genarated by : ai-virtual-assistant
**/

#include<bits/stdc++.h>
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;

    int ans = pow(n,3);
    cout << ans << endl;


    return 0 ;
}


Measured memory_bytes: 4088
#include<stdio.h>

int num[10000];
int main( void ) 
{
  
    int n;
    scanf( "%d", &n );
     
    int i, j;
 
    int snt = n;
    for( i=0; i<n; i++ ) 
	{
        scanf( "%d", &num[i] );
    }
    for( i=0; i<n; i++ ) 
	{    
        if( 2 == *(num+i) )
		{ continue; }
         
        if( 0 == *(num+i)%2 ) {
            snt--;
            continue;
        }
         
        for( j=3; j*j<=*(num+i); j+=2 ) {
            if( 0 == *(num+i)%j ) {
                snt--;
                break;
            }
        }
    }
      
    printf( "%d\n", snt );
    return 0;
	
}

Measured memory_bytes: 628
#define _CRT_SECURE_NO_WARNINGS 1

#include <set>
#include <map>
#include <stack>
#include <deque>
#include <queue>
#include <cmath>
#include <ctime>
#include <vector>
#include <cstdio>
#include <string>
#include <iomanip>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

#define LL long long
#define pii pair<int,int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define rep(i,a,b) for(int i = (a) ; i <= (b) ; i++)
#define per(i,a,b) for(int i = (a) ; i >= (b) ; i--)
#define mem(a) memset(a,0,sizeof(a))
#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1
#define fast_io ios::sync_with_stdio(false)

const LL INF = 1e18;
const LL mod = 1e9 + 7;
const int maxn = 2e5 + 7;

int a[maxn];

int main() {
	int n;
	sd(n);
	LL ans = 0;
	rep(i,1,n) {
		sd(a[i]);
	}
	rep(i,1,n) {
		if(a[i] < a[i-1]) {
			ans += (a[i-1] - a[i]) * 1LL;
			a[i] = a[i-1];
		}
	}
	plld(ans);
	return 0;
}

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

#define f first
#define s second
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define ll long long
#define ull unsigned long long
#define db double
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pli pair<ll, int>
#define px pair<db, db>
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define input(a) for (auto& el : a) cin >> el;
#define output(a) cout << '!'; for (auto& el : a) cout << el << ' '; cout << '\n'; cout.flush();
#define sz(el) int(el.size())
#define sq(a) ((a) * (a))
#define xll bitset<128>
#define xmin(a,b) a = min(a, b)
#define xmax(a,b) a = max(a, b)
#define sun(a) sort(all(a)); a.resize(unique(all(a)) - a.begin());
/**/  /// extra
//#define forn(i,n) for (int i = 0; i < n; ++i)
//#define rforn(i,n) for (int i = n - 1; i >= 0; --i)
#define bn '\n'
#define vi vector<int>
#define vii vector<vi>
#define vl vector<ll>
#define vll vector<vl>
//#define G vector<vector<pii>>
#define GVE vector<vector<edge>>
#define usi unordered_set<int>
#define usp set<pii>
/**/

using namespace std;

const int INF = 1'000'000'017;
const ll LLINF = 1'000'000'000'000'000'017LL;
const ld inf = 1.0 / 0.0;
const ld eps = 1e-9;
const int MOD = 998244353;

//mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

//uniform_int_distribution<int> uid(l, r); [l, r]
//int x = uid(rng);

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

    int n;
    cin >> n;
    for (int x = 1; x <= n; ++x) {
        if (int(x * 1.08) == n) {
            cout << x;
            return 0;
        }
    }
    cout << ":(";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>

using namespace std;

int main() {
	string N;
	cin >> N;
	if (N[0] == N[2]) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3560
#include <stdio.h>

int main(void) {
	// your code goes here
	int a, b, c;
	
	scanf("%d %d %d", &a, &b, &c);
	
	if(a < b && b < c) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 580
import fractions

n = int(input())
a = list(map(int, input().split()))

m = a[0]
for i in range(1, n):
    m = m * a[i] // fractions.gcd(m, a[i])
m -= 1

ans = 0
for i in a:
    ans += (m%i)

print(ans)


Measured memory_bytes: 5432