akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int R = sc.nextInt(); // 赤色の箱に入っているボールの個数
		int G = sc.nextInt(); // 緑色の箱に入っているボールの個数
		int B = sc.nextInt(); // 青色の箱に入っているボールの個数
		int N = sc.nextInt(); // 合計のボールの個数
		sc.close();

		int count = 0;

		for (int i = 0; i <= N;) {
			for (int j = 0; j <= N;) {
				int t = i + j;
				if (t > N) {
					break;
				}
				int tmp = N - (i + j);
				if (tmp >= 0 && tmp % B == 0) {
					count++;
				}
				j += G;
			}
			i += R;
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 21844
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def main():
    N = int(readline())
    K = int((1 + (8 * N + 1) ** 0.5) / 2)
    if not N == K * (K - 1) // 2:
        print('No')
        return

    ans = [[0] * (K - 1) for _ in range(K - 1)]
    for i in range(K - 1):
        n = i * (i + 1) // 2
        for j in range(i + 1):
            ans[i][j] = ans[j][i] = n + j + 1

    print('Yes')
    print(K)
    for row in ans:
        print(K - 1, *row)
    tmp = [ans[i][i] for i in range(K - 1)]
    print(K - 1, *tmp)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9224
#include <stdio.h>

int main()
{
  int v,i,j,q;
  int A[100],N;

  scanf("%d",&N);
  
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
    printf("%d",A[i]);
    if(i != N-1) printf(" ");
  }
  printf("\n");
  
  for(i=1;i<N;i++){
    v = A[i];
    j = i-1;
    while(j >= 0 && A[j] > v){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
    for(q=0;q<N;q++){
      printf("%d",A[q]); 
      if(q != N-1) printf(" ");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 604
n = gets.to_i
n.times do
  time = gets.chomp
  hour = time[0,2].to_i
  minute = time[3,2].to_i
  long_hand = 6*minute
  shor_hand = 30*hour + minute/2.0
  dif = (shor_hand-long_hand).abs
  dif = 360 - dif if 180 < dif
  if 0 <= dif && dif < 30
    puts "alert"
  elsif 90 <= dif && dif <= 180
    puts "safe"
  else
    puts "warning"
  end
end

Measured memory_bytes: 6136
#include <iostream>
using namespace std;
int main() {
	int N;
	cin >> N;
	int answer = 0;
	for (int C = 1; C <= N; C += 2) {
		int num_of_divisors = 0;
		for (int X = 1; X <= C; ++X) {
			if (C % X == 0) {
				++num_of_divisors;
			}
		}
		if (num_of_divisors == 8) {
			++answer;
		}
	}
	cout << answer << '\n';
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
  ll n;
  cin >> n;
  ll sum=0,p=1;
  while(sum<n){
    sum=p*(p+1)/2;
    p++;
  }
  cout << p-1;
  
}

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

using namespace std;

#define ll  long long
#define ld  double

#define sz(x)   (int)x.size()
#define all(x)  x.begin(),x.end()

#define pb  emplace_back
#define X   first
#define Y   second

const int   mod = 1e9 + 7;
const int   N   = 1e5 + 5;

typedef pair<ll,int>    ii;

void add(int &a,int b)  {
    a += b;
    if (a >= mod)
        a -= mod;
}
void sub(int &a,int b)  {
    a -= b;
    if (a <  0)
        a += mod;
}
int mul(int a,int b)    {   return  1ll * a * b % mod;  }
int Pow(int a,int b)    {
    int ans = 1;
    while  (b)  {
        if (b & 1)  ans = mul(ans,a);
        a = mul(a,a);   b >>= 1;
    }
    return  ans;
}
vector<ii>  g[N];

ll  dis[2][N];
int cnt[2][N];

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

    int n, m;   cin >> n >> m;
    int S, T;   cin >> S >> T;

    for(int i = 0 ; i < m ; ++i)    {
        int x;  cin >> x;
        int y;  cin >> y;
        int c;  cin >> c;

        g[x].pb(c,y);
        g[y].pb(c,x);
    }

    for(int t = 0 ; t < 2 ; ++t)    {
        priority_queue<ii,vector<ii>,greater<ii> >  pq;

        fill(dis[t] + 1,dis[t] + 1 + n,1e18);

        if (t)  dis[1][T] = 0, cnt[1][T] = 1,   pq.push(ii(0,T));
        else    dis[0][S] = 0, cnt[0][S] = 1,   pq.push(ii(0,S));

        while (pq.size())   {
            int u  = pq.top().Y;
            ll  du = pq.top().X;    pq.pop();

            if (dis[t][u] != du)
                continue;

            for(ii  e : g[u])   {
                int v = e.Y;

                if (dis[t][v] > du + e.X)   {
                    dis[t][v] = du + e.X;
                    cnt[t][v] = 0;
                    pq.push(ii(dis[t][v],v));
                }
                if (dis[t][v] == du + e.X)
                    add(cnt[t][v],cnt[t][u]);
            }
        }
    }
    int ans = mul(cnt[0][T],cnt[0][T]);

    for(int i = 1 ; i <= n ; ++i)   {
        if (dis[0][i] * 2 == dis[0][T]) {
            int val = 1;
            val = mul(val,mul(cnt[0][i],cnt[0][i]));
            val = mul(val,mul(cnt[1][i],cnt[1][i]));

            sub(ans,val);
        }
        for(ii  e : g[i])   {
            int v = e.Y;
            int w = e.X;

            if (dis[0][i] + w + dis[1][v] != dis[0][T]) continue;
            
            if (dis[0][i] * 2 >= dis[0][T]) continue;
            if (dis[1][v] * 2 >= dis[0][T]) continue;

            int val = 1;

            val = mul(val,mul(cnt[0][i],cnt[0][i]));
            val = mul(val,mul(cnt[1][v],cnt[1][v]));

            sub(ans,val);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 18004
N = gets.to_i
a = gets.chomp.split(" ").map(&:to_i)
count = a.min
sum = 0
ans = []
while (count <= a.max)
    a.each do |a|
       sum += (count - a) ** 2
    end
    ans << sum
    sum = 0
    count += 1
end

puts "#{ans.min}"

Measured memory_bytes: 1788
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 10e9;
const int MAX_V = 201;
int a[4];

void TrainTicket() {
	int v;
	cin >> v;
	int c = 3;
	while (v > 0)
	{
		a[c--] = v % 10;
		v /= 10;
	}

	for (size_t i = 0; i < 2; i++)
	{
		for (size_t j = 0; j < 2; j++)
		{
			for (size_t k = 0; k < 2; k++)
			{
				int val = a[0];
				if (i % 2 == 0) val += a[1];
				else val -= a[1];
				if (j % 2 == 0) val += a[2];
				else val -= a[2];
				if (k % 2 == 0) val += a[3];
				else val -= a[3];
				if (val == 7) {
					cout << a[0] << (i % 2 == 0 ? "+" : "-");
					cout << a[1] << (j % 2 == 0 ? "+" : "-");
					cout << a[2] << (k % 2 == 0 ? "+" : "-");
					cout << a[3] << "=7" << endl;;
					return;
				}
			}
		}
	}

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



Measured memory_bytes: 256
// ----- In the name of ALLAH, the Most Gracious, the Most Merciful -----

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

#define NINJA ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;i<n;i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define dloop(i,n) for(int i=n-1;i>=0;i--)
#define iii tuple<int,int,int>
#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#define int long long
#define pb push_back
#define endl "\n"
#define setbits __builtin_popcountll
#define mp map<int,int>
#define F first
#define S second
#define sz(v) (int)v.size()
#define mod 1000000007
#define inf (int)1e18

int32_t main(){
	NINJA;

	int a,b; cin >> a >> b;

	// if(a==0 || b==0){
	// 	cout << "No" << endl;
	// 	return 0;
	// }

	bool f = 0;
	while(a>0){
		if((b/2==a && b%2==0 )|| (b%4==0 && b/4==a)){
			f = 1;
			break;
		}
		a-=1;
		b-=2;
	}

	if((b/2==a && b%2==0 )|| (b%4==0 && b/4==a)){
		f = 1;
	}

	if(f){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3596
def resolve():
    n = int(input())
    ans = []
    i = 1
    while i * (i + 1) // 2 < n:
        ans.append(i)
        i += 1
    ans.append(i)
    d = i * (i + 1) // 2 - n
    # print(ans)
    if d != 0:
        ans.remove(d)
    print("\n".join([str(i) for i in ans]))


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 3444
#include <iostream>
#include <queue>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <set>
#include <string>
#include <sstream>
#include<map>
#include <vector>
#define maxn 100000+15
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[maxn]={0};
	 for(int i=0;i<n;i++){
	 	int x;
	 	cin>>x;
	 	a[x]++;a[x-1]++;a[x+1]++;
	 }
	 int mx=0;
	 for(int j=0;j<maxn;j++){
	 	if(a[j]>mx){
	 		mx=a[j];
		 }

	 }
			 cout<<mx<<endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a[50][50],p,i,j,k,n,d,l,F,x=0;
    float f;
    cin>>n>>d;
    for(i=0;i<n;i++){
        for(j=0;j<d;j++){cin>>a[i][j];}
    }
    for(i=0;i<n;i++){
        for(j=i+1;j<n;j++){
            p=0;
        for(k=0;k<d;k++){
            p+=(a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
            }
          f=sqrt(p);
          F=f;
          if(f==F){x++;}
        }
    }
    cout<<x<<endl;



}



Measured memory_bytes: 256
#include<iostream>
#define MAX 100
using namespace std;
int main(){
	int num;
	int data[MAX];
	cin>>num;
	for(int i=0;i<num;i++){
		cin>>data[i];
	}
	for(int i=0;i<num;i++){
		int k=i;
		for(int j=i+1;j<num;j++){
			if(data[k]>data[j])k=j;
		}
		int temp=data[k];
		data[k]=data[i];
		data[i]=temp;
	}
	int min=data[0];
	int max=data[num-1];
	cout<<max-min<<endl;
	return 0;
}

Measured memory_bytes: 256
[n,t]=[int(i) for i in input().split()]
a = []
b = []
for i in range(n):
    a.append([int(i) for i in input().split()])
#print(a)
for i in range(n):
    if a[i][1] <= t:
        b.append(a[i][0])
if len(b) == 0:
    print("TLE")
else:
    print(min(b))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
//#define uint __int128_t
 
#define pb push_back
#define fi first
#define se second
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define low(a,b) lower_bound(all(a),(b))-(a).begin()
#define upp(a,b) upper_bound(all(a),(b))-(a).begin()
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<vint> vvint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
typedef pair<pint,pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007;
const ll INF=1e18;

int N,A,B;
string s;
int a[200020];

signed main() {
    IOS();
    //(1ll<<N)シフト演算のオーバーフローに気をつける
    //MOD同士の引き算に注意
    cin>>N>>A>>B;
    cout<<min(A,B)<<" "<<max(0ll,A+B-N)<<endl;
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 256
N = int(input())
ti = [int(input()) for i in range(N)]


def euc_alg(val1, val2):

    if val1 == val2:
        return val1

    mod = min(val1, val2)
    divided = max(val1, val2)
    while 1:
        tmp_mod = divided % mod

        if tmp_mod == 0:
            break
        divided = mod
        mod = tmp_mod

    ret = val1 * val2 // mod

    return ret

maxti = max(ti)
# least_common_mult = max([euc_alg(maxti, t) for t in ti])

ans = ti[0]
for t in ti:
    ans = euc_alg(ans, t)

print(ans)


Measured memory_bytes: 9148
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    var max = 0
    var maxIndex =1
    for (i in 2..N) {
        val calc = calc(i)
        if (max < calc) {
            max = calc
            maxIndex = i
        }
    }
    println(maxIndex)
}

private fun calc(n: Int): Int {
    if (n % 2 == 1) {
        return 0
    }
    return calc(n / 2) + 1
}



Measured memory_bytes: 31744
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
//#define INF 1e18
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int n,m,q;
int a[55],b[55],c[55],d[55];
int ans;

void check(vector<int> v){
  int u=0;
  rep(i,0,q){
    if(v[b[i]] - v[a[i]] == c[i])u += d[i];
  }
  ans = max(ans,u);
}

void dfs(vector<int> v){
  if((int)v.size() == n){
    check(v);
    return;
  }
  int t = v[v.size()-1];
  rep(i,t,m+1){
    vector<int> u=v;
    u.push_back(i);
    dfs(u);
  }
}



int main(){
  cin >> n >> m >> q;
  rep(i,0,q){
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    a[i]--;
    b[i]--;
  }
  rep(i,1,m+1){
    vector<int> k(1,i);
    dfs(k);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3564
from collections import defaultdict
n = int(input())
d = defaultdict(int)

for _ in range(n):
  x = input()
  d[x] += 1

d2 = sorted(d.items(), key=lambda x:x[1], reverse=True)
b = [k for k, v in dict(d2).items() if v == d2[0][1]]

for i in sorted(b):
  print(i)

Measured memory_bytes: 66524
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**7)
import bisect
import heapq
import itertools
import math
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from math import gcd
from operator import add, itemgetter, mul, xor
def cmb(n,r,mod):
  bunshi=1
  bunbo=1
  for i in range(r):
    bunbo = bunbo*(i+1)%mod
    bunshi = bunshi*(n-i)%mod
  return (bunshi*pow(bunbo,mod-2,mod))%mod
mod = 10**9+7
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]

#bisect.bisect_left(list,key)はlistのなかでkey未満の数字がいくつあるかを返す
#bisect.bisect_right(list, key)はlistのなかでkey以下の数字がいくつあるかを返す
#これを応用することで
#len(list) - bisect.bisect_left(list,key)はlistのなかでkey以上の数字がいくつあるかを返す
#len(list) - bisect.bisect_right(list,key)はlistのなかでkeyより大きい数字がいくつあるかを返す
#これらを使うときはあらかじめlistをソートしておくこと！

n = I()
ac = 0
wa = 0
tle = 0
re = 0
for i in range(n):
    s = input()
    if s == "AC":
        ac += 1
    elif s == "WA":
        wa += 1
    elif s == "TLE":
        tle +=1
    else:
        re += 1
ac = str(ac)
wa = str(wa)
tle = str(tle)
re = str(re)
print("AC x "+ac)
print("WA x "+wa)
print("TLE x "+tle)
print("RE x "+re)


Measured memory_bytes: 10116
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
signed main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a+b<c+d) cout<<"Right"<<endl;
  if(a+b>c+d) cout<<"Left"<<endl;
  if(a+b==c+d) cout<<"Balanced"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<set>
#include<algorithm>
using namespace std;
#define int long long
#define V vector
#define vel V<int>
#define rep(i,n) for(int i=0;i<n;i++)
#define mkp make_pair
#define pin pair<int,int>
pin solve(V<pin>& ab, int ex) {
	if (!ex) { return mkp(0, 0); }
	V<V<pin>> qab(2);
	int sz = ab.size();
	qab[0].reserve(sz);
	qab[1].reserve(sz);
	for (pin& x : ab) {
		qab[x.second & 1].push_back(mkp(x.first / 2, x.second / 2));
		if (x.first & 1) { qab[(x.second + 1) & 1].push_back(mkp(x.first / 2, (x.second + 1) / 2)); }
	}
	int c = 0;
	for (pin& x : qab[0]) {
		int qc = 2 * x.first + x.second + 1;
		qc = (qc & (0xffffffff)) + ((qc & (0x7fffffff00000000)) >> 32);//qc<=1ffffffff
		qc = (qc & (0xffff)) + ((qc & (0x1ffff0000)) >> 16);//qc<=2ffff
		qc = (qc & (0xff)) + ((qc & (0x3ff00)) >> 8);//qc<=3ff
		qc = (qc & (0x1f)) + ((qc & (0x3e0)) >> 5);//qc<=3e
		qc = (qc & 7) + ((qc & 56) >> 3);//qc<=14
		qc = (qc & 3) + ((qc & 12) >> 2);
		qc = (qc & 3) + ((qc & 4) >> 2);
		c ^= qc;
	}
	if (!c) {
		pin ans = solve(qab[1], ex - 1);
		ans.first *= 2; ans.second *= 2; ans.second++;
		return ans;
	}
	pin ans = solve(qab[0], ex - 1);
	c = 0;
	int d = 0;
	for (pin& x : qab[1]) {
		int w = ans.second - x.second - 1;
		if ((w & x.first) == w) { c ^= 1; }
		w++;
		if ((w & x.first) == w) { d ^= 1; }
	}
	ans.first *= 2; ans.second *= 2;
	ans.first += (c | d); ans.second -= c;
	return ans;
}
int per(int qc) {
	qc = (qc & (0xffffffff)) + ((qc & (0x7fffffff00000000)) >> 32);//qc<=1ffffffff
	qc = (qc & (0xffff)) + ((qc & (0x1ffff0000)) >> 16);//qc<=2ffff
	qc = (qc & (0xff)) + ((qc & (0x3ff00)) >> 8);//qc<=3ff
	qc = (qc & (0xf)) + ((qc & (0x3f0)) >> 4);//qc<=4e
	qc = (qc & (0xf)) + ((qc & (0x7e)) >> 4);//qc<=18
	qc = (qc & 3) + ((qc & 28) >> 2);
	qc = (qc & 3) + ((qc & 4) >> 2);
	return qc;
}
int qsum(int i) {
	if (i == 0) { return 0; }
	return i % 10 + qsum(i / 10);
}
#define sor(v) sort(v.begin(),v.end())
signed main() {
	int n, l; cin >> n >> l;
	V<string> s(n);
	rep(i, n) { cin >> s[i]; }
	sor(s);
	rep(i, n) { cout << s[i]; }
	cout << endl;
}

Measured memory_bytes: 256
//#define scanf_s scanf
#define gets_s gets
#include <stdio.h>
#include <string>
#include <iostream>
#include <math.h>
using namespace std;
#define MAX 101
int main(void)
{
	char str[MAX];
	int i, j, cou = 0;
	while (gets_s(str) != NULL) {
		++cou;
		for (i = 0; str[i] != '\0'; ++i);
		for (j = 0; j < i / 2; ++j) {
			if (str[j] != str[i - 1 - j]) {
				--cou; break;
			}
		}
	}
	printf("%d\n", cou);
}

Measured memory_bytes: 1112
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define CLEAR(arr, val) memset(arr, val, sizeof(arr))

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

typedef long long ll;
typedef pair<int, int> pint;

const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };



int main()
{
	int n, m, s, t, res = 0;
	cin >> n >> m;
	rep (i, n)
	{
		s = 0;
		rep (j, m)
		{
			cin >> t;
			s += t;
		}
		max_swap(res, s);
	}
	cout << res << endl;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 5;
const int M = 3;
int n;
ll dp[N][M];
int a[N][M];
ll solve(int idx, int st) {
    if (idx == n)
        return 0;
    if (dp[idx][st] != -1)
        return dp[idx][st];
    ll res = 0;
    for (int i = 0; i < 3; i++)
        if (i != st)
            res = max(res, a[idx][i] + solve(idx + 1, i));
    return dp[idx][st] = res;
}

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < 3; j++)
            cin >> a[i][j];
    memset(dp, -1, sizeof dp);
    ll res = 0;
    for (int i = 0; i < 3; i++)
        res = max(res, a[0][i] + solve(1, i));
    cout << res;
    return 0;
}


Measured memory_bytes: 11648
#include<bits/stdc++.h>
#define Tp template<typename Ty>
#define Ts template<typename Ty,typename... Ar>
#define Reg register
#define RI Reg int
#define Con const
#define CI Con int&
#define I inline
#define W while
#define N 200
using namespace std;
int n,p[N+5],q[N+5],a[N+5][N+5];
I int BFS(CI x)
{
	for(RI i=1;i<=n;++i) p[i]=0;
	RI i,k,H=1,T=1;p[q[1]=x]=1;W(H<=T) for(k=q[H++],i=1;i<=n;++i)
		if(a[k][i]) {if(p[i]&&p[i]^(p[k]-1)&&p[i]^(p[k]+1)) return -1;!p[i]&&(p[q[++T]=i]=p[k]+1);}
	return p[q[T]];
}
int main()
{
	RI i,j,t,ans=-1;string s;for(scanf("%d",&n),i=1;i<=n;++i)
		for(cin>>s,j=1;j<=n;++j) s[j-1]&1&&(a[i][j]=1);
	for(i=1;i<=n;++i) ans<(t=BFS(i))&&(ans=t);return printf("%d",ans),0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define fl(i,a,n)      for(int i=a;i<=n;i++)
#define pb             push_back
#define int            long long int
#define ump            unordered_map
#define pii            pair<int,int>
#define ff             first
#define ss             second
#define PI             3.1415926535898
#define inf            1e18
#define vi             vector<int>
#define endl           "\n"
#define print(a)       for(auto x:a){cout<<x<<" ";}cout<<endl;
#define mod            1000000007
using namespace std;
template <typename Arg, typename... Args>
void db(Arg&& arg, Args&&... args) {
    cout << std::forward<Arg>(arg);
    using expander = int[];
    (void)expander{0, (void(cout << ',' << std::forward<Args>(args)), 0)...}; cout << endl;
}
inline int mymod(int A, int M) {return ((A % M) + M) % M;}
inline void solve() {
    int n; cin >> n;
    vi a(n);
    int sum = 0;
    fl(i, 0, n - 1) {
        cin >> a[i];
        sum += mymod(a[i], mod);
        sum = mymod(sum, mod);
    }
    int ans = 0;
    fl(i, 0, n - 1) {
        sum -= mymod(a[i], mod);
        sum = mymod(sum, mod);
        int temp = mymod(a[i], mod) * mymod(sum, mod);
        temp = mymod(temp, mod);
        ans += temp;
        ans = mymod(ans, mod);
    }
    ans = mymod(ans, mod);
    cout << ans << endl;
}
int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
   //freopen("input.txt", "r", stdin);
   // freopen("output.txt", "w", stdout);
#endif
    int t = 1;
    // cin >> t;
    fl(i, 1, t)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 4780
def main():
 num = list(map(int,input().split()))
 fiven=0
 sevenn=0
 for i in range(0,3):
  if num[i]==5 :
   fiven+=1
  elif num[i]==7 :
   sevenn+=1
 if fiven==2 and sevenn==1 :
   print('YES')
 else:
   print('NO')
 
main()

Measured memory_bytes: 2940
function solve()
     function fn(x,y)
        if haskey(dic,(x,y))
           return dic[(x,y)]
        elseif x<=0 return inf
        elseif y<=0 return 0
        else
            z=fn(x,y-ma[x][1])+ma[x][2]
            if x>1 && z>y/ma[x-1][1]*ma[x-1][2]
               z=min(z,fn(x-1,y))
            end
            return dic[(x,y)]=z
         end
    end
    inf=1000000
    ma=readlines()
    ma=map(x->chomp(x),ma)
    ma=map(split,ma)
    ma=map(x->map(y->parse(Int,y),x),ma)
    n,h=ma[1][2],ma[1][1]
    ma=sort(ma[2:end],by=x->x[1]/x[2])
    dic=Dict()
    println(fn(n,h))
 end
solve()

Measured memory_bytes: 139964
# -*- coding: utf-8 -*-
"""
C - Skip
https://atcoder.jp/contests/abc109/tasks/abc109_c

"""
import sys

from bisect import bisect_right, bisect_left

def solve(N, X, points):
    def divisor(N):
        divisors = set()
        for i in range(1, int(N**0.5)+1):
            if N % i == 0:
                divisors.add(i)
                divisors.add(N // i)
        return sorted(divisors)

    left, right = float('inf'), float('inf')
    l = bisect_left(points, X)
    if l:
        left = points[l-1]
    r = bisect_right(points, X)
    if r != len(points):
        right = points[r]

    gaps = [abs(X-p) for p in points]
    candidates = divisor(min(abs(left-X), abs(right-X)))
    while True:
        c = candidates.pop()
        if all([g%c==0 for g in gaps]):
            return c


def main(args):
    N, X = map(int, input().split())
    points = sorted(map(int, input().split()))
    ans = solve(N, X, points)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


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


int main()
{
  ll n, m;
  cin >> n >> m;
  
  map<ll, ll> p;
  for(ll i = 2; i * i <= m; i++)
  {
    while(m % i == 0)
    {
      p[i]++;
      m /= i;
    }
  }
  if(m != 1) p[m]++;
  
  
  ll res = 1;
  for(auto x : p)
  {
    //cout << x.first << " " << x.second << endl;
    rep(i, x.second / n) res *= x.first;
  }
  
  cout << res << endl;
  
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef double ld;
int main() {
	int n;
	ld sum;
	cin >> n;
	for(int i = 0; i < n; i++){
		ld a; string b;
		cin >> a >> b;
		if(b == "JPY") sum += a;
		else{
			sum += a * 380000.0;
		}
	}
	printf("%f\n", sum);
	return 0;
}


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

int main ()
{
    long s;
    cin >> s;
    map<long,bool> mp;
    mp[s]=true;
    for(long i=2;i<=1000000;i++){
        if(s%2==0)s/=2;
        else s=3*s+1;
        if(mp[s]){
            cout<< i<< endl;
            break;
        }
        mp[s]=true;
    }
}












Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string>
using namespace std;
#define LL long long int
#define rep(i,a,n) for(int i=a;i<n;++i)
#define per(i,a,n) for(int i=n-1;i>=a;--i)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define mem(a,t) memset(a,t,sizeof(a))
#define all(v) v.begin(),v.end()
#define scan(t) scanf("%d",&t)
#define N 20
char s[N];
LL ans;
int len;
void fun(int num,int i,LL tmp,LL ret){
    if(i==len){
        ret+=tmp;
        if(num==0)
        {
            ans+=ret;
        }
        return ;
    }
    fun(num-1,i+1,tmp*10+s[i]-'0',ret);
    fun(num,i+1,0,ret+tmp);
}
int main()
{
    ans=0;
    scanf("%s",s);
    len=strlen(s);
    int i=0;
    while(i<len){
        ans=ans*10+s[i]-'0';
        ++i;
    }
    rep(i,0,len) ans+=s[i]-'0';
    for(i=2;i<len;++i){
        fun(i,0,0,0);
    }
    if(len==1)
        ans/=2;
    cout<<ans<<endl;
    return 0;
}


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

struct Node {
	int parent{-1}, children{1}, id{};
	long long d, distance_sum{};
};

int main()
{
	int n;
	scanf("%d", &n);
	std::vector<Node> nodes(n);
	for (int i = 0; i < n; i++)
	{
		scanf("%lld", &nodes[i].d);
		nodes[i].id = i;
	}
	std::sort(nodes.begin(), nodes.end(),
		[](const Node& a, const Node& b){ return a.d < b.d; }
	);
	for (auto node{nodes.rbegin()}; node + 1 < nodes.rend(); node++)
	{
		auto parent = std::lower_bound(nodes.begin(), nodes.end(), node->d - n + 2 * node->children,
			[](Node &e, long long value){ return e.d < value; }
		);
		if (parent == nodes.end() || parent->d != node->d - n + 2 * node->children || parent->id == node->id)
		{
			printf("-1\n");
			return 0;
		}
		node->parent = parent->id;
		parent->children += node->children;
		parent->distance_sum += node->distance_sum + node->children;
	}
	if (nodes[0].distance_sum != nodes[0].d)
	{
		printf("-1\n");
		return 0;
	}
	for (auto node{nodes.begin() + 1}; node < nodes.end(); node++)
	{
		printf("%d %d\n", node->id + 1, node->parent + 1);
	}
	return 0;
}

Measured memory_bytes: 4480
#include<bits/stdc++.h>
#include <vector>
#include <iostream>
using namespace std;
int main(){
  int n;
  cin>>n;
  long long int a,b;
  map<long long int,long long int>mp;
  cin>>a;
  long long int ans[n];
  if(a==0){
    ans[0]=1;
  }else{
    ans[0]=0;
  }
  mp[a]=0;
  for(int i=1;i<n;i++){
    cin>>b;
    a=a+b;
    std::map<long long int,long long int>::iterator itr=mp.find(a);
    if(itr!=mp.end()){
      ans[i]=ans[(itr->second)]+1;
    }else if(a==0){
      ans[i]=1;
    }else{
      ans[i]=0;
    }
    mp[a]=i;
  }
  long long int nans=0;
  for(int i=0;i<n;i++){
    nans+=ans[i];
  }
  cout<<nans<<endl;
  return(0);
}


Measured memory_bytes: 14336
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
using lint = int64_t;

const int mod = 1000000007;
struct ModInt {
    lint x;
    ModInt (lint a) : x((a % mod + mod) % mod) {}
    ModInt operator-() const {
        return ModInt(-x);
    }
    ModInt &operator+=(const ModInt &a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    ModInt &operator-=(const ModInt &a) {
        if ((x -= a.x) < 0) x += mod;
        return *this;
    }
    ModInt &operator*=(const ModInt &a) {
        (x *= a.x) %= mod;
        return *this;
    }
    ModInt operator+(const ModInt &a) const {
        ModInt res(*this);
        return res += a;
    }
    ModInt operator-(const ModInt &a) const {
        ModInt res(*this);
        return res -= a;
    }
    ModInt operator*(const ModInt &a) const {
        ModInt res(*this);
        return res *= a;
    }
    ModInt pow(lint t) const {
        if (!t) return 1;
        ModInt a = pow(t / 2);
        a *= a;
        if (t % 2) a *= *this;
        return a;
    }
    ModInt inv() const {
        return pow(mod - 2);
    }
    ModInt &operator/=(const ModInt &a) {
        return (*this) *= a.inv();
    }
    ModInt operator/(const ModInt &a) const {
        ModInt res(*this);
        return res /= a;
    }
    friend ostream &operator<<(ostream &os, const ModInt &a){
        os << a.x;
        return os;
    }
};

int main() {
    int N;
    cin >> N;
    vector<int> T(N), A(N);
    rep(i, N) cin >> T[i];
    rep(i, N) cin >> A[i];
    if (N == 1) {
        if (T[0] != A[0]) {
            cout << 0 << "\n";
            return 0;
        }
    }
    vector<int> H(N, -1);
    H[0] = T[0];
    H[N - 1] = A[N - 1];
    rep(i, N - 1) {
        if (T[i] < T[i + 1]) {
            if (H[i + 1] != -1 && H[i + 1] != T[i + 1]) {
                cout << 0 << "\n";
                return 0;
            } else {
                H[i + 1] = T[i + 1];
            }
        }
        if (A[i] > A[i + 1]) {
            if (H[i] != -1 && H[i] != A[i]) {
                cout << 0 << "\n";
                return 0;
            } else {
                H[i] = A[i];
            }
        }
    }
    rep(i, N) {
        if (H[i] != -1) {
            if (H[i] > T[i] || H[i] > A[i]) {
                cout << 0 << "\n";
                return 0;
            }
        }
    }
    ModInt ans(1);
    rep(i, N) {
        if (H[i] != -1) continue;
        ModInt M(min(T[i], A[i]));
        ans *= M;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <cstdlib>  
#include <algorithm>
#include <string>

using namespace std;
 
int main() {
    int n;cin>>n;
    int a[n];
    int k[1000005];
    for(int i = 0;i<1000005;i++) k[i] = 0;
    for(int i = 0;i<n;i++) cin>>a[i];
    for(int i = 0;i<n;i++){
     if(k[a[i]] != 0){
       k[a[i]] = 2;
     }
     else{
       for(int j = a[i];j<1000005;j+=a[i]){
       	 k[j]+= 1;
       } 
     }
    }
    int ko=0;
    for(int i = 0;i<n;i++){
      if(k[a[i]] == 1) ko++;
    }
    cout<<ko;
    return 0;
}

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

using ll = long long;
using pp = pair<ll,ll>;
const ll amari = 1e9+7;
const char BC = 'A' - 'a';
#define ben(a) a.begin(),a.end()
#define pb(a,b) a.push_back(b)
//fixed << setprecision(20)

int main(){
	int a,b,c;
	string d,e,f;
	cin >> a;
	cout << 3 * a * a << endl;
	return 0;
}


Measured memory_bytes: 256
equ = input().split()

stack = []


def push(x, stack):
    stack.append(x)
    return stack
def pop(stack):
    val = stack.pop()
    return val,stack

for symbol in equ:
    if symbol.isnumeric():
        stack = push(int(symbol),stack)
    else:
        val1, stack = pop(stack)
        val2, stack = pop(stack)
        if symbol == '+':
            stack = push(val1+val2, stack)
        elif symbol == '-':
            stack = push(val2-val1, stack)
        elif symbol == '*':
            stack = push(val1*val2, stack)

print(stack[0])


Measured memory_bytes: 5600
#include <iostream>
#include <algorithm>
#include <string>
#include <typeinfo>
#include <cmath>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define ii pair<int,int>
#define MAX 1000000007
using namespace std;


int main(){
	int d,n;
	cin>>d>>n;
	int num=1,ans;
	while(n > 0){
		if(num%100==0 && (num/100)%100==0 && (num/10000)%100 != 0 && d==2){
			ans=num;
			n--;
		}
		else if(num%100==0 && (num/100)%100 != 0 && d==1){
			ans=num;
			n--;
		}
		else if(num%100!=0 && d==0){
			ans=num;
			n--;
		}
		num++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>

using namespace std;
typedef long long ll;

int main(){

  int N;
  cin >> N;

  vector<int> a(N+1,0);
  
  for(int i=0;i<N;i++) cin >> a[i];
  a[N]=2000000;
  
  sort(a.begin(), a.end());

  ll res=0;
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      auto itr_l=upper_bound(a.begin(), a.end(), a[j]-a[i]);
      auto itr_u=lower_bound(a.begin(), a.end(), a[j]+a[i]);
      //cout << a[i] << " " << a[j] << " " << *itr_l << " " << *itr_u << endl;
      //cout << "---";for(auto it=itr_l; it<itr_u; it++) cout << *it << " "; cout << endl;
      //cout << "---" << itr_u-itr_l-1 << endl;
      res+=itr_u-itr_l-1;
      if(itr_l<=a.begin()+i) {
	res-=1;
	//cout << "---" << "-1" << endl;

      }
    }
  }

  cout << res/3 << endl;
  
  return 0;

}


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

using namespace std;

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

    if(s.length() > 3) {
        return -1;
    }

    if(s == "AAA" || s == "BBB"){
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
l,r=map(int,input().split())

if r-l+1>=2019:
    print(0)
else:
    m=[]
    for i in range(l,r+1):
        m.append(i%2019)
    n=len(m)
    ans=10**9
    for i in range(n):
        for j in range(i+1,n):
            ans=min(ans,(m[i]*m[j])%2019)
    
    print(ans)

Measured memory_bytes: 64988
#include <iostream>
#include <utility>
#include <string>
#include <vector>
using namespace std;

int main() {
	int n, q;
	cin >> n >> q;
	vector<pair<int, int>> v;
	while(q--) {
		int x, y;
		cin >> x >> y;
		v.push_back({x, y});
	}
	for(int i = 0; i <= 1000; ++i) {
		string s = to_string(i);
		if((int)s.size() == n) {
			bool ok = true;
			for(pair<int, int> x : v) {
				if(s[x.first - 1] - '0' != x.second) {
					ok = false;
					break;
				}
			}
			if(ok)
				return cout << i, 0;
		}
	}
	cout << -1;
}


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

#define sq(x) (x)*(x)
    
int main(){
    int n;
    scanf("%d", &n);
    int sc[n];
    int res=0;
    for(int i=0; i<n; i++){
        scanf("%d", sc+i);
        res+=sc[i];
    } 
    int coord = (double)res/n+0.5;
    res=0;
    for(int i=0; i<n; i++){
        res+=sq(coord-sc[i]);
    }
    printf("%d\n", res);
    return 0;
}

Measured memory_bytes: 256
int main()
{
  int n;
  scanf("%d", &n);
  int a[n], i, j, tmp, min;
  min = pow(2, 31);
  for (i = 0; i < n; i++)
  {
    scanf("%d", &a[i]);
    if (a[i] % 2 != 0)
    {
      printf("0");
      return 0;
    }
    tmp = a[i];
    for (j = 0; tmp % 2 == 0; j++)
    {
      tmp /= 2;
    }
    if (j < min)
      min = j;
  }
  printf("%d", min);
}


Measured memory_bytes: 1724
#include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 #include<deque>
 #include<functional>
 #include<utility>
 
 using namespace std;

 int main()
 {
   string s;
   int count=0;
   while(cin>>s)
   {
     bool flag=true;
     for(int i=0;i<s.length()/2;i++) 
     {
       if(s[i]!=s[s.length()-1-i])
       {
         flag=false;
         break;                           
       }          
     }         
     if(flag) count++;    
   }
   cout<<count<<endl;
   //while(1);
   return 0;
 }

 

Measured memory_bytes: 3044
from heapq import*
def dijkstra(s,e):
 g=10**6;d=[10**18]*n;f=[1]*n;d[s]=f[s]=0;q=[]
 for a,b in e[s]:heappush(q,a*g+b)
 while q:
  m=heappop(q)
  if f[m%g]:
   v=m%g;x=d[v]=m//g;f[v]=0
   for y,w in e[v]:
    if f[w]:heappush(q,(x+y)*g+w)
 return d
(n,m,s,t),*z=[map(int,t.split())for t in open(0)]
e,f=eval('[[]for _ in"_"*n],'*2)
for u,v,a,b in z:u-=1;v-=1;e[u]+=(a,v),;e[v]+=(a,u),;f[u]+=(b,v),;f[v]+=(b,u),
a,m=[],0
for y,s in zip(dijkstra(s-1,e)[::-1],dijkstra(t-1,f)[::-1]):m=max(m,10**15-y-s);a+=m,
print(*a[::-1])

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

using namespace std;

void check(int N, int Y, int& ansX, int& ansY, int& ansZ)
{
	for (int i = N; i >= 0; i--)
	{
		for (int j = N - i; j >= 0; j--)
		{
			int k = N - (i + j);
			{
				bool check1 = 10000 * i + 5000 * j + 1000 * k == Y;
				bool check2 = i + j + k == N;
				if (check1 && check2)
				{
					ansX = i;
					ansY = j;
					ansZ = k;
					return;
				}
			}
		}
	}
}

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

	int ansX = -1, ansY = -1, ansZ = -1;

	check(N, Y, ansX, ansY, ansZ);

	cout << ansX << " " << ansY << " " << ansZ << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char tolower(char ch){
  if('A'<=ch && ch<='Z'){
    return ch-'A'+'a';
  }else{
    return ch;
  }
}

int main(){
  int count=0;
  string W;
  cin>>W;
  string str;
  while(1){
    cin>>str;
    if(str=="END_OF_TEXT")break;
    for(int i=0;i<(int)str.size();i++){
      str[i]=tolower(str[i]);
    }
    if(str==W){
      count++;
    }
  }
  cout<<count<<endl;
  return 0;
}


Measured memory_bytes: 3224
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] group = new int[n];
            if (n % 2 == 0) {
                for (int i = 0; i < n / 2; ++i) {
                    group[i] = i;
                    group[n - 1 - i] = i;
                }
            } else {
                for (int i = 0; i < n / 2; ++i) {
                    group[i] = i;
                    group[n - 2 - i] = i;
                }
                group[n - 1] = n / 2;
            }
            int ne = 0;
            for (int i = 0; i < n; ++i) {
                for (int j = 0; j < i; ++j) {
                    if (group[i] != group[j]) ++ne;
                }
            }
            out.println(ne);
            for (int i = 0; i < n; ++i) {
                for (int j = 0; j < i; ++j) {
                    if (group[i] != group[j]) out.println(i + 1 + " " + (j + 1));
                }
            }
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

    }
}



Measured memory_bytes: 21716
# -*- coding: utf-8 -*-

# combinationを使う

import math

def comb(n, r):
    return math.factorial(n) // (math.factorial(r) * math.factorial(n - r))

n, m = map(int, input().split())

counter = 0

if n >= 2:
    counter = counter + comb(n, 2)

if m >= 2:
    counter = counter + comb(m, 2)

print(counter)

Measured memory_bytes: 9092
#include "bits/stdc++.h"
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define IOS std::cin.tie(0),std::ios::sync_with_stdio(false)

namespace idaten {

	using namespace std;
	using ll = int_fast64_t;
	using ull = uint_fast64_t;
	using P = std::pair<int64_t, int64_t>;
	template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
	template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
	template<class Type>struct is_vector : std::false_type {};
	template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
	template <typename T> inline std::ostream& operator << (std::ostream& out, const std::vector<T>& v) {
		if (v.empty())return out;
		constexpr bool is_vector_v = is_vector<T>::value;
		if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
		else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
		return out;
	}
	inline void put() {}
	template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
	template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
	inline void putn() {}
	template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }

	void solve() {
		IOS;
		int s, w;
		cin >> s >> w;
		if (s > w) {
			put("safe");
		} else {
			put("unsafe");
		}
	}
} // namespace idaten

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


Measured memory_bytes: 3652
using System;
using System.Collections.Generic;

namespace AtCoder {


    class Program {

        class Comparator : IComparer<int> {
            public int Compare(int x, int y) {

                var xs = x.ToString();
                var ys = y.ToString();
                xs = xs.Substring(xs.Length - 1, 1);
                ys = ys.Substring(ys.Length - 1, 1);

                var xd = int.Parse(xs);
                var yd = int.Parse(ys);

                if(xd % 10 == 0) {

                    return -1;
                }
                return -xd.CompareTo(yd);
            }
        }


        static void Main(string[] args) {

            var a = int.Parse(Console.ReadLine());
            var b = int.Parse(Console.ReadLine());
            var c = int.Parse(Console.ReadLine());
            var d = int.Parse(Console.ReadLine());
            var e = int.Parse(Console.ReadLine());

            var list = new List<int>();
            list.Add(a);
            list.Add(b);
            list.Add(c);
            list.Add(d);
            list.Add(e);

            list.Sort(new Comparator());

            var result = 0;
            var count = 0;
            foreach(var integer in list) {

                result += integer;
                count++;
                if(count < 5) {

                    result += result % 10 != 0 ? 10 - result % 10 : 0;
                }
            }

            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 11220
def cumsum(a):
    s = [0]
    for i in range(len(a)):
        s.append(s[i]+a[i][0])
    return s

n = int(input())
a_b = [list(map(int,input().split())) for _ in range(n)]
a_b = sorted(a_b,key=lambda x: x[1])
#print(a_b)
all = cumsum(a_b)
#print(all)
flag = 1
for i in range(n):
    if all[i+1] > a_b[i][1]:
        flag = 0
        break
if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 58252
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	string a, b;
	int aq, bq;
	string u;
	cin >> a >> b >> aq >> bq >> u;
	if (a == u)
	{
		aq--;
	}
	else
	{
		bq--;
	}
	cout << aq << ' ' << bq;
	return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, M; ll K;
ll A[int(2e5 + 5)], B[int(2e5 + 5)];

int main(){
  scanf("%d%d%lld", &N, &M, &K);
  for (int i = 1; i <= N; i++){
    scanf("%lld", A + i);
    A[i] += A[i - 1];
  }
  for (int i = 1; i <= M; i++){
    scanf("%lld", B + i);
    B[i] += B[i - 1];
  }

  ll ans = 0;
  for (int i = 0; i <= N; i++){
    if (K < A[i]) break;
    ll cnt = i, sum = K - A[i];

    if (sum >= B[M]){
      cnt += M;
      ans = max(ans, cnt);
      continue;
    }

    int L = 0, R = M;
    while (R - L > 1){
      int mid = (L + R) / 2;
      if (B[mid] <= sum) L = mid;
      else R = mid;
    }
    cnt += L; ans = max(ans, cnt);
  }
  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 6884
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
ll C[1500][1500];
ll dp[1500][1500];

int main() {
    init();
    ll H,W;
    cin >> H >> W;
    rep(i, H) rep(j, W) cin >> C[i][j];

    ll ans = 0;
    rep(i, H) if (!C[i][0]) dp[i][0] = 1, ans = 1;
    rep(i, W) if (!C[0][i]) dp[0][i] = 1, ans = 1;

    repe(i, 1, H)repe(j, 1, W){
        if (C[i][j]) continue;
        dp[i][j] = min({dp[i - 1][j - 1], dp[i][j - 1], dp[i - 1][j]}) + 1;
        chmax(ans, dp[i][j]);
    }

    cout << ans*ans << endl;
}


Measured memory_bytes: 31256
#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++)
#define FORR(i,m,n) for(int i=(m) ; i>=(n) ; i--)

#define All(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;

const int INF = 1e9;

int main(){
   int h,w;
   cin >> h >> w;
   vector<vector<string>> s(h,vector<string> (w));
   rep(i,h){
      rep(j,w){
         cin >> s[i][j];
      }
   }
   rep(i,h){
      rep(j,w){
         if(s[i][j] == "snuke")cout << char(j+'A') << i+1 << endl;
      }
   }
   return 0;
}

Measured memory_bytes: 256