akhauriyash/Code-Regression huggingface dataset:
import sys
from collections import deque
import bisect
import copy
import heapq
import itertools
import math
import random
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


N, K = read_values()
def main():
    A = read_list()
    # A = [random.randint(-10 ** 9, 10 ** 9) for _ in range(N)]

    A.sort(reverse=True)
    if N == K or (A[0] < 0 and K % 2 == 1):
        res = 1
        for a in A[:K]:
            res *= a
            res %= mod
        print(res)
        return

    A.sort(key=lambda a: abs(a), reverse=True)

    P1 = list(filter(lambda a: a >= 0, A[:K]))
    P2 = list(filter(lambda a: a >= 0, A[K:]))
    N1 = list(filter(lambda a: a < 0, A[:K]))
    N2 = list(filter(lambda a: a < 0, A[K:]))

    if len(N1) % 2 == 1:
        # if N1[-1] * N2[0] : P1[-1] * P2[0]
        if len(P1) == 0 or len(N2) == 0:
            N1[-1] = P2[0]
        elif len(P2) == 0:
            P1[-1] = N2[0]
        else:
            if P1[-1] * P2[0] >= N1[-1] * N2[0]:
                N1[-1] = P2[0]
            else:
                P1[-1] = N2[0]
    
    res = 1
    for p in P1:
        res *= p
        res %= mod

    for n in N1:
        res *= n
        res %= mod
    
    print(res % mod)
        

if __name__ == "__main__":
    main()


Measured memory_bytes: 125656
#include <bits/stdc++.h>
#define newl "\n"
using namespace std;
using lli = long long int;
using vvint = vector <vector <int>>;
const int mod = 1e9 + 7;

const int N = 2e5 + 1;

void solve(){
	int n;
	cin >> n;
	vector <int> a(n);
	map <int,int> mp;
	lli summ = 0;
	for(int i = 0;i < n;++i) cin >> a[i], summ = summ + a[i], ++mp[a[i]];
	int q;
	cin >> q;
	while(q--){
		int b,c;
		cin >> b >> c;
		auto itr = mp.find(b);
		if(itr != mp.end()){
			lli count = itr->second;
			summ = summ - count * b + count * c;
			mp.erase(itr);
			mp[c] += count;
		}
		cout << summ << newl;
	}

	return;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(10);
	#ifdef EXECUTE_LOCALLY
		   freopen("in.txt","r",stdin);
	#endif
	int t = 1;
	//cin >> t;
	while(t--) solve();
	#ifdef EXECUTE_LOCALLY
    	cout << setprecision(3) << "program time: " << (double)clock() / CLOCKS_PER_SEC << newl;
	#endif
	return 0;
}


Measured memory_bytes: 6600
#include<stdio.h>
int main()
{
	int tate, yoko, i, j;//変数宣言
	while (1)//くり返す
	{
		scanf("%d%d", &tate, &yoko);
		if (tate == 0 && yoko == 0)//0 0のとき終了
		{
			break;
		}
		//作画ポイント
		for (i = 1; i <= tate; i++)
		{
			for (j = 1; j <= yoko; j++)
			{
				if ((i > 1) && (i < tate) && (j < yoko) && (j > 1))//中心部分は"."で表示
				{
					printf(".");
				}
				else//端っこは"#"で表示
				{
					printf("#");
				}
			}
			printf("\n");
		}
		printf("\n");

	}
	return 0;
}



Measured memory_bytes: 2040
/* author   : mpily :-()
title : Competing.cpp
time :Mon Aug 26 11:06:10 2019

*/
#include<bits/stdc++.h>
using namespace std;
struct node{
	int parent;
	vector<int>connectedTo;
	int counter;
};
void setParent(int n, vector<node>& tree){
	tree[n].counter  = 0;
	for(auto & a : tree[n].connectedTo){
		if(a == tree[n].parent)continue;
		tree[a].parent = n;
		setParent(a,tree);
	}
}
void updateCounter(int n, vector<node>& tree, int xj){
	tree[n].counter+=xj;
	 
}
void finalise(vector<node>&tree, int toadd, int n){
	tree[n].counter+=toadd;
	for(auto & a : tree[n].connectedTo){
		if(a == tree[n].parent)continue;
		else{
			finalise(tree,tree[n].counter,a);
		}
	}
}
int main(){
	int N,Q;
	cin>>N>>Q;
	vector<node>tree(N);
	for(int i = 0; i < N-1; i++){
		int a , b;
		cin>>a>>b;
		tree[a-1].connectedTo.push_back(b-1);
		tree[b-1].connectedTo.push_back(a-1);
	}
	setParent(0,tree);
	for(int i = 0; i < Q; i++){
		int p,x;
		cin>>p>>x;
		updateCounter(p-1,tree,x);
	}
	finalise(tree,0,0);
	for(auto & a: tree)cout<<a.counter<<" ";
	cout<<"\n";
	return 0;
}


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

int main() {
    int N;
    cin >> N;
    set<string> S;
    string l;
    for ( int i = 0; i < N; i++){
        cin >> l;
        S.insert(l);
    }
    cout << S.size() << endl;
}

Measured memory_bytes: 19172
#include<bits/stdc++.h>
#define ll long long
#define int long long
using namespace std;
const int N=200005;
ll ny[N],jc[N],n,m,A,B,c[N],w[N],cnt[N],sum[N],jj[N];
ll zuixiao,cixiao,ans=1;
const ll mo=1e9+7;
ll ksm(ll x,ll p){
	ll res=1;
	while(p){
		if(p&1) res=(res*x)%mo;
		x=(x*x)%mo;
		p>>=1;
	}
	return res;
}

inline ll C(int x,int y){
	return jc[x]*ny[y]%mo*ny[x-y]%mo;
}

