akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

typedef long long ll;

void solve() {

}

int main() {
  string s;
  cin >> s;
  cout << string((int)s.size(),'x') << endl;

  return 0;
}


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

int main() {
	long long X; cin >> X;
	long long cnt1=0, cnt2 = 0;
	while (X>=500) {
		X -= 500;
		cnt1+=1000;
	}
	while (X >= 0) {
		X -= 5;
		cnt2 += 5;
	}
	cout << cnt1 + cnt2-5 << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class QuestionC
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 文字列の入力
            //string s = Console.ReadLine();

            // 整数の入力
            //int n = int.Parse(Console.ReadLine());

            // 文字列配列の入力
            //string[] inputStrArray = Console.ReadLine().Split(' ');

            // 整数配列の入力
            var inputintArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();

            int A = inputintArray[0];
            int B = inputintArray[1];
            int H = inputintArray[2];
            int M = inputintArray[3];

            int time = 60 * H + M;

            double angle_h = 90 - 0.5 * time;
            double angle_m = 90 - 6 * (time % 60);
            double angle = Math.Abs(angle_h - angle_m);
            angle = Math.Min(angle, 360 -angle);
            double cos = Math.Cos(angle * (Math.PI / 180));
            double result =Math.Sqrt( A * A + B * B - 2 * A * B * cos);


            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 28756
#include<stdio.h>

int main(){
  int N;
  scanf("%d", &N);
  
  int prime[55555];
  for(int i = 0; i < 55555; i++) prime[i] = 1;
  
  int a[N];
  int *p = a;
  for(int i = 2; i < 55555; i++){
    if(prime[i]){
      for(int j = 2; i * j < 55555; j++){
        prime[i * j] = 0;
      }
      if(i % 5 == 1){
        *p = i;
        p++;
      }
      if(p == a + N) break;
    }
  }
  
  for(int i = 0; i < N - 1; i++) printf("%d ", a[i]);
  printf("%d\n", a[N - 1]);
  
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdlib>
#include <queue>
#include <math.h>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main()
{
    int n, l_y, s, x, y, z;
    bool b = false;
    x = -1;
    y = -1;
    z = -1;
    cin >> n >> l_y;
    const int c_1 = 1000;
    const int c_2 = 5000;
    const int c_3 = 10000;
    for(int i=0; i<=n; ++i){
        for(int j=0; j<=n; ++j){
            int k = n - i - j;
            if(k < 0){
                continue;
            }
            s = i * c_1 + j * c_2 + k * c_3;
            if(l_y == s){
                b = true;
                x = k;
                y = j;
                z = i;
                break;
            }   
        }
        if(b){
            break;
        }
    }
    cout << x << " " << y << " " << z << endl;
    return 0;
}

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

using namespace std;

#define int long long

const int N = (int)1e5 + 7;

int a[N];

main () {
    int n; scanf("%lld", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%lld", &a[i]);
    }
    if (a[n] != 2) {
        puts("-1");
        return 0;
    }
    int l = 2;
    int r = 3;
    for (int i = n - 1; i >= 1; i--) {
        int q = r / a[i] - (l - 1) / a[i];
        if (q) {
            l = (l + a[i] - 1) / a[i] * a[i];
            r = r / a[i] * a[i] + a[i] - 1;
        } else {
            puts("-1");
            return 0;
        }
    }
    cout << l << ' ' << r << endl;
}


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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

void solve(long long A, long long B, long long N){
    cout << (A * min(B-1, N) / B) << endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long N;
    scanf("%lld",&N);
    solve(A, B, N);
    return 0;
}



Measured memory_bytes: 3692
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#pragma warning(disable:4996) 

typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define LINF3 1000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;



void solve()
{
    int i;
    int sum = 0;
    for (i = 0; i < 5; i++) {
        int tmp;
        scanf("%d", &tmp);
        sum += tmp;
    }
    printf("%d\n", 15 - sum);
  


    return;
}


int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}





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

int main(){
  int a,b;
  cin >> a >> b;
  cout << a*b << endl;
  return 0;
}

Measured memory_bytes: 3620
## 2 * 100000 % 1000000007 の高速計算法がわからずOUT

n = int(input())
lst = [int(e) for e in input().split(' ')]

lst = sorted(lst)
result = 1

valid_list = []
if n % 2 == 1:
    # 奇数
    valid_list.append(0)
    for i in range(1, int((n + 1) / 2)):
        valid_list.append(i * 2)
        valid_list.append(i * 2)
    if lst == valid_list:
        for i in range(int((n - 1) / 2)):
            result = (result * 2) % 1000000007
        print(int(result))
    else:
        print(0)
else:
    for i in range(1, int((n / 2) + 1)):
        valid_list.append((i * 2) - 1)
        valid_list.append((i * 2) - 1)
    if lst == valid_list:
        for i in range(int(n / 2)):
            result = (result * 2) % 1000000007
        print(int(result))
    else:
        print(0)


Measured memory_bytes: 13880
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main()
{
	int a,b,c,x;
	int count = 0;
	scanf("%d\n%d\n%d\n%d",&a,&b,&c,&x);
	int i,j,k;
	for	(i=0;i<=a;i++)
	for	(j=0;j<=b;j++)
	for	(k=0;k<=c;k++)
	{ 
		if(500*i+100*j+50*k==x) count++;
	} 
	printf("%d\n",count);	 
	
}

Measured memory_bytes: 128
from collections import defaultdict
from collections import deque

def getlist():
	return list(map(int, input().split()))

class Graph(object):

    def __init__(self):
        self.graph = defaultdict(list)

    def __len__(self):
        return len(self.graph)

    def add_edge(self, a, b):
        self.graph[a].append(b)


class breadth(object):
    def __init__(self, graph, s):
        self.g = graph.graph
        self.dist = defaultdict(lambda: float('inf'))
        self.dist[s] = 0
        self.visit = ["no" for i in range(len(graph) + 1)]
        self.visit[s] = "yes"

        self.Q = deque()
        self.Q.append([self.dist[s], s])

        while self.Q:
            dist_u, u = self.Q.popleft()
            for v in self.g[u]:
                if self.visit[v] == "yes":
                    continue
                else:
                    self.dist[v] = dist_u + 1
                    self.visit[v] = "yes"
                    self.Q.append([self.dist[v], v])


N = int(input())
if N == 1:
	print("First")
else:
	g_a = Graph()
	for i in range(N - 1):
		a, b = getlist()
		g_a.add_edge(a, b)
		g_a.add_edge(b, a)
	
	s = 1
	E = breadth(g_a, s)
	x = 0
	for i in E.dist:
		if E.dist[i] > x:
			x = E.dist[i]
			y = i
	F = breadth(g_a, y)
	x = 0
	for i in F.dist:
		if F.dist[i] > x:
			x = F.dist[i]
			y = i

	if x % 3 == 0 or x % 3 == 2:
		print("First")
	else:
		print("Second")


Measured memory_bytes: 119620
# ABC103C - Modulo Summation
from fractions import gcd


def lcm(a, b):
    return (a * b) // gcd(a, b)


n = int(input())
lst = list(map(int, input().rstrip().split()))
ans = 0
f = lcm(lst[0], lst[1])
for i in range(n):
    f = lcm(f, lst[i])
f -= 1
for i in lst:
    ans += f % i
print(ans)

Measured memory_bytes: 5344
x1,x2,x3,x4,x5=gets.chomp.split(" ").map(&:to_i);

print x1==0 ? 1 :
      x2==0 ? 2 :
      x3==0 ? 3 :
      x4==0 ? 4 :
      x5==0 ? 5 : ""
      

Measured memory_bytes: 14260
#include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(), (v).end()
#define lp(i, n) for (int i = 0; i < (n) ; ++i)
#define sz(v) (ll)(v).size()
#define int long long
#define mod 1000000007

int day;
int c[27];
int d[366][26], ansday[366];

void read_input() {
        //freopen("b1.in", "r", stdin);
        cin >> day;
        for (int i= 0; i< 26; i++) {
                cin >> c[i];
        }
        for (int i= 0; i< day; i++) {
                for (int j= 0; j< 26; j++) {
                        cin >> d[i][j];
                }
        }
}

void read_ans() {
        for (int i= 0; i< day; i++) {
                int x; cin >> x;
                ansday[i]= x- 1;
        }
}

int simu() {
        int lastuse[27]= {};
        int finalscore= 0;
        for (int i= 0; i< day; i++) {
                int choose= ansday[i];
                int score= d[i][choose];
                lastuse[choose]= i+ 1;
                int dec= 0;
                for (int j= 0; j< 26; j++) {
                        dec+= c[j]* ((i+ 1)- lastuse[j]);
                }
                finalscore+= score- dec;
        }
        return finalscore;
}

void query() {
        int m; cin >> m;
        vector<pair<int, int>> vp;
        for (int i= 0; i< m; i++) {
                int a, b; cin >> a>> b;
                vp.push_back({a, b});
        }
        for (int i= 0; i< m; i++) {
                int wday= vp[i].first- 1;
                int wc= vp[i].second- 1;
                ansday[wday]= wc;
                simu();
        }
}

void sol() {
        int lastuse[27]= {};
        for (int i= 0; i< day; i++) {
                vector<pair<int, int>> r;
                for (int j= 0; j< 26; j++) {
                        int dec= 0;
                        for (int k= 0; k< 26; k++) {
                                if (k== j) continue;
                                dec+= c[k]* ((i+ 1)- lastuse[k]);
                        }
                        r.push_back( { (d[i][j]- dec), j } );
                }
                sort(all(r));
                int lst= r.size()- 1;
                ansday[i]= r[lst].second;
                lastuse[r[lst].second]= i;
        }

}

void pr() {
        for (int i= 0; i< day; i++) {
                cout << ansday[i]+ 1<< "\n";
        }
}

void rand_query() {
        sol();
        int cur= simu();
        srand(time(0));
        for (int i= 0; i< 222222; i++) {
                int wday= rand() % 365;
                int wc= rand() % 26;
                int old= ansday[wday];
                ansday[wday]= wc;
                int r= simu();
                if (r< cur) {
                        ansday[wday]= old;
                } else {
                        cur = r;
                }
        }
        //cout << cur<< "\n";
        pr();
}

void solve() {
        read_input();
        //sol();
        //read_ans();
        //simu();
        //query();
        rand_query();
}

int32_t main(){
ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
        int t = 1;
        //cin >> t;
        while ( t-- ) {
                solve();
        }
return 0;
}


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

import bisect

n = int(input())
*l, = map(int, input().split())
l.sort()

ans = 0
for i in range(n-1, -1, -1):
    for j in range(i-1, 0, -1):
        sub = l[i]-l[j] 
        idx = bisect.bisect_right(l, sub)
        if idx >= j: continue
        ans += j-idx
print(ans)

Measured memory_bytes: 3188
n = int(input())
p = []
sum = 0
for i in range(n):
    p.append(int(input()))
mp = max(p)
nesage = False
for i in range(n):
    if p[i] == mp and not nesage:
        sum += int(p[i]/2)
        nesage = True
    else:
        sum += p[i]
print(sum)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(x)    (x).begin(),(x).end()
typedef long long ll;
const int MOD = (int)1e9 + 7;
const ll INF = (ll) 1e12 * 3;

int main(){
  int a,b,q;
  cin >> a >> b >> q;
  vector<ll> s(a+2),t(b+2);
  rep(i,a) cin >> s[i+1];
  rep(i,b) cin >> t[i+1];
  s[0] = -INF;
  t[0] = -INF;
  s[a+1] = INF;
  t[b+1] = INF;
  rep(i,q){
    ll x;
    cin >> x;
    int s_index = distance(s.begin(),lower_bound(all(s),x));
    int t_index = distance(t.begin(),lower_bound(all(t),x));
    ll rs = s[s_index];
    ll ls = s[s_index - 1];
    ll rt = t[t_index];
    ll lt = t[t_index - 1];
    //cout<<ls<<"  "<<rs<<endl;
    //cout<<lt<<"  "<<rt<<endl;
    ll ans  = (ll) min((ll) max(rt-x,rs-x),(ll) max(x-ls,x-lt));
    ll ans1 = (ll) min((rt-x+rt-ls),(rs-x+rs-lt));
    ll ans2 = (ll) min((x-lt+rs-lt),(x-ls+rt-ls));
    ll ans3 = (ll) min(ans1,ans2);
    cout << (ll) min(ans,ans3) << endl;
    //cout<<endl;
  }
}


Measured memory_bytes: 2944
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>

using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;

int main(){
    int A,B; cin >> A >> B;
    if(A-B*2<=0){
        cout << 0 << endl;
    }else{
        cout << A-B*2 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
using namespace std;

int main(){
    int N;
    while(cin>>N,N){
        map<string,int> A;
        int B[40];
        fill(B,B+40,0);
        vector<string> D[40];
        set<string> D0;
        string A0;
        cin>>A0;
        A[A0]=0;
        cin>>B[0];
        int C0;
        cin>>C0;
        for(int i=0;i<C0;i++){
            string Di;
            cin>>Di;
            D0.insert(Di);
        }
        int cnt=1;
        for(int i=1;i<N;i++){
            string name;
            cin>>name;
            if(D0.count(name)){
                int b,c;
                cin>>b>>c;
                while(c--) cin>>name;
            }else{
                A[name]=cnt;
                cin>>B[cnt];
                int C;
                cin>>C;
                for(int j=0;j<C;j++){
                    string S;
                    cin>>S;
                    if(!D0.count(S)) D[cnt].push_back(S);
                }
                cnt++;
            }
        }
        N-=C0;

        int64_t mask[N];
        fill(mask,mask+N,0);
        for(int i=0;i<N;i++){
            for(auto s:D[i]){
                int j = A[s];
                mask[i]|=(1LL<<j);
            }
        }

        int DP[1<<N/2];
        fill(DP,DP+(1<<N/2),0);
        for(int64_t s=1;s<(1LL<<N/2);s+=2){
            int64_t adj = 0;
            for(int i=0;i<N/2;i++){
                adj|=((s>>i)&1LL)*(mask[i]&s);
            }
            if(!adj){
                for(int i=0;i<N/2;i++){
                    if((s>>i)&1LL) DP[s]+=B[i];
                }
            }
        }
        for(int64_t s=1;s<(1LL<<N/2);s+=2){
            for(int i=1;i<N/2;i++){
                DP[s|(1LL<<i)]=max(DP[s|(1LL<<i)],DP[s]);
            }
        }
        int ans = 0;
        for(int64_t s=0;s<(1LL<<N);s+=(1LL<<N/2)){
            int64_t adj=0;
            for(int i=N/2;i<N;i++){
                adj|=((s>>i)&1LL)*(mask[i]&s);
            }
            if(adj) continue;
            int sum = 0;
            for(int i=N/2;i<N;i++){
                if((s>>i)&1LL) sum+=B[i];
            }
            int64_t b = (1<<N/2)-1;
            for(int i=N/2;i<N;i++){
                if((s>>i)&1LL) b&=~mask[i];
            }
            ans = max(ans,sum+DP[b]);
        }
        cout<<ans<<endl;
    }
    return 0;
}

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

using namespace std;

int main() {
  char S[4];
  cin >> S;
  int abc[3] = {};
  for (int i = 0; i < 3; i++) {
    if (S[i] == 'a') {
      abc[0]++;
    } else if (S[i] == 'b') {
      abc[1]++;
    } else if (S[i] == 'c') {
      abc[2]++;
    }
  }

  for (int i = 0; i < 3; i++) {
    if (abc[i] == 0) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;

  return 0;
}

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define int long long
#define itn int
#define pb push_back
#define m_p make_pair
#define m_t meke_tuple
#define p_p(a,b) pb(m_p(a,b))
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(all(a));reverse(all(a))
#define UNIQUE(a) a.erase(unique(all(a)),a.end())
#define SZ(a) a.size()
#define ENDL cout<<endl
#define debg(a) cout<<#a<<" "<<a<<endl;
#define call(a) for(auto i:a)cout<<i<<" ";cout<<endl
#define show(a) rep(ghf,SZ(a)){rep(kjh,SZ(a[ghf])){cout<<(a[ghf][kjh]<10?" ":"")<<a[ghf][kjh]<<" ";}ENDL;}
#define out(a) cout<<(a)<<endl
#define fi first
#define se second
#define Vec vector
#define P pair
typedef long long ll;
typedef string str;
typedef vector<ll> V;
typedef pair<ll,ll> Pi;
typedef vector<Pi> VP;
const long long INF = 1LL<<60;
const long long MOD = 1e9+7;
int gcd(int a,int b){if(b==0)return a;return gcd(b,a%b);}
int lcm(int a,int b){return a/gcd(a,b)*b;}
int max(int a,int b){if(a>b)return a; return b;}
int min(int a,int b){if(a>b)return b; return a;}
void Yes(){cout<<"Yes"<<endl;}
void No(){cout<<"No"<<endl;}
void YN(bool b){cout<<(b?"Yes":"No")<<endl;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int a,b,t;
  cin>>a>>b>>t;
  int c=t/a;
  cout<<b*c<<endl;
  
  
  
  return 0;
}



Measured memory_bytes: 256
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
	"strconv"
)

const NIL = -1

type Node struct {
	id     int
	weight int
}

func init() {
	sc.Split(bufio.ScanWords)
}

type NodeHeap []Node

func (h NodeHeap) Len() int           { return len(h) }
func (h NodeHeap) Less(i, j int) bool { return h[i].weight < h[j].weight }
func (h NodeHeap) Swap(i, j int)      { h[i], h[j] = h[j], h[i] }

func (h *NodeHeap) Push(x interface{}) {
	*h = append(*h, x.(Node))
}

func (h *NodeHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := scanInt()

	list := make([][]int, n)
	weight := make([]int, n)
	for i := range list {
		list[i] = make([]int, n)
		weight[i] = NIL
		for j := range list[i] {
			list[i][j] = NIL
		}
	}

	for i := 0; i < n; i++ {
		u := scanInt()
		k := scanInt()
		for j := 0; j < k; j++ {
			v := scanInt()
			w := scanInt()
			list[u][v] = w
		}
	}

	start := Node{id: 0, weight: 0}
	h := &NodeHeap{start}
	heap.Init(h)

	for h.Len() > 0 {
		node := heap.Pop(h).(Node)
		if weight[node.id] != NIL {
			continue
		}
		weight[node.id] = node.weight

		for i, w := range list[node.id] {
			if w == NIL {
				continue
			}
			heap.Push(h, Node{id: i, weight: w + node.weight})
		}
	}

	w := bufio.NewWriter(os.Stdout)
	for i := 0; i < n; i++ {
		fmt.Fprint(w, i)
		fmt.Fprint(w, " ")
		fmt.Fprint(w, weight[i])
		fmt.Fprintln(w)
	}
	w.Flush()
}



Measured memory_bytes: 1700
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define MAXN 4005
#define eps 1e-10
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
	res = 0;T f = 1;char c = getchar();
	while(c < '0' || c > '9') {
		if(c == '-') f = -1;
		c = getchar();
	}
	while(c >= '0' && c <= '9') {
		res = res * 10 + c - '0';
		c = getchar();
	}
	res *= f;
}
template<class T>
void out(T x) {
	if(x < 0) {x = -x;putchar('-');}
	if(x >= 10) {
		out(x / 10);
	}
	putchar('0' + x % 10);
}
int MOD = 1000000007;
int A,B;
int C[MAXN][MAXN],sum[MAXN][MAXN],s[MAXN][MAXN];
int inc(int a,int b) {
	return a + b >= MOD ? a + b - MOD : a + b;
}
int mul(int a,int b) {
	return 1LL * a * b % MOD;
}
void update(int &x,int y) {
	x = inc(x,y);
}
void Solve() {
	read(A);read(B);
	C[0][0] = 1;
	sum[0][0] = 1;
	for(int i = 1 ; i <= A + B ; ++i) {
		C[i][0] = 1;
		sum[i][0] = 1;
		for(int j = 1 ; j <= i ; ++j) {
			C[i][j] = inc(C[i - 1][j],C[i - 1][j - 1]);
			sum[i][j] = inc(C[i][j],sum[i][j - 1]);
		}
	}
	for(int j = 0 ; j <= B ; ++j) {
		s[j][0] = 1;
		for(int i = 1 ; i <= A + B ; ++i) {
			s[j][i] = inc(s[j][i - 1],sum[j][min(i,j)]);
		}
	}
	int ans = 0;
	for(int t = A; t >= 0 ; --t) {
		for(int i = 0 ; i <= t ; ++i) {
			int w = C[B - 1][i];
			if(!i) update(ans,w);
			else {
				update(ans,mul(w,s[i - 1][t - i]));
			}
		}
	}
	out(ans);enter;
}
int main() {
#ifdef ivorysi
	freopen("f1.in","r",stdin);
#endif
	Solve();
}


Measured memory_bytes: 159488
N,K = map(int,input().split())
A = list(map(int,input().split()))
ind = A.index(1)
n = ind//(K-1)
if ind%(K-1):
    n += 1
m = (N-1-ind)//(K-1)
if (N-1-ind)%(K-1):
    m += 1
cmin = n+m
for i in range(max(1,ind+K-N),min(ind,K-1)+1):
    n = (ind-i)//(K-1)
    if (ind-i)%(K-1):
        n += 1
    m = (N-ind-K+i)//(K-1)
    if (N-ind-K+i)%(K-1):
        m += 1
    cnt = n+m+1
    cmin = min(cmin,cnt)
print(cmin)

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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n;
    cin >> n;
    vector<long long> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    auto target = 0ll;
    for (int i = 2; i < n; i++) {
        target ^= a[i];
    }
    auto a0 = a[0], a1 = a[1];

    function<long long(int, long long, long long)> enter;
    enter = [&] (int bt, long long a0, long long a1) -> long long {
        if ((a0 ^ a1) == target) {
            return 0ll;
        }
        if (bt > 45) {
            return -1ll;
        }
        auto mask = 1ll << bt;
        auto b0 = a0 & mask;
        auto b1 = a1 & mask;
        if ((b0 ^ b1) == (target & mask)) {
            auto ans = -1ll;
            if (a0 > mask) {
                auto v0 = enter(bt+1, a0-mask, a1+mask);
                if (v0 != -1) {
                    ans = v0 + mask;
                }
            }
            auto v1 = enter(bt+1, a0, a1);
            if (v1 != -1 && (ans == -1 || v1 < ans)) {
                ans = v1;
            }
            return ans;
        }
        return -1ll;
    };
    auto ans = enter(0, a[0], a[1]);
    cout << ans << endl;
}


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

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

    vector<long long> a;
    long long hp;
    for(int i = 0; i < n; i++){
        cin >> hp;
        a.push_back(hp);
    }

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

    while(1){
        if(a.size() == 1){
            break;
        }
        for(int i = a.size() - 1; i >= 1; i--){
            if(a[i] % a[0] == 0){
                a.erase(a.begin() + i);
            }else{
                a[i] %= a[0];
            }
        }
        sort(a.begin(), a.end());
    }

    cout << a[0] << endl;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
typedef int ll;
typedef vector<ll> vl;
typedef vector<vl> vv;
#define pb push_back
#define MOD 1000000007
#define INF 1000000000
#define endl '\n'
void fast() { ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL); }

