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


auto solve(long long H, long long W){
    auto ret = numeric_limits<long long>::max();
    for(long long i = 1LL; i < W; ++i) {
        auto j = static_cast<long long >(round((W - i) / 2));
        auto k = W - i - j;
        if(0 < k) {
            ret = min(ret, H * (max(i, max(j, k)) - min(i , min(j, k))));
        }

        j = i;
        k = W - i - j;
        if(0 < k) {
            ret = min(ret, H * (max(i, max(j, k)) - min(i , min(j, k))));
        }
    
        j = static_cast<long long>(round(H / 2));
        k = H - j;
        if(0 < k){
            ret = min(ret, max(H * i, (W - i) * max(j, k)) - min(H * i, (W - i) * min(j, k)));
        }

        j = static_cast<long long >(round((H * i) / (W - i)));
        k = H - j;
        if(0 < k) {
            ret = min(ret, max(H * i, (W - i) * max(j, k)) - min(H * i, (W - i) * min(j, k)));
        }
     }

    for(long long i = 1LL; i < H; ++i) {
        auto j = static_cast<long long >(round((H - i) / 2));
        auto k = H - i - j;
        if(0 < k){
            ret = min(ret, W * (max(i, max(j, k)) - min(i , min(j, k))));
        }

        j = i;
        k = H - i - j;
        if(0 < k){
            ret = min(ret, W * (max(i, max(j, k)) - min(i , min(j, k))));
        }

        j = static_cast<long long>(round(W / 2));
        k = W - j;
        if(0 < k){
            ret = min(ret, max(W * i, (H - i) * max(j, k)) - min(W * i, (H - i) * min(j, k)));
        }

        j = static_cast<long long >(round((W * i) / (H - i)));
        k = W - j;
        if(0 < k){
            ret = min(ret, max(W * i, (H - i) * max(j, k)) - min(W * i, (H - i) * min(j, k)));
        }
     }

    return ret;
}

int main(){
    long long H;
    scanf("%lld",&H);
    long long W;
    scanf("%lld",&W);
    auto result = solve(H, W);
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<string,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
ll INF=1LL<<60;
ll MOD=1000000007;
ll A,B,C;


int main(){
    ll D;
    cin >> D;
    ll G;
    cin >> G;
    vector<ll> p(D+1,0);
    vector<ll> c(D+1,0);
    for(ll i=0;i<D;i++){
        cin>>p[i+1]>>c[i+1]
    ;} 
    ll ans=INF;
    for(ll bits=0;bits<(1<<D);bits++){
        ll score=0; 
        ll count=0;
        priority_queue<ll> pq;
        for(ll j=0;j<D;j++){
            if(bits&(1<<j)){
                count+=p[j+1];
                score+=100*p[j+1]*(j+1)+c[j+1];
            }
            else 
            for(ll k=0;k<p[j+1];k++){
                pq.push(100*(j+1));
            ;}
        ;}
        while(score<G){
            score+=pq.top();
            pq.pop();
            count++;
        }
        ans=min(ans,count);
    ;}
    cout<<ans<<endl;


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#define INF 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
using namespace std;
using P = pair<int, int>;
using ll = long long;
int main(){
    ll h,w;
    cin>>h>>w;
    ll ans=INF;
    REP(i,h/2){
        ll a=i*w;
        ll b;
        if((h-i)%2==0)b=(h-i)/2*w;
        else if(w%2==0)b=w/2*(h-i);
        else b=max(h-i,w)/2*min(h-i,w);
        ll c=h*w-a-b;
        ans=min(ans,max({a,b,c})-min({a,b,c}));
    }
    REP(i,w/2){
        ll a=i*h;
        ll b;
        if((w-i)%2==0)b=(w-i)/2*w;
        else if(h%2==0)b=h/2*(w-i);
        else b=max(w-i,h)/2*min(w-i,h);
        ll c=h*w-a-b;
        ans=min(ans,max({a,b,c})-min({a,b,c}));
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
import java.util.*;
import java.util.stream.Collectors;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		double R = Double.parseDouble(in.readLine());
		System.out.println(2.0 * R * Math.PI);
	}

	void calc() {
	}

	void showResult() {
	}
}


Measured memory_bytes: 32956
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        MyReader r = new MyReader();  
        int N, X;
        {int[] a = r.ii(); N = a[0]; X = a[1];}
        int[] L = r.ii();
        int y = 0;
        for(int i = 0; i < N; i++){
            y += L[i];
            if(X < y){
                println(i+1);
                return;
            }                
        }    
        println(N+1);
    }
    static void print(Object o){
        System.out.print(o.toString());
    }
    static void println(Object o){
        System.out.println(o.toString());
    }
    static int Int(String s){
        return Integer.parseInt(s);
    }
    static long Long(String s){
        return Long.parseLong(s);
    }
    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Int(ss[j]);
            return ii;
        }
        long l() throws IOException{
            return Long(s());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long(ss[j]);            
            return ll;
        }
    }
}

Measured memory_bytes: 23252
#include <stdio.h>

int main(void)
{
  int S, h, m, s;
  
  scanf("%d", &S);

  h = S/3600;
  S = S % 3600;
  m = S/60;
  S = S % 60;
  s = S;

  printf("%d:%d:%d\n", h,m,s);
  

  return 0;
}


