akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main()
{
  int i, j;
  int n = 0;
  int y[15] = {};
  int a[100] = {};
  int min = 0;
  int max = 0;

  scanf("%d", &n);
  for(i = 0; i < n; i++)
  {
    scanf("%d", &a[i]);
    if(a[i]/400 < 8)
    {
      y[a[i]/400] += 1;
    }
    else if(a[i]/400 >= 8)
    {
      y[8] += 1;
    }
  }
  for(j = 0; j < 8; j++)
  {
    if(y[j] > 0)
    {
      min += 1;
    }
  }
  max = min + y[8];
  if(min == 0)
  {
    min = 1;
  }
  printf("%d %d", min, max);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using Int = int64_t;

int main() {
  Int X;
  cin >> X;
  Int n500 = X/500;
  X -= n500*500;
  Int n5 = X/5;
  cout << n500*1000 + n5*5 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <istream>
#include <ostream>

#include <cstdlib>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define rep(i,n) for(ll i=0; i < (n); ++i)
#define rrep(i,n) for(ll i=((n)-1); i >= 0; --i)

#define OPLT(T) bool operator<(const T & lop_, const T & rop_)
#define OPEQ(T) bool operator==(const T & lop_, const T & rop_)

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

istream& operator>>(istream& istr, __float128& obj) { double d; istr >> d; obj = d; return istr; };
ostream& operator<<(ostream& ostr, __float128& obj) { ostr << static_cast<double>(obj); return ostr; };

int main() {
	int K, S;
	int res = 0;
	cin >> K >> S;
	for(int i = 0; i <= K; i++) {
		for(int j = 0; j <= K; j++) {
			res += (S-(i+j) <= K) && (S-(i+j) >= 0);
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int i,n,ans=0;
	while(1){
		scanf("%d",&n);
		if(n==0) break;
		while(n>=5){
			ans+=n/5;
			n/=5;
		}
		printf("%d\n",ans);
		ans=0;
	}
		return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }


void solve(long long n, std::vector<long long> p){
	ll res = 0;
	FOR(i, 1, n-1) {
		vector<ll> v(3);
		v[0] = p[i-1];
		v[1] = p[i];
		v[2] = p[i+1];
		ASC(v);
		if (v[1] == p[i]) res++;
	}
	cout << res << "\n";
}

int main(){
    long long n;
    scanf("%lld",&n);
    std::vector<long long> p(n);
    for(int i = 0 ; i < n ; i++){
        scanf("%lld",&p[i]);
    }
    solve(n, std::move(p));
    return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10000000)
import os
import math
import bisect
import collections
import itertools
import heapq
import re
import queue

# import fractions

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    A = il()

    if 0 in A:
        print(0)
        exit()

    ret = 1
    for n in range(N):
        ret *= A[n]
        if ret > 10 ** 18:
            print(-1)
            exit()
    else:
        print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 21264
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
int cmp(const void *a, const void *b);
//your code here!

int main(void){
    ll ans=0;
    char S[4];
    scanf("%s", S);
    rep(i, 0, 3) ans += S[i] - '0';
    printf("%lld\n", ans);
    return 0;
}

int cmp(const void *a, const void *b){
    ll A=*(ll *)a, B=*(ll *)b;
    if(A==B)return 0;
    else return A>B ? 1:-1;//昇順ソート
}


Measured memory_bytes: 128
//package com.company;
import java.util.*;
import java.io.*;
import java.lang.*;


public class Main {

    public static void main(String[] args) {
	// write your code here

      //  System.out.println("Hello World");
        // System.out.println("This is my first package ");
        Scanner s=new Scanner(System.in);
        int n=s.nextInt();
        if(n==0)
        {
            System.out.println(1);
        }
        else {
            System.out.println(0);
        }



    }
}


Measured memory_bytes: 35772
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define SZ(X) ((int)(X).size())
#define endl "\n";
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	int n,sum=0;	
	cin>>n;
	while(n--){
		int l,r;
		cin>>l>>r;
		sum+=(r+1)-l;
	}
	cout<<sum<<endl;
   return 0;
}


Measured memory_bytes: 3644
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s,c;
	cin>>s>>c;int cnt=0;
	for (int i = 0;i<s.length(); ++i)
	{
        if(s[i]!=c[i]){
        	cout<<"No\n";
        	return 0;
        }
	}
	cout<<"Yes\n";
    return 0;
}



Measured memory_bytes: 3624
using System;

public class Test
{
	public static void Main()
	{
		var line = System.Console.ReadLine();
//    	System.Console.WriteLine(line);
		if((line.IndexOf("RRR")) == 0)
			System.Console.WriteLine(3);
		else if((line.IndexOf("RR")) >= 0)
			System.Console.WriteLine(2);
		else if((line.IndexOf("R")) >= 0)
			System.Console.WriteLine(1);
		else
			System.Console.WriteLine(0);
	}
}

Measured memory_bytes: 26208
N = gets.chomp.to_i
str = gets.split
a = Array.new(N)
b = 0
for i in 0...N do
    a[i] = str[i].to_i
    if a[i] != i+1
        b += 1
    end
end
if b <= 2
    puts "YES"
else
    puts "NO"
end

Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <queue>

typedef long long ll;
const ll LL_MAX (1LL<<60);
const ll MOD (1000000007);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

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

    char a, b;
    cin >> a >> b;

    string strb;
    rep(i,0,a-'0')
        strb += b;

    string stra;
    rep(i,0,b-'0')
        stra += a;

    if (stra > strb)
        cout << strb << endl;
    else
        cout << stra << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
const int maxn=1e7+5;
char arr[maxn];
int main()
{
	scanf("%s",arr);
	int len=strlen(arr);
	int flag=1;
	if (len%2!=0)
		printf("No\n");
	else
	{
		for (int i=0;i<len;i++)
		{
			if (i%2==0)
			{
				if (arr[i]!='h')
				{
					flag=0;
					break;
				}
			}
			else
			{
				if (arr[i]!='i')
				{
					flag=0;
					break;
				}
			}
		}
		if (flag)
			printf("Yes\n");
		else
			printf("No\n");
	}
} 

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
const int MAX_N = 100;
int m, n;
vector<vector<int>> table(MAX_N, vector<int>(MAX_N)), used(MAX_N, vector<int>(MAX_N));
int dfs(int y, int x)
{
    int res = 0;
    for(int i = 0; i < 4; i++)
    {
        int ny = y + dy[i];
        int nx = x + dx[i];
        if(ny < 0 || nx < 0 || ny >= n || nx >= m) continue;
        if(table[ny][nx] == 0 || used[ny][nx]) continue;
        used[ny][nx] = 1;
        res = max(res, dfs(ny, nx));
        used[ny][nx] = 0;
    }
    return res + 1;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> m >> n, m | n)
    {
        for(int i = 0; i < n; i++)
        {
            for(int j = 0; j < m; j++)
            {
                cin >> table[i][j];
                used[i][j] = 0;
            }
        }
        int ans = 0;
        for(int i = 0; i < n; i++)
        {
            for(int j = 0; j < m; j++)
            {
                if(table[i][j] == 0) continue;
                used[i][j] = 1;
                ans = max(ans, dfs(i, j));
                used[i][j] = 0;
            }
        }
        cout << ans << endl;
    }
    return 0;
}




Measured memory_bytes: 3184
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <cstring>

using namespace std;

int main(){

	int n;
	int field[16][16];
	while(cin>>n&&n!=0){
		memset(field,0,sizeof(field));
		field[(n/2)+1][n/2]=1;
		int cx=n/2;
		int cy=(n/2)+1;
		int num=2;
		int sw=0;
		while(1){
			if(sw==0){
				int ny=(cy+1)%n;
				int nx=(cx+1)%n;
				if(field[ny][nx]==0){
					field[ny][nx]=num;
					if(num==n*n)
						break;
					num++;
					cx=nx,cy=ny;
				}
				else{
					sw=1;
					cx=nx,cy=ny;
				}
			}
			else{
				int ny=(cy+1)%n;
				int nx=(cx+n-1)%n;
				if(field[ny][nx]==0){
					field[ny][nx]=num;
					if(num==n*n)
						break;
					num++;
					sw=0;
					cx=nx,cy=ny;
				}
				else{
					sw=1;
					cx=nx,cy=ny;
				}
			}

		}
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				printf("%4d",field[i][j]);
			}
			cout<<endl;
		}
	}

	return 0;
}

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