signed main(){
// 	freopen("keep.in","r",stdin);
// 	freopen("keep.out","w",stdout);
	scanf("%lld%lld%lld",&n,&A,&B);
	jc[0]=1;
	for(int i=1;i<=N-5;i++)
		jc[i]=(jc[i-1]*i)%mo,jj[i]=1e17;
	for(int i=1;i<=N-5;i++)	
		ny[i]=ksm(jc[i],mo-2);
	for(int i=1;i<=n;i++)
		scanf("%lld%lld",&c[i],&w[i]),cnt[c[i]]++,jj[c[i]]=min(jj[c[i]],w[i]);
//	zuixiao=1;
//	for(int i=2;i<=n;i++)
//		if(w[i]<w[zuixiao]) zuixiao=i;
//	cixiao=0;w[0]=0x7ffffffffffff;
//	for(int i=1;i<=n;i++)	
//		if(c[i]!=c[zuixiao]&&w[i]<w[cixiao]) cixiao=i;
//	for(int i=1;i<=n;i++){
//		if(c[i]==c[zuixiao]&&i!=zuixiao&&w[i]+w[zuixiao]<=A) continue;
//		if(i==zuixiao&&w[i]+w[cixiao]<=B) continue;
//		if(c[i]!=c[zuixiao]&&w[i]+w[zuixiao]<=A) continue;
//		
//		
//	}
	ll zuixiao=1,cixiao=1e17;
	for(int i=1;i<=n;i++)
		if(jj[i]!=1e17)
			if(jj[i]<jj[zuixiao])
				zuixiao=i;
	
	for(int i=1;i<=n;i++)
		if(jj[i]!=1e17&&i!=zuixiao)		
			cixiao=min(cixiao,jj[i]);
	for(int i=1;i<=n;i++){
		if(w[i]!=jj[c[i]]&&w[i]+jj[c[i]]<=A) continue;
		if(c[i]!=zuixiao&&w[i]+jj[zuixiao]<=B) continue;
		if(c[i]==zuixiao&&w[i]+cixiao<=B) continue;
		cnt[c[i]]--;
	}
	int sum=cnt[zuixiao];
	for(int i=1;i<=n;i++){
		if(i!=zuixiao&&jj[i]+jj[zuixiao]<=B){
			sum+=cnt[i];
			ans=ans*C(sum,cnt[i])%mo;
		}
	}
	printf("%lld",ans);	
	return 0;	
}

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

int n;
int h[110000];

int main() {
	cin >> n;
	rep(i, n) cin >> h[i];
	bool ans = true;
	if (n > 1) {
		for (int i = n - 2; i >= 0; i--) {
			if (h[i] - h[i + 1] > 1) {
				ans = false;
				break;
			}
			else if (h[i] - h[i + 1] == 1) {
				h[i]--;
			}
		}
	}
	cout << (ans ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 640
package main

import (
	"fmt"
)

// CanTakeCakes 円状に並んだ16個のケーキを隣合わないように取れるかどうか
func CanTakeCakes(A int, B int) bool {
	// (A, B) = (1, 1), (1, 2),..., (1, 15)
	const N = 16
	if A > B {
		B, A = A, B
	}
	// A <= B として良い
	if B > int(N/2) {
		return false
	}
	var N2 = N - 2*A
	var B2 = B - A

	// N2個のケーキからB2個を取り分けられるか(橋はB)
	if 2*B2 <= N2 {
		return true
	} else {
		return false
	}
}

func main() {
	var A int
	var B int
	var canTake bool

	fmt.Scan(&A)
	fmt.Scan(&B)
	canTake = CanTakeCakes(A, B)
	// fmt.Printf("A = %d B = %d C = %t", A, B, canTake)
	if canTake {
		fmt.Println("Yay!")
	} else {
		fmt.Println(":(")
	}
}


Measured memory_bytes: 512
#include <cstdio>
#include <cmath>
using namespace std;

int main() {
    int a, b, c, d;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    bool ok = abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d);
    printf("%s\n", ok ? "Yes" : "No");
}

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

using namespace std;

#ifndef ONLINE_JUDGE
	#define W(x, y) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << y;
#else
	#define W(x, y)
#endif

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<pii>;
using vl = vector<ll>;
using vll = vector<pll>;
using ld = long double;
#define ff first
#define ss second
const ld pi = acosl(-1);
const ll prime = 1000000000 + 7;
const ll INF = 1000000000;

struct UnionFind{
    vl pai;
    vl rank;
    vl sum;
    UnionFind(ll n): pai(n), rank(n), sum(n){
        iota(pai.begin(), pai.end(), 0);
        fill(rank.begin(), rank.end(), 1);
        fill(sum.begin(), sum.end(), 1);
    }
    ll Find(ll x){
        if(x == pai[x]){
            return x;
        }
        return pai[x] = Find(pai[x]);
    }
    void Union(ll a, ll b){
        a = Find(a);
        b = Find(b);
        if(a == b){
            return;
        }
        if(rank[a] == rank[b]){
            rank[a]++;
        }
        if(rank[a] < rank[b]){
            sum[b] += sum[a];
            pai[a] = b;
        } else{
            sum[a] += sum[b];
            pai[b] = a;
        }
    }
};

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

    ll n, q;
    while(cin >> n >> q){
        vector<tuple<ll, ll, ll>> vet(n);
        map<ll, ll> conj;
        vl res(q, -1);
        for(int i = 0; i < n; ++i){
            ll s, t, x;
            cin >> s >> t >> x;
            vet[i] = make_tuple(x, s, t);
        }
        sort(vet.begin(), vet.end(), [](tuple<ll, ll, ll>a, tuple<ll, ll, ll>b){
            ll as, at, ax;
            tie(ax, as, at) = a;
            ll bs, bt, bx;
            tie(bx, bs, bt) = b;
            if(ax == bx){
                return as < bs;
            }
            return ax < bx;
        });
        for(int i = 0; i < q; ++i){
            ll d;
            cin >> d;
            conj[d] = i;
        }
        vector<ll> aux;
        for(int i = 0; i < n; ++i){
            ll s, t, x;
            tie(x, s, t) = vet[i];
            auto it1 = conj.lower_bound(s-x);
            if(it1 != conj.end()){
                
            }
            auto it2 = conj.lower_bound(t-x);
            if(it2 != conj.begin()){
                it2;
            }
            for(; it1 != it2; ++it1){
                res[it1->ss] = x;
                aux.push_back(it1->ff);
            }
            while(aux.size()){
                conj.erase(aux.back());
                aux.pop_back();
            }
        }

        for(int i = 0; i < q; ++i){
            cout << res[i] << endl;
        }
    }

    
    return 0;
}