vv dp(1005,vl(1005));
ll h,w;

ll check(ll i,ll j){

    
    ll x=0;
    if(i+1<=h){
        if(dp[i+1][j]!=-1){x=(x+dp[i+1][j])%MOD;}
    }
    if(j+1<=w){
        if(dp[i][j+1]!=-1){x=(x+dp[i][j+1])%MOD;}
    }
    return x;

}

void dpcompute(){

    for(ll i=0;i<=(min(h,w)-1);i++){

        for(ll j=h-i;j>=1;j--){
            if(j==h && w-i==w){continue;}
            if(dp[j][w-i]==-1){continue;}
            // cout<<j<<" "<<w-i<<" ";
            dp[j][w-i]=check(j,w-i);
            // cout<<dp[j][w-i]<<endl;
        }
        // cout<<endl;
        for(ll j=w-i-1;j>=1;j--){
            if(h-i==h && j==w){continue;}
            if(dp[h-i][j]==-1){continue;}
            // cout<<h-i<<" "<<j<<" ";
            dp[h-i][j]=check(h-i,j);
            // cout<<dp[h-i][j]<<endl;

        }
        // cout<<endl;
    }
    

}

int main(){
    
    fast();
    //#ifndef ONLINE_JUDGE
    //freopen("F:\\Codes\\input.txt", "r", stdin);
    //freopen("F:\\Codes\\output.txt", "w", stdout);
    //#endif
    
    ll i,j;
    char c;
    cin>>h>>w;

    for(i=1;i<=h;i++){
        for(j=1;j<=w;j++){
            cin>>c;
            if(c=='#'){dp[i][j]=-1;}
        }
    } 

    dp[h][w]=1;
    dpcompute();

    cout<<dp[1][1]<<endl;

    // for(i=1;i<=h;i++){
    //     for(j=1;j<=w;j++){
    //         cout<<dp[i][j]<<" ";
    //     }cout<<endl;
    // }

    
    return 0;
}