Measured memory_bytes: 2100
from itertools import accumulate as ac

m=101000
num=[1]*m
num[0]=num[1]=0
for i in range(2,int(m**0.5)+1):
    if not num[i]:
        continue
    for j in range(i*2,m,i):
        num[j]=0

a=[0]*m
for i in range(m):
    if i%2==0:
        continue
    if num[i] and num[(i+1)//2]:
        a[i]=1

csum=[0]+a
csum=list(ac(csum))
#print(csum)
q=int(input())
for i in range(q):
    l,r=map(int,input().split())
    print(csum[r+1]-csum[l])

Measured memory_bytes: 8484
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cstring>
#include <string>
#include <cmath>
#include <functional>
#include <queue>
#include <map>
using namespace std;

typedef long long ll;
const int M = 1e9 + 7;
const int N = 1e5 + 7;
const int MAX = 1e9 + 1;
//从北开始顺时针
//int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};
//int exDx[] = {-1, -1, 0, 1, 1, 1, 0, -1}, exDy[] = {0, 1, 1, 1, 0, -1, -1, -1};

int a[N];
int b[N];

int main() {
    int i, j;
    int n;
    cin >> n;
    ll sum = 0;
    for (i = 0; i < n; ++i) {
        cin >> a[i];
        sum += (ll)a[i];
    }

    ll perRoundSum = (ll)(1 + n) * (ll)n / 2L;

    if (sum % perRoundSum != 0) {
        cout << "NO\n";
        return 0;
    }

    int cnt = sum / perRoundSum;
    b[0] = a[0] - a[n - 1];
    for (i = 1; i < n; ++i) {
        b[i] = a[i] - a[i - 1];
    }
    bool flag = true;
    for (i = 0; i < n; ++i) {
        if (!(cnt - b[i] >= 0 && (cnt - b[i]) % n == 0)) {
            flag = false;
            break;
        }
    }
    cout << (flag ? "YES" : "NO") << endl;

    return 0;
}


Measured memory_bytes: 1024
<?php
$n = trim(fgets(STDIN));

$q = new SplPriorityQueue();
$list = [];
for ($i = 0; $i < $n; $i++) {
    $tmp = trim(fgets(STDIN));
    $q->insert($i, $tmp);
    $list[$i] = $tmp;
}

$first = $q->extract();
$second = $q->extract();

for ($i = 0; $i < $n; $i++) {
     if($i === $first) {
         echo $list[$second]. "\n";
     } else {
         echo $list[$first]."\n";
     }
}


Measured memory_bytes: 112496
//ABC95 D Static Sushi
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,c;
    cin>>n>>c;
    vector<ll> x(n+1),v(n+1);
    vector<ll> le(n+1,0);
    FOR(i,1,n+1){
      cin>>x[i]>>v[i];
    }
    ll ans=0;
    vector<ll> f(n+1,0),g(n+1,0);
    ll sum=0;
    FOR(i,1,n+1){
      sum+=v[i];
      f[i]=sum-2*x[i];
      g[i]=max(f[i],g[i-1]);
    }
    ll now;
    sum=0;
    for(ll i=n;i>=0;i--){
      sum+=v[i];
      now=sum-(c-x[i]);
      if(i!=0) now+=g[i-1];
      else now=g[n];
      ans=max(ans,now);
    }
    sum=0;
    FOR(i,1,n+1){
      sum+=v[i];
      f[i]=sum-x[i];
      g[i]=max(f[i],g[i-1]);
    }
    sum=0;
    for(ll i=n;i>=0;i--){
      sum+=v[i];
      now=sum-2*(c-x[i]);
      if(i!=0) now+=g[i-1];
      else now=g[n];
      ans=max(ans,now);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4224
#include <iostream>
#include <fstream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <algorithm>

#define MOD_BIG 1000000007
using std::string;
using std::cin;
using std::cout;
using std::cerr;
using std::endl;
using ll = long long;
using std::vector;
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) {
    vec.resize(len);
    for (auto &v : vec) ndarray(v, args...);
}

//////////////////////////////////////



//////////////////////////////////////

int main() {
    
    int N, K;
    cin >> N >> K;
    
    vector<int> A(N);
    int tot = 0;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        A[i] = a;
        tot += a;
    }
    //総和の約数が候補
    std::priority_queue<int> yks;
    for (int i = 1; i <= sqrt(tot); i++) {
        if (tot % i == 0) {
            yks.push(i);
            if (i != tot / i) yks.push(tot / i);
        }
    }
    int ans = 1;
    while(!yks.empty()) {
        int y = yks.top();
        yks.pop();
        std::multiset<int> ma;
        for (int i = 0; i < N; i++) {
            ma.insert(A[i] % y);
        }
        
        bool f = true;
        int resk = K;
        while (!ma.empty()) {
            if (ma.size() == 1) {
                int b = *ma.begin();
                if (b == 1 && y == 1) {
                    f = true;
                } else {
                    f = false;
                }
                break;
            }
            int b = *ma.begin();;
            int e = *std::prev(ma.end());
            int d = std::min(b, y-e);
            resk -= d;
            if (resk < 0) {
                f = false;
                break;
            }
            ma.erase(ma.begin());
            ma.erase(std::prev(ma.end()));
            if (b - d != 0) ma.insert(b-d);
            if ((e + d) % y != 0) ma.insert((e+d)%y);
        }
        if (f) {
            ans = y;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#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 ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;

int main(){
    int a=0,b=0,c=0,d,n=0,x=0;
    VI m(3);
    string s,s1,s2;
    cin >> a >> b >>c; 
    cout << a*b/2 <<endl;
    return 0;
} 

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>
#include <numeric>
#include<queue>

//const int mod = 1000000007;
//const int mod = 998244353;


int main() {
	int N;
	scanf("%d",&N);
	printf("%d", (N - 1) / 2);
	return 0;
}


Measured memory_bytes: 128
/*
sonu_verma1
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb(a) push_back(a)
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
int main()
{
    ll n,k;
    cin>>n>>k;
    n=n%k;
    if(n>k/2)
        cout<<k-n;
    else
        cout<<n;

    return 0;
}

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

const int MaxN = 100000 + 5;

int N;
int A[MaxN], B[MaxN], C[MaxN];
int dp[MaxN][3];

void init() {
  scanf("%d", &N);
  for (int i = 1; i <= N; ++i)
    scanf("%d %d %d", &A[i], &B[i], &C[i]);
}

void solve() {
  dp[1][0] = A[1], dp[1][1] = B[1], dp[1][2] = C[1];
  for (int i = 2; i <= N; ++i) {
    dp[i][0] = A[i] + max(dp[i - 1][1], dp[i - 1][2]);
    dp[i][1] = B[i] + max(dp[i - 1][0], dp[i - 1][2]);
    dp[i][2] = C[i] + max(dp[i - 1][0], dp[i - 1][1]);
  }
  cout << max(dp[N][0], max(dp[N][1], dp[N][2])) << endl;
}

int main() {
  init();
  solve();
  return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const int MN=2005;int md=1e9+7;int n,sz[MN],p[MN];vector<int>g[MN];int d[MN][MN][2];int f[MN];int a[MN][3],x[MN][3];
signed main(){f[0]=1;
for(int i=1;i<MN;i++)f[i]=f[i-1]*i%md;
cin>>n;for(int i=2;i<=n;i++){cin>>p[i];g[p[i]].push_back(i);}
for(int i=n;i;i--){memset(a,0,sizeof(a));a[0][0]=1;for(auto &j:g[i]){memset(x,0,sizeof(x)); 
rep(k,sz[j]+1)rep(l,sz[i]+1)rep(m,3){
x[k+l][m]+=d[j][k][0]*a[l][m]%md;
if(m<2) x[k+l+1][m+1]+=d[j][k][1]*a[l][m]%md;}
sz[i]+=sz[j];  
rep(j,sz[i]+1)rep(k,3){a[j][k]=x[j][k]%md;}}
rep(j,sz[i]+1){
d[i][j][0]=a[j][0]+a[j][1]*2+a[j][2]*2;
d[i][j][1]=a[j][0]+a[j][1];d[i][j][0]%=md;d[i][j][1]%=md;}
sz[i]++;}
int ret=0;rep(i,n+1){int cur=d[1][i][0]*f[n-i]%md;if(i & 1) cur=md-cur;ret+=cur;}
cout<<ret%md<<endl;}

Measured memory_bytes: 42492
/*
  Hey , lakshay 05
  while( ! ( succeed == try)); // Follow this
  Don't compare yourself with anyone in the world,if you do so it means you are insulting yourself -> Bill Gates
  
*/

#include <bits/stdc++.h>
#define ll long long
#define RUNFAST  ios_base::sync_with_stdio(false);    cin.tie(NULL);
#define vec  vector<ll>
#define pi vector<pair<ll,ll>>
#define fi first
#define se second
#define pb push_back
#define print1(a) cout<<a;
#define print2(a,b) cout<<a<<" "<<b;
#define print3(a,b,c) cout<<a<<" "<<b<<" "<<c;
#define sort(v) sort(v.begin(), v.end())
#define rev(v) reverse(v.begin(), v.end())
#define issorted(v) is_sorted(v.begin(),v.end())
#define eb emplace_back
#define mp make_pair
//#define MOD 1000000007 // 998244353
using namespace std;
 
ll visited[210000]={0}; 
vector<ll>vg[210000];

// Print vector

void printv(vector<ll> v)
{
   for(auto x:v)
   cout<<x<<" ";
}

// Important Functions 

// DFS
void dfs(ll current)
{
    ll i,y;
    visited[current]=1;
 //   cout<<current<<" ";
    for(i=0;i<vg[current].size();i++)
    {
        y=vg[current][i];
        if(visited[y]==0)
        dfs(y);
    }
}
 
// BFS

void bfs(ll current)
{
    ll x,y,i;
    queue<ll>q;
    q.push(current);
    visited[current]=1;
    while(!q.empty())
    {
        x=q.front();
   //     cout<<x<<" ";
        q.pop();
        visited[x]=1;
        for(i=0;i<vg[x].size();i++)
        {
            y=vg[x][i];
            if(visited[y]==0)
            {
                visited[y]=1;
                q.push(y);
            }
        }
    }
}

ll fact(ll n)
{
    ll p=1;
    for(ll i=1;i<=n;i++)
    p*=i;
    return p;
}

// Prime Numbers
void checkprime(ll N) {
        ll count = 0;
        for( ll i = 1;i * i <=N;++i ) {
             if( N % i == 0) {
                 if( i * i == N )
                         count++;
                 else       // i < sqrt(N) and (N / i) > sqrt(N)
                         count += 2;
              }
        }
        if(count == 2)
        {
           // prime number   
        }
}        

// IO File
void IO()
{
    freopen("input.txt" , "r" , stdin);
    freopen("output.txt" , "w" , stdout);
}

// Multiplicative Inverse

ll power(ll x, unsigned ll y, unsigned ll m) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y / 2, m) % m; 
    p = (p * p) % m; 
  
    return (y % 2 == 0) ? p : (x * p) % m; 
} 

ll modInverse(ll a,ll m) 
{ 
     return power(a, m - 2, m); 
     
} 
  
// LCM

ll lcm(ll a,ll b)
{  return (a*b)/__gcd(a,b);  
}


/* ---------------------------------------------------------------------------------------------------------*/ 
 
 void lakshay()
 {
          ll i,z=0,c,d,y=0,x,l=0,A[1000],B[1000],a,b,s=0,j,m,n,p,q,k,r;
          bool ok=true;
          cin>>n;
          s=7;
          
        for(i=1;i<=1000000;i++)
        {
            if(s%n==0)
            {
                cout<<i;
                return;
            }
            s*=10;
            s%=n;
            s+=7;
            s%=n;
        }
          cout<<-1;
 }
 
int main() 
{  RUNFAST
    ll num;
num=1;
//cin>>num;
while(num--)
{ 
lakshay();
cout<<"\n";
}
return 0;
}

Measured memory_bytes: 8548
def nCr(n,r):
    num = den = 1

    for i in range(r):
        num = (num*(n-i)) % MOD #n*(n-1)*...*(n-r)
        den = (den*(i+1)) % MOD #1*2*...*r
    
    return (num * pow(den, MOD-2, MOD)) % MOD
    #フェルマーの小定理を使うことで1/denを作っている
    #最終的に(n*...*(n-r))/(1*...*r)

MOD = 10**9 + 7
n, a, b = map(int, input().split())
x = pow(2, n, MOD)

print((x - nCr(n,a) - nCr(n,b) -1 )% MOD)

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

using namespace std;

int k, x;

int main()
{
    /*#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif*/
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> k >> x;
    if (k * 500 < x)
        cout << "No";
    else
        cout << "Yes";
    return 0;
}


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

using vi = vector<int>;
using vvi = vector<vi>;

struct node {
    char x;
    int step = 0;
    vvi adjs;
};

using vn = vector<node>;
using vvn = vector<vn>;

int main() {
    int H, W;
    int black = 0;
    cin >> H >> W;
    queue<vi> que;
    que.push({0,0});
    vvn graph(H, vn(W));
    graph[0][0].step = 1;
    vvi near = {{-1,0}, {1,0}, {0,-1}, {0,1}};
    vi p(2);

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> graph[i][j].x;
            if (graph[i][j].x == '#') {
                black++;
            }
        }
    }

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            for(vi n : near) {
                if (i+n[0] >= 0 && i+n[0] < H && j+n[1] >= 0 && j+n[1] < W) {
                    if (graph[i+n[0]][j+n[1]].x == '.') {
                        graph[i][j].adjs.push_back({i+n[0], j+n[1]});
                    }
                }
            }
        }
    }

    while (!que.empty()) {
        p = que.front();
        if (p[0] == H-1 && p[1] == W-1) {
            cout << H * W - black - graph[p[0]][p[1]].step << endl;
            return 0;
        }
        for (vi np : graph[p[0]][p[1]].adjs) {
            if (graph[np[0]][np[1]].step == 0) {
                que.push(np);
                graph[np[0]][np[1]].step = graph[p[0]][p[1]].step + 1;
            }
        }
        que.pop();
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 1280
// きさま！ 見ているなッ！

#include<iostream>
#include<queue>
#include<memory>
#include<map>
#include<set>
#include<unordered_map>
#include<array>
#include<vector>
#include<algorithm>
#include<list>
#include<limits>
#include<stdio.h>
#include<math.h>
#include<string>
#include<thread>

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using lst = list<ll>;

const ll MOD = 1000000007;


int main()
{
	string S;
	cin >> S;
	vec cnt(2019);
	ll ans = 0;

	for(char c : S)
	{
		int k = c - '0';
		
		vec tmp(2019);
		for (int i = 0; i < 2019; ++i)
		{
			tmp[(i * 10 + k) % 2019] = cnt[i];
		}
		tmp[k]++;
		cnt = tmp;

		ans += cnt[0];
	}
	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 3736
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;
typedef std::int_fast32_t i32;
typedef std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

int main() {
  i64 N, M;
  std::cin >> N >> M;

  i64 L_max = 1;
  i64 R_min = N;
  for (i64 i = 0; i < M; ++i) {
    i64 L_i, R_i;
    std::cin >> L_i >> R_i;
    L_max = std::max(L_max, L_i);
    R_min = std::min(R_min, R_i);
  }

  std::cout << std::max<i64>(R_min - L_max + 1, 0) << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define rep(i,N) for(int (i)=0;(i)<(N);++(i))
#define SORT(i) sort((i).begin(),(i).end())
constexpr ll INF = 2000000000;
constexpr ll mod = 1000000007;

int main() {
	int N;cin >> N;
	int S = 0;
	string a = to_string(N);
	rep(i, a.size()) S += a[i] - '0';
	cout << ((N % S == 0) ? "Yes" : "No") << "\n";

	return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
import Control.Monad
import Data.Maybe
import Debug.Trace
import Data.List
import qualified Data.Map.Strict as Map
import qualified Data.IntMap.Strict as IntMap
import qualified Data.Set as Set
import qualified Data.IntSet as IntSet
import Data.Functor
import Data.Array

main :: IO ()
main = do
  (hh:ww:_) <- fmap (map read . words) getLine :: IO [Int]
  (h:w:_) <- fmap (map read . words) getLine :: IO [Int]
  print $ solve h w hh ww

solve h w hh ww = (hh - h) * (ww - w)

Measured memory_bytes: 508
/*****/

#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>	//cout << fixed << setprecision(桁数);
#include <stdexcept>

//#define int long long

using namespace std;
using ll = long long;
using ld = long double;
using vecll = vector<ll>;

#define nextline() (std::cerr << "\n")
#define debug(x) (#x " : " + (x))
#define debug_cout(x) (std::cerr << #x << " : " <<  (x) << "\n")
#define debug_tabcout(n, x) (std::cerr << strMulti("\t",n) << #x << " : " <<  (x) << "\n")
#define debug_headcout(h, x) (std::cerr << h << " : " <<  (x) << "\n")
#define debug_tabheadcout(n, h, x) (std::cerr << strMulti("\t",n) << h << " : " <<  (x) << "\n")

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; i++)
#define rep1(i, n) for(int i=1, i##_len=(n); i<=i##_len; i++)
#define rrep(i, n) for(int i=(n)-1; i >= 0; i--)
#define rrep1(i, n) for(int i=(n); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define pair(a, b) make_pair(a, b);
constexpr int INF = 2000000100;
constexpr ll DIV = 1000000007;	// 10e9+7
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> T divup(T a, T b) { if (a % b == 0) { return a / b; } return a / b + 1; }
#define diup(a, b) (a % b == 0 ? a / b : a / b + 1)
std::string strMulti(std::string t, int n) { std::string out = ""; for (int i = 0; i < n; i++) { out += t; } return out; }
template<class T> T math_P(T m, T n) { T ret = 1; for (T i = m; i > m - n; i--) { ret *= i; } return ret; }
template<class T> T math_C(T m, T n) { T ret = mathP(m, n); for (T i = 2; i <= n; i++) { ret /= i; } return ret; }
template<class T> bool compare_by_b(pair<T, T> a, pair<T, T> b) { if (a.second != b.second) { return a.second < b.second; } return a.first < b.first; }
template<class T> T math_gcd(T a, T b) { a = abs(a); b = abs(b); if (a < b) { std::swap(a, b); } T tmp; while (b != 0) { tmp = b; b = a % b; a = tmp; } return a; }
template<class T> T math_lcm(T a, T b) { a = abs(a); b = abs(b); if (a > b) { std::swap(a, b); } if (a == 1) { return b; } T i = a; while (i % b != 0) { i += a; } return i; }

/*****/

void Main()
{
	string S0, S1, S2;
	cin >> S0 >> S1 >> S2;
	cout << "A" << S1[0] << "C";
}

/*****/

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

	std::cout << std::fixed << std::setprecision(10);


	/*
	while (true)
	{
		Main();
		cout << endl;
	}
	//*/


	Main();

	return 0;
}


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

using namespace std;

typedef long long ll;

const int N(2e5 + 9);

int T, n, m, ans;
int a[N];

int main()
{
    cin>>n;
    int Max = 0, Max1 = 0;
    for (int i = 1; i <= n; i++)
    {
        cin>>a[i];
        if (a[i] > Max)
        {
            Max1 = max(Max, Max1);
            Max = a[i];
        }
        else Max1 = max(Max1, a[i]);
    }
    for (int i = 1; i <= n; i++)
    {
        if (a[i] == Max) m++;
    }
    if (m == 1)
    {
        for (int i = 1; i <= n; i++)
        {
            if (a[i] == Max) cout<<Max1<<endl;
            else cout<<Max<<endl;
        }
    }
    else
    {
        for (int i = 1; i <= n; i++)
        {
            cout<<Max<<endl;
        }
    }

}


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

int main(){
  long long l,r; cin>>l>>r;

  if(l+2019<r)cout<<0<<endl;
  else{
  vector<long long> m;
  for(int i=l; i<=min(r,l+2019); ++i)m.push_back(i%2019);

  long long fl=0, ans=3000;
  for(int i=0; i<m.size()-1; ++i){
    for(int j=i+1; j<m.size(); ++j){
      ans=min(ans, m[i]*m[j]%2019);
    }
  }
  cout<<ans<<endl;
  }
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] a=new int[N];
        for(int i=0; i<N; i++){
            a[i]=sc.nextInt();
        }
        Arrays.sort(a);
        int res=a[N-1]-a[0];

        
        System.out.println(res);
                
            
        
        
        
        
        
        }
    }