Measured memory_bytes: 23968
#include<iostream>
using namespace std;
#include<algorithm>
#include<cstring>
#include<string>
#include<stdio.h>
#include<map>
#include<vector>
#include<cmath>
#include<iomanip>
#include<queue>
#include<stack>
#include<set>
#define maxn 1000005
#define INF 1e9
#define ll long long
ll a[3],dif;
int main()
{
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	dif = a[0] * a[1];
	if (a[2] % 2)cout << dif << endl;
	else cout << "0" << endl;
	return 0;
}

Measured memory_bytes: 3156
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define mid ((l+r)>>1)
#define lowbit(x) (x&(-x))
#define INF 0x3f3f3f3f
using namespace std;
template<class T>il read(T &x){
	int f=1;char k=getchar();x=0;
	for(;k>'9'||k<'0';k=getchar()) if(k=='-') f=-1;
	for(;k>='0'&&k<='9';k=getchar()) x=x*10+k-'0';
	x*=f;
}
template<class T>il _print(T x){
	if(x>=10) _print(x/10);
	putchar(x%10+'0');
}
template<class T>il print(T x){
	if(x<0) putchar('-'),x=-x;
	_print(x);
}
ll mul(ll a,ll b,ll mod){long double c=1.;return (a*b-(ll)(c*a*b/mod)*mod)%mod;}
it qpow(int x,int k,int mod){
	int res=1,bas=x;
	while(k){
		if(k&1) res=1ll*res*bas%mod;
		bas=1ll*bas*bas%mod,k>>=1;
	}
	return res;
}
int n,opt,x,y;
ll sum1,sum2,b;
priority_queue<int> q1,q2;
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	read(n);
	for(ri i=1;i<=n;++i){
		read(opt);
		if(opt==1){
			read(x),read(y),b+=y;
			if(!q1.size()) q1.push(x),sum1+=x;
			else if(q1.top()>=x) q1.push(x),sum1+=x;
			else q2.push(-x),sum2+=x;
			while((int)q1.size()-(int)q2.size()>1){
				int t=q1.top();q1.pop(),sum1-=t;
				q2.push(-t),sum2+=t;
			}
			while((int)q2.size()-(int)q1.size()>=1){
				int t=-q2.top();q2.pop(),sum2-=t;
				q1.push(t),sum1+=t;
			}
		}
		else{
			int val=q1.size()?q1.top():0;
			ll res=b+1ll*val*q1.size()-sum1+sum2-1ll*val*q2.size();
			printf("%d %lld\n",val,res);
		}
	}
	return 0;
}

Measured memory_bytes: 3452
n,k = map(int,input().split())
a = [int(i) for i in input().split()]

mod = 10**9+7

g = 0
for i in range(n):
    for j in range(n):
        if i == j:
            continue
        elif i >= j:
            continue
        if a[i] > a[j]:
            #print(i,j)
            g += 1

if k == 1:
    print(g)
    exit()
    
a2 = []

for i in range(2*n):
    a2.append(a[i%n])
    
f = 0

for i in range(n):
    for j in range(2*n):
        if i == j:
            continue
        elif i >= j:
            continue
        if a2[i] > a2[j]:
            #print(i,j)
            f += 1

t = f-g
k = k

#print(t)
#exit()
#print(int((k*g%mod + t*(0.5*((k-1)*k))%mod)%mod))
#print(int(( (k%mod*g%mod)%mod + (t*(0.5*((k-1)%mod*k%mod)) ) %mod)%mod))
#print(int((k*g%mod + t*(0.5*((k-1)%mod*k%mod))%mod)%mod))
#print(int((k*g%mod + t*(0.5*((k-1)%mod*k%mod))%mod)%mod))
#ans1 = int((k*g%mod)%mod)
#ans2 = t*(0.5* (k-1)%mod * k%mod ) %mod
#ans2 = t*(0.5*((k-1)%mod*k%mod))%mod
#ans2 = int(t*(((k-1)%mod*k%mod)%mod)//2%mod)
ans = g*k + t*k*(k-1)//2
print( ans%mod)
#print(int(((k*g) + (t*(0.5*((k-1)*k))))%mod))
exit()



Measured memory_bytes: 42348
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	n := nextInt()
	_ = nextInt()
	//list := make([]int, n+1)
	sukimap := map[int]int{}

	for i := 0; i < n; i++ {
		nowk := nextInt()
		for j := 0; j < nowk; j++ {
			tmp := nextInt()
			sukimap[tmp]++
		}
	}

	cnt := 0
	for _, v := range sukimap {
		if v == n {
			cnt++
		}
	}

	fmt.Println(cnt)

}