Measured memory_bytes: 7632
import numpy as np
import itertools as it
N, D = map(int, input().split())
def dis(ls1, ls2):
    distance = 0
    for i in range(D):
        distance += ( ls1[i] - ls2[i] ) ** 2
    return np.sqrt(distance)

ls = []
ls_ap = ls.append
for i in range(N):
    ls_ap(list(map(int, input().split())))

count = 0
ran = [i for i in range(N)]
for x in it.combinations(ran, 2):
    d = dis(ls[x[0]], ls[x[1]])
    if d.is_integer():
        count += 1
print(count)

Measured memory_bytes: 20780
#include<stdio.h>
#include<stdlib.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 max3(p,q,r)max(max(p,q),r)
#define min3(p,q,r)min(min(p,q),r)
#define INF ((1LL<<62)-(1LL<<31))


ll ans=INF;

void f(ll h,ll w){
	//hを分割

	ll hh=h/3;//真の1/3より小さいかも
	ll rh=h-hh;
	ll c1=hh*w;
	if(w%2==0||rh%2==0){
		ll c2=w*rh/2;
		ans=min(ans,llabs(c1-c2));
	}else{
		//長い方を割る
		if(rh>w){
			ll c2=(rh+1)/2*w;
			ll c3=rh*w-c2;
			ans=min(ans,max3(c1,c2,c3)-min3(c1,c2,c3));
		}else{
			ll c2=(w+1)/2*rh;
			ll c3=rh*w-c2;
			ans=min(ans,max3(c1,c2,c3)-min3(c1,c2,c3));
		}
	}
	
	hh=h/3+1;//真の1/3より大きい
	rh=h-hh;
	c1=hh*w;
	if(w%2==0||rh%2==0){
		ll c2=w*rh/2;
		ans=min(ans,llabs(c1-c2));
	}else{
		//長い方を割る
		if(rh>w){
			ll c2=(rh+1)/2*w;
			ll c3=rh*w-c2;
			ans=min(ans,max3(c1,c2,c3)-min3(c1,c2,c3));
		}else{
			ll c2=(w+1)/2*rh;
			ll c3=rh*w-c2;
			ans=min(ans,max3(c1,c2,c3)-min3(c1,c2,c3));
		}
	}
	
}

