akhauriyash/Code-Regression huggingface dataset:
#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <float.h>

#pragma region 定義
typedef long long  ll;
typedef unsigned long long  ull;


#define _itoa(A,N) sprintf(A, "%d", N);

int i_dsort(const void* a, const void* b);
int i_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);

int s_asort(const void* a, const void* b);
int s_dsort(const void* a, const void* b);

//昇順
int s_asort(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(strcmp((char*)b, (char*)a));
}

int i_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int i_asort(const void* a, const void* b) {
	return(*(int*)a - *(int*)b);
}


int i_gcd(int a, int b);
int i_gcd(int a, int b) {
	if (!b)return a;
	return i_gcd(b, a % b);
}
int i_lcm(int a, int b);
int i_lcm(int a, int b) {
	return (a * b) / i_gcd(a, b);
}
int ll_gcd(ll a, ll b);
int ll_gcd(ll a, ll b) {
	if (!b)return a;
	return ll_gcd(b, a % b);
}
int ll_lcm(ll a, ll b);
int ll_lcm(ll a, ll b) {
	return (a * b) / ll_gcd(a, b);
}

// puts("Yes\n") puts("No\n")
// scanf("%d.%d") 浮動小数点入力を整数２つで得る


//#define pai  3.1415926535 
//#define  _USE_MATH_DEFINES でM_PIが使える

#define deg_rad(X)  (X*(M_PI/180))


int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}
#define _abs(x) ((x)>0?(x):-(x))
#define _min(x,y) ((x)<(y)?(x):(y))
#define _max(x,y) ((x)<(y)?(y):(x))

int _cknum(char* a, int n) {
	int i;
	char t = '0';

	for (i = 0; i < n; i++) {
		if (a[i] < '0' || a[i]>'9') return 1;
	}
	return 0;
}


int _atoi(char* s, int len) {
	char tmp[20];
	memcpy(tmp, s, len);
	tmp[len] = 0x00;
	return (atoi(tmp));
}

//素因数分解　pf素数が入る　pc 素数の数
//ll _pfact(ll a);
//static ll pf[100000000];
//static ll pc;
//
//ll _pfact(ll a) {
//	long i, r;
//	if (a % 2 == 0) {
//		pf[pc] = 2; pc++;
//		return(_pfact(a / 2));
//	}
//	r = sqrt(a);
//	for (i = 3; i <= r; i += 2) {
//		if (a % i == 0) {
//			pf[pc] = i; pc++;
//			return(_pfact(a / i));
//		}
//	}
//	if (a != 1) {
//		pf[pc] = a; pc++;
//	}
//	return 0;
//
//}

//同じものの最初の文字をNULLにして降順
int _sort(const void* a, const void* b);
int _sort(const void* a, const void* b) {
	char rc;

	rc = strcmp((char*)b, (char*)a);
	if (rc == 0) {
		*(char*)a = 0x00;
		return(1);
	}
	return(rc);
}
// 立っている ビットの数
int bitcount(unsigned int uc);
int bitcount(unsigned int uc)
{
	int bit;

	for (bit = 0; 0 != uc; uc = (unsigned int)(uc >> 1))
		if (0 != (uc & 1))++bit;

	return bit;
}//bitco

#define _rnd(a,b)    ((a+b-1)/b) //　A/Bの余りを繰り上げる

#pragma endregion

// ABC081 B- Shift only
int _div2(int n);
int _div2(int n) {
	int cnt = 0;
	while (1) {
		if (n % 2) return(cnt);
		n /= 2;
		cnt++;
	}
}


int main(void) {
	const int INF = 10000000;
	int n, a;
	int i, cnt,res=INF;

	scanf("%d", &n);

	for (i = 0; i < n; i++) {
		scanf("%d", &a);
		cnt = 0;
		while (1) {
			if (a % 2) break;
			a /= 2;
			cnt++;
		}
		res = _min(cnt, res);
	}
	
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 1728
n,m=map(int,input().split())

k=[]
s=[]
for i in range(m):
    templist=[int(x)-1 for x in input().split()]
    k.append(templist[0]+1)
    s.append(templist[1:])

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

b=[] #全部の可能性
for i in range(2**n):
    temp=[]
    for j in range(n):
        if (i>>j)&1==1:
            temp.append(1)
        else:
            temp.append(0)
    b.append(temp)

ans=0
for x in b:
    cnt=0
    for i in range(m):
        temp=0
        for j in range(len(s[i])):
            temp+=x[s[i][j]]
        if temp%2 != p[i]:
            continue
        else:
            cnt+=1
            if cnt==m:
                ans+=1
print(ans)


Measured memory_bytes: 3316
using System;

namespace Unbalanced
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            var chars = Console.ReadLine().ToCharArray();
     
            for (int i = 0; i < chars.Length; i++)
            {
                // AAのとき
                if (chars.Length <= i + 1)
                {
                    break;
                }
                if (chars[i] == chars[i + 1])
                {
                    Console.WriteLine(string.Format("{0} {1}",i + 1 ,i + 2));
                    return;
                }

                // A_Aのとき
                if (chars.Length <= i + 2)
                {
                    break;
                }
                if (chars[i] == chars[i + 2])
                {
                    Console.WriteLine(string.Format("{0} {1}",i + 1 ,i + 3));
                    return;
                }
            }

            Console.WriteLine("-1 -1");
        }
    }
}