// ---- readfunc
func scanInit() {
	const cap = 64 * 1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


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

using namespace std;
using ll = long long;

const int MOD = 1000000007;

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

  ll a = 0, ab = 0, abc = 0, c = 1;
  for (int i = 0; i < S.size(); i++) {
    if (S[i] == 'A')
      a = (a + c) % MOD;
    else if (S[i] == 'B')
      ab = (ab + a) % MOD;
    else if (S[i] == 'C')
      abc = (abc + ab) % MOD;
    else if (S[i] == '?') {
      abc = (3 * abc + ab) % MOD;
      ab  = (3 * ab + a) % MOD;
      a   = (3 * a + c) % MOD;
      c   = (c * 3) % MOD;
    }
  }
  cout << abc << '\n';
  return 0;
}


Measured memory_bytes: 512
import numpy as np

N = int(input())
data = np.array([int(i) for i in input().split()])


cout = 0
while 1:
    index = np.where(data%2 == 0)
    data_even = data[index]
    if len(data_even) == len(data):
        cout += 1
        data = data_even / 2
    else:
        break


print(cout)

Measured memory_bytes: 12504
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		boolean or=true;
		int n=sc.nextInt();
		int[][] num = new int[n][6];
		for(int j=0;j<n;j++){
			for(int i=0;i<6;i++){
				num[j][i]=sc.nextInt();
			}
		}
		Dice3[] d = new Dice3[n];
		for(int i=0;i<n;i++){
			d[i]=new Dice3(num[i]);
		}
		for(int i=0;i<n-1;i++){
			for(int j=i+1;j<n;j++){
				//System.out.println("check"+check(d[i],d[j]));
				if(check(d[i],d[j])){
					//System.out.println("///"+i+" "+j);
					or=false;
					break;
				}
			}
			if(!or){
				break;
			}
		}
		if(or){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
	static boolean check(Dice3 d1,Dice3 d2){
		int up=-1,fr=-1;
		boolean yn=true;
		for(int i=0;i<6;i++){
			//System.out.println(d1.label[0]+"/"+d2.label[i]);
			if(d1.label[0]==d2.label[i]){
				up=i;
				break;
			}
		}
		if(up<0){
			yn=false;
		}else{
		for(int i=0;i<6;i++){
			//System.out.println(d1.label[1]+"/"+d2.label[i]);
			if(d1.label[1]==d2.label[i]){
				fr=i;
				break;
			}
		}
		//System.out.println(d1.label[0]+" 0 "+d2.label[up]);
		//System.out.println(d1.label[1]+" 1 "+d2.label[fr]);
		if(fr<0){
			yn=false;
		}else{
		//System.out.println(d2.label[rcheck(up, fr)]+" 2 "+d1.label[2]);
		if(d2.label[rcheck(up, fr)]!=d1.label[2]){
			yn=false;
		}
		//System.out.println(d2.label[5-rcheck(up, fr)]+" 3 "+d1.label[3]);
		if(d2.label[5-rcheck(up, fr)]!=d1.label[3]){
			yn=false;
		}
		//System.out.println(d2.label[5-fr]+" 4 "+d1.label[4]);		
		if(d2.label[5-fr]!=d1.label[4]){
			yn=false;
		}
		//System.out.println(d2.label[5-up]+" 5 "+d1.label[5]);
		if(d2.label[5-up]!=d1.label[5]){
			yn=false;
		}
		}
		}
		return yn;
	}
	static int rcheck(int up,int fr){
		int a=0;
		if(up==0){
			if(fr==1){
				a=2;
			}else if(fr==2){
				a=4;
			}else if(fr==3){
				a=1;
			}else if(fr==4){
				a=3;
			}
		}else if(up==1){
			if(fr==0){
				a=3;
			}else if(fr==2){
				a=0;
			}else if(fr==3){
				a=5;
			}else if(fr==5){
				a=2;
			}
		}else if(up==2){
			if(fr==0){
				a=1;
			}else if(fr==1){
				a=5;
			}else if(fr==4){
				a=0;
			}else if(fr==5){
				a=4;
			}
		}else if(up==3){
			if(fr==0){
				a=4;
			}else if(fr==1){
				a=0;
			}else if(fr==4){
				a=5;
			}else if(fr==5){
				a=1;
			}
		}else if(up==4){
			if(fr==0){
				a=2;
			}else if(fr==2){
				a=5;
			}else if(fr==3){
				a=0;
			}else if(fr==5){
				a=3;
			}
		}else if(up==5){
			if(fr==1){
				a=3;
			}else if(fr==2){
				a=1;
			}else if(fr==3){
				a=4;
			}else if(fr==4){
				a=2;
			}
		}
		return a;
	}

}

class Dice3{
	int[] label=new int[6];
	Dice3(int[] a){
		for(int i=0;i<6;i++){
			label[i]=a[i];
		}
	}
}

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

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

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

	vector<int> A( N );
	for( auto& v: A ) { cin >> v; }

	cout << ((N-1) + (K-2)) / (K-1) << endl;

	return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner scan = new Scanner(System.in);
		String c1 = scan.next();
		String c2 = scan.next();
		String c3 = scan.next();

		System.out.println("" + c1.charAt(0) + c2.charAt(1) + c3.charAt(2));
	}

}


Measured memory_bytes: 21844
import itertools
N, M, Q = map(int, input().split())
abcd = [list(map(int, input().split())) for _ in range(Q)]

A = []
for i in range(1, M + 1):
    A.append(i)
H = list(itertools.combinations_with_replacement(A, N))

C = 0
while len(H) > 0:
    CC = 0
    h = H.pop()
    for i in range(Q):
        a = abcd[i][0] - 1
        b = abcd[i][1] - 1
        c = abcd[i][2]
        d = abcd[i][3]
        if h[b] - h[a] == c:
            CC += d
    C = max(C, CC)