int main(){
	ll h,w;
	scanf("%lld%lld",&h,&w);
	f(h,w);
	f(w,h);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main()
{
	int k, a, b;
	scanf("%d", &k);
	
	a=k/100;
	b=k%100;
	
	if(1<=a&&a<=12)
	{
		if(1<=b&&b<=12)
			printf("AMBIGUOUS");
		else
			printf("MMYY");
	}
	else
	{
		if(1<=b&&b<=12)
			printf("YYMM");
		else
			printf("NA");
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
const double PI = acos(-1);
#define rep(i, n) for (int i = 0; i < (int)(n); i++ )
using namespace std;
int main(){
    long long n;
    cin >> n;
    long long m = n;
    int sum = 0;
    while(true){
        sum += n % 10;
        n /= 10;
        if(n == 0) break;
    }
    if( m % sum == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3544
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
	Main m = new Main();
	m.answer();
    }

    private Scanner scan = new Scanner(System.in);
    private final int N;
    private final int W;
    private int[][] vn;
    private int[] n;
    private long w0 = 0;

    public Main() {
	N = Integer.parseInt(scan.next());
	W = Integer.parseInt(scan.next());
	int[][] vs = new int[4][N];
	n = new int[4];

	for (int i = 0; i < N; i++) {
	    int w = Integer.parseInt(scan.next());
	    int v = Integer.parseInt(scan.next());

	    if(i == 0) w0 = w;

	    vs[(int)(w-w0)][n[(int)(w-w0)]] = v;
	    n[(int)(w-w0)]++;
	}
	for (int i = 0; i < 4; i++) {
	    Arrays.sort(vs[i]);
	}

	vn = new int[4][N+1];

	for (int i = 0; i < 4; i++) {
	    for (int j = 1; j <= N; j++) {
		vn[i][j] = vn[i][j-1] + vs[i][N-j];
	    }
	}

	scan.close();
    }

    public final void answer() {
	int ans = 0;
	for (int n0 = 0; n0 <= n[0]; n0++) {
	    for (int n1 = 0; n1 <= n[1]; n1++) {
		for (int n2 = 0; n2 <= n[2]; n2++) {
		    for (int n3 = 0; n3 <= n[3]; n3++) {
			if(w0*n0 + (w0+1)*n1 + (w0+2)*n2 + (w0+3)*n3 <= W) {
			    int tmp = vn[0][n0] + vn[1][n1] + vn[2][n2] + vn[3][n3];
			    if(tmp > ans ) ans = tmp;
			} else {
			    break;
			}
		    }
		}
	    }
	}
	System.out.println(ans);
    }
}


Measured memory_bytes: 22996
using System;

namespace A___Range_Product
{
    class Program
    {
        static void Main (string[] args)
        {
            var input = Console.ReadLine ().Split (' ');
            var a = int.Parse (input[0]);
            var b = int.Parse (input[1]);
            if (a >= 1 && b >= 1)
                Console.WriteLine ("Positive");

            else if (a < 0 && b < 0 && (Math.Abs (a - b) + 1) % 2 == 1)
                Console.WriteLine ("Negative");

            else if (a < 0 && b < 0 && (Math.Abs (a - b) + 1) % 2 == 0)
                Console.WriteLine ("Positive");

            else if (a <= 0 && b >= 0)
                Console.WriteLine ("Zero");
        }
    }
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll          long long
#define pb          push_back
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define rs(v,n)     v.resize(n)
#define hell        1000000007
#define peak        9123372036854775807
#define pii         acos(-1)
#define clr(a,x)    memset(a,x,sizeof(a))
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
template<class x,class y> x sum(x a,y b){return a+b;}
template<class x,class y> x mul(x a,y b){return a*b;}
template<class x,class y> x sub(x a,y b){return a-b;}
template<class x,class y> x divi(x a,y b){return a/b;}

template<class x,class y>
istream &operator>>(istream &in,pair<x,y> &p) 
{ 
    in>>p.F>>p.S;
    return in;
}
template<class x>
istream &operator>>(istream &in,vector<x> &v) 
{
    for(auto& i:v)
        in>>i;
    return in;
}
template<class x,class y>
ostream &operator<<(ostream &out,pair<x,y> &p) 
{ 
    out<<"("<<p.F<<","<<p.S<<") ";
    return out; 
}
template<class x>
ostream &operator<<(ostream &out,vector<x> &v) 
{ 
    out<<v.size()<<endl;
    for(auto i:v)
        out<<i<<" ";
    out<<endl;
    return out; 
}
#define N  1000005

int main()
{
    ios;
    ll tt=1;
    // cin>>tt;
    while(tt--)
    {
        ll i,j,k,l,m,n;
        string s,t,ss;
        cin>>s>>t;
        n=t.size();
        for(i=0;i<n-1;i++)
            ss.pb(t[i]);
        if(s==ss)
        {
            cout<<"Yes";
        }
        else
            cout<<"No";
    }
    return 0;
}

Measured memory_bytes: 3652
//FA専用
#include <bits/stdc++.h>
using namespace std;
#define int long long
const long long LINF=1e18;
using ld=long double;
template<typename T>
void chmax(T &a,T b){
  if(a<b)a=b;
}
template<typename T>
void chmin(T &a,T b){
  if(a>b)a=b;
}
template<typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}

signed main(){
  int n,m;cin>>n>>m;
  vector<int> v(n);
  for(int i=0;i<n;i++)cin>>v[i];
  int sum=0;
  for(int i=0;i<n;i++)sum+=v[i];
  int cnt=0;
  for(int i=0;i<n;i++){
    cnt+=v[i]*4*m>=sum;
  }
  cout<<(cnt>=m?"Yes":"No")<<endl;
}


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

int main()
{
    int a[5]={0},cn=0;
    for(int i=1;i<4;i++)
    {
        int b,c;
        cin>>b>>c;
        a[b]++;
        a[c]++;
    }
    for(int i=1;i<5;i++)
    if(a[i]==1)
    cn++;
   // cout<<cn<<" ";
    if(cn==2)
    cout<<"YES";
    else
    cout<<"NO";
}

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

#define	MOD 1000000007;
#define PI 3.14159265358979323846;
#define rep(i,n) for(ll i = 0;i<(ll)n;i++)
using namespace std;
typedef long long ll;
static const int MAX = 50;
static const long long INFTYL = 9223372036854775807;
ll mod = 1000000007;

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

	string t;

	vector<string> T = { "SS","SW","WW","WS" };
	for (vector<string>::iterator it = T.begin(); it != T.end(); it++)
	{
		t = *it;

		rep(i, s.size() - 1) {
			if (i == 0) {
				continue;
			}
			if (s[i] == 'o') {
				if (t[i] == 'S') {
					t += t[i - 1];//i+2
				}
				else {
					t += t[i - 1] == 'S' ? 'W' : 'S';//i+2
				}
			}
			else {
				if (t[i] == 'S') {
					t += t[i - 1] == 'S' ? 'W' : 'S';//i+2
				}
				else {
					t += t[i - 1];//i+2
				}
			}
		}
		bool valid_1 = false;
		bool valid_L = false;
		ll l = t.size() - 1;
		if (t[0] == 'S') {
			valid_1 = (s[0] == 'o' && t[1] == t[l] || s[0] == 'x' && t[1] != t[l]);
		}
		else {//t[i] == 'W'
			valid_1 = (s[0] == 'o' && t[1] != t[l] || s[0] == 'x' && t[1] == t[l]);
		}

		if (t[l] == 'S') {
			valid_L = (s[l] == 'o' && t[0] == t[l - 1] || s[l] == 'x' && t[0] != t[l - 1]);
		}
		else {//t[i] == 'W'
			valid_L = (s[l] == 'o' && t[0] != t[l - 1] || s[l] == 'x' && t[0] == t[l - 1]);
		}

		if (valid_1 && valid_L) {
			cout << t << endl;
			return 0;
		}
	}
	cout << -1 << endl;

	return 0;
}

Measured memory_bytes: 776
n = gets.chomp.to_i
arr = gets.chomp.split(" ").map(&:to_i)

# 操作を逆にたどって空配列に戻せるかを確認する
operation = []
while arr.length > 0 do
  flag = true
  arr.length.downto(1) do |i|
    if arr[i - 1] == i
      operation << i
      arr.delete_at(i - 1)
      flag = false
      break
    end
  end
  if flag
    puts -1
    exit
  end
end

operation.reverse.each do |a|
  puts a
end


Measured memory_bytes: 14292
#include<stdio.h>

#define MAX 101

int main(){
  int n,i,u,k,j,v;
  int Adj[MAX][MAX];

  for(i=0;i<MAX;i++){
    for(j=0;j<MAX;j++){ 
      Adj[i][j]=0;
    }
  }

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      Adj[u][v]=1;
    }
  }

  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      printf("%d",Adj[i][j]);
      if(j!=n) printf(" ");
    }
    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 644