Measured memory_bytes: 35812
#!/usr/bin/env python
import sys
from collections import deque, defaultdict
from itertools import combinations, combinations_with_replacement
import bisect
from math import factorial, sqrt, log, ceil, floor
sys.setrecursionlimit(1000000)


def main():
    #N, M = map(int, input().split())
    #N, K = map(int, input().split())

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

    count = 0
    for i in range(len(S)):
        s = S[i]
        if s == 'L' and i > 0:
            if S[i-1] == 'L':
                count += 1
        if s == 'R' and i < len(S) - 1:
            if S[i+1] == 'R':
                count += 1

    state = None
    for i in range(len(S)):
        s = S[i]
        if state is None:
            state = s
            continue
        if len(state) == 1:
            if state != s:
                state += s
        else:
            if (state == 'RL' and s == 'R') or (state == 'LR' and s == 'L'):
                count += 2
                state = s
                K -= 1
                if K == 0:
                    break

    if K > 0 and (state == 'RL' or state == 'LR'):
        count += 1

    print(count)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
#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 ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
const ll INF = 1e15;

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

  FOR(i, 1, 60000) {
    ll tmp = i * 1.08;
    if (tmp == n) {
      cout << i << endl;
      return 0;
    }
  }

  cout << ":(" << endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using static System.Console;