print(C)

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

int main() {
    int n;
    cin >> n;
    for (int i = 1; ; i++) {
        int count = 0;
        for (int j = 1; j <= i; j++) {
            if (i % j == 0) count++;
        }
        if (count == n) {
            cout << i << endl;
            return 0;
        }
    }
}

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

int main() {

	int a, b;

	cin >> a >> b;

	if (a + b >= 24) {
		cout << abs(24 - (a + b)) << endl;
	}

	else {
		cout << a + b << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int getLog(long long idx)
{
  long long s = 1LL;
  int keta = 0;
  while(s <= idx) {
    s *= 10LL;
    ++keta;
  }
  return(keta);
}
 
long long S;
 
 
pair< bool, long long > Count(long long idx)
{
  long long mozi = 0;
 
  int keta = getLog(idx); // 何桁あるか
  long long small = 1, big = min(10LL, idx + 1);
 
  for(int i = 1; i <= keta; i++) {
    long long head_3 = (small + 2) / 3 * 3;
    long long top_3  = (big   + 2) / 3 * 3;
    long long head_5 = (small + 4) / 5 * 5;
    long long top_5  = (big   + 4) / 5 * 5;
 
    long long head_15 = (small + 15) / 15 * 15;
    long long top_15  = (big   + 15) / 15 * 15;
 
    long long four = (top_3 - head_3) / 3 + (top_5 - head_5) / 5;
    long long eight = (top_15 - head_15) / 15;
 
    mozi += four * 4 + 1LL * (big - small - (four - eight)) * i;
    if(mozi >= S) return(make_pair(false, mozi));
    small *= 10;
    big *= 10;
    big = min(big, idx + 1);
  }
  return(make_pair(true, mozi));
}
 
int main()
{
  cin >> S;
 
  long long low = 1, high = S;
  while(low < high) {
    long long mid = (low + high + 1) / 2LL;
    if(Count(mid).first) low = mid;
    else high = mid - 1;
  }
 
  long long pos = Count(low).second;
 
 
  if(S == 1) {
    pos = 0;
    low = 0;
  }
  string ret = "";
  for(long long i = low + 1; i < low + 15; i++) {
    stringstream sss;
    if(i % 15LL == 0) sss << "FizzBuzz";
    else if(i % 3LL == 0) sss << "Fizz";
    else if(i % 5LL == 0) sss << "Buzz";
    else sss << i;
    ret += sss.str();
  }
 
  cout << ret.substr(S - pos - 1, 20) << endl;
}

Measured memory_bytes: 1220
#include<iostream>
#include<stack>

using namespace std;

static const int N = 100;
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[N][N];
int color[N], d[N], f[N], tt;
int nt[N];

int next(int u){
  for(int v = nt[u]; v < n; v++){
    nt[u] = v + 1;
    if(M[u][v]) return v;
  }
  return -1;
}

void dfs_visit(int r){
  for(int i = 0; i < n; i++) nt[i] = 0;

  stack<int> S;
  S.push(r);
  color[r] = GRAY;
  d[r] = ++tt;

  while(!S.empty()){
    int u = S.top();
    int v = next(u);

    if(v != -1){
      if(color[v] == WHITE){
	color[v] = GRAY;
	d[v] = ++tt;
	S.push(v);
      }
    }
    else {
      S.pop();
      color[u] = BLACK;
      f[u] = ++tt;
    }
  }
}

void dfs(){
  for(int i = 0; i < n; i++){
    color[i] = WHITE;
    nt[i] = 0;
  }
  tt = 0;

  for(int u = 0; u < n; u++){
    if(color[u] == WHITE) dfs_visit(u);
  }
  for(int i = 0; i < n; i++){
    cout << i+1 << " " << d[i] << " " << f[i] << endl;
  }
}

int main(){
  int u, k, v;

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

  for(int i = 0; i < n; i++){
    cin >> u >> k;
    u--;
    for(int j = 0; j < k; j++){
      cin >> v;
      v--;
      M[u][v] = 1;
    }
  }
  dfs();

  return 0;
}
    



Measured memory_bytes: 3152
#include <stdio.h>
#include <math.h>
#include <string.h>
#define rep(i,a,n) for(int i=a;i<n;i++)

int main(){
	int lens,lenp;
	char s[210],p[110];
	int f=0;
	scanf("%s %s",s,p);
	lens=strlen(s);
	lenp=strlen(p);
	sprintf(s,"%s%s",s,s);
	rep(i,0,lens){
		rep(j,0,lenp){
			if(s[i+j]!=p[j]) break;
			if(j==lenp-1) f=1;
		}
		if(f) break;
	}
	if(f) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 980
number_of_sticks = int(input())

sticks = [int(x) for x in input().split(' ')]

sticks.sort()

triangles = 0

import bisect

for i in range (number_of_sticks - 2):
    for j in range (i+2, number_of_sticks):
        max_range = j
        min_range = max(bisect.bisect(sticks, sticks[j] - sticks[i]), i + 1)
        triangles += max_range - min_range

print(triangles)

Measured memory_bytes: 3316
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,-1,0};
int dy[4]={1,0,0,-1};
long double eps = 1e-6;
long double pi = acos(-1);

const int MAX = 1510000;
const int mod = 1000000007;

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

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

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

ll P(int n,int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * finv[n-k] % mod;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    ll n,m;
    cin>>n>>m;
    COMinit();
    ll ans = P(m,n) * P(m,n) % mod;
    for(int i=1;i<=n;i++){
        ll ret = COM(n,i) * P(m,i) % mod;
        ret *= (P(m-i,n-i) * P(m-i,n-i)) % mod;
        ret %= mod;
        if(i%2){
            ans += mod - ret;
        }
        else ans+=ret;
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 39024
#include <stdio.h>
int main(void){
    int a,b=0;
    int length=0;
    int area=0;
    scanf("%d %d\n",&a,&b);
    length=2*a+2*b;
    area=a*b;
    
    printf("%d %d\n",area,length);
    return(0);
}



Measured memory_bytes: 2044
#define ONLINE_JUDGE
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(n);++i)
#define _repe3(i,a,b) for(ll i=(a);i<=(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(b)-1;i>=(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<class T>
using pq=priority_queue<T,vector<T>,greater<T>>;

void solve();

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

template<typename T>
struct edge{
    int src,to;
    T cost;
    edge(int from,int to,T cost):src(src),to(to),cost(cost){}
    edge(int to,T cost):edge(-1,to,cost){}
    operator int()const{return to;}
};

template<typename T>
using Edges=vector<edge<T>>;

template<typename T>
using Graph=vector<Edges<T>>;

void solve(){
    ll x,y;cin>>x>>y;

    vl a={x,y,-x,-y};
    Graph<ll> g(4);
    rep(i,4)rep(j,4){
        if(abs(a[i])==abs(a[j]))g[i].emplace_back(j,1);
        if(a[i]<=a[j])g[i].emplace_back(j,a[j]-a[i]);
    }

    vl d(4,LINF);
    d[0]=0;
    pq<pl> q;
    q.emplace(0,0);
    while(q.size()){
        ll dd,src;
        tie(dd,src)=q.top();q.pop();
        if(dd>d[src])continue;
        for(auto &e:g[src]){
            if(d[e.to]<=d[src]+e.cost)continue;
            d[e.to]=d[src]+e.cost;
            q.emplace(d[e.to],e.to);
        }
    }
    
    cout<<d[1]<<endl;
}

Measured memory_bytes: 256
n = int(input())
lis = list(map(int,input().split()))
a = min(lis)
b = max(lis)
all_lis = []

for i in range(a,b+1):
    tmp = 0
    for l in lis:
        tmp += (l-i)**2
    all_lis.append(tmp)
print(min(all_lis))

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

int main()
{
    int n,a;
    long long sum=0;
    vector<bool> c(1000000000,0);
    cin >> n;
    for (int i=0;i<n;i++)
    {
        cin >> a;
        c[a-1]=!c[a-1];
    }
    for (int i=0;i<1000000000;i++)
        sum+=c[i];
    cout << sum;
    return 0;
}


Measured memory_bytes: 122368
#include <bits/stdc++.h>
using namespace std;
#define ll long long int

int main() {
    string s;
    cin>>s;
    int temp=0,mx=0;
    for(int i=0;i<s.length();i++){
        if(s[i]=='A' || s[i]=='C' || s[i]=='G' || s[i]=='T')temp++;
        else temp=0;
        if(temp>mx)mx=temp;
    }
    cout<<mx;
}

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

#define F first
#define S second
#define MP make_pair
#define PB push_back

using namespace std;

typedef long long ll;
typedef long double ld;

const int max_n = 100011, inf = 1000111222;



int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int a[4];
    for (int i = 0; i < 4; ++i) cin >> a[i];
    sort(a, a + 4);
	if (a[0] == 1 && a[1] == 4 && a[2] == 7 && a[3] == 9) {
		cout << "YES\n";
	} else {
		cout << "NO\n";
	}
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll ZERO = 0;
const int INF = 1e9;
const ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

int main() {
    char A;
    cin >> A;
    A++;
    cout << A << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
    return x*f;
}
inline void write(int x)
{
    if(x<0)putchar('-'),x=-x;
    if(x>9)write(x/10);
    putchar(x%10+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
struct node
{
	int d,p;
}a[100010];
bool cmp(node a,node b){return a.d<b.d;}
int now,ex[100010];
int s[100010];
inline int lowbit(int x){return x&-x;}
inline void change(int x,int d)
{
	while(x<=now)
	{
		s[x]=max(s[x],d);
		x+=lowbit(x);
	}
}
inline int getmx(int x)
{
	int mx=0;
	while(x>=1)
	{
		mx=max(mx,s[x]);
		x-=lowbit(x);
	}return mx;
}
int main()
{
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    int n=read();
    for(int i=1;i<=n;i++)a[i].d=read(),a[i].p=i;
    sort(a+1,a+n+1,cmp);
    a[0].d=-1;
    for(int i=1;i<=n;i++)
	{
		if(a[i].d!=a[i-1].d)now++;
		ex[a[i].p]=now;
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		ex[i]=now-ex[i]+1;
		int uf=getmx(ex[i])+1;
		ans=max(ans,uf);change(ex[i],uf);
	}pr2(ans);
    return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e6+5,mod=998244353;
vector<int>v[N];
int n,a[N],tot,head[N],nex[N*20],to[N*20];
void add(int u,int v){to[++tot]=v;nex[tot]=head[u];head[u]=tot;}
ll sum[N],p[N],f[N],inv[N];
int main()
{
    inv[1]=1;
    for(int i=2;i<=1000000;i++) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
    int tot=0;
    for(int i=1;i<=1000000;i++)
        for(int j=i;j<=1000000;j+=i)
            add(j,i);
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        for(int j=head[a[i]];j;j=nex[j])
        {
            int v=to[j];
            p[v]=(p[v]+sum[v]*a[i])%mod;
            sum[v]=(sum[v]+a[i])%mod;
        }
    }
    ll ans=0;
    for(int i=1000000;i>=1;i--)
    {
        for(int j=i+i;j<=1000000;j+=i)
            p[i]=(p[i]-p[j])%mod;
        ans=(ans+p[i]*inv[i])%mod;
    }
    ans=(ans+mod)%mod;
    printf("%lld\n",ans);
}



Measured memory_bytes: 164440
#include<bits/stdc++.h>
using namespace std;
long long A,B,C,X,Y,p,ans;
int main()
{
	scanf("%lld%lld%lld%lld%lld",&A,&B,&C,&X,&Y);X*=2;Y*=2;
	if(2*C<A+B){
		ans+=min(X,Y)*C;
		if(X<=Y){
			Y-=X;
			if(2*C<B)ans+=Y*C;
			else ans+=(Y/2)*B;
		}
		else{
			X-=Y;
			if(2*C<A)ans+=X*C;
			else ans+=A*(X/2);
	}
}
	else{
		int p=min(X,Y);
		ans+=B*(p/2);
		ans+=A*(p/2);X-=p;Y-=p;
		//cout<<ans<<endl;
	if(X)
		if(2*C>A)ans+=A*X/2;
	else ans+=C*X;
	else
		if(2*C>B)ans+=B*Y/2;
	else ans+=C*Y;
	}
	cout<<ans<<endl;
	return 0;
}

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

#ifdef DEBUG
    #include "debug.h"
    #define dump(...)                                                              \
        DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
                << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
                << endl                                                            \
                << "    ",                                                         \
            dump_func(__VA_ARGS__)
#else
    #define dump(...)
#endif


// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

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

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

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

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

#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
#define ALL(v) (v).begin(), (v).end()
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

//*
#define mod 1000000007 /*/
#define mod 998244353 //*/

typedef pair<int, int> P;
#define INF (1LL<<60)

void solve(){
    int N;
    cin >> N;
    vector<int> h(N+1);
    rep(i,N) cin >> h[i+1];
    
    vector<int> dp(N+1);
    dp[1] = 0;
    for(int i=2; i<=N; i++){
        if(i==2)
            dp[i] = dp[i-1] + abs(h[i]-h[i-1]);
        else
            dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]),
                      dp[i-2] + abs(h[i]-h[i-2]));
    }
    
    cout << dp[N] << endl;
}


signed main(){
    cout << fixed << setprecision(18);
//    cerr << fixed << setprecision(18);
    solve();
}


Measured memory_bytes: 4772
#!/usr/bin/env python3
# coding: utf-8
# import sys
# import pprint
# import numpy as np
# import code


if __debug__:
    debug = lambda *x: None
else:
    import logging
    logger = logging.getLogger()
    logger.setLevel(logging.DEBUG)
    ch = logging.StreamHandler()
    ch.setLevel(logging.DEBUG)
    formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
    ch.setFormatter(formatter)
    logger.addHandler(ch)
    debug = logger.debug

s = input()
debug(s[2])

print('Yes' if s[2] == s[3] and  s[4] == s[5] else 'No')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>
 
template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<endl;}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}
 