Measured memory_bytes: 13536
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
typedef int64_t llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());


int main(){
    int n;
    cin >> n;
    llong a,b,c;
    a=2;
    b=1;
    REP(i,n-1){
        c=a+b;
        a=b;
        b=c;
    }
    cout << b << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <map>

using ll = long long;

using namespace std;

#define LIM ((ll)1e18)

using P = pair<ll, ll>;
#define fi first
#define se second

int main() {
    int T; cin >> T;
    while (T--) {
        ll n, a, b, c, d;
        cin >> n >> a >> b >> c >> d;
        map<ll, ll> mp;
        for (ll i=max(n-4, 1ll); i<=n+4; i++)
            mp[i] = d * abs(n - i);
        ll ans = (n > 5 ? 1e18 : d * n);
        while (!mp.empty()) {
            P f = *mp.rbegin(); mp.erase(f.fi);
            vector<P> cands;
            for (int i=-4; i<=4; i++) {
                if (f.fi % 2 == 0) 
                    cands.push_back({f.fi / 2 + i, f.se + d * abs(i) + a});
                if (f.fi % 3 == 0) 
                    cands.push_back({f.fi / 3 + i, f.se + d * abs(i) + b});
                if (f.fi % 5 == 0) 
                    cands.push_back({f.fi / 5 + i, f.se + d * abs(i) + c});
            }
            for (auto &ci:cands) {
                if (ci.fi <= 0 || ci.fi >= f.fi || ci.se > ans) continue;
                if (ci.fi <= (ans - ci.se) / d) {
                    ans = min(ans, ci.fi * d + ci.se);
                }
                if (!mp.count(ci.fi) || ci.se < mp[ci.fi]) {
                    mp[ci.fi] = ci.se;
                }
            }
        }
        cout << ans << '\n';
    }
    return 0;
}

Measured memory_bytes: 4200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    ll sum1=0,sum2=0;
    vector<ll> A(N),B(N),C(N);
    rep(i,N) cin >> A[i],sum1+=A[i];
    rep(i,N) cin >> B[i],sum2+=B[i];
    rep(i,N) if (A[i]>B[i]) C[i]=A[i]; else C[i]=B[i]+(B[i]-A[i])%2;
    ll cnt=sum2-sum1,cnt1=0,cnt2=0;
    rep(i,N) cnt1+=(C[i]-A[i])/2,cnt2+=C[i]-B[i];
    if (cnt>=0&&cnt1<=cnt&&cnt2<=cnt&&(cnt-cnt1)*2==cnt-cnt2) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
typedef long long ll;
typedef pair<int, int> pii;
const int inf=100100100;
const int mod=(int)1e9+7;

int n,m,q;
vector<int>a,b,c,d;
int ans;
void dfs(vector<int>v){
    if(v.size()==n+1){
        int now = 0;
        rep(i,0,q){
            if(v.at(b.at(i))-v.at(a.at(i))==c.at(i)){
                now+=d.at(i);
            }
        }
        ans = max(ans,now);
        //for(int i=0; i<v.size(); i++){
        //    cout<<v.at(i)<<endl;
        //}
        return;
    }
    v.push_back(v.back());
    while(v.back()<=m){
        dfs(v);
        v.back()++;
    }
}

int main() {
    cin>>n>>m>>q;
    a=b=c=d=vector<int>(q);
    for(int i=0; i<q; i++){
        cin>>a.at(i)>>b.at(i)>>c.at(i)>>d.at(i);
    }
    dfs(vector<int>(1,1));
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <limits.h>
#include <cstring>
#include <tuple>
#include <cassert>
#include <numeric>
using namespace std;
// type alias
typedef long long LL;
typedef vector < int > VI;
typedef unordered_map < int, int > MAPII;
typedef unordered_set < int > SETI;
typedef pair< int , int > II;
typedef tuple< int, int, int > III;
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// minmax
#define SMAX(a,b) a = max(a,b)
#define SMIN(a,b) a = min(a,b)
// debug cerr
#define TRACE true
#define dump(x) if(TRACE) { cerr << #x << " = " << (x) << endl; }
#define dump2(x,y) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << endl; }
#define dump3(x,y,z) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << endl; }
#define dump4(x,y,z,a) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << ", " << #a << " = " << (a) << endl; }
#define dumpAR(ar) if(TRACE) { FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }

// $ g++ -std=c++11 -Wall -O2 -D_GLIBCXX_DEBUG x.cpp && ./a.out
// 21:20-
const int MAX_N=2e5+1;
int N;
LL A[MAX_N];
LL solve() {
  unordered_map<LL,LL> M;
  LL res=0,sum=0;
  M[0]=1;
  REP(i,N) {
    sum+=A[i];
    if(M.count(sum)) res+=M[sum];
    M[sum]++;
//    dump2(sum,M[sum]);
  }
  return res;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  cin>>N;
  REP(i,N) cin>>A[i];
  cout<<solve()<<endl;
  return 0;
}


Measured memory_bytes: 10056
def is_integer(n):
    try:
        float(n)
    except ValueError:
        return False
    else:
        return float(n).is_integer()


X, Y = list(map(int, input().split()))
Turtle = (Y - 2*X ) / 2
Crane = X - Turtle
if Turtle >= 0 and Crane >= 0 and is_integer(Turtle) and is_integer(Crane):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9184
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;


public class Main {
	
	public static int cal(int a,int b){
		if(b > a){
			return (b - a);
		}else{
			return a;
		}
	}
	
	public static int next(int a,int b){
		if(b > a){
			return 2;
		}else{
			return 1;
		}
	}
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNextLine()){
			String str = sc.nextLine();
			Map<Character,Integer> map = new HashMap<Character,Integer>(7);
			map.put('I', 1);
			map.put('V', 5);
			map.put('X', 10);
			map.put('L', 50);
			map.put('C', 100);
			map.put('D', 500);
			map.put('M', 1000);
			 
			int pos = 0;
			int sum = 0;
			while(true){
				char s1 = ' ';
				char s2 = ' ';
				if(pos < str.length()){
					s1 = str.charAt(pos);
				}else{
					break;
				}
				
				if((pos+1) < str.length()){
					s2 = str.charAt((pos+1));
					int a = map.get(s1);
					int b = map.get(s2);
					sum += cal(a,b);
					pos += next(a,b);
				}else{
					sum += cal(map.get(s1),1);
					pos++;
				}
			}
			
			System.out.println(sum);
				 
		}
	}
}