n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))
dmap = {}
for i in range(n):
    dmap[d[i]] = dmap.get(d[i], 0) + 1
# print(dmap)
tmap = {}
for i in range(m):
    tmap[t[i]] = tmap.get(t[i], 0) + 1
# print(tmap)
for i in range(m):
    if dmap.get(t[i], -1) == -1 or dmap.get(t[i], -1) < tmap[t[i]]:
        print("NO")
        exit()
print("YES")

Measured memory_bytes: 56672
A, B, Q = map(int, input().split())
S = [int(input()) for _ in range(A)]
T = [int(input()) for _ in range(B)]
query, X = [], {}

for i in range(Q):
    q = int(input())
    query.append(q)
    X[q] = i
query.sort()

near_s = [0 for _ in range(Q)]
near_t = [0 for _ in range(Q)]
j = 0
while j < Q and query[j] < S[0]:
    near_s[j] = [0, S[0]]
    j += 1    
for i in range(A-1):
    while j < Q and S[i] < query[j] < S[i+1]:
        near_s[j] = [S[i], S[i+1]]
        j += 1
near_s = near_s[:j] + [[S[A-1],0] for _ in range(Q-j)]

j = 0
while j < Q and query[j] < T[0]:
    near_t[j] = [0, T[0]]
    j += 1