const double EPS =1e-9;
const long INF =2147483647;//32bit 2*1e+9
const long MOD =1e+9+7;
#define PI 3.14159265258979
 
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};
 
 
int main(void){
	string S;
	cin>>S;
	if(S[0]==S[1]&&S[1]==S[2]) puts("Yes");
	else if(S[1]==S[2]&&S[2]==S[3]) puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<queue>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;

const int mod = 1000000007;
struct mint {
  ll x;

  mint(ll 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 {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    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];
  }
};

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

  int m = min(n-1, k);
  combination com(n);
  mint all = 0;
  rep(i,m+1) all += com(n,i) * com((n-i-1)+i,i);
  cout << all.x << endl;
  return 0;
}


Measured memory_bytes: 3328
#include<iostream>
#include<fstream>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstring>
#include<string.h>
#include<algorithm>
using namespace std;
int n,m,a[100],g;
int main()
{
	cin>>n>>m;
	for(int i=1; i<=n; i++)
	    cin>>a[i];
	sort(a+1,a+1+n);
	for(int i=n; i>=n-m+1; i--)
	    g+=a[i];
	cout<<g<<endl;
	return 0;
}

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

        using namespace std;
        #define sd(x) scanf("%d",&x);
        #define sdl(x) scanf("%lld",&x);
        #define pr(x) printf("%d\n",x);
        #define prl(x) printf("%lld\n",x);
    
    long long int mod=1000000007;

    long long int gcd(long long int a,long long int b)
    {
        if (b<a)return gcd(b,a);
        else if (b%a==0)return a;
        else return gcd(b%a,a);

    }

    long long fast_exp(long long a,long long n,long long mod1)
    {

    if (n==0)return 1;
    else if (n==1)return a;
    if (n%2==0)return fast_exp((a*a)%mod1,n/2,mod1);
    else return (a*fast_exp((a*a)%mod1,n/2,mod1))%mod1;
    }
    bool is_square(long long  a)
    {
    long long int b=sqrt(a);
    if (b*b==a)return true;
    else return false;
    }
    long long n_fact[1000001];
    void calc_fact(int n) // calculates the factorial % mod and stores in n_fact upto n 
    {
        n_fact[0]=1;
        for (int c(1);c<=n;c++)
            n_fact[c]=(c*n_fact[c-1])%mod;
        return ;
    }
    long long calc_inverse_mod(long long x,long long mod)
    {
        return fast_exp(x,mod-2,mod);

    }
    bool n_primes[100001]={false};
    void calc_primes(int n)
    {
        for (int c(2);c<=100000;c++)
        {
            if (n_primes[c]==true)continue;
            for (int c1(c+c);c1<=100000;c1=c1+c)
                n_primes[c1]=true;
        }
        return ;
    }

    int main ()
    {
    
        ios_base::sync_with_stdio(false);
        int t;
        //cin >> t;
        t=1;
        for (int tt=0;tt<t;tt++)
        {
            int n,m;
            cin >> n >> m;
            cout << (n*(n-1))/2+(m*(m-1))/2 << endl;
        }
        


        
            
        
    return 0;




        
    }


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

