akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int N,X,Y,Z;
int S;

bool nx[1<<16][11];
ll dp[41][1<<16];

ll dfs(int now, int state){
    if(dp[now][state]>=0) return dp[now][state];
    if(now==N) return 1;
    
    ll ret=0;
    rep1(i,10){
        if(nx[state][i]){
            ret+=dfs(now+1,((state<<i)+(1<<(i-1)))%(1<<S));
            ret%=MOD;
        }
    }
    return dp[now][state]=ret;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>N>>X>>Y>>Z;
    S = X+Y+Z-1;
    
    rep(mask,1<<S){
        V b;
        int st=0;
        rep(i,S){
            if((mask>>i)&1){
                b.push_back(i-st+1);
                st=i+1;
            }
        }
        
        int B=b.size();
        rep1(i,10){
            bool ok=true;
            int x=0,y=0,z=i;
            int bidx=0;
            while(bidx<B && z<Z) z+=b[bidx++];
            while(bidx<B && y<Y) y+=b[bidx++];
            while(bidx<B && x<X) x+=b[bidx++];
            if(x==X && y==Y && z==Z) ok=false;
            
            nx[mask][i]=ok;
        }
    }
    
    ll p10=1;
    rep(i,N) p10=(p10*10)%MOD;
    
    mem(dp,-1);
    ll r=dfs(0,0);
    ll ans=(p10-r+MOD)%MOD;
    cout1(ans);
}

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

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

const long long INF = 1LL << 60;

int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  cout << max(a*b, c*d) << endl;

  return 0;
}


Measured memory_bytes: 256
<?php
error_reporting(0);
$stdin = file_get_contents('php://stdin');
$line = explode("\n",$stdin);
$fi = 0;
$cnt = 0;
$list = array();
$key = new stdclass();
foreach($line as $l) {
  if (strlen($l)==0) continue;
  if ($fi == 0) {
    $a = explode(" ",$l);
    $key->A = $a;
    $fi++;
    continue;
  }
  if ($fi > 0) {
    $a = explode(" ",$l);
    $key->X[] = $a;
  }
}
$N = $key->A[0];
$M = $key->A[1];
$countline=array();
for($i=0;$i<$N;$i++) {
  $countline[$i]=0;
  foreach($key->X as $r) {
    if ($i == $r[0]-1 || $i == $r[1]-1) {
      $countline[$i]++;
    }
  }
}
for($i=0;$i<$N;$i++) {
  printf("%d\n",$countline[$i]);
}

Measured memory_bytes: 3956
#include <iostream>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <algorithm>
#include <cassert>
#include <string>
#include <climits>
#include <numeric>

#define all(x) begin(x),end(x)

using namespace std;
using ll = long long;

int main()
{
	vector<int> v(3);
	cin >> v[0] >> v[1] >> v[2];
	if (v[0] == v[1] && v[1] == v[2])
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

}



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

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

    string s;
    cin >> s;
    if (s == "ABC") {
        cout << "ARC" << endl;
    } else {
        cout << "ABC" << endl;
    }
}


Measured memory_bytes: 3636
n = int(input())
a = [int(i) for i in input().split()]
ans = "APPROVED"
for i in range(n):
    if a[i] % 2 != 0:
        continue
    if a[i] % 3 != 0 and a[i] % 5 != 0:
        ans = "DENIED"
        break
print(ans)


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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

vector<pair<int, int>> v;

void solve() {
  int n, d, a; scanf("%d%d%d", &n, &d, &a);
  for (int x, h, i = 0; i < n; ++i) {
    scanf("%d%d", &x, &h);
    v.emplace_back(x, h);
  }
  sort(v.begin(), v.end());
  long long sub = 0, ans = 0;
  queue<pair<int, int>> q;
  for (int i = 0; i < n; ++i) {
    while (!q.empty() && q.front().first < v[i].first) {
      sub -= q.front().second;
      q.pop();
    }
    v[i].second -= sub;
    if (v[i].second <= 0) continue;
    long long bomb = (v[i].second+a-1)/a;
    sub += bomb*a;
    ans += bomb;
    q.emplace(v[i].first+d*2, bomb*a);
  }
  printf("%lld", ans);
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 5668
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<numeric>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int, int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define pque(type) priority_queue<type,vector<type>,greater<type> >

int main(void){
  int n, m, x;
  cin >> n >> m >> x;
  vector<int> a(n+1, 0);
  rep(i, m){
    int t;
    cin >> t;
    a[t] = 1;
  }

  int ans, sum = 0;
  rep(i, x) sum += a[i];
  ans = sum;
  sum = 0;
  reg(i, x, n) sum += a[i];
	cout << min(ans, sum) << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
    int W = sc.nextInt();
    int h = sc.nextInt();
    int w = sc.nextInt();
    System.out.println((H-h)*(W-w));
  }
}

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

template<typename T, typename U> void cmax(T &a, U b) { if (a < b) a = b; }
template<typename T, typename U> void cmin(T &a, U b) { if (a > b) a = b; }

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

  string S;
  cin >> S;
  cout << S;
  cout << ((S.back() == 's') ? "es" : "s") << "\n";
}