using System.Linq;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            int a = cin.ReadInt;
            int b = cin.ReadInt;
            int c = cin.ReadInt;
            int x = cin.ReadInt;

            int cnt = 0;
            
            for (int i = 0; i <= a; i++)
            {
                for (int j = 0; j <= b; j++)
                {
                    for (int k = 0; k <= c; k++)
                    {
                        if ((500 * i + 100 * j + 50 * k) == x) cnt++;
                    }
                }
            }
            
            WriteLine(cnt);

        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}


Measured memory_bytes: 11220
using System;

namespace Kyopuro
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] a = Console.ReadLine().Split(' ');

            int N = int.Parse(a[0]);
            int K = int.Parse(a[1]);
            int i;

            double tempnum=0;
            int tempCount=0;

            double P=0.0;

            for (i = 1; i <= N; i++)
            {
                tempnum = i;
                tempCount = 1;

                while (true)
                {
                    if (tempnum < K)
                    {
                        tempnum *= 2;
                        tempCount*=2;
                    }
                    else
                    {
                        P +=(1.0/tempCount);

                        break;
                    }
                }
            }
            P /= N;
            Console.WriteLine(String.Format("{0:0.00000000000}", P));


        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; 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(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#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 show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
//const ll INF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
//inline int in() { int x; scanf("%d",&x); return x;}
template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main () {
  int n, r;
  cin >> n >> r;
  int ans = r + max(0, 100*(10-n));
  cout << ans << 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 lint=long long;

int main(){
	int n; scanf("%d",&n);
	vector<int> a(n);
	rep(i,n) scanf("%d",&a[i]);

	map<int,int> L,R;
	rep(i,n) ++R[i-a[i]];

	lint ans=0;
	rep(i,n){
		--R[i-a[i]];
		ans+=L[i-a[i]];
		ans+=R[i+a[i]];
		++L[i+a[i]];
	}
	printf("%lld\n",ans/2);

	return 0;
}


Measured memory_bytes: 37868
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 100005

int N;
ll input[NUM],table[NUM];
ll need[NUM];
ll BIT[NUM];
vector<ll> V;

void add(int loc,ll value){

	BIT[loc] += value;

	loc += loc & -loc;

	while(loc <= N){
		BIT[loc] += value;
		loc += loc & -loc;
	}
}

ll getSum(int loc){

	ll sum = BIT[loc];

	loc -= loc & -loc;

	while(loc > 0){
		sum += BIT[loc];
		loc -= loc & -loc;
	}
	return sum;
}


int main(){

	scanf("%d",&N);

	table[0] = 0;
	for(int i = 1; i <= N; i++){
		scanf("%lld",&table[i]);
		input[i-1] = table[i];
		table[i] += table[i-1];
		V.push_back(table[i]);
	}

	sort(table+1,table+N+1);

	for(int i = 1; i <= N; i++){
		scanf("%lld",&need[i]);
		if(need[i] > table[i]-table[i-1]){
			printf("-1\n");
			return 0;
		}
	}


	int index = 1;
	map<ll,int> MAP;
	for(int i = 1; i <= N; i++){
		auto at = MAP.find(table[i]);
		if(at != MAP.end())continue;
		MAP[table[i]] = index++;
	}

	for(int i = 0; i <= N; i++)BIT[i] = 0;

	ll ans = 0;

	for(int i = 0; i < N; i++){
		ans += i-getSum(MAP[V[i]]);
		add(MAP[V[i]],1);
	}

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

	return 0;
}



Measured memory_bytes: 13120
#include <iostream>
using namespace std;
int dp[105][105][3] = { 0 };

int main() {
	int n, k, a[105], b[105], ans = 0;
	cin >> n >> k;
	for (int i = 0; i < k; i++) {
		cin >> a[i] >> b[i];
		b[i]--;
	}
	for (int i = 0; i < 3; i++){
		dp[1][i][1] = 1;
	}	
	for (int i = 0; i < k; i++) {
		if (a[i] == 1) {
			dp[1][(b[i] + 1) % 3][1] = 0;
			dp[1][(b[i] + 2) % 3][1] = 0;
		}
	}
	for (int i = 2; i <= n; i++) {
		bool bo = false;
		int m = 0;
		for (m = 0; m < k; m++) {
			if (a[m] == i) {
				bo = true;
				break;
			}
		}
		if (bo) {
			dp[i][b[m]][1] += dp[i - 1][(b[m] + 1) % 3][1] + dp[i - 1][(b[m] + 2) % 3][1];
			dp[i][b[m]][1] %= 10000;
			dp[i][b[m]][1] += dp[i - 1][(b[m] + 1) % 3][2] + dp[i - 1][(b[m] + 2) % 3][2];
			dp[i][b[m]][1] %= 10000;
			dp[i][b[m]][2] = dp[i - 1][b[m]][1];
			dp[i][b[m]][2] %= 10000;
		}
		else {
			for (int j = 0; j < 3; j++) {
				dp[i][j][1] += dp[i - 1][(j + 1) % 3][1] + dp[i - 1][(j + 2) % 3][1];
				dp[i][j][1] %= 10000;
				dp[i][j][1] += dp[i - 1][(j + 1) % 3][2] + dp[i - 1][(j + 2) % 3][2];
				dp[i][j][1] %= 10000;
				dp[i][j][2] = dp[i - 1][j][1];
				dp[i][j][2] %= 10000;
			}
		}
	}
	for (int i = 0; i < 3; i++) {
		ans += dp[n][i][1] + dp[n][i][2];
		ans %= 10000;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3196
from collections import defaultdict

def main():
    N, K, Q = map(int,input().split())
    cnt = defaultdict(int)

    for _ in range(Q):
        a = int(input())
        cnt[a] += 1

    for n in range(1, N+1):
        score = K - Q + cnt[n]

        if score > 0:
            print("Yes")
        else:
            print("No")
    

if __name__ == "__main__":
    main()



Measured memory_bytes: 85532
def main():
    x_max, y_max, n = map(int, input().split())
    x_min, y_min = 0, 0

    for n in range(n):
        x, y, a = map(int, input().split())

        if (a == 1) and (x > x_min):
            x_min = x
        elif (a == 2) and (x < x_max):
            x_max = x
        elif (a == 3) and (y > y_min):
            y_min = y
        elif (a == 4) and (y < y_max):
            y_max = y

        if (x_max <= x_min) or (y_max <= y_min):
            print(0)
            return

    print((x_max - x_min) * (y_max - y_min))

if __name__ == "__main__":

    main()


Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n, d, a;
pair<int, int> m[200009];
long long ans;

void fun()
{
	queue<pair<int, long long> > qu;
	long long cnt = 0, cur = 0;
	for (int i = 0; i < n; i++) {
		while (!qu.empty()) {
			auto x = qu.front();
			if (x.fi >= m[i].fi) break;
			cur -= x.se;
			qu.pop();
		}
		long long tmp = m[i].se - cur;
		if (tmp > 0) {
			int t_cnt = (tmp + a - 1) / a;
			cnt += t_cnt;
			cur += t_cnt * 1LL * a;
			qu.push({ m[i].fi + d + d, t_cnt * 1LL * a });
		}
	}
	ans = cnt;
}

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> d >> a;
	for (int i = 0; i < n; i++) {
		cin >> m[i].fi >> m[i].se;
	}
	sort(m, m + n);
	fun();
	cout << ans << E;
	//system("pause");
	return 0;
}

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    long long ans = 0;

    for(int i=1;i<=n;i++){
        if(i%3 != 0 && i%5 != 0)
            ans = ans + i;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3664
#include<stdio.h>
int main()
{
	int n;
	scanf("%d", &n);
	int i;
	int a[100005];
	for (i = 0; i < n; i++)
		scanf("%d", &a[i]);
	int ans = 1;
	int j = 0;
	for (i = 1; i < n; i++)
	{
		if (a[i - 1] < a[i])
		{
			if (j == 0)
				j = 1;
			if (j == -1)
			{
				ans++;
				j = 0;
			}
		}
		if (a[i - 1] > a[i])
		{
			if (j == 0)
				j = -1;
			if (j == 1)
			{
				ans++;
				j = 0;
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 512
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()

print(N*(N - 1)//2)

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

int main(){
  int k,x;
  
  scanf("%d %d",&k,&x);
  
  for(int i=x-k+1;i<=x+k-1;i++){
    if(-1000000<=i&&i<=1000000)printf("%d\n",i);
  }
}

Measured memory_bytes: 256
/*
   Created by Rahul Goel.
*/
/*******************************************************************************/
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
/*******************************************************************************/
using namespace std;
using ll = long long;
using ld = long double;
ll mod = 1000000007;
const int INF = 1e9;
const ll LINF = 1e18;
/*******************************************************************************/
/*
.-.. . -. -.- .- / .. ... / .-.. --- ...- . -.-.--
 */
/* For PBDS */
/*Two new methods X.order_of_key() and X.find_by_order()*/
/*
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/

/*******************************************************************************/
ll mod_sum() { return 0LL; }
template<typename T, typename... Args>
T mod_sum(T a, Args... args) { return ((a + mod_sum(args...))%mod + mod)%mod; }

ll mod_prod() { return 1LL; }
template<typename T, typename... Args>
T mod_prod(T a, Args... args) { return (a*mod_prod(args...))%mod; }
/*******************************************************************************/
using pii = pair < ll, ll >;
using vi = vector < ll >;
using vb = vector < bool >;
using vvi = vector < vector < ll > >;
using vvb = vector < vector < bool > >;
using vpii = vector < pii >;
using vvpii = vector < vector < pii > >;
#ifdef ONLINE_JUDGE
#define endl '\n'
#endif
#define fastio          ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(c)          (c).begin(), (c).end()
#define present(c,x)    ((c).find(x) != (c).end())
#define cpresent(c,x)   (find(all(c),x) != (c).end())
#define uniq(c)         (c).resize(distance((c).begin(), unique(all(c))))
#define min_pq(t)       priority_queue < t, vector < t >, greater < t > >
#define max_pq(t)       priority_queue < t >
#define pb              push_back
#define ff              first
#define ss              second
/*******************************************************************************/

/*
    Code begins after this.
*/


ll solve(){
    ll x, y;
    cin >> x >> y;
    if(y&1)
        cout << "No" << endl;
    else{
        if(y/2 - x >= 0 && 2*x - y/2 >=0)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    return 0;
}


signed main(){
    fastio;

    ll t = 1;
    while(t--)
        solve();

    return 0;
}

/*******************************************************************************/
// Remeber - In a custom comparator cmp(a, b) a==b must always return to false.


Measured memory_bytes: 3608
#include <bits/stdc++.h>
    
using namespace std;
    
#define endl "\n"
#define ll unsigned long long
#define int long long int
#define vi vector <int >
#define vii vector < pii >
#define vvi vector < vector < int >  >
#define vll vector <ll >
#define pii pair <int, int>
#define pdd pair< double, double>
#define piii pair < pii, int > 
#define pll pair<ll, ll >
#define umap unordered_map
#define pb push_back
#define pq priority_queue
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define fore(i,c) for(int i = 1; i <= (int)c; i++)
#define rep(i,b,c) for(int i = (int)b; i < (int)c; i++)
// #define double long double
// #define a first
// #define b second

int32_t main(){
    ios::sync_with_stdio(0),cin.tie(0);

    int n;
    cin >> n;
    vi arr(n);
    forn(i, n - 1)
        cin >> arr[i];
    
    int ans = arr[0];
    int last = arr[0];
    rep(i, 1 , n - 1){
        ans += min(last, arr[i]);
        last = arr[i];
    }
    ans += arr[n - 2];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pii pair<int,int>
#define fi first
#define se second
#define int long long
#define pb push_back
#define mod 1000000007
#define pll pair<long long,long long>
using namespace std;
long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    return ans;
        
}
bool prime(int n){
    for(int i=2;i*i<=n;i++){
        if(n%i==0)return false;
    }
    return true;
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    int a=0,b=0,c=0,d=0;
    while(n--){
        string s;
        cin>>s;
        if(s[0]=='A')a++;
        else if(s[0]=='W')b++;
        else if(s[0]=='T')c++;
        else if(s[0]=='R')d++;
    }
    cout<<"AC"<<" "<<'x'<<" "<<a<<endl;
    cout<<"WA"<<" "<<'x'<<" "<<b<<endl;
    cout<<"TLE"<<" "<<'x'<<" "<<c<<endl;
    cout<<"RE"<<" "<<'x'<<" "<<d<<endl;
    return 0;
}
    

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using ll=long long;
const ll MOD=1e9+7;
const int INF=1<<30;

int main(){
  double pi=3.1415926535;
  double a,b,x;
  cin >> a >> b >> x;
  if(x>=a*a*b/2){
    double tan=2*(b-x/(a*a))/a;
    cout << fixed << setprecision(10) << atan(tan)/(2*pi)*360 << endl;
  }
  else{
    double tan=a*b*b/(2*x);
    cout << fixed << setprecision(10) << atan(tan)/(2*pi)*360 << endl;
  }
  
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include <unordered_map>  
#include <algorithm>
#include <functional>
#include <map>
#include <string>
#include <sstream>
#include <cmath>
using namespace std;

int main() {
	string s, result;
	cin >> s;
	if (s[0] != s[1] && s[1] != s[2] && s[0] != s[2]) {
		result = "Yes";
	}
	else {
		result = "No";
	}
	cout << result << endl;
	return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e18;

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

  int B[101];
  REP(i,N-1)cin >> B[i];

  int ans=B[0]+B[N-2];
  if(N>2){
    REP(i,N-2)ans+=min(B[i],B[i+1]);
  }
  cout << ans << endl;
}



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

using namespace std;

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

    int a, b;
    cin >> a >> b;

    cout << max(a + b, max(a - b, a * b));

    return 0;
}


Measured memory_bytes: 256
import itertools
import numpy as np

N = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

length = len(p)

n_array = [i for i in range(1, N + 1)]

index_dict = {}
for index, v in enumerate(sorted(itertools.permutations(n_array, length))):
    index += 1
    if list(v) == list(p):
        index_dict[str(p)] = index
    if list(v) == list(q):
        index_dict[str(q)] = index

    if str(q) in index_dict and str(p) in index_dict:
        break

print(np.abs(index_dict[str(p)] - index_dict[str(q)]))

Measured memory_bytes: 20404