int main()
{
	int N, r, t;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> r >> t;
		if ((r + 99) / 100 == r / 100) {
			if ((t + 29) / 30 == t / 30) {
				cout << r / 100 + t / 30 * 5 << endl;
			}
			else {
				cout << r / 100 + t / 30 * 5 << " " << r / 100 + (t + 29) / 30 * 5 << endl;
			}
		}
		else {
			if ((t + 29) / 30 == t / 30) {
				cout << r / 100 + t / 30 * 5 << " " << (r + 99) / 100 + t / 30 * 5 << endl;
			}
			else {
				cout << r / 100 + t / 30 * 5 << " " << (r + 99) / 100 + t / 30 * 5 << " " << r / 100 + (t + 29) / 30 * 5 << " " << (r + 99) / 100 + (t + 29) / 30 * 5 << endl;
			}
		}
	}
	return 0;
}

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

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

using namespace std;

template <class T>
void printv(vector<T> v)
{
  cout << '[';
  for (auto vec: v)
  {
    cout << vec << ' ';
  }
  cout << ']' << endl;
}

int main()
{
  long long a, b;
  cin >> a >> b;

  if (a < 0 && b < 0)
  {
    if ((a + b) % 2 == -1)
    {
      cout << "Positive" << endl;
      exit(0);
    }
    else 
    {
      cout << "Negative" << endl;
      exit(0);
    }
  }
  else if (a <= 0 || b <= 0)
    cout << "Zero" << endl;
  else 
    cout << "Positive" << endl;
}


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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