Measured memory_bytes: 12000
#include<iostream>
#define INF 1000000
#define MAX 300
#define SF 100
#include<map>
#include<queue>
using namespace std;
typedef pair<int,int> P;
int main(){
	int n,t,sx,sy,dx[]={0,1,1,0,-1,-1},dy[]={-1,0,1,1,0,-1};
	int d[MAX][MAX],x,y;
	while(cin>>t>>n,t||n){
		for(int i=0;i<MAX;i++)
		for(int j=0;j<MAX;j++)
		d[i][j]=INF;
		for(int i=0;i<n;i++){
			cin>>x>>y;
			d[x+SF][y+SF]=1;
		}
		cin>>sx>>sy;
		sx+=SF;
		sy+=SF;
		queue<P> que;
		que.push(P(sx,sy));
		int ans=0;
		d[sx][sy]=0;
		while(!que.empty()){
			P p=que.front();
			que.pop();
			if(d[p.first][p.second]==t)
				break;
			for(int i=0;i<6;i++){
				int nx=p.first+dx[i];
				int ny=p.second+dy[i];
				if(d[nx][ny]==INF){
					ans++;
					que.push(P(nx,ny));
					d[nx][ny]=d[p.first][p.second]+1;
				}
			}
		}
		cout<<ans+1<<endl;
	}
	return 0;
}

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

int main()
{
  int H, W;

  while(1)
  {
    cin >> H >> W;

    if(H == 0 && W == 0) break;

    for(int i = 0; i < H; i++)
    {
      for(int j = 0; j < W; j++)
      {
        cout << "#";
      }
      cout << endl;
    }
  cout << endl;
  }

  return 0;
}


Measured memory_bytes: 3092
from __future__ import print_function
import sys


if sys.subversion[0] == "PyPy":
    import io, atexit

    sys.stdout = io.BytesIO()
    atexit.register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))

    sys.stdin = io.BytesIO(sys.stdin.read())
    input = lambda: sys.stdin.readline().rstrip()
RS = raw_input
RA = lambda x=int: map(x, RS().split())
RN = lambda x=int: x(RS())


def solve():
    ans = 0
    for i in range(1, n+1):
        if i % 2 == 1 and a[i-1] % 2 == 1:
            ans += 1
    print(ans)
    return




n = RN()
a = RA()
solve()


Measured memory_bytes: 65036
#include <iostream>
#include <utility>
#include <stdint.h>

using namespace std;

int main()
{
  uint64_t L,R;
  cin >> L >> R;

  uint64_t min_ = 2018;
  
  for (uint64_t ii=L; ii<R && ii<L+2030; ++ii) {
    for (uint64_t jj=ii+1; jj<=R && jj<ii+2030; ++jj) {
      min_ = min((ii*jj)%2019, min_);
    }
  }

  cout << min_ << endl;

  return 0;
}


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

int main()
{
	int N;
	int abc[100010][3]={};
	int dp[100010][3]={};
	
	cin >> N;
	for(int i=1;i<=N;i++)
		for(int j=0;j<3;j++)
			cin >> abc[i][j];
	
	for(int i=0;i<N;i++)
	{
		dp[i+1][0]=max(dp[i][1]+abc[i+1][0],dp[i][2]+abc[i+1][0]);
		dp[i+1][1]=max(dp[i][0]+abc[i+1][1],dp[i][2]+abc[i+1][1]);
		dp[i+1][2]=max(dp[i][0]+abc[i+1][2],dp[i][1]+abc[i+1][2]);
	}
	
	cout << max({dp[N][0],dp[N][1],dp[N][2]}) << endl;
	return 0;
}



