akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
int a[3];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  FOR(i, 0, 3) cin >> a[i];
  sort(a, a+3);
  cout << a[0]+a[1] << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import Counter
from itertools import chain

def readlines(n):
    for _ in range(n):
        yield list(map(int, input().split()))

def main():
    h, w = map(int, input().split())

    C = list(readlines(10))

    for k in range(10):
        for i in range(10):
            for j in range(10):
                C[i][j] = min(C[i][j], C[i][k] + C[k][j])

    c = Counter(chain(*readlines(h)))

    for i in range(10):
        yield C[i][1] * c[i]


print(sum(main()))


main()

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

int main()
{
  int d, t, s;
  cin >> d >> t >> s;
  if ((double)d / s <= (double)t)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

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

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

    double ansrev = 0;
    for(int i=0;i<n;i++){
        double a;
        cin >> a;
        ansrev += 1.0/a;
    }
    
    printf("%.10f\n", 1.0/ansrev);
    return 0;
}

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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 10e10;
const ll MINF = -10e10;
//const int INF = INT_MAX;
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)

typedef priority_queue<P, vector<P>, greater<P> > PQ_ASK;
const int mod = 1000000007;
//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

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

    cout << (n >= 1000 ? "ABD" : "ABC") << endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
//	"sort"
//	"math"
//	"regexp"
)

var N, ans int
func main(){
	fmt.Scan(&N)
	lr := make([][]int,N)
	
	for i:=0;i<N;i++{
		lr[i] = make([]int,2)
		for j:=0;j<2;j++{
			fmt.Scan(&lr[i][j])
		}
	}
	
	for i:=0;i<N;i++{
		x:= lr[i][0]
		y:= lr[i][1]

		ans +=y-x+1
	}
	fmt.Println(ans)
}

Measured memory_bytes: 640
// Problem : I - Coins
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_i
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

//Macros

#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define inf 1e10
#define PI acos(-1.0)
#define int long long
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 3002

//Solution

int n;
db p[N],dp[N][N];

void solve(){
    cin>>n;
    for(int i=1;i<=n;i++) cin>>p[i];
    dp[0][0] = 1;
    for(int i=1;i<=n;i++){
        for(int j=0;j<=i;j++){
            if(j-1 >= 0) dp[i][j] += p[i]*dp[i-1][j-1];
            dp[i][j] += (1-p[i])*dp[i-1][j];
        }
    }
    db ans = 0;
    for(int i=(n+1)/2;i<=n;i++) ans += dp[n][i];
    cout<<fixed<<setprecision(12)<<ans;
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int tests;
    //cin>>tests;
    tests = 1;
    while(tests--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 85560
#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 INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
typedef long long ll;

int main(){
    string s;
    cin >> s;
    int a = 0;  int b = 0; int c = 0;

    int siz = s.length();

    REP(i, siz){
        if (s[i] == 'a') a++;
        else if (s[i] == 'b') b++;
        else c++;
    }

    if (abs(a-b)>= 2 || abs(b-c) >= 2 || abs(c-a) >= 2){
        cout << "NO" << endl;
    }
    else{
        cout << "YES" << endl;
    }


}


Measured memory_bytes: 3712
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            solve(in);
        }
    }

    private static void solve(Scanner in) {
        final int N = in.nextInt();
        final int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = in.nextInt();
        }

        int count = 0;
        for (int i = 0; i < A.length; i++) {
            for (int j = A.length - 1; j > i; j--) {
                if (A[j - 1] > A[j]) {
                    int temp = A[j];
                    A[j] = A[j - 1];
                    A[j - 1] = temp;
                    count++;
                }
            }
            // print(A);
            // System.out.println(count);
        }
        print(A);
        System.out.println(count);
    }

    private static void print(int[] A) {
        if (A.length == 0)
            return;
        for (int i = 0; i < A.length - 1; i++)
            System.out.print(A[i] + " ");
        System.out.println(A[A.length - 1]);
    }
}

