akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a==b)
    {
        cout<<a;
    }
    else if(a>b)
        cout<<a-1;
    else if(a<b)
        cout<<a;
    return 0;
}





Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
n,m = list(map(int, readline().split()))
py = []
for _ in range(m):
    py.append(list(map(int, readline().split())))

spy = sorted(py, key=lambda x: x[1])

Y = {}
for i in range(m):
    Y[spy[i][1]] = 0

P = [0 for _ in range(n+1)]

for i in range(m):
    P[spy[i][0]] += 1
    Y[spy[i][1]] = P[spy[i][0]]

for i in range(m):
    print(str(py[i][0]).zfill(6) + str(Y[py[i][1]]).zfill(6))


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

dp = [0] * (n + 1)
dp[0] = 1
for i in range(n):
  if n >= i + 4 and dp[i] >= 1:
    dp[i + 4] = 1
  if n >= i + 7 and dp[i] >= 1:
    dp[i + 7] = 1

if dp[n] == 0:
  print("No")
else:
  print("Yes")

Measured memory_bytes: 3060
#include <algorithm>
#include <cmath>
#include <climits>
#include <functional>
#include <iostream>
#include <queue>
#include <string>
#include <numeric>
#include <vector>

using namespace std;
using ll = long long;
template<typename T> void print(T t) {cout << t << endl;}