Measured memory_bytes: 2560
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! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

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

// Test Code
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
}

use std::collections::HashMap;
use std::collections::VecDeque;

fn main() {
    println!("{}", solve(&stdin!()));
}

fn solve(src: &str) -> String {
    input!{
        source = src,
        n: usize,
        k: usize,
        pn: [usize; n],
    }

    let pnn = expected_values(pn);
    let mut q = VecDeque::new();
    let mut max: f64 = -1.0;
    let mut s: f64 = 0.0;
    for i in 0..n {
        s += pnn[i];
        q.push_back(pnn[i]);
        if q.len() > k {
            let qv = match q.pop_front() {
                Some(x) => x,
                None => -10000.0,
            };
            s -= qv;
        }
        if q.len() == k {
            if s > max {
                max = s;
            }
        }
    }

    return max.to_string();
}


fn expected_values(ns: Vec<usize>) -> Vec<f64> {
    let mut ev: HashMap<usize, f64> = HashMap::new();
    let mut vec: Vec<f64> = Vec::new();
    for n in ns.iter() {
        let mut a : f64 = match ev.get(n) {
            Some(x) => *x,
            None => -1.0
        };


        if a < 0.0 {
            let mut sum: usize = 0;
            for i in 1..(n+1) {
                sum += i;
            }
            a = (sum as f64) / (*n as f64);
            ev.insert(*n, a);
        } else {
            // println!("skip, {} - {}", n, a);
        }

        vec.push(a);
    }

    return vec;
}


Measured memory_bytes: 11504
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>

#define max 100000

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main()
{
    int i, n, k, h[max], cnt=0;
    
    scanf("%d%d", &n, &k);
    for (i=0; i<n; i++) {
        scanf("%d", &h[i]);
        if (h[i]>=k) {
            cnt++;
        }
    }
    
    printf("%d", cnt);
    
    return 0;
}



Measured memory_bytes: 512
#include <iostream>
#include <algorithm>

using namespace std;


int main() {
   long long i,j,k,m,n,a,b,r;

   cin >> k >> a >> b;

  r = a % k;
  if ((r == 0) || ((a+(k-r)) <= b)) {
    cout << "OK" << endl;
  }
  else     cout << "NG" << endl;


  return 0;
}


Measured memory_bytes: 3636
N = gets.to_i

res = Array.new
N.times do |i|
	city, score = gets.split(' ')
	res.push([city, score.to_i, i+1])
end

res.sort!{|a,b| a[0]==b[0] ? b[1]<=>a[1] : a[0]<=>b[0]}

N.times do |j|
	puts res[j][2]
end

Measured memory_bytes: 1788
def main():
    n, x, y = map(int, input().split())
    m = [0] * (n - 1)
    for i in range(1, n):
        for j in range(i + 1, n + 1):
            p = min([abs(i - j), abs(x - i) + 1 + abs(j - y), abs(y - i) + 1 + abs(j - x)])
            m[p - 1] += 1

    ans = "\n".join(map(str, m))
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include <stdio.h>
int partition(int *,int,int);

int main(){
  int i,A[1000000],num,pa;

  scanf("%d",&num);

  for(i=0;i<num;i++){
    scanf("%d",&A[i]);
  }

  pa = partition(A,0,num-1);

 for(i=0;;i++){
    printf("%d",A[i]);
    if(i>=pa-1){
      break;
    }
    printf(" ");
  }

 printf(" [%d] ",A[pa]);
  
  for(i=pa+1;;i++){
    printf("%d",A[i]);
    if(i>=num-1){
      break;
    }
    printf(" ");
  }

  printf("\n");

  return 0;
}

int partition(int A[],int p,int r){
  int x = A[r];
  int i = p-1,j,tmp;

  for(j=p;j<r;j++){
    if(A[j] <= x){
      i++;
      tmp = A[i];
      A[i] = A[j];
      A[j] = tmp;
    }
  }

  tmp = A[i+1];
  A[i+1] = A[r];
  A[r] =tmp;

  return i+1;
}

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

c0=0
c1=0
c2=0
c3=0
for i in range(n):
  Sn=input()
  if Sn=="AC":
    c0+=1
  elif Sn=="WA":
    c1+=1
  elif Sn=="TLE":
    c2+=1
  elif Sn=="RE":
    c3+=1
 
print("AC x "+(str(c0)))
print("WA x "+(str(c1)))
print("TLE x "+(str(c2)))
print("RE x "+(str(c3)))

Measured memory_bytes: 9232
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <set>
#include <vector>
using namespace std;

set<string> D, F;

void insert(const string &s) {
  F.insert(s);
  for(int i = 0; i < s.size(); ++i) {
    if(s[i] == '/') D.insert(s.substr(0,i+1));
  }
}