Measured memory_bytes: 26160
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=205;
int ne[N],fi[N],ans1,ans2,zz[N],num,c[N],x[N],y[N],n;
void jb(int x,int y)
{
	ne[++num]=fi[x];
	fi[x]=num;
	zz[num]=y;
}
void dfs(int x,int y,int d)
{
	int s=0;
	for (int i=fi[x];i;i=ne[i])
	 if (zz[i]!=y)s++,dfs(zz[i],x,d+1);
	c[d]=max(c[d],s);
}
void upd()
{
	int u=0,v=1;
	while (c[u])v*=c[u++];
	if (u<ans1||u==ans1&&v<ans2)
	 {
	 	ans1=u;
	 	ans2=v;
	 }
}
signed main()
{
	scanf("%d",&n);
	for (int i=1;i<n;i++)
	 {
	 	scanf("%d%d",&x[i],&y[i]);
	 	jb(x[i],y[i]);jb(y[i],x[i]);
	 }
	ans1=n+1;
	for (int i=1;i<=n;i++)
	 {
		memset(c,0,sizeof c);
		c[0]=1;
		dfs(i,0,1);
		upd();
	 } 
	for (int i=1;i<n;i++)
	 {
	 	memset(c,0,sizeof c);
	 	c[0]=2;
	 	dfs(x[i],y[i],1);dfs(y[i],x[i],1);
	 	upd();
	 } 
	printf("%lld %lld",ans1,ans2); 
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>

using namespace std;

int main(){
  int n;
  cin >> n;
  int a[n];
  int odd = 0, mul4 = 0;
  for(int i = 0; i < n; i++){
    cin >> a[i];
    if(a[i] % 4 == 0) {
      mul4++;
    } else if (a[i] % 2 != 0) {
      odd++;
    }
  }

  if(odd -1 < mul4) {
    cout << "Yes" << endl;
  } else if ((odd -1 == mul4) && (odd + mul4 == n)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3980
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define SZ
int main()
{
	ll a,b,c,k;
	cin>>a>>b>>c>>k;
	if(k&1) cout<<b-a<<"\n";
	else cout<<a-b<<"\n";
}
//A,B,C
//S-A,S-B,S-C 

Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
	int A, B, C, D; cin >> A >> B >> C >> D;
	cout << min(A, B) + min(C, D) << endl;
	return 0;
}

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

int main(void){
  string S,T;
  int count=0;
  cin >> S;
  cin >> T;
  for(int i;i<S.length();i++){
    if(S[i]!=T[i]){
		count++;
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int ht[n];
    for (int i=0;i<n;i++)
    cin>>ht[i];
    int dp[n];
    for (int i=0;i<n;i++)
    {
        if(i==0) dp[i] = 0;
        else if (i==1) dp[i] = abs(ht[1]-ht[0]);
        else if (i==2) dp[i] = min(abs(ht[2]-ht[0]) , dp[1]+abs(ht[2]-ht[1]));
        else
        {
            dp[i] = min(dp[i-2]+abs(ht[i]-ht[i-2]) , dp[i-1]+abs(ht[i]-ht[i-1]));
        }
    }
    cout<<dp[n-1];
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    int a, b;
    cin >> a >> b;
    if(8 < a || 8 < b) {
        cout << ":(";
    }
    else {
        cout << "Yay!";
    }
    
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
//		System.setOut(new PrintStream(new File("result.txt")));
		
		int n = stdIn.nextInt();
		for(int i=0;i<n;i++){
			int y = stdIn.nextInt();
			int m = stdIn.nextInt();
			int d = stdIn.nextInt();
			
			int toku = (y-1)/3;
			int kihon = y-1-toku;
			int day = toku*200;
			day += kihon*195;
			
			if(y%3==0){
				day += (m-1)*20;
			}
			else{
				int t_sho = (m-1)/2;
				int t_dai = m-1-t_sho;
				day += t_sho*19;
				day += t_dai*20;
			}
			day += d-1;
			day = 196470-day;
			System.out.println(day);
		}
	}
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int a, p;
  cin >> a >> p;
  p += a * 3;
  cout << p / 2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdlib> // abs(x-y)
#include <iomanip> // 出力の桁数指定
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)

using namespace std;

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<char>> c(h, vector<char>(w));
  
  rep (i, 0, h) {
    rep (j, 0, w)
      cin >> c.at(i).at(j);
    rep (j, 0, w)
      cout << c.at(i).at(j);
    cout << endl;
    rep (j, 0, w)
      cout << c.at(i).at(j);
    cout << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int h,n,a;
  cin>>h>>n;
  for(int i = 0; i < n; i++) {
    cin>>a;
    h-=a;
    if(h<=0){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
 
using namespace std;
typedef unsigned long long int ll;
ll X;

int main()
{
  ll i;
  long double t=100;
  long double li;
  long double lX;

  cin >> X;

  for (i=1; ; i++) {
    t = floor(t*101/100);
    if (t>=X) break;
  }
  printf("%lld\n", i);

  return 0;
}


Measured memory_bytes: 3764
#include "bits/stdc++.h"
using namespace std;
//#define int long long
#define repo(i, begin, end) for(__typeof(end)i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define ll long long
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<"  ";
#define fastr ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define rep(i,a,b) for(ll i = a; i < b; i++)
#define rrep(i,a,b) for(int i = (a-1); i >= b; i--) 
#define fi first
#define se second
#define tit(v,i,c) get<c>(v[i])
#define mt make_tuple 
#define pb push_back
#define eb emplace_back
#define mp make_pair
double jk=0.004;
#define power(x,y) pow(x,y)+jk
#define endl "\n"
const long long mod=1e9+7;
const long long N=1000000000;
const ll val=1000005;
int in(){
int n;cin>>n;
return n;}
bool visited[val];
void _do_(){
	memset(visited,false,sizeof(visited));
	ll n,k;
	cin>>n>>k;
	ll a[n+1];
	rep(i,1,n+1)cin>>a[i];
	ll i=1;
	vector<ll> v,s;
	s.pb(0);
 
	while(visited[i]==false&&k>0)
	{
		visited[i]=true;
		v.pb(i);
		k--;
		i=a[i];
	}
	if(!k)cout<<i<<endl;
	else {
	memset(visited,false,sizeof(visited));
		//visited[i]=true;
	while(!visited[i])
	{
		visited[i]=true;
		s.pb(i);
		i=a[i];
	}
	ll z=k+1;
	ll t=s.size()-1;
	z=z%t;
	if(z==0)z=t;
	//if(z==0)z=t;
	//dbg(z);
	cout<<s[z]<<endl;
	}
 
 
 
 
}
signed main(){
fastr
//int tc=in();
int tc=1;
while(tc--)_do_();
cerr<<"Time elapsed:";
cerr<<1000*clock()/CLOCKS_PER_SEC<<" ms ";
return 0;}

Measured memory_bytes: 8716
#include<cstdio>

int d[3][1002][1002], N, M, K;

int main()
{
        char buf[1024];

        scanf("%d%d%d", &N, &M, &K);

        for (int i = 1; i <= N; i++) {
                scanf("%s", buf + 1);
                for (int j = 1; j <= M; j++)  {
                        for (int k = 0; k < 3; k++) {
                                d[k][i][j] = d[k][i][j-1] + d[k][i-1][j] - d[k][i-1][j-1];
                        }
                        switch (buf[j]) {
                                case 'J': d[0][i][j]++;break;
                                case 'O': d[1][i][j]++;break;
                                case 'I': d[2][i][j]++;
                        }
                }
        }

        while (K--) {
                int x1, y1, x2, y2;
                scanf("%d%d%d%d", &y1, &x1, &y2, &x2);
                for (int i = 0; i < 3; i++) {
                        i?putchar(' '):0;printf("%d", d[i][y2][x2] - d[i][y1-1][x2] - d[i][y2][x1-1] + d[i][y1-1][x1-1]);
                }
                puts("");
        }

        return 0;
}

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

int main()
{
    
    
    int n,w;
    cin>>n>>w;
    
    int a[n],v[n];
    
    for(int i=0;i<n;i++)cin>>a[i]>>v[i];
    
    long int dp[n][w+1];
    
    for(int i=0;i<n;i++)dp[i][0]=0;
    
    for(int i=0;i<=w;i++)
    {if(i>=a[0])dp[0][i]=v[0];else dp[0][i]=0;}
    
     //for(int i=0;i<=w;i++)
     //cout<<dp[0][i]<<" ";cout<<endl;
    
    for(int i=1;i<n;i++)
    {
        for(int j=1;j<=w;j++)
        {
            if(j>=a[i])dp[i][j]=max((v[i]+dp[i-1][j-a[i]]),dp[i-1][j]);
            else dp[i][j]=dp[i-1][j];
        }
    }
    
    cout<<dp[n-1][w];
    return 0;
}


Measured memory_bytes: 78336
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int n;
    while(cin>>n,n){
        int a[100];
        for(int i=0;i<n;i++)cin>>a[i];
        int cnt=0;
        for(int i=n-1;i>0;i--)
            for(int j=0;j<i;j++)
                if(a[j]>a[j+1]){
                    swap(a[j],a[j+1]);
                    cnt++;
                }

        cout<<cnt<<endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <cstdio>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <sstream>
#include <cctype>
using namespace std;

#define PQ priority_queue
#define P pair<int,int>
#define CLA(array) memset(array,0,sizeof array)
#define CLINF(array) memset(array,0x3f,sizeof array)
#define CLF(array) memset(array,-1,sizeof array)
#define DB(a) cout << "DEBUG " << a << endl;
typedef long long LL;
typedef unsigned long long ULL;
const int MAXN = 100000 + 50;
const int INF = 1 << 30;
int h, w;
int mp[105][105];
int n;
int a[MAXN];

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

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

	for(int i = 0; i < w; i++){
		int j = i&1 ? h-1 : 0;
		if(i&1){
			while(j >= 0){
				if(a[tot]) {
					mp[j][i] = tot+1;
					a[tot] --;
				}
				else{
					++tot;
					mp[j][i] = tot+1;
					a[tot]--;
				}
				j--;
			}
		}
		else{
			while(j < h){
				if(a[tot]) {
					mp[j][i] = tot+1;
					a[tot] --;
				}
				else{
					++tot;
					mp[j][i] = tot+1;
					a[tot]--;
				}
				j++;
			}
		}		
	}
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			printf("%d ", mp[i][j]);
			if(j == w-1) printf("\n");
			else printf(" ");
		}
	}
    return 0;
}


Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <iostream> 
#include <string>
#include <map>
#include <math.h>
using namespace std; 
int main(){
	double  N, A, B, C ,D;
	cin >> N >> A >> B >> C >> D;
	double X = ceil(N/A);
	double Y = ceil(N/C);
	if(X*B <= Y*D){
		cout << X*B << endl;
	}
	else{
		cout << Y*D << endl;
	}
	return 0;
}


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

using namespace std;

#define MAX_V 1145
typedef pair<int, int> pii;
typedef long long ll;
const ll MOD = ((1e9) + 7);

int N, cmp[MAX_V];
bool used[MAX_V];
vector<int> G[MAX_V], rG[MAX_V], vs;

void add_edge(int from, int to)
{
    G[from].push_back(to);
    rG[to].push_back(from);
}

void dfs(int v)
{
    used[v] = 1;
    for (int i = 0; i < (int)G[v].size(); i++) {
	if (!used[G[v][i]]) {
            dfs(G[v][i]);
        }
    }
    vs.push_back(v);
}

void rdfs(int v, int k)
{
    used[v] = 1;
    cmp[v] = k;
    for (int i = 0; i < (int)rG[v].size(); i++) {
	if (!used[rG[v][i]]) {
            rdfs(rG[v][i], k);
        }
    }
}

int scc()
{
    memset(used, 0, sizeof(used));
    vs.clear();
    for (int v = 0; v < N; v++) {
	if (!used[v]) {
            dfs(v);
        }
    }
    memset(used, 0, sizeof(used));
    int k = 0;
    for (int i = vs.size() - 1; i >= 0; i--) {
	if (!used[vs[i]]) {
            rdfs(vs[i], k++);
        }
    }
    return k;
}

vector<int> nG[MAX_V];

ll solve(int v)
{
    ll res = 1;
    for (int i = 0; i < (int)nG[v].size(); i++) {
        res *= solve(nG[v][i]);
        res %= MOD;
    }
    res += 1;
    return res % MOD;
}

int main()
{
    int M, a, b;
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        cin >> a >> b; a--; b--;
        add_edge(a, b);
    }
    
    auto K = scc();
    
    set<pii> st;
    int deg[MAX_V] = {};
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < (int)G[i].size(); j++) {
            int from = cmp[i], to = cmp[G[i][j]];
            if (from != to && st.count(pii(from, to)) == 0) {
                st.insert(pii(from, to));
                nG[to].push_back(from);
                deg[from]++;
            }
        }
    }
    
    ll res = 1;    
    for (int i = 0; i < K; i++) {
        if (deg[i] == 0) {
            res *= solve(i);
            res %= MOD;
        }
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3352
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
// lazy version

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

///
/// # Examples
///
/// # integers
/// input! { n: usize, m: usize, ... }
///
/// # array
/// input! { n: usize, v: [i32; n], }
///
/// # matrix
/// input! { n: usize, m: usize, mat: [[]] }
///
/// # string
/// input! { s: chars }

// https://practice.contest.atcoder.jp/tasks/practice_1
fn main() {
    input!{
        a: usize, b: usize
    }
    if a*b % 2 == 0 {
        println!("No");
    } else {
        println!("Yes");
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define rFORe(i, a, n) for(int (i) = (int)(n); (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 1, (n))
#define REPo(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rREPe(i, n) rFORe((i), 1, (n))
#define rREPo(i, n) rFORe((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fi first
#define se second
#define dup(x, y) (((x)+(y)-1)/(y))
#define vc(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using P = pair<int,int>;
using pll = pair<ll,ll>;
using T = tuple<int,int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using vp = vector<P>;
using vt = vector<T>;

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;
  cin>>n;
  vi ans(10005);
  FORe(x, 1, 100) {
    int xx = x*x;
    FORe(y, 1, 100) {
      int xy = x*y;
      int yy = y*y;
      FORe(z, 1, 100) {
        int yz = y*z;
        int zx = z*x;
        int zz = z*z;
        int now = xx+yy+zz+xy+yz+zx;
        if(now > n) continue;
        ans[now]++;
      }
    }
  }
  FORe(i, 1, n) cout << ans[i] << endl;

  return 0;
}

Measured memory_bytes: 3668
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N, M;
    cin >> N >> M;
    FOR(i, N, M / 2 + 1) {
        if (M % i == 0) {
            cout << M / i << endl;
            return 0;
        }
    }
    cout << 1 << endl;
    return 0;
}

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

using namespace std;


#define INF (1<<29)

// math
#define Sq(x) ((x)*(x))

// container utility
#define ALL(x) (x).begin(), (x).end()
#define MP make_pair
#define PB push_back
#define EACH(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)

// rep
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define rep(i,n) REP(i,0,n)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

// typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef vector<VI> VVI;

typedef long long ll;

// conversion
template<class T> inline string toStr(T a) { ostringstream oss; oss << a; return oss.str(); }
inline int toInt(string s) { return atoi(s.c_str()); }

// prime
bool isPrime(int a) { for(int i=2; i*i <=a; i++) if(a%i == 0) return false; return true; }
/////////////////////////

struct Cake
{
  int w, d;
  Cake() {}
  Cake(int w, int d) : w(w), d(d) {}
  
  bool operator < (const Cake& c) const {
    return w * d < c.w * c.d;
  }
};

void CDump(vector<Cake> &cont) {
  cout << "-------------------" << endl;
  cout << "| dump container: |" << endl;
  EACH(it, cont) {
    cout << "| " << it->w << " " << it->d << "             |" << endl;
  }
  cout << "-------------------" << endl;
}

int main() {
  
  int N, W, D;
  while(cin >> N >> W >> D && (N|W|D)) {
    
    vector<Cake> cakes;
    cakes.PB( Cake(W,D) );

    int p, s;
    for(int i=0; i<N; i++) {
      cin >> p >> s; p--;
      
      Cake cp = cakes[p]; cakes.erase(cakes.begin()+p);
      
      s %= (cp.w*2 + cp.d*2);
      int angle = -1;
      int temp = -s;
      
      rep(i, 2) {
	angle++; temp += cp.w;
	if(temp > 0) goto SKIP;
	angle++; temp += cp.d;
	if(temp > 0) goto SKIP;
      }
      
    SKIP:;
      switch(angle) {
      case 0: case 2:
	{
	  int a = temp, b = cp.w-temp;
	  if(b < a) { swap(a, b); }
	  cakes.PB( Cake(a, cp.d) );
	  cakes.PB( Cake(b, cp.d) );
	}
	break;
	
      case 1: case 3:
	{
	  int a = temp, b = cp.d-temp;
	  if(b < a) { swap(a, b); }
	  cakes.PB( Cake(cp.w, a) );
	  cakes.PB( Cake(cp.w, b) );
	}
	break;
      }
    }
    
    sort(ALL(cakes));
    for(int i=0; i<cakes.size(); i++) {
      if(i) cout << " ";
      cout << cakes[i].w * cakes[i].d;
    }
    cout << endl;
  }
  
  return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    int n;
    cin >> n;
    ll mod = 1e9 + 7;
    ll ans = 1;
    string s1, s2;
    cin >> s1 >> s2;

    int i = 0;
    bool flag = 0;

    if (s1[0] == s2[0])
    {
        ans = 3;
        i++;
        flag = 0;
    }
    else
    {
        ans = 6;
        i += 2;
        flag = 1;
    }

    while (i < n)
    {
        if (flag)
        {
            if (s1[i] == s2[i])
            {
                i++;
                flag = 0;
            }
            else
            {
                i += 2;
                ans = (ans * 3) % mod;
            }
        }
        else
        {
            if (s1[i] == s2[i])
                i++;
            else
            {
                i += 2;
                flag = 1;
            }
            ans = (ans * 2) % mod;
        }
    }
    OP(ans % mod);
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int maxW = sc.nextInt();
		
		int[] w = new int[n + 1];
		int[] v = new int[n + 1];
		int sumV = 0;
		for (int i = 1; i <= n; i++) {
			w[i] = sc.nextInt();
			v[i] = sc.nextInt();
			sumV += v[i];
		}
		
		long[][] dp = new long[n + 1][sumV + 1];
		for (int i = 0; i <= n; i++)
			for (int j = 1; j <= sumV; j++)
				dp[i][j] = Integer.MAX_VALUE;

		
		for (int i = 1; i <= n; i++) {
			for (int j = 0; j <= sumV; j++) {
				dp[i][j] = dp[i - 1][j];
				if (j - v[i] >= 0)
					dp[i][j] = Math.min(dp[i][j], dp[i - 1][j - v[i]] + w[i]);
			}
		}
		
		long ans = 0;
		for (int i = sumV; i >= 0; i--) {
			if (dp[n][i] <= maxW) {
				ans = i;
				break;
			}
		}
		
		System.out.println(ans);
		
		sc.close();
	}
}



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

int main(){
  int n,a;cin>>n;
  deque<int>b;
  rep(i,n){
    cin>>a;
    if(i%2==0)b.push_back(a);
    else b.push_front(a);    
  }
  if(n%2==0)rep(i,n)cout<<b.front()<<" ",b.pop_front();
  else rep(i,n)cout<<b.back()<<" ",b.pop_back();
}

Measured memory_bytes: 2944
#include<stdio.h>
int main(void)
{
  int a,b,i,max;
  scanf("%d%d",&a,&b);
  int c[3]={a+b,a-b,a*b};
  max=c[0];
  for(i=1;i<3;i++){
    if(max<c[i]){
      max=c[i];
    }
  }
  printf("%d",max);
  return 0;
}
    

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ls( s) (s&(-s))
#define ll long long
#define inf 0x3f3f3f3f
const ll N = 200030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =    1e9+7;

int main()
{
	ll h;
	cin>>h;
	ll cnt=1;
	ll ans=0;
	while(h)
	{
		
		ans+=cnt;
		cnt*=2;
		h/=2;
	}



cout<<ans;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
	public static void main(String[] args){
		FastScanner sc = new FastScanner(System.in);
		String s = sc.next();
		String out = "Yes";
		for (int i = 0; i < s.length(); i++) {
			char c = s.charAt(i);
			String rstr = s.replaceAll(String.valueOf(c), "");
			if (rstr.length() != 2) {
				out = "No";
				break;
			}
		}
		System.out.println(out);

	}

}

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: 21204
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PipedInputStream;
import java.util.*;

public class Main {
    private static final int MOD = (int) Math.pow(10, 9);
    private static final int[][] DIRS = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};

    public static void main(String[] args) {
        FastReader sc = new FastReader();
        char[] a = sc.next().toCharArray();
        char[] b = sc.next().toCharArray();

        if (a[0] == b[2] && a[1] == b[1] && a[2] == b[0]) {
            print("YES");
        } else {
            print("NO");
        }

        // print("" + ( b * 2 - a));
        System.exit(0);
    }

    static  private void print(String s) {
        System.out.println(s);
    }

    static private int log2(int x) {
        return (int)(Math.log(x) / Math.log(2));
    }

    static private long gcd(long m, long n) {
        if (m < n) { return gcd(n, m); }
        if (m % n == 0) { return n; }
        return gcd(n, m%n);
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String str = "";
            try{
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 22856
import collections
N=int(input())
Slst=["".join(sorted(list(input()))) for i in range(N)]
dic={}
namelst=set()

for S in Slst:
    if S in namelst:
        dic[S]+=1
    else:
        namelst.add(S)
        dic.update({S:1})
#print(dic)

print(sum([dic[i]*(dic[i]-1)//2 for i in dic if dic[i]>=2]))


Measured memory_bytes: 23900
#include <iostream>
#include <string>
using namespace std;
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define rep(i,n) FOR(i,0,n)
 

int main(){
	
	int n,k;cin>>n>>k;
	int ans = 0;
	rep(i,n)
	{
		int x;cin>>x;
		ans += min(x,k-x)*2;
	}
	cout << ans << endl;
}

//cout << ans << endl;

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(int i=0;i<(n);i++)
#define REPm(i,n) for(int i=(n)-1;i>=0;i--)
#define REP1(i,n) for(int i=1;i<=(n);i++)
typedef long long ll;
int main(){
    bool flag[26] = {};
    string S;
    cin >> S;
    REP(i,S.length()){
        if(flag[(int)S[i]-97]){
            cout << "no" << endl;
            return 0;
        }
        flag[(int)S[i]-97] = true;
    }
    cout << "yes" << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {

//    	File file = new File("test.txt");
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);
    	int H = sc.nextInt();
    	int W = sc.nextInt();
    	int h = sc.nextInt();
    	int w = sc.nextInt();
    	sc.close();
    	System.out.println((H * W) - (h * W +(H - h) * w));
    }
}

Measured memory_bytes: 23124
import sys
N = int(sys.stdin.readline().rstrip())
A = list(map(int, sys.stdin.readline().rstrip().split()))
S= 0
for n in range(N):
  S = S^A[n]
  
ans = ''
for n in range(N):
  m = S^A[n]
  ans += str(m) + ' '

print(ans[:-1])

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

int main(){
  int64_t X,yokin;
  cin >> X;
   yokin=100;
  int i =0;
  while(1){
    if(yokin>=X)
      break;
	i++;
    yokin+=(int64_t)(yokin*0.01);
  }
  cout << i<<endl;
}

Measured memory_bytes: 3632
//Chebyshev's Theorem
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

vector<int> prime;
int pn[123456*2+1];

int main(){
  prime.push_back(2);
  pn[2]=1;
  for(ll i=3; i<123456*2+1; i++){
    bool flag=true;
    for(ll j=0; j<prime.size() && i>=prime[j]*prime[j]; j++){
      if(i%prime[j]==0){flag=false; break;}
    }
    if(flag){prime.push_back(i); pn[i]=pn[i-1]+1;}
    else{pn[i]=pn[i-1];}
  }
  ll n;
  while(true){
    cin>>n;
    if(n==0)break;
    cout<<pn[n*2]-pn[n]<<endl;
  }
  return 0;
}

Measured memory_bytes: 2328
import heapq

def energy_drink_collector(M, heap):
    left = M
    ret = 0

    while left:
        ele = heapq.heappop(heap)
        deduct = min(left, ele[1])
        ret += ele[0] * deduct
        left -= deduct

    return ret


if __name__ == "__main__":
    N, M = map(int, input().split())

    heap = []
    for _ in range(N):
        a, b = map(int, input().split())
        heapq.heappush(heap, (a, b))

    result = energy_drink_collector(M, heap)
    print(result)


Measured memory_bytes: 62552
#include <iostream>

using namespace std;

int main()
{
    int counter[26];
    
    for(int i = 0; i < 26; ++i)
    { counter[i] = 0; }
    
    char ch;
    
    while(cin >> ch)
    {
        ch = tolower(ch);
        
        int a = ch - 'a';
        ++counter[a];
    }
    
    for(int i = 0; i < 26; ++i)
    { cout << (char) ('a' + i) << " : " << counter[i] << endl; }
    
    return 0;
}


Measured memory_bytes: 3084
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class C
{
	public static void Main() => (new Solver()).Solve();
}


public class Solver
{
	public void Solve()
	{
		long N = GetLong();
		long M = GetLong();
		int[] A = new int[M];
		int[] B = new int[M];
		for(int i = 0; i < M; i++)
		{
			A[i] = GetInt() - 1;
			B[i] = GetInt() - 1;
		}

		int[] color = new int[N];
		var adj = Enumerable.Range(0, (int)N).Select(_ => new List<int>()).ToArray();
		for(int i = 0; i < M; i++)
		{
			adj[A[i]].Add(B[i]);
			adj[B[i]].Add(A[i]);
		}

		if(isBipartite(0, 1, color, adj))
		{
			long p = (long)color.Count(x => (x == 1));
			long q = N - p;
			WriteLine(p * q - M);
		}
		else
		{
			WriteLine((N * (N - 1)) / 2 - M);
		}
	}

	private bool isBipartite(int v, int c, int[] color, List<int>[] adj)
	{
		color[v] = c;
		foreach(int u in adj[v])
		{
			if(color[u] == c)
				return false;

			if(color[u] == 0 && !isBipartite(u, -c, color, adj))
				return false;
		}
		return true;
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(int N) => Enumerable.Range(0, N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(int N) => Enumerable.Range(0, N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(int N) => Enumerable.Range(0, N).Select(_ => GetDouble()).ToArray();
	public static string[] GetStrings(int N) => Enumerable.Range(0, N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}

Measured memory_bytes: 29492
#include <iostream>
#include <bits/stdc++.h>
#include <time.h>
#include <sys/timeb.h>
#include <cstdio>
#include <sys/time.h>

using namespace std;
#define ll long long
#define uint unsigned int
#define ulong unsigned long long int

int main(){
	
	int A,B,C;
	cin >> A >> B >> C;
	
	cout << (A + B >= C ? "Yes" : "No") << endl;
	
    return 0;
}

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

int parent(int i){return i/2;}
int left(int i){return 2*i;}
int right(int i){return 2*i+1;}
int main()
{
  int H,i,A[MAX+1];
  cin >> H;
  for(i=1;i<=H;i++)
  {
    cin >> A[i];
  }
  for(i=1;i<=H;i++)
  {
    cout << "node " << i << ": key = " << A[i] << ", ";
    if(parent(i) >= 1) cout << "parent key = " << A[parent(i)] << ", ";
    if(left(i) <= H) cout << "left key = " << A[left(i)] << ", ";
    if(right(i) <= H) cout << "right key = " << A[right(i)] << ", ";
    cout << endl;
  }
  return 0;
}



Measured memory_bytes: 3096
import math

A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

ceil = lambda number: math.ceil(number / 10) * 10
ceiled_A = ceil(A)
ceiled_B = ceil(B)
ceiled_C = ceil(C)
ceiled_D = ceil(D)
ceiled_E = ceil(E)

maximum_diff = 0
for minitues in [A, B, C, D, E]:
    ceiled = ceil(minitues)
    diff = ceiled - minitues
    if diff == 0: continue

    if maximum_diff is None or diff > maximum_diff:
        maximum_diff = diff

answer = ceiled_A + ceiled_B + ceiled_C + ceiled_D + ceiled_E - maximum_diff
    
print(answer)


Measured memory_bytes: 3064
n = int(input())
a = [int(i) for i in input().split()]
sum1 = 0
sum2 = 0
a.sort(reverse=True)
for i in range(n):
	if i % 2 == 0:
		sum1 += a[i]
	else:
		sum2 += a[i]
print(sum1 - sum2)

Measured memory_bytes: 3060
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
int x[200000];
int y[200000];
int dp[200000][2];
int main()
{
	int num;
	scanf("%d", &num);
	for (int i = 0; i < num; i++)
	{
		int z;
		scanf("%d", &z);
		for (int j = 0; j < 30; j++)if (z&(1 << j))x[i + 1] = j;
		if ((1 << x[i + 1]) == z)y[i + 1] = 1;
		else x[i + 1]++;
	}
	int cnt = 0;
	dp[0][0] = 1000000000, dp[0][1] = 0;
	for (int i = 1; i <= num; i++)
	{
		if (y[i] == 0)
		{
			dp[i][0] = min(dp[i - 1][0] + max(0, x[i] - x[i - 1] + 1), dp[i - 1][1] + max(0, x[i] - x[i - 1]));
			dp[i][1] = min(dp[i - 1][0] + max(0, x[i] - x[i - 1]), dp[i - 1][1] + max(0, x[i] - x[i - 1] - 1)) + 1;
		}
		else
		{
			dp[i][0] = 1000000000;
			dp[i][1] = min(dp[i - 1][0] + max(0, x[i] - x[i - 1] + 1), dp[i - 1][1] + max(0, x[i] - x[i - 1]));
		}
		//printf("%d %d\n", dp[i][0], dp[i][1]);
	}
	printf("%d\n", min(dp[num][0], dp[num][1]));
}

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

bool custom(pair<int, int> a, pair<int, int> b){
  return a.second > b.second;
}
int main(){
  int n, m;
  cin >> n >> m;
  vector<int> card(n);
  for(int i = 0; i < n; ++i) cin >> card[i];
  sort(card.begin(), card.end());
  vector<pair<int, int>> xy(m);
  for(int i = 0; i < m; ++i) cin >> xy[i].first >> xy[i].second;
  sort(xy.begin(), xy.end(), custom);
  int index = 0;
  int j;
  bool flag = true;
  for(int i = 0; i < m; ++i){
    for(j = index; j < index + xy[i].first && j < n; ++j){
      if(card[j] > xy[i].second){
       	continue;
      }
      card[j] = xy[i].second;
    }
    index = j;
  }
  long long sum = 0;
  for(auto a: card) sum += a;
  cout << sum << endl;
}


Measured memory_bytes: 1408
n,k = map(int,input().split())
s = input()
al = []

a0 = 1
    
for i in range(n-1):
    if s[i] != s[i+1]:
        al.append(a0)
        a0 = 1
    else:
        a0 += 1
        
al.append(a0)

if s[0] == "0":
    al = [0] + al
if s[-1] == "0":
    al = al + [0]
    
nn = len(al)
nagasa = min(2*k+1,nn)
r = (nn-nagasa) // 2

ans = sum(al[:nagasa])
cur = sum(al[:nagasa])
for i in range(1,r+1):
    cur = cur + (al[nagasa+i*2-1] + al[nagasa+i*2-2]) -(al[i*2-1] + al[i*2-2])
    ans = max(cur,ans)
    
print(ans)

Measured memory_bytes: 47984
N, K = map(int, input().split(" "))
A = list(map(int, input().split(" ")))
Abin = map(bin, A)
ans_length = max(len(bin(K)), len(bin(max(A)))) - 2
one_counter = [0 for i in range(ans_length)]
for abin in Abin:
    rabin = abin[::-1]
    for i, c in enumerate(rabin):
        if ans_length <= i:
            break
        if c == "1":
            one_counter[i] += 1
        elif c == "b":
            break
now = 0
border = N/2
ans = 0
#print(one_counter)
for i, n in enumerate(one_counter[::-1]):
#    print(n)
    temp = now
    point = 2**(ans_length - i - 1)
    if n >= border:
        ans += n*point
    else:
        temp += point
        if temp <= K:
            now = temp
            ans += (N-n)*point
        else:
            ans += n*point
#    print(now, point, ans)
print(ans)


Measured memory_bytes: 14984
//IncubatorMan
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
char gap = 32;
template<typename T> 
ostream& operator<<(ostream &os, const vector<T> &v) { 
    os << '{'; 
    for (const auto &x : v) os << gap << x;
        return os << '}'; 
}
template<typename A, typename B> 
ostream& operator<<(ostream &os, const pair<A, B> &p) {
        return os << '(' << p.first << gap << p.second << ')';
}

template <class T>
void read(T &x) {
    char c;
    for (c = getchar(); c < '0' || c > '9'; c = getchar())
        ;
    for (x = 0; c <= '9' && c >= '0'; c = getchar()) x = x * 10 + (c & 15);
}
#define ll long long 
#define lll __int128_t
#define pb push_back
#define mp make_pair
typedef pair < int,int> ii;
typedef vector<ii> vii;
typedef vector<ll>vl;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void solve(){
    ll n;
    read(n);
    ll ans =0;
    for(ll i=1;i<=n;i++){
        if(i%3==0 | i%5==0) continue;
        ans += i;
    }
    cout<<ans<<endl;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
        int test=1;
        //read(test);
        while(test--){
            solve();
        }
    return 0;
}

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

int main(){
    int i, m;
    long long n;
    cin >> n;
    for(i=1; i<=sqrt(n); i++){
        if(n%i == 0){
            m = i;
        }
    }
    cout << (int)log10(n/m)+1;
    return 0;
}

Measured memory_bytes: 512