int main() {
	string S; cin >> S;
	int N = (int)S.length();
	for (size_t n = N/2-1; n >=0; n--) {
		bool ok = true;
		for (int j = 0; j < n; j++) {
			if (S[j] != S[j + n]) ok = false;
		}
		if (ok) {
			print(n * 2);
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3560
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
        self._size = [1] * (n+1)

    # return root of x
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 木の併合、入力は併合したい各ノード
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        self._size[x] = self._size[y] = self._size[x] + self._size[y]
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def same_check(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        return self._size[self.find(x)]


def main():
    n, m = map(int, input().split())
    u = UnionFind(n)
    for _ in range(m):
        x, y, z = map(int, input().split())
        u.unite(x, y)
    s = set()
    for i in range(1, n+1):
        s.add(u.find(i))
    print(len(s))
    
    
main()

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

// https://atcoder.jp/contests/abc124/tasks/abc124_a
using namespace std;


int main(){
 int a,b;
 cin>>a;
 cin>>b;
 int s = 0 ;
 int may;
 if(a > b){
  s = a;
  a--;
  if( a > b){
   s += a;
  }else{
   s+=b;
  }
 }else{
 s = b;
 b--;
 if(b > a ){
  s+=b;
 }else{
  s+=a;
 }
 }
 cout<<s<<endl;	
 return 0;
}

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

int compare_int(const void *a, const void *b){
    return *(int*)a - *(int*)b;
}
int compare_int2(const void *a, const void *b){
    return *(int*)b - *(int*)a;
}


int main(void){
    int N,M;
    scanf("%d %d",&N,&M);
        int X[M];
        for(int i=0;i<M;i++){
            scanf("%d",&X[i]);
        }
    if(N<M){
        qsort(X,sizeof(X)/sizeof(int),sizeof(int),compare_int);
        int L[M-1];
        for(int i=0;i<M-1;i++){
            L[i] = X[i+1]-X[i];
        }
        qsort(L,sizeof(L)/sizeof(int),sizeof(int),compare_int2);
        int sum = 0;
        for(int i=0;i<N-1;i++){
            sum += L[i];
        }
        printf("%d",X[M-1]-X[0]-sum);
    }else{
        printf("0");
    }
    return 0;
}

Measured memory_bytes: 1268
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<cctype>
#include<string.h>
#include <stdlib.h>

#define PI 3.1415926
void swap(int* x, int* y) {
	int a = *x;
	int b = *y;
	*x = b;
	*y = a;
}
int factorial(int n);
int sum(int n, int*);
int ave(int n, int*);
int min(int n, int*), min(int n, int m);
int max(int n, int*), max(int n, int m);

int main() {
	int N,ichi[50];
	char y[400], X[400];
	int ans = 0;
	int k;
	int flag = 0;
	int a1, a2;
	scanf("%d", &N);
	scanf("%s", &y);
	//printf("%s\n", y);
	

	//while (1) {
		//scanf("%d", &n);
		//printf("%c\n", x[n]);
		//if (n == 0) break;
	//}
	//printf("%d\n", strlen(x));
	//printf("%s\n", y);
	for (int i = 1; i <= N; i++) {
		flag = 0;
		scanf("%s", &X);
		k = 0;
		//printf("%s\n", y);
		//printf("%s\n", X);
		for (int j = 0; j <= strlen(X);j++) {
			for (int k = 0; k <= strlen(X); k++) {
				for (int l = 0; l < strlen(y); l++) {
					//printf("%d %c\n", l, y[l]);
					//printf("%s\n", y);
					if (j*l + k >= strlen(X))break;
					if (y[l] != X[j*l + k]) {
						break;
					}
					if (l == strlen(y) - 1) {
						flag = 1;
						//printf("%d %d\n", ans,i);
						//printf("%d %d\n", j, k);
						for (int m = 0; m < strlen(y); m++) {
							//printf("%d%c", k + m*j, X[k + m * j]);
						}
						//printf("\n");
						break;
					}
				}
				if (flag == 1)break;
			}
		}
		if (flag == 1) {
			ans++;
		}

	}
	printf("%d\n", ans);
	return 0;
}

int factorial(int n) {
	if (n > 0) {
		return n * factorial(n - 1);
	}
	else {
		return 1;
	}
}
int sum(int n, int *all) {
	int total = 0;
	for (int i = 0; i < n; ++i) {
		total += all[i];
	}
	return total;
}
int ave(int n, int *all) {
	int total = 0;
	for (int i = 0; i<n; ++i) {
		total += all[i];
	}
	return total / n;
}
int min(int n, int *all) {

	int min = all[0];
	for (int i = 1; i < n; ++i) {
		if (all[0] > all[i]) {
			min = all[i];
		}
	}
	return min;
}
int max(int n, int *all) {
	int max = all[0];
	for (int i = 1; i<n; ++i) {
		if (all[0]<all[i]) {
			max = all[i];
		}
	}
	return max;
}
int max(int n, int m) {
	if (n >= m) {
		return n;
	}
	else {
		return m;
	}
}
int min(int n, int m) {
	if (n >= m) {
		return m;
	}
	else {
		return n;
	}
}

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

int main(){
  int sx,sy,tx,ty;
  cin >> sx >> sy >> tx >> ty;
  int x=tx-sx,y=ty-sy;

  cout << string(y,'U') << string(x,'R');

  cout << string(y,'D') << string(x,'L');

  cout << 'L' << string(y+1,'U') << string(x+1,'R') << 'D';

  cout << 'R' << string(y+1,'D') << string(x+1,'L') << 'U';

  cout << endl;
  
 }

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <list>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef long double ld;
using namespace std;
int main(){
	int h, w;
	cin >> h >> w;
	int c[10][10];
	REP(i, 10){
		REP(j, 10) cin >> c[i][j];
	}
	int d[10][10];
	REP(i, 10){
		REP(j, 10){
			d[i][j] = c[i][j];
		}
	}
	REP(i, 10){
		REP(j, 10){
			REP(k, 10){
				d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
			}
		}
	}
	ll ans = 0;
	REP(i, h*w){
		int a;
		cin >> a;
		if(a != -1){
			ans += d[a][1];
		}
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

long long arr[100001];

int main(){
    long long n, k, q;
    cin >> n >> k >> q;
    for(long long i = 0; i < q; ++i){
        long long tmp; cin >> tmp;
        arr[tmp]++;
    }
    for(long long i = 1; i <= n; ++i){
        if(k - (q - arr[i]) <= 0){
            cout << "No" << endl;
        }else cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<cstring>
using namespace std;
char s[200050];
int main ()
{   scanf("%s",s+1);
    int len=strlen(s+1);
    int sum=0;
    for(int i=1;i<=len;i++)
    {   sum+=s[i]-'0';
	}
	if(sum%9==0) printf("Yes");
	else printf("No");
}

Measured memory_bytes: 3912
#include <stdio.h>

int main(void)
{
	int n;
	scanf("%d", &n);
	if((n/100+10)%10 == 1){
		n += 800;
	}else{
		n -= 800;
	}

	if(n/10%10 == 1){
		n += 80;
	}else{
		n -= 80;
	}

	if(n%10 == 1){
		n += 8;
	}else{
		n -= 8;
	}

	printf("%d\n", n);
	return 0;
}

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

string S;

int main(void) {
	cin >> S;
	int cnt_0 = count(S.begin(), S.end(), '0');
	int cnt_1 = S.length() - cnt_0;
	int cnt = min(cnt_0, cnt_1);
	cout << cnt * 2 << '\n';
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
int num[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
bool uru(int checkyear){if(checkyear%4==0){if(checkyear%100!=0||checkyear%400==0)return true;}return false;}
int gcd( int x, int y ){return y ? gcd(y, x%y) : x;}
bool pairCompare(const pairint& firstElof, const pairint& secondElof)
{
  if(firstElof.second!= secondElof.second)    return firstElof.second> secondElof.second;
  else return firstElof.first< secondElof.first;
}
signed main() {
int x=0,y=0,z=0,w=0,n=0,m=0;
std::cin >> x>>y;
z=x+y;
w=x-y;
n=x*y;
if(z>=w){
  if(z>=n)std::cout << z << '\n';
  else std::cout << n << '\n';
}else{
  if(w>=n)std::cout << w << '\n';
  else std::cout << n << '\n';

}
}


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

int main() {
    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> students;
    vector<pair<int, int>> checkpoint;
    int temp1, temp2;
    for (int i = 0; i < N; ++i) {
        cin >> temp1 >> temp2;
        students.emplace_back(make_pair(temp1, temp2));
    }

    for (int i = 0; i < M; ++i) {
        cin >> temp1 >> temp2;
        checkpoint.emplace_back(make_pair(temp1, temp2));
    }

    for (int i = 0; i < N; ++i) {
        int ans = 1, temp = abs(students[i].first - checkpoint[0].first) + abs(students[i].second - checkpoint[0].second);
        for (int j = 0; j < M; ++j) {
            int length = abs(students[i].first - checkpoint[j].first) + abs(students[i].second - checkpoint[j].second);
            if(temp > length) {
                temp = length;
                ans = j + 1;
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#include<cstring>
#include<cstdio>
#include<cmath>
#include<iostream>
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
using namespace std;
const long long Maxn=1e5+5;
typedef long long ll;

int s[4];

int main(){
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	s[1]=a;
	s[2]=b;
	s[3]=c;
	sort(s+1,s+1+3);
	int x=s[3]-s[1];
	int y=s[3]-s[2];
	int sum=x+y;
	if(sum%2==0) printf("%d",sum/2);
	else{
		int sid=(sum+1)/2+1;
		printf("%d",sid);
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
ll dp[401][401];

ll f(int i, int j, ll *a, ll *b)
{
    if(i==j)
    {
        return 0;
    }
    if(dp[i][j]!=-1)return dp[i][j];
    ll ans=1e18;
    for(int l=i;l<j;l++)
    {
        ans=min(ans, f(i, l, a, b)+f(l+1, j, a, b));
    }
    dp[i][j]=ans+b[j]-((i-1)<0?0:b[i-1]);
    return dp[i][j];
}

int main()
{
   memset(dp, -1, sizeof(dp));
   int n;
   cin>>n;
   ll a[n], b[n];
   for(int i=0;i<n;i++)cin>>a[i];
   b[0]=a[0];
   for(int i=1;i<n;i++)
   {
       b[i]=b[i-1]+a[i];
   }
   cout<<f(0, n-1, a, b)<<endl;
   return 0;
}


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

int main() {
	int n; cin>>n;
	long double inv,sum=0;
	int a[n];
	for(int i=0;i<n;i++) { 
		cin>>a[i];
		sum+=(1.000/a[i]);
	}
	inv=1/sum;
	cout<<inv<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 4

int main(){
  int i, s=0, t=0, a[4], b[4];

  for(i=0; i<N; i++) scanf("%d", &a[i]);
  for(i=0; i<N; i++) scanf("%d", &b[i]);

  for(i=0; i<N; i++) s += a[i];
  for(i=0; i<N; i++) t += b[i];

  if(s >= t) printf("%d\n", s);
  else printf("%d\n", t);

  return 0;
}

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

int main(int argc, char const *argv[]) {
    map<string, int> m;
    int n;
    cin >> n;

    for (size_t i = 0; i < n; i++) {
        string key;
        cin >> key;
        m[key] = 1;
    }

    cout << m.size() << endl;
    return 0;
}


Measured memory_bytes: 19200
#include <bits/stdc++.h>
using namespace std;
int main(){
  string a,b;
  cin>>a>>b;
  int y=stoi(a+b);

  
  int f=0;
  for(int i=0;i<1000000;i++){
    if(i*i==y)++f;
  }
  
  if(f>0){cout<<"Yes"<<endl;}
  else
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define FOR0(i,n) for(int i=0, _##i=(n); i<_##i; ++i)
#define FOR(i,l,r) for(int i=(l), _##i=(r); i<_##i; ++i)
#define FORD(i,l,r) for(int i=(r), _##i=(l); --i>=_##i; )
#define repi(i,a) for(__typeof((a).begin()) i=(a).begin(), _##i=(a).end(); i!=_##i; ++i)
#define dwni(i,a) for(__typeof((a).rbegin()) i=(a).rbegin(), _##i=(a).rend(); i!=_##i; ++i)
#define SZ(a) ((int)((a).size()))
#define printCase() "Case #" << caseNum << ": "
#define pb push_back
#define mp make_pair
#define INF ((ll)1e16)
#define SYNC std::ios::sync_with_stdio(false);  cin.tie(NULL);
#define ff first
#define ss second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define N 100005
int main() {
    SYNC
    int m, n, p, a, preva;
    ll dp1[N] = {}, dp2[N] = {}, ans = INF;
    cin >> n >> m >> preva;
    while(--n) {
        cin >> a;
        int d = a - preva;
        if(a > preva) {
            dp1[preva] += d - (a + 1);
            dp1[a] += a + 1 - d;
            dp1[m] += d;
            dp2[a]++; dp2[preva]--;
        } else {
            dp1[preva] += d - a - 1;
            dp1[a] += 1 + a - d - m;
            dp1[m] += 1 + m + a;
            dp2[m]++; dp2[preva]--; dp2[a]++;
        }
        preva = a;
    }
    FORD(i,1,m+1) {
        dp2[i] += dp2[i+1];
        dp1[i] += dp1[i+1];
        ans = min(ans, dp1[i] - i*dp2[i]);  
    }
    cout << ans;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K;
  cin >> N >> K;
  vector<int> have(N, 0);
  int d, A;
  for (int i = 0; i < K; i++) {
    cin >> d;
    for (int j = 0; j < d; j++) {
      cin >> A;
      have.at(A-1)++;
    }
  }
  
  int count = 0;
  for (int i = 0; i < N; i++) {
    if (have.at(i) == 0) {
      count++;
    }
  }
  cout << count << endl;
  return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

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

	int n, y;
	cin>>n>>y; y /= 1000;
	for(int c = 0; c <= n && 10*c <= y; c++){
		for(int b = 0; b + c <= n && 5*b + 10*c <= y; b++){
			int a = n - b - c;
			if(a + 5*b + 10*c == y){
				cout<<c<<" "<<b<<" "<<a<<endl;
				exit(0);
			}
		}
	}
	cout<<-1<<" "<<-1<<" "<<-1<<endl;

	return 0;
}

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

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

  vector<long> h(N);
  for (int i = 0; i < N; i++) {
    cin >> h.at(i);
  }

  sort(h.begin(), h.end());

  long min_diff = 1000000000;
  for (int i = 0; i < N - (K - 1); i++) {
    min_diff = min(min_diff, h.at(i + (K - 1)) - h.at(i));
  }

  cout << min_diff << endl;
}


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


int main()
{
	int a;
  cin >> a;
  if (a<1200){
    cout << "ABC" << endl;
  }
  else if (a<2800){
cout <<"ARC" << endl;
  }
  else{
    cout << "AGC" << endl;
  }


	
}



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

string f(int n,int a,int b){
  for(int i = min(a,b); i <= max(a,b); i++){
      if(i%n == 0) return "OK\n";
  }
  return "NG\n";
}
int main(){
  int n,a,b;
  cin >> n >> a >> b;
  cout << f(n,a,b) << endl;
  
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <string.h>
#include <ctype.h>
#include <algorithm>
#include <math.h>

using namespace std;

struct Rest {
  string name;
  int value;
  int label;
};

int main() {
  int n;
  Rest R[110];
  cin >> n;

  for(int i = 0; i < n; i++)
    cin >> R[i].name >> R[i].value;
  for(int i = 0; i < n; i++)
    R[i].label = i+1;
  
  for(int i = 0; i < n; i++) {
    for(int j = n-1; j >= i+1; j--) {
      if(R[j].name < R[j-1].name) 
        swap(R[j],R[j-1]);
      else if(R[j].name == R[j-1].name) {
        if(R[j].value > R[j-1].value)
          swap(R[j],R[j-1]);
      }
    }
  }
  
  for(int i = 0; i < n; i++) 
    cout << R[i].label << endl;
}

Measured memory_bytes: 3500
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String t[] = s.split("");
    int ans = 0;
    for (int i = 0; i < 3; i++){
      if (t[i].equals("o")) ans += 100;
    }
    System.out.println(ans + 700);
  }
}

Measured memory_bytes: 35436
#include<bits/stdc++.h>
using namespace std;
using ull=unsigned long long;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define setbits(x)  __builtin_popcount(x)
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;

//int divr[maxn];
/**/
/*void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
/*int find(int a){
     if(a==par[a])return a;
     return par[a]=find(par[a]);
}
void unite(int a,int b){
     a=find(a),b=find(b);
     if(a==b)return ;
     par[b]=a;
}
ll modexpo(ll a,ll b)
{
     int ans=1LL;
     while(b>0)
     {
          if(b&1)ans=(ans*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return ans;
}
*/















int s[200005],t[200005],c[100005];
int res[200005],tmp[200005];
int main(){
     int n,C;
     cin>>n>>C;
     for(int i=0;i<n;i++){
          cin>>s[i]>>t[i]>>c[i];
     }
     for(int i=1;i<=C;i++){
          for(int j=0;j<200002;j++)tmp[j]=0;
          for(int j=0;j<n;j++)if(c[j]==i)tmp[2*s[j]-1]++,tmp[2*t[j]]--;
          for(int j=1;j<200002;j++)tmp[j]+=tmp[j-1];
          for(int j=0;j<200002;j++){
               if(tmp[j]>0)res[j]++;
          }
     }
     int ans=0;
     for(int i=0;i<200002;i++)ans=max(ans,res[i]);
     cout<<ans;

}



















































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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
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;}
const int MOD = 1000000007;

// 3 * 673
int main() {
    ll l, r;
    cin >> l >> r;
    ll x = 2018;
    FOR(i, l, min(r, l + 2019)) {
        FOR(j, l + 1, min(r + 1, l + 2020)) {
            chmin(x, (ll)i * j % 2019);
        }
    }
    cout << x << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    int n;
    int a;
    scanf("%d", &n);
    n=n+1;
    for (a=1;a<n;a++)
    {
        if (a%3==0)
        {
            printf(" %d", a);
        }
        else if (a%10==3)
        {
            printf(" %d", a);
        }
        else if ((a/10)%10==3)
        {
            printf(" %d", a);
        }
        else if ((a/100)%10==3)
        {
            printf(" %d", a);
        }
        else if (a/10==3)
        {
            printf(" %d", a);
        }
        else if (a/100==3)
        {
            printf(" %d", a);
        }
        else if (a/1000==3)
        {
            printf(" %d", a);
        }
 
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 600
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
#include <stack>
using namespace std;

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


int main() {
	int n;
	cin >> n;
	vector<ll> vec(n);
	vector<ll> vec2(n);
	rep(i, n) cin >> vec.at(i);
	rep(i, n) vec2.at(i) = vec.at(i);
	sort(vec2.begin(), vec2.end());
	ll med = vec2.at(n/2);
	rep(i, n) {
		if (vec.at(i)<med) cout << vec2.at(n/2) << endl;
		else cout << vec2.at(n/2-1) << endl;
	}
}

Measured memory_bytes: 5376
n,a,b,c = list(map(int,input().split()))
ls = [""]*n
moji = [""]*n
for i in range(n):
    moji[i] = input()
for i in range(n):
    s = moji[i]
    if s == "AB":
        if a > b:
            a -= 1;b+=1
            ls[i] = 'B'
        elif a < b or i == n-1:
            a += 1;b-=1
            ls[i] = 'A'
        else:
            if moji[i+1] == "AC":
                b -= 1;a += 1
                ls[i] = "A"
            else:
                a -= 1;b+=1
                ls[i] = "B"
    if s == "BC":
        if c > b:
            c -= 1;b+=1
            ls[i] = 'B'
        elif c < b or i == n-1:
            c += 1;b-=1
            ls[i] = 'C'
        else:
            if moji[i+1] == "AC":
                b -= 1;c += 1
                ls[i] = "C"
            else:
                c -= 1;b+=1
                ls[i] = "B"

    if s == "AC":
        if a > c:
            a -= 1;c+=1
            ls[i] = 'C'
        elif a < c or n-1 == i:
            a += 1;c-=1
            ls[i] = 'A'
        else:
            if moji[i+1] == "AB":
                c -= 1;a += 1
                ls[i] = "A"
            else:
                a -= 1;c+=1
                ls[i] = "C"
    if a < 0 or b < 0 or c < 0:break

if a < 0 or b < 0 or c < 0:
    print("No")
else:
    print("Yes")
    for i in range(n):
        print(ls[i])

Measured memory_bytes: 76636
#include <iostream>
#include <vector>
using namespace std;
const long INF = 1e9;
const long MOD = 1e9 + 7;
#define repi(i, n, init) for (int i = init; i < int(n); i++)

bool binary_search(vector<int> vec, int num)
{
    int left = 0, right = vec.size() - 1;
    while (right >= left)
    {
        int mid = left + (right - left) / 2;
        if (vec.at(mid) == num)
        {
            return true;
        }
        else if (vec.at(mid) > num)
        {
            right = mid - 1;
        }
        else if (vec.at(mid) < num)
        {
            left = mid + 1;
        }
    }
    return false;
}
int main()
{
    int n, q;
    cin >> n;
    vector<int> S(n);
    repi(i, n, 0)
    {
        cin >> S[i];
    }
    cin >> q;
    vector<int> T(q);
    repi(i, q, 0)
    {
        cin >> T[i];
    }

    int cnt = 0;
    bool once = false;
    repi(i, q, 0)
    {
        once = false;
        if (binary_search(S, T.at(i)) && !once)
        {
            once = true;
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3868
#include<bits/stdc++.h>
using namespace std ;
const int maxn = 2e5 + 10 ;
map < int , int > mp ;
multiset < int > s ;
int n  , ans, a[maxn] ;
int main()
{
	cin >> n ;
	for ( int i = 0; i<n ; i++)
	{
		cin>> a[i] ;
		s.insert ( a[i] ) ;
		mp[a[i]] ++ ;
	}
	while ( s.size() ) 
	{
		auto t = s.end() ; t-- ;
		s.erase ( t ) ;
		int x = *t ;
		mp[x]-- ;
		//cout<< x << " " << __builtin_clz(x) << endl;
		int y =  31 - (__builtin_clz(x)) ;
	  	int z = (x ^ ((1 << (y+1)) -1 ))+ 1 ;
		//cout << "z " << z << endl;
		if ( mp[z] )
		{
			auto a = s.find ( z ) ;
			s.erase ( a ) ;
		   mp[z]-- , ans ++ ;	
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 19712
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

ll n;
ll memo[1001] = {};

void input(){
    cin >> n;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    map<int, ll> cnt;
    for(int a=1;a<=n;a++){
        ll b = a;
        for(int i=2;i*i<=n;i++){
            while(b % i == 0){
                // cout << b << endl;
                b /= i;
                cnt[i]++;
            }
        }
        if(b > 1) cnt[b]++;
    }
    ll ans = 1;
    for(auto &p:cnt){
        // cout << p.first << endl;
        ans = (ans % MOD) * ((p.second + 1) % MOD) % MOD;
    }
    cout << ans << endl;
    return 0; 
}

Measured memory_bytes: 256
import kotlin.math.*

fun str() = readLine()!!
fun int() = str().toInt()
fun long() = str().toLong()

fun read(d:String = " ") = str().split(d)
fun <T> list(d:String = " ",f:String.()->T) = read(d).map {f(it)}
fun list() = list {toInt()}

fun <T> MutableList<T>.removeLast() = this.removeAt(this.lastIndex)

const val mod = 1000000007L

fun main() {
	abc000X()
}

val dx = arrayOf(0,1,0,-1)
val dy = arrayOf(1,0,-1,0)

fun abc000X() {
	val (h,w) = list()
	val (ch,cw) = list()
	val (dh,dw) = list()

	val a = Array(h) {str()}

	val r = Array(h) {IntArray(w) {Int.MAX_VALUE/2}}

	r[ch-1][cw-1] = 0

	val q = java.util.ArrayDeque<Triple<Int,Int,Int>>()

	fun f(y:Int,x:Int,v:Int) {
		for(d in 0..3) {
			val nx = x+dx[d]
			val ny = y+dy[d]
			if(nx in 0 until w&&ny in 0 until h&&a[ny][nx]=='.'&&r[ny][nx]>v) {
				r[ny][nx] = v
				q.addFirst(Triple(ny,nx,v))
			}
		}

		for(dy in -2..2) {
			for(dx in -2..2) {
				val nx = x+dx
				val ny = y+dy
				if(nx in 0 until w&&ny in 0 until h&&a[ny][nx]=='.'&&r[ny][nx]>v+1) {
					r[ny][nx] = v+1
					q.addLast(Triple(ny,nx,v+1))
				}
			}
		}
	}
	q.add(Triple(ch-1,cw-1,0))

	while(!q.isEmpty()) {
		val (y,x,v) = q.poll()
		f(y,x,v)
	}

	println(r[dh-1][dw-1].let {if(it==Int.MAX_VALUE/2) -1 else it})
}


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

using namespace std;
using ll = long long;

class Rolling_Hash {
  private:
    ll n;
    static constexpr ll base1 = 1007, base2 = 2009;
    static constexpr ll mod1 = (1e9+7), mod2 = (1e9+9);
    vector<ll> hash1, hash2, mpow1, mpow2;
  public:
    Rolling_Hash(const string& s) {
        n=s.size();
        hash1.assign(n + 1, 0);
        hash2.assign(n + 1, 0);
        mpow1.assign(n + 1, 1);
        mpow2.assign(n + 1, 1);
        for(int i = 0; i < n; i++) {
            hash1[i + 1] = (hash1[i]*base1+s[i])%mod1;
            hash2[i + 1] = (hash2[i]*base2+s[i])%mod2;
            mpow1[i + 1] = (mpow1[i]*base1) % mod1;
            mpow2[i + 1] = (mpow2[i]*base2) % mod2;
        }
    }

    //get_hash [l, r)
    auto get(ll l, ll r) {
        ll lefval = hash1[r] - hash1[l]*mpow1[r-l]%mod1;
        ll rigval = hash2[r] - hash2[l]*mpow2[r-l]%mod2;
        if(lefval<0)lefval += mod1;
        if(rigval<0)rigval += mod2;
        return make_pair(lefval,rigval);
    }

    //最小共通接頭辞をO(log|S|)で求める
    auto get_LCP(ll a,ll b){
        ll len = min( n-a+1,n-b+1 );
        ll low=0,high=len;
        while( high-low>1 ){
            ll mid=(high+low)/2;
            if(get(a,a+mid)!=get(b,b+mid))high=mid;
            else low=mid;
        }
    return low;
    }


};



int main(){
    string s, t; cin >> s >> t;
    Rolling_Hash rh(s);
    Rolling_Hash prh(t);
    int n = s.size(), m = t.size();

    for(int i = 0; i <= n - m; i++) {
        if(rh.get(i, i + m) == prh.get(0, m))cout << i << endl;
    }
    return 0;

}



Measured memory_bytes: 35680
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007


int main() {
	string s;
	ll n;
	cin>>s>>n;
	for(int i=0;i<s.size();i+=n){
		cout << s[i];
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int sx = sc.nextInt();
		int sy = sc.nextInt();
		
		int tx = sc.nextInt();
		int ty = sc.nextInt();
		
		tx = tx - sx;
		ty = ty - sy;
		
		for (int i=0; i<tx; i++) {
			System.out.print("R");
		}
		for (int i=0; i<ty; i++) {
			System.out.print("U");
		}
		for (int i=0; i<tx; i++) {
			System.out.print("L");
		}
		for (int i=0; i<ty; i++) {
			System.out.print("D");
		}
		
		System.out.print("D");
		
		for (int i=0; i<=tx; i++) {
			System.out.print("R");
		}
		for (int i=0; i<=ty; i++) {
			System.out.print("U");
		}
		System.out.print("LU");

		for (int i=0; i<=tx; i++) {
			System.out.print("L");
		}
		
		for (int i=0; i<=ty; i++) {
			System.out.print("D");
		}
		System.out.println("R");
		sc.close();	
	}
}



Measured memory_bytes: 22468
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
const int MOD=1e9+7;


int main() {
    ios_base::sync_with_stdio(false);
    int r;
    cin >> r;
    cout << fixed << setprecision(15) << 2*r*3.141592 << endl;
    return 0;
}

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll N,D,ans,t;
  cin >> N>> D;
  t = 2*D+1;
  if(N%t == 0){
    ans = N/t;
  }else{
    ans = N/t+1;
  }
  cout << ans<< endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void) {
	long long a, b, c, ans;
	cin >> a >> b >> c;
	if (a + b >= c - 1)
		ans = b + c;
	else
		ans = 2 * b + a + 1;
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
import numpy as np
 
n, k = map(int, input().split())
p = list(map(int, input().split()))
c = list(map(int, input().split()))
 
cycles, check = [], [False]*n
for pi in p:
    if not check[pi-1]:
        curr, cycle = pi, []
        check[pi-1] = True
        while pi != p[curr-1]:
            check[curr-1] = True
            cycle.append(c[curr-1])
            curr = p[curr-1]
        check[curr-1] = True
        cycles.append(cycle + [c[curr-1]])

scores = []
for cycle in (np.array(cycle) for cycle in cycles):
    for i in range(cycle.size):
        cum = np.roll(cycle, i).cumsum()
        if cum[-1] > 0 and k > cycle.size:
            scores.append(cum[-1]*(k//cycle.size-1) + np.concatenate([cum, cum[:k % cycle.size]+cum[-1]]).max())
        else:
            scores.append(cum[:min(k, cum.size)].max())

print(max(scores))

Measured memory_bytes: 28428
#include "bits/stdc++.h"
using namespace std;
int main(){
    vector<int> v;
    int a;
    for(int i=0; i<10; i++){
        cin >> a;
        v.push_back(a);
    }
    sort(v.begin(), v.end());
    cout << v[9] << endl;
    cout << v[8] << endl;
    cout << v[7] << endl;
    
    return 0;
}

Measured memory_bytes: 3156
#include <utility>
#include <stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;
int main() {
	int64_t a[200000], count = 0, n, sum = 0;
	cin >> n;
	REP(i, n) {
		cin >> a[i];
		sum += a[i];
		if (i > 0) {
			if ((a[i] - a[i - 1]) > 1) {
				cout << -1;
				return 0;
			}
			if (a[i] > a[i - 1]) {
				count += a[i - 1];
			}
		}
	}
	cout << (a[0] != 0 ? -1 : sum - count);
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
#define pb push_back
#define ll long long
#define d1(x)  cerr << #x << "--> " << x << endl
#define d2(x, y)  cerr << #x << "--> " << x << " | " << #y << "--> " << y << endl
#define d3(x, y,z)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<" | " << #z << "--> "<< z<< endl
 
using namespace std;
 
bool compare(ll &x, ll &y){
    return x>=y;
}
 
ll mode=pow(10,9)+7;

 
int main(){ 
    
    
    ios::sync_with_stdio(0);
    cin.tie(0);
 
 
 	ll n,m;
 	cin>>n>>m;
 	vector<pair<ll,ll>> v;
 	for (int i=0;i<n;i++){
 		ll a,b;
 		cin>>a>>b;
 		v.pb({a,b});
	 }
	 sort(v.begin(), v.end());
	 multiset<ll> ms;
	 ll ind=0;
	 ll ans=0;
	 for (int i=1;i<=m;i++){
	 	while(ind<n && v[ind].first<=i){
	 		ms.insert(v[ind].second);
	 		ind++;
		 }
		 if (ms.size()>0){
		 	auto it=ms.end();
		 	it--;
		 	ans=ans+*it;
		 	ms.erase(it);
		 }
	 }
 
 	cout<<ans<<endl;
    return 0; 
}
	

Measured memory_bytes: 6640
#include <iostream>
#include<cmath>
using namespace std;
const int maxn=1e5+5;
int a[maxn];
int main()
{

    int n;
    while(cin>>n)
    {
  int pan=0;
  int ans=0;
        for(int i=0;i<n;i++)
        {

            cin>>a[i];
            if(a[i]==0)
                pan++;
            if(a[i]<0)
                ans++;
        }
        long long sum=0;
        if(pan==1)
        {
             for(int i=0;i<n;i++)
             {
                 if(a[i]<0)
                    a[i]=-a[i];
                 sum+=a[i];
             }
             cout<<sum<<endl;
             continue;
        }
        if(ans%2==0)
        {
             for(int i=0;i<n;i++)
             {
                 if(a[i]<0)
                    a[i]=-a[i];
                 sum+=a[i];
             }
             cout<<sum<<endl;
             continue;

        }
        int _min=1e9;
        int j=0;
        for(int i=0;i<n;i++)
             {
                 if(fabs(a[i])<_min)
                   {

                    _min=fabs(a[i]);
                    j=i;
                   }
             }
             a[j]=0;
             sum+=-_min;
             for(int i=0;i<n;i++)
             {
                 if(a[i]<0)
                    a[i]=-a[i];
                 sum+=a[i];
             }
             cout<<sum<<endl;

    }
    return 0;
}


Measured memory_bytes: 640
N = int(input())
S = [input() for _ in range(N)]

cnt = {'AC':0, 'WA':0, 'TLE':0, 'RE':0}
for si in S:
  cnt[si] += 1
  
for key, val in cnt.items():
  print('{} x {}'.format(key, val))
 

Measured memory_bytes: 16148
f = [1,3,5,7,8,10,12]
g = [4,6,9,11]
x,y = map(int,input().split())

if x == 2 and y == 2:
    print('Yes') 
elif x in f and y in f:
    print('Yes') 
elif x in g and y in g:
    print('Yes') 
else:
    print('No')    

Measured memory_bytes: 9144
import sys
input = sys.stdin.readline

n,c = map(int, input().split())
color = []
for _ in range(c):
    color.append(list(map(int, input().split())))

grid = {i:{} for i in range(3)}
for i in range(n):
    for j,t in enumerate(map(int, input().split())):
        t -= 1
        if t not in grid[(i+j + 2) % 3]:
            grid[(i+j + 2) % 3][t] = 0
        grid[(i+j + 2) % 3][t] += 1

costs = [[0 for _ in range(c)],[0 for _ in range(c)],[0 for _ in range(c)]]
for cc in range(c):
    for i in range(3):
        for d,cnt in grid[i].items():
            costs[i][cc] += color[d][cc] * cnt

rc = range(c)
x = sorted(list(rc), key=lambda x: costs[0][x])[:3]
y = sorted(list(rc), key=lambda x: costs[1][x])[:3]
z = sorted(list(rc), key=lambda x: costs[2][x])[:3]

mn = 10**9
for i in x:
    for j in y:
        for k in z:
            if i == j or j == k or k == i:
                continue
            if mn > costs[0][i] + costs[1][j] + costs[2][k]:
                mn = costs[0][i] + costs[1][j] + costs[2][k]
print(mn)

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <vector>

int main(int argc, char const* argv[])
{
    int h, w;
    std::cin >> h >> w;

    auto vec = std::vector<std::string>(h);

    for (auto& s : vec) {
        std::cin >> s;
    }

    bool result = true;
    for (int i = 0; i < h; ++i) {
        auto& s = vec[i];
        for (int j = 0; j < w; ++j) {
            auto c = s[j];
            if (c == '#') {
                if (j != 0) {
                    if (s[j - 1] == '#') {
                        continue;
                    }
                }
                if (j != (w - 1)) {
                    if (s[j + 1] == '#') {
                        continue;
                    }
                }

                if (i != 0) {
                    auto prev_s = vec[i - 1];
                    if (prev_s[j] == '#') {
                        continue;
                    }
                }
                if (i != (h - 1)) {
                    auto next_s = vec[i + 1];
                    if (next_s[j] == '#') {
                        continue;
                    }
                }

                result = false;
                goto finish;
            }
        }
    }

finish:
    if (result) {
        std::cout << "Yes" << std::endl;
    }
    else {
        std::cout << "No" << std::endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
  int H, W, i;
  cin >> H >> W;
  vector<string> vec(H+2);
  for (i=0; i<H+2; i++) {
    string str;
    if (i==0 || i==H+1) {
      string s(W+2, '#');
      vec.at(i) = s;
    }
    else {
      cin >> str;
      vec.at(i) = '#' + str + '#'; 
    }
  }
  for (i=0; i<H+2; i++) {
    cout << vec.at(i) << endl;
  }
  return 0;
}

Measured memory_bytes: 256
<?php

while (true) {
    fscanf(STDIN, '%d %d', $a, $b);
    if (feof(STDIN)) {
        break;
    }
    $gcd = gcd($a, $b);
    $lcm = $gcd * ($a / $gcd) * ($b / $gcd);
    echo "$gcd $lcm";
    echo PHP_EOL;
}

function gcd($a, $b) {
    while ($a !== $b) {
        if ($a > $b) {
            $a = $a - $b;
        } else {
            $b = $b - $a;
        }
    }

    return $a;
}

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

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
//const int N=;
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    printf("%d\n",max(n*(n-1)/2,0)+max(0,m*(m-1)/2));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int,int>;
using pll = pair<long long, long long>;
const long long INF = 1<<29;

const int MOD = 1000000007;
long long ruizyou(long long m,long long n){
  if(m == 0)return 0;
  if(m == 1)return 1;
  long long ans = 1;
  long long tmp = m;
  for(int i=0;i<=30;i++){
    if(n & (1<<i)){
      ans *= tmp;
      ans %= MOD;
    }
    tmp *= tmp;
    tmp %= MOD;
  }
  return ans;
}
long long kaizyou(long long x){
  if(x == 0)return 1;
  return x * kaizyou(x-1) % MOD;
}
long long comb(long long x,long long y){
  long long bunsi = kaizyou(x);
  long long bunbo = kaizyou(x-y) * kaizyou(y) % MOD;
  return bunsi * ruizyou((int)bunbo,MOD-2) % MOD;
}
struct unionfind{
  vector<int> par;
  vector<int> hukasa;
  unionfind(int n){
    par = vector<int>(n);
    hukasa = vector<int>(n,0);
    for(int i=0;i<n;i++){
      par.at(i) = i;
    }
  }
  int root(int x){
    if(par.at(x) == x)return x;
    return root(par.at(x));
  }
  void unite(int x,int y){
    int rx = root(x);
    int ry = root(y);
    if(rx == ry)return;
    if(hukasa.at(rx) >= hukasa.at(ry)){
      par.at(ry) = rx;
      hukasa.at(rx) = max(hukasa.at(ry) + 1,hukasa.at(rx));
    }
    else{
      par.at(rx) = ry;
    }
  }
  bool same(int x,int y){
    return root(x) == root(y);
  }
};
int ctoi(char a){
  return a - '0';
}
long long gcd(long long a,long long b){
  long long c = max(a,b);
  long long d = min(a,b);
  if(d % c == 0)return c;
  return gcd(c,d%c);
}
long long lcm(long long a,long long b){
  return a * b / gcd(a,b);
}
int main(){
  int h,w,k;
  cin >> h >> w >> k;
  vector<vector<char>> c(h,vector<char>(w));
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++)cin >> c.at(i).at(j);
  }
  int ans = 0;
  for(int i=0;i<(1<<h);i++){
    for(int j=0;j<(1<<w);j++){
      int tmp = 0;
      for(int k=0;k<h;k++){
        for(int l=0;l<w;l++){
          if(!(i&(1<<k)) && !(j&(1<<l)) && c.at(k).at(l) == '#')tmp++;
        }
      }
      if(tmp == k)ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3600
#include <iostream>
#include <math.h>
using namespace std;

int main() {
	// your code goes here
	int x,y;
	cin>>x>>y;
	int a,b;
	a=x*y;
	b=2*(x+y);
	cout<<a<<" "<<b<<endl;
	return 0;
}

Measured memory_bytes: 1164
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

def main():
    N = I()
    S = [_S() for _ in range(N)]
    S_count = collections.Counter(S).most_common()
    S_most = list(filter(lambda t:t[1]>=S_count[0][1],S_count))
    for s in sorted(S_most,key=lambda tup:tup[0]):
        print(s[0])

main()



Measured memory_bytes: 66964
#include <bits/stdc++.h>
#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(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define FI first
#define SE second
#define PB push_back
#define EB emplace_back
#define SZ(x) (int)(x).size()
#define BN(x) ((1<<x)-1)
#define DUP(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main () {
  int n;
  cin >> n;
  vi a(n);
  rep(i,n) cin >> a[i];

  vi b(n);
  rep(i,n) {
    int sng;
    if (n%2 == 0) {
      sng = (i%2 == 0 ? 1 : -1);
    }
    else {
      sng = (i%2 == 0 ? -1 : 1);
    }
    b[n/2+(sng)*((i+1)/2)] = a[i];
  }

  rep(i,n) {
    printf("%d%s",b[i],i!=n-1?" ":"\n");
  }
}

Measured memory_bytes: 3712
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long k = sc.nextLong();
   
        long diff = Math.abs(n - k);
        if(diff == 0) {
            System.out.println("0");
            return;
        }
        long a = n % k;
        long b = k - a;

        System.out.println(Math.min(a, b));
    }
}


Measured memory_bytes: 35712
a = list(map(int, input().split()))
for i in range(a[0]):
    for j in range(a[1]):
        if i<a[3] :
            if j<a[2] :print(0,end="")
            else :print(1,end="")
        else :
            if j<a[2] :print(1,end="")
            else :print(0,end="")
    print("")

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

set<int> H[101][101], K[101][101];
int main()
{
    int n; cin>>n;
    vector<int> x(n), y(n), h(n);
    for(int i=0; i<n; ++i) cin>>x[i]>>y[i]>>h[i];

    for(int cx=0; cx<=100; ++cx) for(int cy=0; cy<=100; ++cy)
        for(int i=0; i<n; ++i)
            (h[i] ? H :K)[cx][cy].insert(h[i]+abs(cx-x[i])+abs(cy-y[i]));

    for(int cx=0; cx<=100; ++cx) for(int cy=0; cy<=100; ++cy) if (H[cx][cy].size()==1) {
        int a=*begin(H[cx][cy]);
        bool ok=true;
        for(int i=0; i<n; ++i)
            if (!h[i] && a-abs(cx-x[i])-abs(cy-y[i])>0) ok=false;
        if (ok) {
            cout<<cx<<' '<<cy<<' '<<a<<endl;
            return 0;
        }
    }
}


Measured memory_bytes: 31104
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;

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

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}


#include <iostream>

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

    cout << N / 3 << endl;

}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

ans = 0
for i in range(n):
    for j in reversed(range(i+1, n)):
        if a[j] < a[j - 1]:
            a[j], a[j - 1] = a[j - 1], a[j]
            ans += 1
print(' '.join(map(str, a)))
print(ans)


Measured memory_bytes: 5600
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){
	string s, t;
	cin >> s >> t;
	int sc[26], tc[26];
	fill(sc, sc+26, 0);
	fill(tc, tc+26, 0);
	REP(i, s.length()){
		sc[s[i]-'a']++;
		tc[t[i]-'a']++;
	}
	vector<int> sv, tv;
	REP(i, 26){
		if(sc[i] != tc[i]){
			sv.push_back(sc[i]);
			tv.push_back(tc[i]);
		}
	}
	bool yes=true;
	if(sv.size()!=tv.size()){
		yes=false;
	}else{
		std::sort(sv.begin(), sv.end());
		std::sort(tv.begin(), tv.end());
		REP(i, sv.size()){
			if(sv[i]!=tv[i]){
				yes=false;
				goto LAST;
			}
		}
	}
LAST:
	if(yes) cout << "Yes\n";
	else cout << "No\n";
	
	return 0;
}


Measured memory_bytes: 776