string cut(string s) {
  string in;
  string t = "/";
  bool isD = *s.rbegin() == '/';
  replace(s.begin(), s.end(), '/', ' ');
  stringstream ss(s);
  while(ss >> in) {
    if(in == ".") continue;
    if(in == "..") {
      if(t.size() < 2) return "";
      int p = t.rfind('/',(int)t.size()-2);
      t.erase(p+1);
    } else {
      t += in;
      if(!ss.eof() || isD) {
	t += "/";
	if(!D.count(t)) return "";
      }
    }
  }
  return t;
}

int main() {
  int N, M;
  while(cin >> N >> M && N|M) {
    F.clear();
    D.clear();
    string s, t;
    while(N--) {
      cin >> s;
      insert(s);
    }
    while(M--) {
      cin >> s >> t;
      s = cut(s);
      t = cut(t);
      if(s == "" || t == "") {
	cout << "not found" << endl;
	continue;
      }
      vector<string> a,b;
      if(*s.rbegin() == '/') {
	a.push_back(s+"index.html");
      } else {
	a.push_back(s);
	a.push_back(s+"/index.html");
      }
      if(*t.rbegin() == '/') {
	b.push_back(t+"index.html");
      } else {
	b.push_back(t);
	b.push_back(t+"/index.html");
      }
      int found = 0;
      bool yes = false;
      for(int i = 0; i < a.size() && !yes; ++i) {
	for(int j = 0; j < b.size() && !yes; ++j) {
	  bool fa, fb;
	  fa = F.count(a[i]);
	  fb = F.count(b[j]);
	  if(fa) found |= 1;
	  if(fb) found |= 2;
	  if(fa && fb && a[i] == b[j]) yes = true;
	}
      }
      if(found != 3) cout << "not found" << endl;
      else if(yes) cout << "yes" << endl;
      else cout << "no" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 0
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)

    # divisors.sort()
    return divisors


def input():
    return sys.stdin.readline().rstrip()


def main():
    N = int(input())

    res = 0
    divisors = make_divisors(N)
    for d in divisors:
        m = d - 1
        if m > 0:
            if (N // m) == (N % m):
                res += m

    print(res)


if __name__ == '__main__':
    main()


Measured memory_bytes: 39276
n=int(input())
A=list(map(int,input().split()))
dic={}
ans=0
for i in range(n):
    x=i-A[i]
    y=i+A[i]
    if x in dic:
        ans+=dic[x]
    if y in dic:
        dic[y]+=1
    else:
        dic[y]=1
print(ans)

Measured memory_bytes: 40464
// B - Iron Bar Cutting
// https://atcoder.jp/contests/ddcc2020-qual/tasks/ddcc2020_qual_b
#include <bits/stdc++.h>
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007      //10^9+7
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define Vec(K, L, N, S) vector<L> K(N, S)
#define rt sqrt
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vs = vector<string>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli c, h, k, n, w, ans = 0, sum = 0, count = 0;
  string s, t;
  cin >> n;
  vlli a(n), b(n + 1, 0);
  rep(i, 0, n)
  {
    cin >> a[i];
    b[i + 1] = b[i] + a[i];
  }
  ans = b[n];
  rep(i, 0, n)
  {
    ans = min(ans, abs(b[i] - (b[n] - b[i])));
  }
  cout << ans << endl;
}

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

#define MOD 10000007
#define f first
#define s second
#define es " "
#define pb push_back
#define endl "\n"
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define ll long long int
#define fastio ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)

int main(){
    fastio;
    int n, k, resp=0, x;
    cin >> n >> k;
    for(int i=1; i<=n; i++){
        cin >> x;
        if(x>=k){
            resp++;
        }
    }
    cout << resp << endl;
    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <climits>
#include <cmath>
#include <cstring>
#include <cassert>
#include <chrono>
#include <random>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
using namespace std;

#define pb push_back
#define fst first
#define snd second

#ifdef QLEG_DEBUG
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) { os << '{'; string sep; for (const auto& x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream& os, const pair<A, B>& p) { return os << '(' << p.first << ", " << p.second << ')'; }
void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll, ll>;
template<typename T> using min_queue=priority_queue<T,vector<T>,greater<T>>;

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

  ll N, X, M; cin>>N>>X>>M;

  vector<ll> v = {X};
  vector<int> lst(M, -1);
  lst[X] = 0;
  int l = -1;
  while (1) {
    ll y = v.back() * v.back() % M;
    if (lst[y] != -1) {
      l = lst[y];
      break;
    }
    lst[y] = v.size();
    v.pb(y);
  }
  ll per = accumulate(v.begin()+l, v.end(), 0LL);
  ll res = accumulate(v.begin(), v.begin() + min(N, (ll)l), 0LL);
  dbg(l,per,res);
  N = max(N-l, 0LL);
  int K = v.size() - l;
  res += per * (N/K) + accumulate(v.begin()+l, v.begin()+l+N%K, 0LL);

  cout << res << '\n';
}


Measured memory_bytes: 4156
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    string s; cin >> s;
    ll x = stoll(s);
    ll t = 0;
    rep(i,s.size()) t += s[i]-'0';
    if(x % t) cout << "No" << endl;
    else cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,m;
	cin >> n >> m;
	vector<vector<pair<long long,long long>>> graph(n);
	for(int i=0;i<m;i++){
		long long a,b,c;
		cin >> a >> b >> c;
		a--;
		b--;
		c *= (-1);
		graph[a].push_back({b,c});
	}
	vector<long long> dist(n,1LL<<60);
	dist[0] = 0;
	auto bf = [&](int x){
		for(int i=0;i<x;i++){
			for(int j=0;j<n;j++){
				for(auto p:graph[j]){
					if(dist[p.first] > dist[j] + p.second){
						dist[p.first] = dist[j] + p.second;
                    }
				}
			}
		}
	};
	bf(n-1);
	long long ans = dist[n-1];
	bf(n);
	if(ans != dist[n-1]) cout << "inf" << endl;
	else cout << -ans << endl;
}


Measured memory_bytes: 3648
import math
r,g,b,n = map(int,input().split())

max_r, max_g = math.floor(n/r),math.floor(n/g)

c = 0
for i in range(max_r+1):
    for j in range(max_g+1):
        b_n = n - (i*r) - (j*g)
        if b_n < 0:
            continue
        if b_n % b == 0:
            c += 1

print(c)

Measured memory_bytes: 40940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    ll n,m,d; cin >> n >> m >> d;
    if(d == 0){
        double ans = (double)(m-1)/n;
        printf("%.10lf\n", ans);
    }
    else{
        double ans = (m-1)*(double)2*(n-d)/(n*n);
        printf("%.10lf\n", ans);
    }
}

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

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