ll gcd(ll a,ll b)
{
	if(b!=0)
		return gcd(b,a%b);
	else
		return a;
}

int main(void)
{
	int a,i,j,k;
	ll sum=0;
	scanf("%d",&a);
	
	for(i=1;i<=a;i++)
	{
		for(j=1;j<=a;j++)
		{
			for(k=1;k<=a;k++)
			{
				sum+=gcd(gcd(i,j),k);
			}
		}
	}
	
	printf("%lld",sum);
	return 0;
}

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


int main() {
  
	unordered_map<string, int> m;
	int n;
	cin >> n;
	string x;
	for (int i = 0; i < n; i++) {
		cin >> x;
		if (x == "AC") {
			m["AC"]++;
		} else if (x == "WA") {
			m["WA"]++;
		} else if (x == "TLE") {
			m["TLE"]++;
		} else {
			m["RE"]++;
		}
	}


	int ac = m["AC"];
	int wa = m["WA"];
	int tle = m["TLE"];
	int re = m["RE"];

	printf("AC x %d\n", ac);
	printf("WA x %d\n", wa);
	printf("TLE x %d\n", tle);
	printf("RE x %d", re);


}







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

#define pb         push_back

const int INF = 100000000;

int main(void) {
	int m;
	cin >> m;
	for(int i=0; i<m; i++){
		string s;
		cin >> s;
		set<string> sset;
		string sr = s;
		reverse(s.begin(), s.end());
		for(int i=0; i<s.size() - 1; i++){
			string s1 = s.substr(0, i+1);
			string s2 = s.substr(i+1);
			string s1r = sr.substr(sr.size() - (i+1));
			string s2r = sr.substr(0, sr.size() - (i+1));
			
			sset.insert(s1 + s2);
			sset.insert(s1r + s2);
			sset.insert(s1 + s2r);
			sset.insert(s1r + s2r);

			sset.insert(s2 + s1);
			sset.insert(s2r + s1);
			sset.insert(s2 + s1r);
			sset.insert(s2r + s1r);
		}
		cout << sset.size() << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1292
N, M = map(int,input().split())
Cities = []
for _ in range(M):
    Cities.append(list(map(int,input().split())))
L = [[] for i in range(N+1)]
for P, Y in Cities:
    L[P].append(Y)
for i in range(N+1):
    L[i].sort()
D = [{} for _ in range(N+1)]
for i in range(1, N+1):
    for val, key in enumerate(L[i], 1):
        D[i][key] = val

for P, Y in Cities:
    left = str(P).zfill(6)
    right = str(D[P][Y]).zfill(6)
    print(left + right)

Measured memory_bytes: 77968
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
ll two(ll a){
  ll key=0;
  while(a%2==0) {
    a/=2;
    key++;
  }
  return min((ll)2,key);
}
int main(){
  int a,b; cin >>a>>b;
  if(a!=1&&b!=1) cout<<1<<endl;
  if(a!=2&&b!=2) cout<<2<<endl;
  if(a!=3&&b!=3) cout<<3<<endl;
}

Measured memory_bytes: 3576
#include <stdio.h>

int main(void)
{
	int a,b,c;
	scanf("%d %d",&a,&b);
	if(a>b){
		a=b;
	}
	scanf("%d %d",&b,&c);
	if(b>c){
		b=c;
	}
	printf("%d",a+b);
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int main(){
    int n,i,j;
    char s[5];
    scanf("%s",s);
    int a=s[0]-'0',b=s[1]-'0',c=s[2]-'0',d=s[3]-'0';
    if(a+b+c+d==7)printf("%d+%d+%d+%d=7\n",a,b,c,d);
    else if(a+b+c-d==7)printf("%d+%d+%d-%d=7\n",a,b,c,d);
    else if(a+b-c+d==7)printf("%d+%d-%d+%d=7\n",a,b,c,d);
    else if(a+b-c-d==7)printf("%d+%d-%d-%d=7\n",a,b,c,d);
    else if(a-b+c+d==7)printf("%d-%d+%d+%d=7\n",a,b,c,d);
    else if(a-b+c-d==7)printf("%d-%d+%d-%d=7\n",a,b,c,d);
    else if(a-b-c+d==7)printf("%d-%d-%d+%d=7\n",a,b,c,d);
    else if(a-b-c-d==7)printf("%d-%d-%d-%d=7\n",a,b,c,d);

}


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

int main(){
    while(1){
        int result=0;
        int n,x;
        cin>>n>>x;
        if((n==0)&&(x==0))break;
        for(int i=1;i<n;i++){
            int y=x;
            y-=i;
            for(int j=i+1;j<=n;j++){
                if(((y-j)>j)&&((y-j)<=n)){
                    result++;
                }
            }
        }
        cout<<result<<endl;
    }
    return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define L_T_S_K ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);  
const int mod = 1e9 + 7;
const int N = 1e5 + 100;
std::vector <int> v[N];
int add(int a , int b){
  return (a % mod +  b % mod)%mod;
}
int mul(int a , int b){
  return ((a % mod) *  (b % mod))%mod;
}
//color 0 -- > Black
//color 1 -- > White
int dp[N][2]; 
int dfs(int src , int par , int color){
  if(dp[src][color] != -1) return dp[src][color];
  int ans = 1;
  for(auto x : v[src]){
    if(x == par) continue;
    else{
      if(color == 1){
       ans = mul(ans , add( dfs(x , src , color), dfs(x , src , color ^ 1)));
      }else ans = mul(ans , dfs(x , src , color ^ 1));
    }
  }
  dp[src][color] = ans;
  return ans;
}

int32_t main(){
 L_T_S_K;
  int n;
  cin >> n;
  memset(dp , -1 , sizeof dp);
  for(int i = 1 ; i < n ; i++){
    int x  , y;
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  cout << add(dfs(1 , -1 , 1) , dfs(1 , -1 , 0));
  return 0;
}

Measured memory_bytes: 15616
def main():
    N, M = map(int, input().split())
    S = []
    for _ in range(M):
        a = list(map(int, input().split()))
        S.append([b-1 for b in a[1:]])
    P = list(map(int, input().split()))

    # set mask
    mask = [0 for _ in range(M)]
    for i in range(M):
        m = 0
        for s in S[i]:
            m += 2 ** s
        mask[i] = m
    
    ans = 0
    for k in range(2 ** N):
        res = True
        for i in range(M):
            if bin(k & mask[i]).count('1') % 2 != P[i]:
                res = False
                break
        if res:
            ans += 1

    print(ans)

main()

Measured memory_bytes: 3064
#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define rep(a,t) for(int a=0;a<t;a++) 
#define forever while(true)
#define Sort(a) sort(a.begin(),a.end())
#define Reverse(a) reverse(a.begin(),a.end())
#define pb push_back
vector<int>Eratosthenes_10000ver(int n) {
	bool dp[1000000];
	for (int i = 0; i <=n; i++) { dp[i] = true; }
	dp[0] = dp[1] =false;
	vector<int>prime;
	for (int i = 2; i < n+1; i++) {
		if (!dp[i]) { continue; }
		prime.pb(i);
		for (int j = i * 2; j < n+1; j += i) {
			dp[j] = false;
		}
	}
	return prime;
	
}
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	vector<int>primes=Eratosthenes_10000ver(300000);
	while (true) {
		int n;
		cin >> n;
		if (n == 0) { break; }
		long long ans = 0;
		rep(i, n) { ans += primes[i]; }
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3520
#include <cstdio>
#include <cstring>
#include <algorithm>
 
using namespace std;
 
typedef long long ll;
 
struct Edge {
  int t,next;
  Edge() {}
  Edge(int a,int b):t(a),next(b) {}
};
 
Edge e[200005];
int head[100005],d[100005];
 
ll num[100005];
 
ll dfs(int x,int fa) {
  if (d[x]==1) return num[x];
  ll sum=0,maxn=0;
  for(int i=head[x];i;i=e[i].next)
    if (e[i].t!=fa) {
        int u=e[i].t;
        ll s=dfs(u,x);
        if (s<0) return -1;
        sum+=s;maxn=max(maxn,s);
    }
  ll t=(maxn>sum-maxn)?sum-maxn:(sum>>1);
  return (sum>=num[x]&&sum-num[x]<=t)?(num[x]<<1)-sum:-1;
}
 
int main() {
  int n;
  scanf("%d",&n);
  for(int i=1;i<=n;i++) scanf("%lld",&num[i]);
  for(int i=1;i<n;i++) {
    int x,y;
    scanf("%d%d",&x,&y);
    e[2*i-1]=Edge(y,head[x]);
    head[x]=2*i-1;
    e[2*i]=Edge(x,head[y]);
    head[y]=2*i;
    d[x]++;d[y]++;
  }
  if (n==2) {
    puts((num[1]==num[2])?"YES":"NO");
    return 0;
  }
  int rt=0;
  for(int i=1;i<=n;i++)
    if (d[i]>1) rt=i;
  puts((dfs(rt,0)==0)?"YES":"NO");
  return 0;
}


Measured memory_bytes: 9088
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


struct Info{
	int hit,blow;
};

struct Data{
	int number,hit,blow;
};

int N;
int table[5040];
Data data[5040];

Info calc(int left,int right){

	Info ret;

	int table_left[10],table_right[10];

	for(int i = 0; i < 10; i++){
		table_left[i] = -1;
		table_right[i] = -1;
	}

	int S = 10;
	for(int i = 1; i <= 4; i++){
		table_left[left%S] = i;
		left /= S;
		table_right[right%S] = i;
		right /= S;
	}

	ret.hit = 0;
	ret.blow = 0;

	for(int i = 0; i < 10; i++){
		if(table_left[i] != -1){
			if(table_left[i] == table_right[i]){
				ret.hit++;
			}else if(table_right[i] != -1){
				ret.blow++;
			}
		}
	}

	return ret;
}

void func(){

	for(int i = 0; i < N; i++){
		scanf("%d %d %d",&data[i].number,&data[i].hit,&data[i].blow);
	}

	vector<int> CANDIDATE;
	bool FLG;
	Info ret;

	for(int i = 0; i < 5040; i++){
		FLG = true;
		for(int k = 0; k < N; k++){
			ret = calc(data[k].number,table[i]);
			if(ret.hit != data[k].hit || ret.blow != data[k].blow){
				FLG = false;
				break;
			}
		}
		if(FLG){
			CANDIDATE.push_back(i);
		}
	}

	if(CANDIDATE.size() == 1){
		if(table[CANDIDATE[0]] < 1000){
			printf("0");
		}
		printf("%d\n",table[CANDIDATE[0]]);
		return;
	}

	vector<int> WORK;
	int tmp_number,hit_blow;

	for(int i = 0; i < 5040; i++){
		tmp_number = table[i];
		WORK.clear();

		FLG = true;
		for(int k = 0; k < CANDIDATE.size(); k++){
			if(tmp_number == CANDIDATE[k])continue;

			ret = calc(tmp_number,table[CANDIDATE[k]]);
			hit_blow = 10000*ret.hit+ret.blow;

			for(int a = 0; a < WORK.size(); a++){
				if(WORK[a] == hit_blow){
					FLG = false;
					break;
				}
			}
			if(!FLG)break;
			else{
				WORK.push_back(hit_blow);
			}
		}
		if(FLG){
			if(tmp_number < 1000){
				printf("0");
			}
			printf("%d\n",tmp_number);
			return;
		}
	}

	printf("????\n");
}

int main(){

	int index = 0;

	for(int a = 0; a <= 9; a++){
		for(int b = 0; b <= 9; b++){
			for(int c = 0; c <= 9; c++){
				for(int d = 0; d <= 9; d++){
					if(a != b && a != c && a != d && b != c && b != d && c != d){
						table[index] = 1000*a+100*b+10*c+d;
						index++;
					}
				}
			}
		}
	}

	while(true){
		scanf("%d",&N);
		if(N == 0)break;

		func();
	}

	return 0;
}

Measured memory_bytes: 3184
#!/usr/bin/env python3
from itertools import permutations
n, m = map(int, input().split())
G = [[] for _ in [0] * -~n]
for _ in [0] * m:
    a, b = map(int, input().split())
    G[a] += b,
    G[b] += a,
ans = 0
for i in permutations(range(2, n + 1), n - 1):
    i = (1,) + i
    if all(i[j] in G[i[j + 1]] for j in range(n - 1)):
        ans += 1
print(ans)

Measured memory_bytes: 3188
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

class DisjointSet{
    public:
    vi rank, p;
    
    DisjointSet(){}
    DisjointSet(int size){
        rank.resize(size,0);
        p.resize(size,0);
        rep(i,size)makeSet(i);
    }
    
    void makeSet(int x){
        p[x]=x;
        rank[x]=0;
    }
    
    bool same(int x,int y){
        return findSet(x)==findSet(y);
    }
    
    void unite(int x,int y){
        link(findSet(x),findSet(y));
    }
    
    void link(int x,int y){
        if(rank[x]>rank[y]){
            p[y]=x;
        }
        else{
            p[x]=y;
            if(rank[x]==rank[y]){
                rank[y]++;
            }
        }
    }
    
    int findSet(int x){
        if(x!=p[x]){
            p[x]=findSet(p[x]);
        }
        return p[x];
    }
};

void run(){
    string s,t;
    cin>>s>>t;
    int l=s.length();
    vi a(26),b(26);
    rep(i,l){
        a[s[i]-'a']++;
        b[t[i]-'a']++;
    }
    sort(all(a));
    sort(all(b));
    reverse(all(a));
    reverse(all(b));
    rep(i,26){
        if(a[i]!=b[i]){
            cout<<"No"<<endl;
            return;
        }
    }
    cout<<"Yes"<<endl;
}

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


int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  rep(i, n) cin >> d[i];
  int m;
  cin >> m;
  vector<int> t(m);
  bool flag = true;
  rep(i, m) cin >> t[i];
  sort(all(d));
  sort(all(t));
  int p = 0;
  rep(i, m) {
    for (int j = p; j < n; j++) {
      if (d[j] == t[i]) {
        p = j+1;
        break;
      }
      else if (d[j] > t[i]) {
        p = j;
        flag = false;
      }
    }
  }
  if (flag) puts("YES");
  else puts("NO");
  return 0;
}

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

int main()
{
    while (1)
    {
        int n, x;
        int ans = 0;
        cin >> n >> x;
        if (n == 0 && x == 0)
            break;
        for (int i = 1; i <= n - 2; i++)
        {
            for (int j = i + 1; j <= n - 1; j++)
            {
                for (int k = j + 1; k <= n; k++)
                {
                    if ((i + j + k) == x)
                        ans++;
                }
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3092
import java.io.IOException;

import java.io.BufferedReader;
import java.io.InputStreamReader;


public class Main {
    public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            final String s = reader.readLine();

            int M = Integer.parseInt(s);

            System.out.println(48 - M);
        }
    }
}


Measured memory_bytes: 22868
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <queue>

using namespace std;
typedef long long ll;

int main(){
    ll n, m;
    cin >> n >> m;
    unordered_map<ll, vector<ll>> arbeit;
    for(int i = 0; i < n; ++i){
        ll a, b;
        cin >> a >> b;
        arbeit[a].push_back(b);
    }
    priority_queue<ll> q;
    ll ans = 0;
    for(int i = 1; i <= m; ++i){
        if(arbeit.count(i)){
            for(ll x : arbeit.at(i)){ q.push(x); }
        }
        if(!q.empty()){
            ans += q.top();
            q.pop();
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 10144
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxN = 5e3 + 13;
int n, h[maxN], p[maxN], dp[maxN][maxN], ans, arr[maxN];
bool cmp (int i, int j) {
    if (h[i] + p[i] < h[j] + p[j])
	return 1;
    return 0;
}
int32_t main () {
    cin >> n;
    for (int i = 1; i <= n; i++) {
	cin >> h[i] >> p[i];
    }
    iota(arr + 1, arr + n + 1, 1);
    sort(arr + 1, arr + n + 1, cmp);
    memset(dp, 63, sizeof dp);
    dp[0][0] = 0;
    for (int i = 1; i <= n; i++) {
	for (int j = 1; j <= i + 1; j++) {
	    if (dp[i - 1][j - 1] > h[arr[i]])
		dp[i][j] = dp[i - 1][j];
	    else {
		dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - 1] + p[arr[i]]);
	    }
	}
    }
    for (int i = 1; i <= n; i++) {
	if (dp[n][i] < 1e18)
	    ans = i;
    }
    cout << ans << endl;
    
}


Measured memory_bytes: 196736
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2000;
int main()
{
    std::ios::sync_with_stdio(false);
    ll d, s, t;
    cin >> d >> s >> t;
    if(s * t >= d) cout << "Yes" << "\n";
    else cout << "No" << "\n";
    return 0;
}


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

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

using namespace std;

int main(){
	int a,b,c,k; cin>>a>>b>>c>>k;
	if(a<b) swap(a,b);
	if(a<c) swap(a,c);
	cout<<a*(1<<k)+b+c<<endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
using namespace std;
typedef long long ll;
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, a, b;
	cin >> n >> a >> b;
	if (n == 1)puts("Hello World");
	else cout << a + b << endl;
	return 0;
}

Measured memory_bytes: 256
/* ex3_2
   moka223711 */

#include <stdio.h>

int main(void){
  int N;
  // 入力Nを受け取る
  scanf("%d", &N);
  
  // N % 10で1の位を取得する
  // switch文で各値に対してN本の本の読み方を出力する
  switch(N % 10){
    case 2: case 4: case 5: case 7: case 9:
      printf("hon");
      break;
    case 0: case 1: case 6: case 8:
      printf("pon");
      break;
    default:
      printf("bon");
  }
  
  return 0;
}


Measured memory_bytes: 1732
#include<bits/stdc++.h>
#define for0(i,n) for(int i=0;i<n;i++)
#define rep(i,s,n) for(int i=s;i<n;i++)
#define sp <<" "<<					// giving space
#define MOD 1000000007				// for mod
#define ll_max 1000000000000000000
#define ll long long
#define ld long double
#define BOOST ios_base::sync_with_stdio ( false ); cin.tie ( nullptr ); cout.tie ( nullptr );
using namespace std;
// Vector
#define vi vector<int>					//integer vector
#define vll vector<ll>
#define pb push_back				//vector element insertion
#define pf push_front
#define er(v,i) v.erase(v.begin()+i)			// erase ith element in a vector
#define erng(v,x) v.erase(v.begin(),v.begin()+x)       	// delete a range in array

//Stack
/*  stack<int> s;						//declaring stack
s.push(1)						// enter  element in stack
s.top()							//returns top element in stack
s.pop()							//removes top element in  stack
*/
// pair
#define pii pair<int,int>					//pair integers
#define ff first
#define ss second
#define mp(a,b) make_pair(a,b)			// entering pair element in vector(size not defined)

//Hashmap
/* map<string,string> a;				//declaration
a[“abc”]=”xyz”;					// element entry in map;
gquiz1.insert(pair<int, int>(1, 40));
map<string,string>::iterator itr;			//iterating map
for (itr = a.begin(); itr!=a.end(); itr++){
    cout <<(*itr).first  << itr->second <<endl;
  }
  itr = companies.find("abc");		//finding element in map
  cout << itz->second;

//*/

int dp[1005][1005];
int solve(int i,int j)
{
    if(dp[i][j]==-2)return 0;
    if(i==1&&j==1)return 1;
    if(i==0||j==0)return 0;
    if(dp[i][j]!=-1)return dp[i][j];
    dp[i][j]=(solve(i-1,j)+solve(i,j-1))%MOD;
    return dp[i][j];
}
int main()
{
   int h,w;
   char c;
   cin>>h>>w;
   for0(i,h)
   {
       for0(j,w)
       {
           cin>>c;
           if(c=='#')dp[i+1][j+1]=-2;
            else dp[i+1][j+1]=-1;
       }
   }
    int ans=solve(h,w);
    cout<<ans;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP1(i,n) for(int i = 1; i < n+1 ;i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
using namespace std;
typedef long long ll;
using p = pair<int, int>;
using P = pair<ll, ll>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using Graph = VV;

int main(){
    ios::sync_with_stdio(false); cin.tie(0);
    double l;
    cin >> l;
    cout << std::fixed << std::setprecision(15)<<(l/3.0)*(l/3.0)*(l/3.0) <<endl;

}

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

public class Hello
{
    public static void Main()
    {
        var s = Console.ReadLine().Trim();
        var d = new Dictionary<char, int>();
        foreach (var x in s)
            if (d.ContainsKey(x)) d[x]++;
            else d[x] = 1;
        Console.WriteLine(getAns(d));
    }
    static int getAns (Dictionary<char,int> d)
    {
        var count = 0;
        foreach (var x in d)
            if (x.Value % 2 == 1) count++;
        return  count / 2;
    }
}



Measured memory_bytes: 17772
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
import math
import time
import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)]
        rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()
#sys.setrecursionlimit(10**5)
input=lambda: sys.stdin.readline().rstrip()

def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

show_flg=False
show_flg=True

n,a,b=LI()
if (a-b)%2==0:
    ans=abs(b-a)//2
else:
    ans=min(max(n-a,n-b),max(a-1,b-1),a+abs(b-a-1)//2,n-b+1+abs(a+n-b+1-n)//2)
    
print(ans)

Measured memory_bytes: 39404
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(n) begin(n),end(n)
using ll = long long;
using P = pair<int,int>;
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; }
const long long INF = 1LL << 60;

ll h[1010000];
ll dp[1010000];

int main() {
    int n, k; 
    cin >> n >> k;
    rep(i,n) cin >> h[i];
    rep(i,1010000) dp[i] = INF; 
    dp[0] = 0;
    rep(i,n) {
        for(int j = 1; j <= k; ++j){
            chmin(dp[i+j], dp[i] + abs(h[i+j] - h[i]) );
        }
    }
    cout << dp[n-1] << endl;
    return 0;
}

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

using namespace std;

bool p[100010];

void erato(){
    fill(p, p+100010, true);
    p[0] = p[1] = false;
    for(int i=0; i < 100010; i++){
        if(!p[i]) continue;
        for(int j=i+i; j < 100010; j += i){
            p[j] = false;
        }
    }
}

int main(){
    erato();
    int n;
    while(cin >> n){
        int count = 0;
        for(int i=1; i <= n; i++){
            if(p[i] && p[n-i+1]) count++;
        }
        cout << count << endl;
    }
}

Measured memory_bytes: 1256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;

int main()
{
    string s;
    int ans = 0;
    cin >> s;
    rep(i, 3)if(s[i] == 'o')++ans;
    cout << 700 + ans * 100 << endl;
    return 0;
}


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


int V,E;
int color=0;
int C[LARGE];

typedef struct list{
	int id;
	struct list *next;
}list;


list * makelist(int x){
	list *new=malloc(sizeof(list));
	new->id=x;
	new->next=NULL;
	return new;
}

void list_insert(list* L[],int x,list *new){
	list **p=&L[x];
	
	while((*p)!=NULL){
		p=&((*p)->next);
	}
	(*p)=new;
	
	return;
}

int push(int stack[],int x,int top){
	stack[top++]=x;
	return top;
}

int pop(int stack[],int *top){
	(*top)--;
	return stack[*top];
}

void dfs(int C[],int x,list* L[]){
	int stack[LARGE];
	int top=0;
	int temp;
	list *p;
	
	color++;
	top=push(stack,x,top);
	while(top>0){
		temp=pop(stack,&top);
		if(C[temp]==0)C[temp]=color;
		p=L[temp];
		while(p!=NULL){
			if(C[p->id]==0){
				top=push(stack,p->id,top);
				C[p->id]=color;
			}
			p=p->next;
		}
	}
	
	return;
}

int main(){
	int i,j;
	int s,t,q;
	int x,y;
	list *L[LARGE];
	list *new;
	
	scanf("%d %d",&V,&E);
	
	for(i=0;i<V;i++){
		L[i]=NULL;
		C[i]=0;
	}
	
	for(i=0;i<E;i++){
		scanf("%d %d",&s,&t);
		new=makelist(t);
		list_insert(L,s,new);
		new=makelist(s);
		list_insert(L,t,new);
	}
	
	scanf("%d",&q);
	for(i=0;i<q;i++){
		scanf("%d %d",&x,&y);
		if(C[x]==0)dfs(C,x,L);
		if(C[y]==0)dfs(C,y,L);
		if(C[x]==C[y])printf("yes\n");
		else printf("no\n");
	}
		
	
	return 0;
	
}



Measured memory_bytes: 9132
N = input()

if int(N) < 10:
    if int(N) == 9:
        print('Yes')
    elif int(N) == 0:
        print('Yes')
    else:
        print('No')
elif int(N) >= 10:
    l = [int(n) for n in list(N)]
    a = sum(l)
    if a % 9 == 0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 12388
#include <bits/stdc++.h>
using namespace std;
 
string S; int N, cnt;
 
int main() {
	int A,B;
    cin >> A >> B;
    if(A-B==0)cout << "0" << endl;
    else if((A+B)%2==0)cout << (A+B)/2 << endl;
    else cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxn=2e5+10;
string a,b;
int p[100],f[50][maxn],ans,pos,pre;
signed main()
{
	cin>>a>>b;
	a=a+a;
	int lena=a.length(),lenb=b.length();
	for(register int i=1;i<=26;i++)
		p[i]=-1;
	for(register int j=lena-1;j>=0;j--)
	{
		for(register int i=1;i<=26;i++)
			f[i][j]=p[i];
		p[a[j]-96]=j;
	}
	for(register int i=0;i<lenb;i++)
		if(p[b[i]-96]==-1)
		{
			puts("-1");
			return 0;
		}
	pos=p[b[0]-96];
	ans+=pos;
	pre=pos;
	for(register int i=1;i<lenb;i++)
	{
		pos=f[b[i]-96][pre];
		ans+=pos-pre;
		pre=pos%(lena/2);
	}
	printf("%lld",ans+1);
	return 0;
}

Measured memory_bytes: 42240
#include <stdio.h>

int main()
{
	int i, N, t, A[100000];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) {
		scanf("%d", &t);
		A[t] = i;
	}

	for (i = 1; i <= N; i++) {
		printf("%d ", A[i]);
	}
}

Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <queue>
#define llint long long

using namespace std;

llint n, m;
priority_queue<llint> Q;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> m;
	llint a;
	for(int i = 1; i <= n; i++){
		cin >> a;
		Q.push(a);
	}
	
	for(int i = 1; i <= m; i++){
		if(Q.size() == 0){
			cout << 0 << endl;
			return 0;
		}
		llint x = Q.top();
		Q.pop();
		x /= 2;
		Q.push(x);
	}
	llint ans = 0;
	while(Q.size()){
		ans += Q.top();
		Q.pop();
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 1400
#include<cstdio>
#include<iostream>
#include<bits/stdc++.h>
#include<vector>
#include<algorithm>

using namespace std;

long long int f(int num){


	if(num<=1){
		return 1;
	}
	else{
		return (num*f(num-1));
	}

}

int combine(int n,int m){
	return (n*(n-1))/2;
}


int main(){

        ios::sync_with_stdio(false);
        cin.tie(0);

	int n=0,m=0;
	cin >> n >> m;
	
	//cout << combine(13,2)<<endl;
	if(n<=1 || m<=1){
		if(n<=1 && m<=1) cout << "0";
		else if(n<=1){
			cout << combine(m,2);
		}
		else if(m<=1){
			cout << combine(n,2);
		}			
	}
	else{
		//cout <<"nnn="<<n<<"m="<<m<<endl;
		//cout <<"re="<< combine(n,2)<<" " <<combine(m,2)<<endl;
		cout << combine(n,2)+combine(m,2);

	}
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
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;
  ll ans = 0;
  for(int a=1;a<=N;a++){
    for(int b=1;b<=N;b++){
      if(a*b<N) ans++;
      else break;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <map>
#include <queue>
#include <string>
using namespace std;

typedef long long ll;

string S;
size_t cur=0;
int parse();

int digit(){
    assert(isdigit(S[cur]));
    int n=S[cur]-'0';
    cur++;
    return n;
}

int number(){
    int n=digit();
    while(cur<S.size()&&isdigit(S[cur]))
	n=n*10+digit();
    return n;
}

int expression();
int factor(){
	if(S[cur]!='(')return number();
	cur++;
	int n=expression();
	assert(S[cur]==')');
	cur++;
	return n;
}

int term(){
    int a=factor();
    while(cur<S.size()&&(S[cur]=='*'||S[cur]=='/')){
		char op=S[cur++];
		int b=factor();
		if(op=='*')a*=b; else a/=b;
    }
    return a;
}

int expression(){
    int a=term();
    while(cur<S.size()&&(S[cur]=='+'||S[cur]=='-')){
	char op=S[cur++];
	int b=term();
	if(op=='+')a+=b; else a-=b;
    }
    return a;
}

int main() {
    int n;
    cin>>n;
    while(cin>>S){
	cur=0;
	cout<<expression()<<endl;
    }
} 

Measured memory_bytes: 0
package main

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

func main() {
  var n int = NextInt()
  var a []int = make([]int,n+2)
  for i:=1;i<n+1;i++ { a[i] = NextInt() }
  var m,s int
  for i:=0;i<n+2;i++ {
    if a[i] == 0 {
      m += s/2
      s = 0
      continue
    }
    s += a[i]
  }
  fmt.Println(m)
}

var reader = bufio.NewReaderSize(os.Stdin,1000000)
func NextLine() string {
  var line,buffer []byte
  var isPrefix bool = true
  var err error
  for ;isPrefix; {
    line,isPrefix,err = reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
  }
  return string(buffer)
}
func NextInt() int {
  var x int
  x,_ = strconv.Atoi(NextLine())
  return x
}

Measured memory_bytes: 5632
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 11;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

int in[4];
int main() {
	scanf("%1d%1d%1d%1d", &in[0], &in[1], &in[2], &in[3]);

	int i, j;
	for (i = 0; i < 8; i++) {
		int v = in[0];
		for (j = 0; j < 3; j++) {
			if (i & (1 << j)) v += in[j + 1];
			else v -= in[j + 1];
		}
		if (v == 7) {
			printf("%d", in[0]);
			for (j = 0; j < 3; j++) {
				if (i & (1 << j)) printf("+");
				else printf("-");
				printf("%d", in[j + 1]);
			}
			return !printf("=7\n");
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int val[105];
int main(){
  string s;
  cin>>s;
  int contg = 0;
  int w = 0;
  int l = 0;
  for (int i = 0; i < s.length(); i++){
    if(s[i] == 'g'){
      if(contg > 0){
        contg--;
        w++;
      }else{
        contg++;
      }
    }else{
      if(contg > 0){
        contg--;
      }else{
        contg++;
        l++;
      }
    }
    //cout<<w<<" "<<l<<endl;
  }
  cout<<w-l<<endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
const int MOD=1000000007;

bool isPowerOfTwo (ll x)  
{  
    return x && (!(x&(x-1)));  
}
bool isPrime(int n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
int highestPowerof2(unsigned int n) 
{ 
    // Invalid input 
    if (n < 1) 
        return 0; 
  
    int res = 1;
    for (int i=0; i<8*sizeof(unsigned int); i++) 
    { 
        int curr = 1 << i; 
        if (curr > n) 
           break; 
  
        res = curr; 
    } 
  
    return res; 
} 
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}       
////////////////////////////////////////////////////////////////////

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(NULL);
  ll t=1;
  while(t--)
  {
    ll n;
    cin>>n;
    cout<<1LL*n*(n-1)/2;
  }  
  return 0;
}

Measured memory_bytes: 256
#解説AC,9割写経
n = int(input())
def dfs(s):
    if int(s)>n:
        return 0
    ret = 1 if all(s.count(c) > 0 for c in "753") else 0
    for c in "753":
        ret += dfs(s+c)
    return ret

print(dfs("0"))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){

	int n,k; cin >> n >> k;
	vector<int> d(k);

	rep(i,k) cin >> d[i];

	for(int i = n; i < 100000; i++){
		int tmp = i;
		set<int> s;

		while(tmp != 0){
			s.insert(tmp%10);
			tmp /= 10;
		}
		bool jud = true;
		
		rep(j,k) if(s.count(d[j])) jud = false;

		if(jud){
			cout << i << endl;
			return 0;
		}
	}
}
    

Measured memory_bytes: 256