Measured memory_bytes: 3596
N = int(input())
S = [input() for _ in range(N)]
a=S.count('AC')
b=S.count('WA')
c=S.count('TLE')
d=S.count('RE')
print('AC x '+str(a))
print('WA'+' x '+str(b))  
print('TLE'+' x '+str(c))
print('RE'+' x '+str(d))  

Measured memory_bytes: 16280
using System;

namespace abc132
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var c = input[0].ToCharArray();
            if(((c[0]==c[1] && c[2]==c[3]) || (c[0]==c[2] && c[1]==c[3]) || (c[0]==c[3] && c[1]==c[2])) && !(c[0]==c[1] && c[0]==c[2]))
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 13140
#include<stdio.h>
#include<string.h>
#include<iostream>
using namespace std;
const int mod = 1e9 + 7;
int main()
{
	int n, m;
	int i, j;
	char a[110][110];
	scanf("%d %d", &n, &m);
	for(i = 1; i <= n; i++)
		scanf("%s", &a[i]);
		for(i = 1; i <= m + 2; i++)
		{
			if(i != m + 2)
			printf("#");
			else
				printf("#\n");
		}
		for(i = 1; i <= n; i++)
			printf("#%s#\n", a[i]);
			for(i = 1; i <= m + 2; i++)
			{
				if(i != m + 2)
					printf("#");
					else
						printf("#\n");
			}
}

Measured memory_bytes: 256
n = int(input())

INF = float("inf")

dp = [INF]*100010
dp[0] = 0

pow6 = [6**i for i in range(1,7)]
pow9 = [9**i for i in range(1,6)]

for i in range(1,n+1):
    dp[i] = dp[i-1] + 1
    for p6 in pow6:
        dp[i] = min(dp[i],dp[i-p6]+1)
    for p9 in pow9:
        dp[i] = min(dp[i],dp[i-p9]+1)

print(dp[n])

Measured memory_bytes: 9496
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;

#define ll long long
#define pb push_back

int main(){

	int N;
	vector<string> W;
	cin>>N;
	for(int i=0;i<N;i++){
		string s;
		cin>>s;
		W.pb(s);
	}
	bool flag=true;
	for(int i=1;i<N;i++){
		if(W[i-1][W[i-1].size()-1]!=W[i][0])flag=false;
		for(int j=0;j<i;j++){
			if(W[i]==W[j])flag=false;
		}
	}
	if(flag)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char const *argv[]) {
  long long H, W;
  cin >> H >> W;
  if (H == 1 || W == 1)
  {
    cout << 1 << endl;
  }else
  {
    cout << ((H * W + 2 - 1) / 2) << '\n';
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string>
using namespace std;
string n;
int main(){
  cin >> n;
  for(int i = 0; i <= 2; i++){
    if(n[i] == '9') n[i] = '1';
    else if(n[i] == '1') n[i] = '9'; 
  }
  cout << n << endl;
}

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

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

  int count = 0;
  for (int i = 0; i < S.size()/2 ; i++){
    if( S.at(i) != S.at(S.size()-i-1)){
      count ++;
    }
  }
       cout << count << endl;
}

Measured memory_bytes: 256
import fractions
N, X = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
a = []
for i in range(N):
    a.append(abs(X - x[i]))
ans = a[0]
if len(a) > 1:
    for i in range(1, len(a)):
        ans = fractions.gcd(ans, a[i])
print(ans)

Measured memory_bytes: 16296
#include <bits/stdc++.h>
using namespace std;
int main(){
  string a;
  cin >> a;
  string ans;
  if (a=="A") ans = "T";
  if (a=="T") ans = "A";
  if (a=="C") ans = "G";
  if (a=="G") ans = "C";
  cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define vi vector <ll>
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define INF 10000000000

using namespace std;

int main() {
	int n;
	vi dp,h;
	cin >> n;
    dp.assign(n+5,0);
    h.assign(n+5,0);
    for (int i = 0; i <n ; ++i){
   		cin >> h[i];
    }
    dp[1] = abs(h[1]-h[0]);
    for (int i = 2; i < n; ++i){
    	dp[i] = min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]));
    }
    cout << dp[n-1] << endl;
   return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int j;
	string kkk;
	cin>>kkk;
	bool flagc=0,flagf=0;
	for(int i=0;i<kkk.length();i++){
		if(kkk[i]=='C'){
			j=i;
			flagc=1;
		}
	}
	for(int k=j;k<kkk.length();k++)
	{
		if(kkk[k]=='F')
		{
			flagf=1;
		}
	}
	if(flagc&&flagf)cout<<"Yes";
	else cout<<"No"; 
	return 0; 
}

Measured memory_bytes: 256
n=int(input())
a=[]
for _ in range(n):
    x=int(input())
    a.append(x)
b=sorted(a)
p=b[-1]
q=b[-2]
cnt=0
for y in a:
    if y==p:
        cnt+=1
if cnt>=2:
    for i in range(n):
        print(p)
else:
    for i in range(n):
        if a[i]==p:
            print(q)
        else:
            print(p)


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