Measured memory_bytes: 3068
n=int(input())
pyramid=[list(map(int, input().split())) for i in range(n)]
pyramid=sorted(pyramid, key=lambda p:p[2])
for x in range(101):
    for y in range(101):
        px=pyramid[-1][0]
        py=pyramid[-1][1]
        ph=pyramid[-1][2]
        h=ph+abs(x-px)+abs(y-py)
        for i in range(n):
            px=pyramid[i][0]
            py=pyramid[i][1]
            ph=pyramid[i][2]
            if not (ph==max(h-abs(x-px)-abs(y-py), 0)):
                break
            if i==n-1:
                print(x,y,h)
                exit()

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int mod = 1e9 + 7;
const int N = 5050;
const int K = 20;
int dp1[N], dp2[N][N], sz[N], a[N];
vector < int > g[N];
int s[N];
void dfs(int v, int p = -1){
    sz[v]++;
    if (a[v] > 0) dp1[v] = 0;
    for (auto u: g[v]){
        if (u == p) continue;
        dfs(u, v);
        for (int i = 0; i < sz[u]; i++){
            if (dp1[u] + 1 < N) dp2[u][dp1[u] + 1] = min(dp2[u][dp1[u] + 1], 0LL);
        }
        for (int i = 0; i < sz[u]; i++){
            if (dp2[u][i] <= 0){
                if (dp2[u][i] != 0) dp1[u] = min(dp1[u], i + 1);
                dp2[u][i + 1] = min(dp2[u][i + 1], 0LL);
            }
        }
        if (sz[v] == 1){
            for (int i = 0; i <= sz[u]; i++) dp2[v][i] = dp2[u][i];
        } else{
            for (int i = sz[v] + sz[u]; i >= 0; i--){
                dp2[v][i] = dp2[v][i] + dp2[u][0];
                for (int j = min(sz[u], i); j >= 1; j--){
                    dp2[v][i] = min(dp2[v][i], dp2[v][i - j] + dp2[u][j]);
                }
            }
        }
        sz[v] += sz[u];
        dp1[v] += dp1[u];
    }
   // cout << "s[v] = " << s[v] << " v = " << v << endl;
    if (g[v].size() == 1 && p != -1){
        if (a[v] > 0){
            dp1[v] = 0;
            dp2[v][0] = a[v];
        } else{
            dp2[v][0] = a[v];
        }
    } else{
        for (int i = 0; i < sz[v]; i++){
        dp2[v][i] += a[v];
        }
    };
   // cout << "v = " << v << " " << dp1[v] << endl;
   // for (int i = 0; i <= sz[v]; i++){
   //     cout << dp2[v][i] << " ";
   // }
  //  cout << endl;
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
   // freopen("input.txt", "r", stdin);
    int n;
    cin >> n;
    srand(time(NULL));
    for (int i = 0; i <= n; i++){
        dp1[i] = 1e15;
        for (int j = 0; j <= n; j++){
            dp2[i][j] = 1e15;
        }
    }
    for (int i = 1; i <= n; i++){
        cin >> a[i];
    }
    for (int i = 1; i < n; i++){
        int u, v;
        cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
    }
    int iv = rand() % n + 1;
    dfs(iv);
    int ans = dp1[iv];
    for (int i = 0; i <= n; i++){
        if (dp2[iv][i] < 0) ans = min(ans, i);
    }
    cout << ans;
}