using ll = long long;
using ull = unsigned long long;
using veci = vector<int>;
using vecll = vector<ll>;
using vecull = vector<ull>;

ll A;
long double B;

int main(void) {
    cin >> A >> B;

    ll ans = A * B;

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


Measured memory_bytes: 3724
import java.util.*;






// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail

public class Main{
    public static void main(String args[] ) throws Exception {
        
        //Scanner
        Scanner scanner = new Scanner(System.in);
        long a=0,b=0;
        a = scanner.nextLong();
        b = scanner.nextLong();
        long sum = a+b;
        if(sum%2==0) {
            System.out.println(sum/2);
        }
        else {
            System.out.println("IMPOSSIBLE");
        }
        
    }
    
    
    
}


Measured memory_bytes: 22996
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

struct Music {
	char s[101];
	int t;
};

int main(int argc, char **argv)
{
	int N;
	scanf("%d", &N);
	struct Music T[50];
	for (int i = 0; i < N; i++)
		scanf("%s%d", T[i].s, &T[i].t);
	char X[101];
	scanf("%s", X);
	int i;
	for (i = 0; i < N; i++) {
		if (!strcmp(T[i].s, X))
			break;
	}
	++i;
	int n = 0;
	for (; i < N; i++) {
		n += T[i].t;
	}
	printf("%d\n", n);
	return 0;
}


Measured memory_bytes: 128
import sys
import math
import itertools
import bisect
from copy import copy,deepcopy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

N = i()
print((10**N-9**N*2+8**N)%mod)

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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >
# define PQ priority_queue

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvs vector < vs >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

string vow = "aeiou";
int month[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.1415926535897932384626 ;
const ll mod = 1e9 + 7 ;

/// Tip : If a and b are positive integers ; we may say - ceil (a/b) = 1 + floor ( (a-1)/b ) .

const int N = 1e5 + 10 ;
int a[N] , b[N] , c[N] ;

int n ;

void read ()
{
    cin >> n ;

    for ( int i=1 ; i <= n ; i ++ )
    {
        cin >> a[i] >> b[i] >> c[i] ;
    }
}

int dp[3][N] ;

void solve ( int test_case )
{
    read () ;

    for ( int i = 1 ; i <= n ; i ++ )
    {
        dp[0][i] = a[i] + max ( dp[1][i - 1] , dp[2][i - 1] ) ;
        dp[1][i] = b[i] + max ( dp[0][i - 1] , dp[2][i - 1] ) ;
        dp[2][i] = c[i] + max ( dp[0][i - 1] , dp[1][i - 1] ) ;
    }

    int ans = max ( { dp[0][n] , dp[1][n] , dp[2][n] } ) ;
    cout << ans ;

    line ;
}

int main()
{fast
    int t = 1;
    // cin >> t;

    for ( int i=1 ; i <= t ; i ++ ) solve ( i ) ;
    return 0;
}


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

int main() {
  int m1,d1,m2,d2;
  cin >> m1 >> d1 >> m2 >> d2;
  if(m1!=m2 && d2==1) cout << 1 << endl;
  else cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 256
h, w, m = (int(x) for x in input().split())
bomb = {}
bomb_h = [0]*h
bomb_w = [0]*w
for i in range(m):
    hm, wm = (int(x) for x in input().split())
    hm-=1
    wm-=1
    bomb[(hm, wm)] = 0
    bomb_h[hm]+=1
    bomb_w[wm]+=1
h_kouho = []
w_kouho = []
h_max = max(bomb_h)
w_max = max(bomb_w)
for i in range(h):
    if bomb_h[i]==h_max:
        h_kouho.append(i)
for i in range(w):
    if bomb_w[i]==w_max:
        w_kouho.append(i)
boo = False
for i in h_kouho:
    for j in w_kouho:
        if (i, j) not in bomb:
            boo=True
            break
    else:
        continue
    break
if boo:
    print(h_max+w_max)
else:
    print(h_max+w_max-1) 


Measured memory_bytes: 199096