const int mod = 1000000007;
struct mint {
    long long x;
    mint(long long x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-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(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    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;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

void Main()
{
    int n;
    cin >> n;
    mint sum = 0, sum2 = 0;
    for (int i = 0; i < n; i++)
    {
        long a;
        cin >> a;
        sum += a;
        sum2 += a*a;
    }
    mint ans = (sum*sum-sum2)/2;
    
    cout << ans << endl;
}

int main(int argc, char **argv)
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    Main();
    return 0;
}


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

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MAXN 100000
#define ff first
#define ss second
#define ll long long
#define int long long
#define mod 1000000007
#define pii pair<ll,ll>
#define vi vector<ll>
#define mii map<ll,ll>
#define pb push_back
#define mp make_pair
#define ps(x,y) fixed<<setprecision(y)<<x
#define mk(arr,n,type) type *arr=new type[n];
#define w(x) ll x; cin>>x; while(x--)
#define endl '\n'
#define str string
void kehsihba(){
   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
   freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
#endif
}
int32_t main() {
	//kehsihba();
	ll n,k,x,y;
	cin>>n>>k>>x>>y;
	if(n<=k){
		cout<<x*n;
	}
	else{
		cout<<x*k+(n-k)*(y);
	}
	return 0;
}

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

S=[""]*N
P=[0]*N
for i in range(N):
    S[i],P[i] = input().split()
    
P = [int(s) for s in P]

list=[]
for i in range(N):
    cnt = 1
    for j in range(N):
        if i == j:
            continue
        if S[i] > S[j]:
            cnt += 1
        if S[i] == S[j] and P[i]<P[j]:
            cnt +=1
    list.append(cnt)

for i in range(1,N+1):
    print(list.index(i) + 1)



Measured memory_bytes: 39280
#include <iostream>
using namespace std;
typedef long long int ll;

main(){
	ll M,rD,rR,cD,cR;
	cin>>M>>rD>>rR>>cD>>cR;
	M -= (cD*100+rD-1)/rD + (cR*100+rR-1)/rR;
	cout << (M<0?-1:M) << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int N = 100 * 1000 + 10;

vector<int> beat[N];
int dp[N];

int solve(int v) {
    if (beat[v].size() == 0)
        return 0;
    vector<int> kids;
    for (int to : beat[v])
        kids.push_back(solve(to));
    sort(kids.begin(), kids.end());
    reverse(kids.begin(), kids.end());
    int cur = 1;
    int res = 0;
    for (int x : kids) {
        res = max(res, cur + x);
        cur++;
    }
    return res;
}


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    int n;
    cin >> n;
    for (int i = 1; i < n; i++) {
        int x;
        cin >> x;
        x--;   
        beat[x].push_back(i); 
    }
    cout << solve(0) << endl;
}   

Measured memory_bytes: 13568
#include<iostream>
#include<algorithm>
using lint=long long;
using namespace std;

bool cmp(const pair<int,int> &lhs,const pair<int,int> &rhs)
{
	return lhs.second<rhs.second;
}

int main()
{
	int N,M;
	pair<int,int> p[100010]={};
	
	cin >> N >> M;
	for(int i=0;i<M;i++)
		cin >> p[i].first >> p[i].second;
	
	
	sort(p,p+M,cmp);
	
	int Min=0;
	int ans=0;
	for(int i=0;i<M;i++)
	{
		if(Min<p[i].first)
		{
			ans++;
			Min=p[i].second-1;
		}
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
def insertionSort(A, N):
    for i in range(N):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j+1] = A[j]
            j -= 1
        A[j+1] = v
        print(*A)
    return A


N = int(input())
A = list(map(int, input().split()))

insertionSort(A, N)



Measured memory_bytes: 5976
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.AbstractMap;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		int a = sc.nextInt();
		int b = sc.nextInt();
		
		out.println((a-1)*(b-1));
		
		out.flush();
	}

	public static int gcd(int a, int b) {
		if(a < b) return gcd(b, a);
		if(b == 0) return a;
		return gcd(b, a % b);
	}
}

class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {

    public Pair(final K key, final V value) {
        super(key, value);
    }
 }

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

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

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

Measured memory_bytes: 23252
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<numeric>
#include<map>
using namespace std;


int main(){
	int a[5], b[5];

	for (size_t i = 0; i < 3; i++) {
		scanf("%d", &a[i]);
	}
	for (size_t i = 0; i < 3; i++) {
		b[i] = abs(a[(i+1)%3] - a[i]);
	}

	int ans = accumulate(b, b+3, 0);
	ans -= *max_element(b, b+3);
	printf("%d\n", ans);
	
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n,d,a,vt;
ll x[200001],h[200001],kc[200001],r_range[200001],damage[200001];
pair <ll,ll> XH[200001];
int right_bound(ll a)
{
    int left = -1;
    int right = n;
    while(abs(right-left) > 1)
    {
        int mid = (left + right)/2;
        if(XH[mid].first > a) right = mid;
        else left = mid;
    }
    return left;
}
void init()
{
    sort(XH, XH + n);
    for(int i = 0; i < n; ++i)
    {
        r_range[i] = right_bound(XH[i].first + 2*d);
    }
}
int main()
{
    cin >> n >> d >> a;
    for(int i = 0; i < n;i ++) cin >> XH[i].first >> XH[i].second;
    init();
    ll res = 0;
    for(int i = 0; i < n;i ++)
    {
        XH[i].second -= damage[i];
        ll k = (max(0LL, XH[i].second) + a - 1)/a;
        res += k;
        damage[i] += a*k;
        damage[r_range[i] + 1] -= a*k;
        damage[i+1] += damage[i];
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 8448
#include <cstdio>
#include <string>
#include <cmath>
#include <string>
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
#include <iomanip>
#include <tuple>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i, a, n) for (int i=a;i<n;++i)
#define repeq(i, a, n) for(int i=a;i<=n;++i)
#define repi(m, itr) for (auto itr = m.begin();itr != m.end();++itr)
#define per(i, a, n) for (int i=n-1; i>=a;--i)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()

// 
int N, i;
int ans = 0;

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

    ans = N - i + 1;

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




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

int main(void){
    int N,M,X;
    int C[12];
    int A[12][12];
    int min = 1000000000;
    int ans = -1;
    
    scanf("%d%d%d",&N,&M,&X);
    
    for(int i = 0; i < N; i++){
        scanf("%d",&C[i]);
        for(int j = 0; j < M; j++){
            scanf("%d",&A[i][j]);
        }
    }
    
    for(int i = 1; i < (int)pow(2,N); i++){
        int und[12] = {};
        int sum = 0;
        
        for(int j = 0; j < N; j++){
            if((i >> j & 1) == 1){
                sum += C[j];
                for(int z = 0; z < M; z++){
                    und[z] += A[j][z];
                }
            }
        }
        
        int flag = 1;
        for(int j = 0; j < M; j++){
            if(und[j] < X){
                flag = 0;
                break;
            }
        }
        
        if(flag == 1 && min > sum){
            min = sum;
            ans = i;
        }
    }
    
    if(ans == -1){
        printf("-1\n");
    }
    else{
        printf("%d\n",min);
    }
}


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


using namespace std;

using ll   = long long;
using ii   = pair   < int , int >;
using i3   = pair   < int , ii  >;
using li   = pair   < ll  , int >;
using lii  = pair   < ll  , ii  >;
using pll  = pair   < ll  , ll  >;
using vi   = vector < int       >;
using vl   = vector < ll        >;
using vii  = vector < ii        >;
using vli  = vector < li        >;
using vpll = vector < pll       >;
using vi3  = vector < i3        >;
using vlii = vector < lii       >;


const int N = 1000 + 5;
const ll INF = 1e17 + 7 , mod = 1e9 + 7;
const double eps = 1e-9 , PI = acos(-1);


int n , m;

char a[N][N];

void solve(int testCase){

    scanf("%d %d" , &n , &m);

    for(int i = 0 ; i < n ; i ++){
            scanf("%s" , a[i]);
    }

    vector < vl > dp(n+1 , vl(m+1 , 0));
    dp[1][1] = 1;

    for(int i = 1 ; i <= n ; i ++){
            for(int j = 1 ; j <= m ; j ++){
                    if(a[i-1][j-1] == '#')continue;

                    if(i < n){
                            dp[i+1][j] += dp[i][j]; dp[i+1][j] %= mod;
                    }
                    if(j < m){
                            dp[i][j+1] += dp[i][j]; dp[i][j+1] %= mod;
                    }
            }
    }

    printf("%lld\n" , dp[n][m]);
}

main(){

    int t = 1;
    // scanf("%d" , &t);

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

    return 0;
}


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


using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<string> &o) {
    string a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

typedef pair<ll, ll> P;

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;


int main() {

    struct Direction {
        int x, y;
    };

    vector<Direction> directions = {
            {0,  1},
            {1,  1},
            {1,  0},
            {1,  -1},
            {0,  -1},
            {-1, -1},
            {-1, 0},
            {-1, 1},
            {0,  0},
    };


    ll h, w, n;
    cin >> h >> w >> n;

    ll ma = (h - 2) * (w - 2);
    set<P> points;
    rep(i, n) {
        ll a, b;
        cin >> a >> b;
        points.insert({a, b});
    }

    set<P> need_check;
    for (P p : points) {


        for (Direction &d : directions) {
            P next = {p.first + d.y, p.second + d.x};
            if (next.first <= 1) continue;
            if (next.first >= h) continue;
            if (next.second <= 1) continue;
            if (next.second >= w) continue;
            need_check.insert(next);
        }
    }

    vector<ll> ans(10);

    for (P p : need_check) {
        int count = 0;
        for (Direction &d : directions) {
            P q = {p.first + d.y, p.second + d.x};
            if (points.find(q) != points.end()) count++;
        }
        ans[count]++;
        ma--;
    }

    ans[0] = ma;
    for (ll i : ans) cout << i << endl;

}

Measured memory_bytes: 62720
#include <array>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <tuple>
using namespace std;


typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}

template <class T>
T clampMax(const T& a, const T& b) { return min(a, b); }

template <class T>
T clampMin(const T& a, const T& b) { return max(a, b); }

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

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

#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define PB push


#define MOD 1000000007LL
#define EPS 1e-10

using Node = vector<int>;
using Tree = vector<Node>;

enum Color
{
    White,
    Black
};

LL memo[100005][2];

LL Solve(const Tree& tree, int prev, int curr, Color color)
{
    if (tree[curr].size() == 0) return memo[curr][color] = 1;
    if (prev != -1 && tree[curr].size() == 1) return memo[curr][color] = 1;
    if (memo[curr][color] > 0) return memo[curr][color];

    LL res = 1;

    for (const int next : tree[curr])
    {
        if (next == prev) continue;

        LL tmp = 0;

        if (color == Color::White)
        {
            tmp = (tmp + Solve(tree, curr, next, White)) % MOD;
            tmp = (tmp + Solve(tree, curr, next, Black)) % MOD;
        }
        else
        {
            tmp = (tmp + Solve(tree, curr, next, White)) % MOD;
        }

        res = (res * tmp) % MOD;
    }

    return memo[curr][color] = res;
}

int main()
{
    int N;
    cin >> N;
    Tree tree(N);
    int x, y;
    REP(i, N - 1)
    {
        cin >> x >> y;
        --x; --y;
        tree[x].push_back(y);
        tree[y].push_back(x);
    }
    Solve(tree, -1, 0, White);
    Solve(tree, -1, 0, Black);
    // cout << memo[0][White] << endl;
    // cout << memo[0][Black] << endl;
    LL ans = (memo[0][White] + memo[0][Black]) % MOD;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 15616
#include <bits/stdc++.h>
using namespace std ;
#define ll long long
inline int D(){
    int t ;
    scanf( "%d" , &t ) ;
    return t ;
}
inline ll LLD(){
    ll t ;
    scanf( "%lld" , &t ) ;
    return t ;
}


//#########################################

int main() {

int n=D(),m=D();
char a[n][n];
char b[m][m];
for(int i=0;i<n;i++){
   for(int j=0;j<n;j++){
   cin>>a[i][j];

   }

}
for(int i=0;i<m;i++){
   for(int j=0;j<m;j++){
cin>>b[i][j];
   }

}



for(int i=0;i<n;i++){
   for(int j=0;j<n;j++){
int cnt=0;

     for(int ii=0;ii<m;ii++){
       for(int jj=0;jj<m;jj++){

       if(b[ii][jj]==a[i+ii][j+jj]){
       cnt++;

       }

       }





     }
     if(cnt==(m*m)){
     cout<<"Yes";
     return 0;
     }



   }

}
cout<<"No";

}

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

int main()
{
    int n;
    cin >> n;
    vector<pair<int,int>> arm;
    vector<int> L(n);
    vector<int> R(n);
    for(int i = 0; i < n; ++i)
    {
        int x,l;
        cin >> x >> l;
        arm.push_back(make_pair(x+l,i));
        arm.push_back(make_pair(x-l,i));
        L[i] = x-l;
        R[i] = x+l;
    }
    sort(arm.begin(), arm.end());

    int ans = 0;
    vector<int> cur;
    vector<int> tmpCur;
    vector<bool> checker(n);
    vector<bool> outer(n);
    for(pair<int,int> p : arm)
    {
        int id = p.second;
        int val = p.first;
        if(outer[id])
        {
            continue;
        }
        else if(checker[id])
        {
            ++ans;
            //cout << L[id] << " " << id << " " << R[id] << endl;
            tmpCur.clear();
            for(int c : cur)
            {
                if(L[c] == val)
                {
                    tmpCur.push_back(c);
                    continue;
                }
                outer[c] = true;
            }
            cur.clear();
            cur = tmpCur;
        }
        else
        {
            checker[id] = true;
            cur.push_back(id);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 6052
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
typedef unsigned long long ull;
typedef long double ldouble;
const ll INF=1e18;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
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; }


int main(){
    int N, W;
    cin >> N >> W;
    vector<ll> w(N), v(N);
    rep(i, N) cin >> w[i] >> v[i];
    vector<vector<ll> > dp(N+1, vector<ll>(1001 * N, INF));
    dp[0][0] = 0;
    rep(i, N) {
        rep(j, 1001 * N) {
            if(j < v[i]) {
                dp[i+1][j] = dp[i][j];
            }
            else {
                dp[i+1][j] = min(dp[i][j], dp[i][j-v[i]] + w[i]);
            }
        }
    }
    ll ans = 0;
    rep(j, 1001 * N) {
        if(dp[N][j] <= W) chmax(ans, j);
    }
    cout << ans << endl;
}

Measured memory_bytes: 83196
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define MAXN 100001
#define mod 1000000007
int dp[MAXN][13];   
int nanjou[6];
int main () {
    nanjou[0] = 1;
    nanjou[1] = 10;
    nanjou[2] = 9;
    nanjou[3] = 12;
    nanjou[4] = 3;
    nanjou[5] = 4;
    string s;
    cin >> s;
    memset(dp, 0, sizeof(dp));
    int n = s.length();
    if (s[n - 1] == '?') {
        for (int i = 0; i < 10; i++) {
            dp[n - 1][i] = 1;
        }
    }
    else {
        dp[n - 1][s[n - 1] - 48] = 1;
    }
    for (int i = n - 2; i >= 0; i--) {
        if (s[i] == '?') {
            int jou = (n - 1 - i) % 6;
            for (int j = 0; j <= 9; j++) {
                for (int k = 0; k < 13; k++) {
                    dp[i][(k + j * nanjou[jou]) % 13] = (dp[i][(k + j * nanjou[jou]) % 13] + dp[i + 1][k]) % mod;
                } 
            }
        }
        else {
            int jou = (n - 1 - i) % 6;
            for (int k = 0; k < 13; k++) {
                dp[i][(k + (s[i] - 48) * nanjou[jou]) % 13] = (dp[i][(k + (s[i] - 48) * nanjou[jou]) % 13] + dp[i + 1][k]) % mod;
            } 
        }
    }
    cout << dp[0][5] << endl;
    return 0;
}

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

int main() {
	int n;
	cin>>n;
	vector<vector<long> > dp(n,vector<long>(n,0));
	long long sum = 0 ;
	for(int i = 0 ; i < n ; i++){
		long long temp ;
		cin>>temp ;
		sum+=temp;
		dp[i][i] = temp;
	}
	for(int i = 1 ; i <= n-1 ; i++){
		for(int j = 0 ; i+j < n ; j++){
			int col = j+i;
			int row = j;
			if(i==1){
				dp[row][col] = max(dp[row+1][col],dp[row][col-1]);
			}
			else{
				dp[row][col] = max(dp[row][row] + min(dp[row+2][col],(dp[row+1][col-1])) 
					,dp[col][col] + min(dp[row+1][col-1],(dp[row][col-2])));
			}
		}
	}
	cout<<2*dp[0][n-1] - sum;

return 0;
}

Measured memory_bytes: 70656
def power(n, r, mod=10**9+7):
    if r == 0: return 1
    if r%2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * power(n, r-1, mod) % mod


N = int(input())
C = list(map(int, input().split()))
C.sort(reverse=True)

MOD = 10**9 + 7
ans = 0

for i, c in enumerate(C, 1):
  ans += c*(i+1) % MOD

ans *= power(4, N-1)
ans %= MOD
print(ans)

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

#define fi first
#define se second

using namespace std;
typedef pair <int, int> pi;

const int N = 605;

int n, d1, d2, m;
int flag[N][N], vis[N][N], ok[N][N];
vector < pair <int, int> > lis;

void dfs (int x, int y) {
	vis[x][y] = true;
	for (auto &t : lis) {
		int dx = x + t.fi, dy = y + t.se;
		if (dx < 0 || dx >= n || dy < 0 || dy >= n || !ok[dx][dy]) continue;
		if (vis[dx][dy]) assert (flag[dx][dy] ^ flag[x][y]);
		else flag[dx][dy] = !flag[x][y], dfs (dx, dy);
	}
}

void solve (int D) {
	lis.clear();
	memset (vis, 0, sizeof(vis));
	memset (flag, 0, sizeof(flag));
	int x, y;
	for (x = 0; x * x <= D; x ++) {
		y = sqrt(D - x * x + 0.5);
		if (x * x + y * y == D) {
			lis.push_back (pair <int, int> (x, y));
			lis.push_back (pair <int, int> (-x, y));
			lis.push_back (pair <int, int> (x, -y));
			lis.push_back (pair <int, int> (-x, -y));
		}
	}
	for (x = 0; x < n; x ++) for (y = 0; y < n; y ++) if (ok[x][y] && !vis[x][y]) dfs (x, y);
}

int main () {
	int x, y, a, b, cnt;
	scanf ("%d%d%d", &n, &d1, &d2);
	m = n * n, n <<= 1;
	for (x = 0; x < n; x ++) for (y = 0; y < n; y ++) ok[x][y] = true;
	solve (d1);
	for (cnt = x = 0; x < n; x ++) for (y = 0; y < n; y ++) if (flag[x][y]) cnt ++;
	if (cnt < m * 2) for (x = 0; x < n; x ++) for (y = 0; y < n; y ++) flag[x][y] ^= 1;
	for (x = 0; x < n; x ++) for (y = 0; y < n; y ++) ok[x][y] = flag[x][y];
	solve (d2);
	for (cnt = x = 0; x < n; x ++) for (y = 0; y < n; y ++) if (flag[x][y]) cnt ++;
	if (cnt < m) for (x = 0; x < n; x ++) for (y = 0; y < n; y ++) if (ok[x][y]) flag[x][y] ^= 1;
	for (x = 0; x < n; x ++) for (y = 0; y < n; y ++) if (flag[x][y]) {
		printf ("%d %d\n", x, y);
		m --;
		if (m == 0) return 0;
	}
	return 0;
}

Measured memory_bytes: 22016
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD = 1000000007;
const ll INF = 1061109567;
const double EPS = 1e-10;

int main(){
  string s;
  ll k,cnt;
  cin>>s>>k;
  for(int i=0;i<100000;i++){
    if(s[i]!='1'){
      break;
    }else{
      cnt++;
    }
  }
  if(k-1<=cnt){
    cout<<s[k-1]<<endl;
  }else{
    cout<<s[cnt]<<endl;
  }
}

Measured memory_bytes: 3632
#include<iostream>

using namespace std;

int main(){

    int Alice, Bob;

    cin >> Alice >> Bob;

    if(Alice==1){
        if(Bob==1){
            cout << "Draw";
        }else{
            cout << "Alice";
        }
    }else if(Bob==1){
        cout << "Bob";
    }else if(Bob<Alice){
        cout << "Alice";
    }else if(Bob==Alice){
        cout << "Draw";
    }else{
        cout << "Bob";
    }
}


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



int main(){
	string s;
	long long puncak=0;
	long long tebing=0;
	long long ans=0;
	cin>>s;
	for(long long i=0; i<s.length(); i++){
		if(s[i]=='>'){
			if(i>0 && s[i-1]=='<') tebing=0;	
			tebing++;
			if(puncak>=tebing) ans+=tebing-1;
			else ans+=tebing;
		}
		else if(s[i]=='<'){
			if(i>0 && s[i-1]=='>') puncak=0;
			puncak++;
			ans+=puncak;
		}
	}
	cout<<ans<<endl;
}

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);

  int n;
  cin >> n;
  vector<int> h(n);
  rep(i, n) { cin >> h[i]; }

  int count = 0;
  vector<bool> has_grown_up(n, false);
  rep(i, n) {
    if (h[i] == 0) {
      has_grown_up[i] = true;
      count++;  
    }
  }

  ll ans = 0;
  while (count < n) {
    int start = 0; 
    while (has_grown_up[start] && start < n) { start++; }
    int min_h = h[start];
    for (int i = start; !has_grown_up[i] && i < n; ++i ) {  
      min_h = min(min_h, h[i]);
    }
    ans += min_h;
    for (int i = start; !has_grown_up[i] && i < n; ++i ) {  
      h[i] -= min_h;
      if (h[i] == 0) {
        count++;
        has_grown_up[i] = true;
      }
    }

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

int main(){
    int N;
    cin >> N;
    priority_queue<int> que;
    for(int i = 0; i < N; i++){
        int temp;
        cin >> temp;
        que.push(temp);
    }
    
    int cnt = 0;
    int now = 1000;
    while(!que.empty()){
        int temp = que.top();
        que.pop();
        if(temp < now){
            cnt++;
            now = temp;
        }
    }
    
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,m;
cin>>n>>m;
int arr[m];
int sum=0;
for(int i=0;i<m;i++){
    cin>>arr[i];
    sum+=arr[i];
}
if(sum>n) cout<<-1<<endl;
else {
    cout<<n-sum<<endl;
}
return 0;
}


Measured memory_bytes: 3664
#include <iostream>
using namespace std;
void k(int,int);
int m;
int main(){
  int e,i,j,k;
  while(1){
    m=10000000;
    cin >> e;
    if(e==0) break;
    for(i=0;i<=100;i++){
      for(j=0;j<=1000;j++){
	k=e-j*j-i*i*i;
        if(k>=0&&j>=0&&i>=0&&m>i+j+k){
	  m=i+j+k;
	}
      }
    }
    cout << m << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#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;
typedef long long ll;

int main(){

    int N, K, Q;
    cin >> N >> K >> Q;

    vector<int> A(N + 1);
    rep(i, N)cin >> A[i];
    A[N] = 0;

    int ans = 1000000000;
    rep(loop1, N){

        int minimum = A[loop1];
        vector<int> canuse;
        
        {
            int l = 0;
            rep(r, N + 1){
                if(A[r] < minimum){
                    if(r - l >= K){
                        priority_queue<int, vector<int>, greater<int>> que;
                        for(int i = l; i < r; i++)que.push(A[i]);
                        rep(i, r - l - K + 1){
                            canuse.push_back(que.top());
                            que.pop();
                        }
                    }
                    l = r + 1;
                }
            }
        }

        if((int)canuse.size() >= Q){
            sort(all(canuse));
            chmin(ans, canuse[Q - 1] - minimum);
        }
        
    }

    cout << ans << endl;
    return 0;

}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> V(N + M);
  for (int i = 0; i < M; i++) V.at(i)++;
  
  int cnt = 0;
  for (int i = 0; i < N + M; i++)
    for (int j = 0; j < i; j++) if ((V.at(i) + V.at(j)) % 2 == 0) cnt++;

  cout << cnt << "\n";
}

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

void solve(long long W, long long H, vector<long long> p, vector<long long> q){
	SORT(p);
	SORT(q);
	ll pivp = 0, pivq = 0, res = 0;
	while(pivp != W || pivq != H) {
		if (pivq == H || (pivp != W && p[pivp] < q[pivq])) {
			res += p[pivp]*(H-pivq+1);
			// cout << "p " << p[pivp] << " " << (H-pivq+1) << " " << p[pivp]*(H-pivq+1) << endl;
			pivp++;
		} else {
			res += q[pivq]*(W-pivp+1);
			// cout << "q " << q[pivq] << " " << (W-pivp+1) << " " << q[pivq]*(W-pivp+1) << endl;
			pivq++;
		}
	}
	cout << res << endl;
}

int main(){	
	long long W;
	long long H;
	scanf("%lld",&W);
	vector<long long> p((W-1)-0+1);
	scanf("%lld",&H);
	vector<long long> q((H-1)-0+1);
	for(int i = 0 ; i <= (W-1)-0 ; i++){
		scanf("%lld",&p[i]);
	}
	for(int i = 0 ; i <= (H-1)-0 ; i++){
		scanf("%lld",&q[i]);
	}
	solve(W, H, p, q);
	return 0;
}



Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define speed_up ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long
#define ara(A,N) sort(A,A+N)
#define rev(A,N) sort(A,A+N,greater<int>())
using namespace std;
int main()
{
  speed_up;
  int i, j, k;
  int n, s, sum = 0;
  cin>>n>>s;
  sum = 0;

  for(i = 0; i<=n; i++)
  {
      for(j = 0; j<=n; j++)
      {
          k = s - i - j;
          if(0<=k && k<=n) sum++;
      }
  }
  cout<<sum<<endl;
      return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int k;
  string s;
  cin >> k >> s;
  if(s.size()<=k){
    cout << s << endl;
    exit(0);
  }else{
    for (int i = 0; i < k; i++) {
      cout << s.at(i);
    }
    cout << "..." << endl;
  }
}

Measured memory_bytes: 3628
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ldouble = long double;

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s) cout << fixed << setprecision(10) << s << endl;


int main()
{
	ll m, n, x, y;
	cin >> m >> n >> x >> y;

	vector<ll> a(m);
	ll a0 = -101;
	for (ll i = 0; i < m; i++)
	{
		cin >> a[i];

		a0 = max(a0, a[i]);
	}

	vector<ll> b(n);
	ll b0 = 101;
	for (ll i = 0; i < n; i++)
	{
		cin >> b[i];

		b0 = min(b0, b[i]);
	}

	string res = "No War";

	if (a0 >= b0)
	{
		res = "War";
	}

	if (b0 <= x)
	{
		res = "War";
	}

	if (a0 >= y)
	{
		res = "War";
	}

	println(res);
}


Measured memory_bytes: 3596
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cctype>
#include<complex>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<functional>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
using namespace std;
const int dx[] = {1,0,-1,0},dy[] = {0,1,0,-1};
#define INF 1e+8
#define rep(i,j) for(int i = 0; i < (j); i++)
#define reps(i,j,k) for(int i = j; i < k; i++)
typedef long long ll;
typedef unsigned long long ull;
int main(){
    typedef pair<double,int> P;
    priority_queue < P, vector< P >, greater< P > > hoge;
    vector < P > ans; 
    P fuga;
    int cnt = 0;
    rep(i,3){
        P p[10];
        rep(j,8){
            cin >> p[j].second >> p[j].first;
        }
        sort(p,p+8); 
        ans.push_back(p[0]);
        ans.push_back(p[1]);   
        hoge.push(p[2]);
        hoge.push(p[3]);
    }
    rep(i,6){
        cout << ans[i].second << " " << ans[i].first << endl;
    }
    fuga = hoge.top();hoge.pop();
    cout << fuga.second << " "<< fuga.first << endl; 
    fuga = hoge.top();hoge.pop();
    cout << fuga.second << " "<< fuga.first << endl;
    return 0;
}

Measured memory_bytes: 1308
#include<math.h>
#include<stdio.h>

int main(){
  double A,B,H,M;
  scanf("%lf %lf %lf %lf",&A,&B,&H,&M);
  double thetaH,thetaM,ans2;
  thetaH = 2*M_PI/12*(H + M/60);
  thetaM = 2*M_PI/60*M;
  
  ans2 = A*A + B*B - 2*A*B*cos(fabs(thetaH - thetaM));
  printf("%.20lf\n",sqrt(ans2));
}

Measured memory_bytes: 2600
///not today

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

#define SZ(x) (int)(x).size()
#define pb push_back
#define ll long long
#define xmax(x, y) (x) = max((x), (y))
#define xmin(x, y) (x) = min((x), (y))
#define F first
#define S second
#define pii pair<int, int>
#define pll pair<long long, long long>
#define int long long
#define pipii pair<int, pair<int, int> >

const int maxn = 1000* 100 + 5, inf = 1000* 100 + 5;
int a[maxn], dp[2][maxn];

int32_t main(){
    int n;
    cin >>n;
    for(int i = 0; i < n; i ++){
        cin >>a[i];
        dp[1][i] = inf;
        dp[0][i] = inf;
    }
    dp[0][0] = 1;
    dp[1][0] = 1;
    for(int i = 1; i < n; i ++){
        if(a[i] >= a[i - 1]){
            xmin(dp[1][i], dp[1][i - 1]);
            xmin(dp[0][i], min(dp[1][i - 1], dp[0][i - 1]) + 1);
        }
        if(a[i] <= a[i - 1]){
            xmin(dp[0][i], dp[0][i - 1]);
            xmin(dp[1][i], min(dp[0][i - 1], dp[1][i - 1])+ 1);
        }
//        cout <<dp[0][i] <<' ' <<dp[1][i] <<endl;
    }
    cout <<min(dp[0][n - 1], dp[1][n - 1]) <<endl;
    return false;
}


Measured memory_bytes: 2560
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

struct UnionFind {
	vector<int> data;
	UnionFind(int n) : data(n, -1) {}

	int find(int x) {
		return data[x] < 0 ? x : data[x] = find(data[x]);
	}

	bool unite(int x, int y) {
		x = find(x);
		y = find(y);

		if (x == y) {
			return false;
		}

		if (data[x] > data[y] || data[x] == data[y] && x > y) {
			swap(x, y);
		}

		data[x] += data[y];
		data[y] = x;

		return true;
	}

	bool same(int x, int y) {
		return find(x) == find(y);
	}
};

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

	int n, m;
	cin >> n >> m;

	vector<int> p(n);
	for (auto& v : p) {
		cin >> v;
		v--;
	}

	UnionFind uf(n);
	for (int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		x--; y--;

		uf.unite(x, y);
	}

	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (uf.same(i, p[i])) {
			ans++;
		}
	}

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


Measured memory_bytes: 1024