Measured memory_bytes: 199552
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
struct City {
    City(int i, int p, int y) : i(i), p(p), y(y) {}
    int i, p, y;
    int id_lower;
};
int main() {
    int N, M;
    scanf("%d %d%*c", &N, &M);
    vector<int> num(N, 1);
    vector<City> cities;
    for (int i = 0; i < M; i++) {
        int p, y;
        scanf("%d %d%*c", &p, &y);
        cities.emplace_back(i, p, y);
    }
    sort(cities.begin(), cities.end(), [](const auto& p, const auto& q) { return p.y < q.y; });
    for (auto& city : cities) {
        city.id_lower = num[city.p-1]++;
    }
    sort(cities.begin(), cities.end(), [](const auto& p, const auto& q) { return p.i < q.i; });
    for (const auto& city : cities) printf("%06d%06d\n", city.p, city.id_lower);
}

Measured memory_bytes: 3568
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

struct UFTree {
private:
	vector<int> mNode;
	vector<int> mRank;
	vector<int> mNodeNum;

public:
	UFTree(int n) : mNode(n), mRank(n), mNodeNum(n)
	{
		for (int i = 0; i < n; i++) {
			mNode[i] = i;
			mNodeNum[i] = 1;
		}
	}

	int find(int x)
	{
		if (mNode[x] == x) {
			return x;
		}
		else {
			mNode[x] = find(mNode[x]);
			return mNode[x];
		}
	}

	void unite(int x, int y)
	{
		int idxX = find(x);
		int idxY = find(y);

		if (idxX == idxY) {
			return;
		}

		if (mRank[idxX] > mRank[idxY]) {
			mNode[idxY] = idxX;
			mNodeNum[idxX] += mNodeNum[idxY];
		}
		else {
			mNode[idxX] = idxY;
			mNodeNum[idxY] += mNodeNum[idxX];
			if (mRank[idxX] == mRank[idxY]) {
				mRank[idxY]++;
			}
		}
	}

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

	int getNodeNum(int x)
	{
		auto node = find(x);
		return mNodeNum[node];
	}
};


int main()
{
	int N, M;
	cin >> N >> M;
	vector<pair<int, int>> e;
	for (auto i = 0; i < M; ++i)
	{
		int A, B;
		cin >> A >> B;
		--A;
		--B;
		e.push_back({ A, B });
	}

	UFTree t(N);
	vector<ll> ans;
	ans.push_back((ll)N * (N - 1) / 2);
	for (auto i = M - 1; i > 0; --i)
	{
		auto p = e[i];
		auto num = *ans.rbegin();
		if (!t.isSameSet(p.first, p.second))
		{
			num -= (ll)t.getNodeNum(p.first) * t.getNodeNum(p.second);
			t.unite(p.first, p.second);
		}
		ans.push_back(num);
	}

	reverse(ans.begin(), ans.end());
	for (auto i = 0; i < (int)ans.size(); ++i)
	{
		cout << ans[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 4212
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

void solve(){
  string s; cin >> s;
  int n = s.size();
  ll mod = 1000000007;
  vector<ll> dp(13, 0);
  dp[0] = 1;
  ll ten = 1;
  for(int i = n - 1; i >= 0; i--){
    vector<ll> dp2(13, 0);
    for(int j = 0; j < 13; j++){
      ll x = dp[j];
      if(s[i] != '?'){
        int num = s[i] - '0';
        num = (num * ten) % 13;
        dp2[(j + num) % 13] = (dp2[(j + num) % 13] + x) % mod;
      }
      else{
        for(int k = 0; k <= 9; k++){
          int num = (k * ten) % 13;
          dp2[(j + num) % 13] = (dp2[(j + num) % 13] + x) % mod;
        }
      }
    }
    ten = (ten * 10) % 13;
    dp = dp2;
  }
  cout << dp[5] << endl;
  return;
}

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


Measured memory_bytes: 512
import pprint
D = int(input())
A = [[0]*26]*D
S = 0
C = list(map(int,input().split()))
P = 0
ld =[0]*26#最後に行った日の格納
l = [0]*26#損失の計算
sp = 0#一時格納
t = [0]*D
for i in range(D):
  A[i] = list(map(int,input().split()))
for j in range(D):
  maxvalue = max(A[j])
  index = A[j].index(maxvalue)
  for n in range(26):
    ld[n] = ld[n]+1
  sp = ld[index]
  ld[index] = 0 
  for k in range(26):
    l[k] = C[k]*ld[k]
  lmax =max(l)
  if 13*lmax > maxvalue:
    lindex = l.index(lmax)
    ld[index] = sp
    ld[lindex] = 0
    for m in range(26):
      l[m] = C[m]*ld[m]
  S = S+maxvalue-sum(l)
  t[j] = index+1
[print(i) for i in t]

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

int main() {
    long long x;
    cin >> x;

    long long cnt = 0;
    for (int i = 1; i <= x; i++) {
        cnt += i;
        if (cnt >= x) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

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

    int n;
    cin >> n;
    vector<int> l(n);
    rep(i, n) cin >> l[i];
    sort(l.begin(), l.end(),greater<int>());
    int cnt = 0;
    for (int i = 0; i < n-2;i++){
        for (int j = i+1; j < n-1; j ++){
            int len = l[i] - l[j];
            if (len < 0)
                break;
            for (int k = j + 1; k < n ; k++){
                if(l[k]>len)
                    cnt++;

            }
        }
    }
    cout << cnt << endl;
    }

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vb vector<bool>
#define vi vector<int>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -(1e18)
#define inf 1e18
#define f first
#define se second
#define mod 1000000007
using namespace std;
using namespace __gnu_pbds; 
ll mi(ll n,ll m){ll pw=n%m;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans%mod;}
ll pw(ll a,ll n){ll pw=a;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw;pw = pw*pw;ex>>=1;}return ans;}
ll pwm(ll a,ll n){ll pw=a%mod;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw%mod;pw = pw*pw%mod;ex>>=1;}return ans%mod;}
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
template<typename T> using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//st.order_of_key(num)->number of elements <=num
//st.find_by_order(i)->iterator of ith element in sorted order starting from zero
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define mkp make_pair
//#define d double
//#define int long long int
//Binary_Search->dp->greedy
void solve(){
	ll n,m;
	cin>>n>>m;
	ll s=n+m;
	ll ans=(s*(s-1))/2;
	ans-=(n*m);
	cout<<ans<<endl;
 
 
 
 
}
int32_t main(){
int t=1;
//scanf("%d",&t);
while(t--){
	solve();
}
}   

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
       int A =sc.nextInt();
      int B =sc.nextInt();
      int C =sc.nextInt();
      int K =sc.nextInt();
      
      for(int i=1; i<=K; i++){
      if(K-A==0){
      System.out.println(A*1);
        return;
      }
        if(K-A<0){
        System.out.println(K*1);
          return;
        }
        if((K-A)-B<=0){
         System.out.println(A*1+B*0);
          return;
        }
        if((K-A)-B>0){
        System.out.println(A*1+B*0+(((K-A)-B)*(-1)));
          return;
        }
      }
    }
}