for i in range(B-1):
    while j < Q and T[i] < query[j] < T[i+1]:
        near_t[j] = [T[i], T[i+1]]
        j += 1
near_t = near_t[:j] + [[T[B-1],0] for _ in range(Q-j)]

ans = [0]*Q
for i in range(Q):
    q, s0, s1, t0, t1 = query[i], near_s[i][0], near_s[i][1], near_t[i][0], near_t[i][1]
    l1 = q - min(s0, t0)
    l2 = max(s1, t1) - q
    l3 = s1 - t0 + min(s1 - q, q - t0)
    l4 = t1 - s0 + min(t1 - q, q - s0)
    if s0 == 0:
        l1, l4 = float('inf'), float('inf')
    if s1 == 0:
        l2, l3 = float('inf'), float('inf')
    if t0 == 0:
        l1, l3 = float('inf'), float('inf')
    if t1 == 0:
        l2, l4 = float('inf'), float('inf')
    ans[X[q]] = min(l1, l2, l3, l4)

for a in ans:
    print(a)

Measured memory_bytes: 50848
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>
#include <tuple>

template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct range {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int l_, int r_): l(l_), r(std::max<int>(l_, r_)) { }
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct revrange {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr r, l;
  constexpr revrange(int l_, int r_): l(l_ - 1), r(std::max<int>(l_, r_) - 1) { }
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

int main() {
  int N, K;
  std::cin >> N >> K;
  int ans = 0;
  while (N > 0) {
    ++ans;
    N /= K;
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long int sum=0,dp[100005];
long long int rec(long long int h[],long long int n)
{
	if(dp[n-1]!=-1)
	{
		return dp[n-1];
	}
	if(n==0 || n==1)
	{
		return 0;
	}
	if(n==2)
	{
		return fabs(h[1]-h[0]);
	}
	else
	{
		return dp[n-1]=min(rec(h,n-1)+fabs(h[n-1]-h[n-2]),rec(h,n-2)+fabs(h[n-1]-h[n-3]));
	}
	
}
int main()
{
	long long int n,i,ans;
	cin>>n;
	long long int h[n];
	for(i=0;i<n;i++)
	{
		dp[i]=-1;
		cin>>h[i];
	}
	ans=rec(h,n);
	cout<<ans<<"\n";
	return 0;
}



Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll a,b,c,d,ans,k;
int main(){
	scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
	k=__gcd(c,d);
	ans+=b/c-a/c;
	if(a%c==0)ans++;
	ans+=b/d-a/d;
	if(a%d==0)ans++;
	ans=ans-(b/(c*d/k)-a/(c*d/k));
	if(a%(c*d/k)==0)ans--;
	printf("%lld",b-a+1-ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
using namespace std;

unsigned long long int func(unsigned long long int l, long long int r){
  if(l < r) return 0;
  unsigned long long int ret = 1;
  for(long long int i = l; i >= l - r + 1; i--){
    ret *= i;
  }
  for(int i = r; i >= 1; i--){
    ret /= i;
  }
  return ret;
}

void solve(){
  unsigned long long int n; cin >> n;
  map<char, int> mp;
  unsigned long long int sum = 0;
  for(int i = 0; i < n; i++){
    string s; cin >> s;
    if(s[0] == 'M' || s[0] == 'A' || s[0] == 'R' || s[0] == 'C' || s[0] == 'H'){
      mp[s[0]]++;
      sum++;
    }
  }
  unsigned long long int ans;
  ans = sum * (sum - 1) * (sum - 2) / (3 * 2);
  for(auto itr = mp.begin(); itr != mp.end(); itr++){
    if(itr->second == 1) continue;
    ans -= (sum - itr->second) * func(itr->second, 2) + func(itr->second, 3);
  }
  cout << ans << endl;
  return;
}

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 1000000000
#define LLINF 2000000000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
// #define int long long

signed main(){
	int n;
	cin >> n;
	priority_queue<pair<int, int>, vector<P>, greater<pair<int, int> > > que;

	int nt = 0;
	LOOP(i,n){
		int f,s;
		cin >> f >> s;
		que.push(P(s,f));
	}

	while(!que.empty()){
		P fr = que.top();
		que.pop();
		nt+=fr.second;
		// cout << fr.second << ":" << fr.first << endl;
		if(nt>fr.first){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl; return 0;
}


Measured memory_bytes: 2420
#include<bits/stdc++.h>
//#define ll long long int32_t 
#define int long long int
#define getFaster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define rev(i,n,init) for(int i=n;i>=init;i--)
#define MAXN 200005
#define MOD2 998244353
#define MOD1 1e9+7
#define f first
#define s second
#define endl '\n'
#define pii pair<int,int>
#define piii pair<pii,int>
#define precise(i) cout<<fixed<<setprecision(i)
using namespace std;
const double PI = atan(1.0)*4;
const int64_t INF=1000000000000000003;
const int32_t LOG=21;
const int MOD=MOD1;
int h[200005];
int dp[200005];
int32_t main()
{ 
      getFaster;
      int tests=1;
      //cin>>tests;
      rep(ii,0,tests)
      {
           int n;
           cin>>n;
           rep(i,0,n)cin>>h[i];
           dp[0]=0;
           rep(i,1,n)
           {
           	   dp[i]=INF;
           	   rep(dec,1,3)
           	   {
           	   	   int j=i-dec;
           	   	   if(j>=0)
                   dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j])); 
           	   }
           }
           cout<<dp[n-1]<<endl;
      }
      return 0;     
}


Measured memory_bytes: 1792
#include <stdio.h>
int main(void){
  char s[100];
  int count=0,count2=0;
  scanf("%s",s);
  if(s[count2]=='+'){count++;}
  else {count--;}
  count2++;
      if(s[count2]=='+'){count++;}
  else {count--;}
  count2++;
      if(s[count2]=='+'){count++;}
  else {count--;}
  count2++;
      if(s[count2]=='+'){count++;}
  else {count--;}
printf("%d",count);
    return 0;
  
}

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

int main() {
    int A, B, K;
    cin >> A >> B >> K;
    
    vector<int> yakusu;
    for(int i=1; i<A+1 && i<B+1; i++){
        if(A%i==0 && B%i==0){
            yakusu.push_back(i);
        }
    }
    cout << yakusu[yakusu.size()-K] << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
typedef long long ll;

int main(void) {
  ll i, a, ans = 1, max = 1;
  for(i = 0; i < 3; ++i) {
    scanf("%lld", &a);
    if(max < a) max = a;
    ans *= a;
  }
  printf("%lld", ans / max / 2);
  return 0;
}

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

int main(){
   int N,T,L,B;
   while(cin>>N>>T>>L>>B, N||T||L||B){
      vector<int> field(N+1, 0);
      for(int i=0; i<L; i++){
         int l; cin>>l;
         field[l] = 1;
      }
      for(int i=0; i<B; i++){
         int b; cin>>b;
         field[b] = 2;
      }

      vector<vector<double>> dp(T+3, vector<double>(N+1, 0));
      dp[0][0] = 1.0;

      for(int i=0; i<T; i++){
         for(int j=0; j<N; j++){
            if(dp[i][j] == 0) continue;
            for(int k=1; k<7; k++){
               int nextI = i+1;
               int nextJ = j+k>N ? N-(j+k-N) : j+k;
               if(field[nextJ] == 1) nextI++;
               if(field[nextJ] == 2) nextJ = 0;
               dp[nextI][nextJ] += dp[i][j]*(1.0/6);
            }
         }
      }

      double ans = 0;
      for(int i=0; i<=T; i++){
         ans += dp[i][N];
      }
      cout << fixed << setprecision(10) <<ans << endl;
   }
}



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

using namespace std;


int main() {
	int n;
	cin >> n;
	vector<int> nums(n);
	for (int i = 0; i < n; i++) cin >> nums[i];
	long long res = LLONG_MAX;
	for (int i = -100; i <= 100; i++) {
		long long cost = 0;

		for (auto num : nums) {
			cost += ((num - i) * (num - i));
		}

		res = min(res, cost);
	}

	cout << res;
}


Measured memory_bytes: 256
[N,K] = list(map(int,input().split()))
A = list(map(int,input().split()))
 
#ループする場合
flag=[0]*N
patt=[]
aaaa=0
i=0
while True:
    patt.append(i)
    if flag[i]==1:
        #del patt[-1]
        break
    flag[i]=1
    i=A[i]-1
 
 
srt = patt.index(patt[-1])
#print('srt',srt)
end = len(patt)-2
ptrn = patt[srt:end+1]
 
if K<srt:
    print(patt[K]+1)
else:
    B = (K-srt) % len(ptrn)
    #print('B',B)
 
    print(ptrn[B]+1)
    #print('0000000')
 
    #print('ptrm',ptrn)
    #print(patt)

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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
// cout << fixed << setprecision(20);

signed main() {
    int S;
    cin>>S;
    int ans=114514;
    for(;S>=100;S/=10){
        int a=abs(S%1000-753);
        if(abs(S%1000-753)<ans)ans=a;
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int N, M;
	int cost, maxcost = 0, costsum = 0;
	int i;
	if (scanf("%d%d", &N, &M) != 2) return 1;
	for (i = 0; i < M; i++) {
		int A, B;
		if (scanf("%d%d", &A, &B) != 2) return 1;
		cost = (A >= N ? 0 : N - A);
		costsum += cost;
		if (cost > maxcost) maxcost = cost;
	}
	printf("%d\n", costsum - maxcost);
	return 0;
}

Measured memory_bytes: 600
//lover~ crazy~
#include<bits/stdc++.h>
using namespace std;
int a,b;
int main() {
    cin>>a>>b;
    if(a+b==15) cout<<"+";
    else if(a*b==15) cout<<"*";
    else cout<<"x";
	return 0;
}
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//

Measured memory_bytes: 256
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		double r = Double.valueOf(line);

		BigDecimal R = BigDecimal.valueOf(r);
		BigDecimal p = BigDecimal.valueOf(Math.PI);
		BigDecimal two = new BigDecimal("2");
		BigDecimal m = R.multiply(R);
		BigDecimal M = m.multiply(p);
		BigDecimal e = R.multiply(two);
		BigDecimal E = e.multiply(p);

		BigDecimal MM = M.setScale(6, BigDecimal.ROUND_HALF_UP);
		BigDecimal EE = E.setScale(6, BigDecimal.ROUND_HALF_UP);

		System.out.println(MM + " " + EE);
	}

}

Measured memory_bytes: 26516