Measured memory_bytes: 35568
import bisect
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()

#print(bisect.bisect_left(A, 13))

ct_AB = [0 for _ in range(N)] 
for i in range(N):
  ct_AB[i] = bisect.bisect_left(A, B[i])

ct_AB_sum = [0 for _ in range(N)] 
ct_AB_sum[0] = ct_AB[0]
for i in range(1,N):
  ct_AB_sum[i] = ct_AB[i] + ct_AB_sum[i-1]
  
ans = 0
for i in range(N):
  j = bisect.bisect_left(B, C[i]) - 1
  #print(i, j, ct_AB_sum[j])
  if j >= 0:
    ans += ct_AB_sum[j]
print(ans)
  
  
  

  
  
  

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

int main() {
  int N;
  cin >> N;
  
  vector<uint64_t> L(N+1);
  L.at(0) = 2LL;
  L.at(1) = 1LL;
  for (int i = 2; i<N+1; i++) {
    L.at(i) = L.at(i-1) + L.at(i-2); 
  }
  printf("%lld\n", L.at(N));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;

// string S;

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

  int y, m, d;
  scanf("%d/%d/%d", &y, &m, &d);

  // printf("%d/%d/%d\n", y, m, d);

  // 5/1以降
  string res = (y >= 2019 && m >= 5) ? "TBD" : "Heisei";
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
//Robs Code
/***********HEADER***************/
#include <iostream>
#include <bitset>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#include <list>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <set>
#include <queue>
#include <map>
/***********MACROS***************/
#define int long long int
#define fri(l,k) for (i=l;i<=k;i++)
#define frj(l,k) for (j=l;j>=k;j--)
#define fij(a,b,l,k) for(i=a;i<=b;i++) for(j=l;j<=k;j++)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define mxsz 1e5+10
#define mod 1e9 + 7
#define pii pair<int,int>
using namespace std;
const int N = 1e5 + 1;
int n,m,i,j,l,k,x,y,a,b,cnt[3],sum[3];
/***********MAIN**************/
int dp[(int)1e5+1][2];
int v[(int)100+1];
bool brute(int k,int flag){
	if(k < 0){
		return 0;
	}
	if(k == 0){
		return 1;
	}
	if(dp[k][flag] != -1){
		return dp[k][flag]^1;
	}
	bool ans = 0;
	for(int i=0;i<n;i++){
		ans = ans||(brute(k-v[i],flag^1));
	}
	// cout<<k<<" "<<flag<<" "<<ans<<"\n";
	dp[k][flag] = ans;
	return ans^1;
}
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>v[i];
	}
	memset(dp,-1,sizeof dp);
	brute(k,0);
	if(dp[k][0])
		cout<<"First";
	else cout<<"Second";
    return 0;
}
//.........

Measured memory_bytes: 6528