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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;

#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// #define mp make_pair
//#define endl '\n'



int main() {
  int n;
  cin >> n;
  vector<double> a(n);
  rep (i, n) {
    cin >> a[i];
  }

  rep (_, n - 1) {
    sort(all(a));
    double x = a[0], y = a[1];
    a.erase(a.begin());
    a.erase(a.begin());
    a.push_back((x + y) / 2.0);
  }
  Sp(a[0]);
}


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

const ll INF = 1e+9;

int main(){
	int a,b,c,x,y;
	cin >> a >> b >> c >> x >> y;
	
	int ans = INF;
	//ABピザをi枚買うとする
	for (int i = 0; i <= max(2*x,2*y) ; ++i) {
		int kakaku = i*c + max(0,(x-i/2))*a + max(0,(y-i/2))*b;
		ans = min(ans,kakaku);
	}
	
	cout << ans << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;

int main() {
	int A1, A2, A3;
	cin >> A1 >> A2 >> A3;
    if (A1 + A2 + A3 >= 22) {
        cout << "bust" << endl;
    }
    else {
        cout << "win" << endl;
    }
}

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

int main() {
    ll N, A, B;
    cin >> N >> A >> B;
    ll num = N/(A+B);
    ll remainder = N%(A+B);

    ll ans = num*A;
    ans += min(remainder, A);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int i;
	int n;
	int sum;
	int min;
	int a;
	int b;
	
	sum = 0;
	for (i = 0; i < 4; i++){
		scanf("%d", &n);
		
		if (i == 0){
			min = n;
		}
		else if (min > n){
			min = n;
		}
		
		sum += n;
	}
	
	scanf("%d %d", &a, &b);
	
	if (a >= b){
		printf("%d\n", (sum - min) + a);
	}
	else {
		printf("%d\n", (sum - min) + b);
	}
	
	return (0);
}

Measured memory_bytes: 1828
// timusg
#include <iostream>
#include <bits/stdc++.h>

int main(){
	using namespace std;
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int mod = 1e9 + 7;
	int cas = 1;
	//cin >> cas;
	while(cas--){
		string s, t;
		cin >> s >> t;
		int res = t.size();
		for(int i=0; i<=s.size()-t.size(); ++i){
			int cur = 0;
			for(int j=0; j<t.size(); ++j){
				if(t[j]!=s[j+i]) cur++;
			}
			res =  min(res, cur);
		}

		cout << res << "\n";
	}
	
	return 0;
}  



Measured memory_bytes: 3596
import sys
stdin=sys.stdin

ip=lambda: int(sp())
fp=lambda: float(sp())
lp=lambda:list(map(int,stdin.readline().split()))
sp=lambda:stdin.readline().rstrip()

n=ip()
a=lp()

a.sort()

rui=[0]

for i in range(n):
  rui.append(rui[-1]+a[i])
  
ch=1

rui.sort(reverse=True)

for j in range(n):
  if rui[j]<=rui[j+1]*3:
    ch+=1
  else:
    break
print(ch)

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

ans = 1
flag = True
a = list(map(int, input().split()))

a.sort()

if a[0] == 0:
    print(0)
    exit(0)

for i in a:
    ans *= i
    if ans > 10 ** 18:
        print(-1)
        exit(0)

print(ans)


Measured memory_bytes: 84684
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String[] tokens = in.nextLine().split(" ");
		int n = Integer.parseInt(tokens[0]);
		int k = Integer.parseInt(tokens[1]);
		if (n % k == 0) {
			System.out.println("0");
		} else {
			System.out.println("1");
		}

		in.close();
	}

}

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

#define MOD 1000000007

int main(int argc, char const *argv[]) {
    int n;
    cin >> n;
    vector<long long> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    vector<long long> s(n);
    s[n-1] = a[n-1];
    for (int i = n-2; i >= 0; i--) s[i] = (s[i+1] + a[i])%MOD;

    long long ans = 0;
    for (int i = 0; i < n - 1; i++) {
        ans += a[i] * s[i+1];
        ans %= MOD;
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6408
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static final int MAX = 600;

	public static void main(String[] args) {
		//?????°?¨????
		int length = 0;
		int ans = 0;
		int num = 0;
		int count = 0;

		while(sc.hasNext()) {
			length = sc.nextInt();

			for(count = 0; count * length < 600; count++) {
				num = length * count;
				ans += num * num;
			}

			ans *= length;

			System.out.println(ans);
			ans = 0;
		}

	}

}

Measured memory_bytes: 26164
import java.util.*;
public class Main {
	public static void main(String[] args){	
		Scanner sc=new Scanner(System.in);
		String a=sc.next(),b=sc.next();
		if(a.equals("H")&&b.equals("H"))System.out.println("H");
		else if(a.equals("H")&&b.equals("D"))System.out.println("D");
		else if(a.equals("D")&&b.equals("H"))System.out.println("D");
		else if(a.equals("D")&&b.equals("D"))System.out.println("H");
	}
}

Measured memory_bytes: 21460
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <sys/timeb.h>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define FOR(NAME, START, NUM) for (ll NAME = START; NAME < (NUM); NAME++)
#define REP(NAME, NUM) for (ll NAME = 0; NAME < (NUM); NAME++)
#define BREP(NAME, NUM) for (ll NAME = (NUM)-1; NAME >= 0; NAME--)
#define ALL(NAME) (NAME).begin(), (NAME).end()
const ll LINF = 1e18;
const int INF = 1e9;
const int mod = 1e9+7;

int main(){
	int a;
	cin >> a;
	cout << 3*a*a << endl;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
c = list(map(int, input().split()))
dp = [float('inf')]*(n+1)
dp[0] = 0
for i in range(m):
    for j in range(n+1):
        if j - c[i] >= 0:
            dp[j] = min(dp[j], dp[j-c[i]] + 1)

print(dp[n])


Measured memory_bytes: 7528
#include <bits/stdc++.h> 
using namespace std;
typedef long long intl;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	intl n,a,b;
	cin>>n>>a>>b;
	if(a%2==b%2){
		cout<<abs(a-b)/2<<endl;
	}
	else{
		if(a>b){
			swap(a,b);
		}
		cout<<min((a-1)+(b-a-1)/2+1,(n-b)+(b-a-1)/2+1)<<endl;
	}
}

Measured memory_bytes: 256
import java.util.*;
import java.math.*;
import java.lang.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		int curMaxH =0;
		int count = 0;
		for (int i = 0; i < n; i++) {
			int h = sc.nextInt();

			curMaxH = Math.max(curMaxH,h);
			if(curMaxH==h){
				count++;
			}
		}

		System.out.println(count);

	}
}


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

long long  solve(long long  q , long long h , long long s , long long d)
{
	return min(4*q , min(2*h , s));
}
int main()
{
	int q , h , s , d;

	cin >> q >> h >> s >> d;

	int n;

	cin >> n;

	if(n>1)
	{
		int qq = 8*q , hh = 4*h , ss = 2*s;

		if(n%2==0)
		{
			long long x = n/2;

			long long ans = min(x*qq , min(x*hh , min(x*ss , x*d)));

			cout << ans;
			return 0;
		}
		else
		{
			long long x = n/2;

			long long ans = min(x*qq , min(x*hh , min(x*ss , x*d))) + solve(q , h , s , d);

			cout << ans;
			return 0;
		}
	}
	else
	{
		cout << solve(q , h , s , d);
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  char a;
  map<char, int> mp;
  for(int i = 0; i < 3; i++){
    cin >> a;
    mp[a]++;
  }
  if(mp.size() == 2)cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
///////////////////////////////////////


int main() {
	int N; cin >> N;
	if (N == 1) {
		cout << 1 << endl;
		return 0;
	}
	ll x[51], y[51];
	for (int i = 0; i < N; ++i) {
		cin >> x[i] >> y[i];
	}
	map<pair<ll, ll>, int>ma;
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			if (i == j)continue;
			pair<ll, ll> P = { x[i] - x[j],y[i] - y[j] };
			ma[P]++;
		}
	}
	int ans = 0;
	for (auto itr = ma.begin(); itr != ma.end(); ++itr) {
		ans = max(ans, itr->second);
	}
	cout << N-ans << endl;
	return 0;
}

Measured memory_bytes: 384
h,w=map(int,input().split())
a=[[0 for _ in range(h)] for _ in range(w)]
ans=[]
#print(a)
for i in range(h):
    b=list(input())#w nonagasa 
    if '#'  in b:
        for j in range(w):
            a[j][i]=b[j]
#for i in range(w):
    #print(a[i])
c=0
for i in range(0-c,w-c):
    if '#' not in a[i]:
        for j in range(h):
            a[i][j]=0
for i in range(h):
    for j in range(w):
        if a[j][i]!=0:
            print(a[j][i],end="")
            c+=1
    if c!=0:
        print()
    c=0


                
        

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

using namespace std;

using ll = long long;

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

    int n, k;
    string s;
    cin >> n >> s >> k;

    for (int i = 0; i < n; ++i) {
        if (s[i] != s[k - 1]) s[i] = '*';
    }
    cout << s << endl;

    return 0;
}


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

void solve(long long N, long long M, std::vector<long long> a, std::vector<long long> b, std::vector<long long> c,
           std::vector<long long> d) {
    rep(i, N) {
        ll min_distance = 1e10;
        ll ans = 0;
        rep(j, M) {
            ll distance = abs(c[j] - a[i]) + abs(d[j] - b[i]);
            if (distance < min_distance) {
                ans = j + 1;
                min_distance = distance;
            }
        }
        cout << ans << endl;
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can
// remove this line by using your custom template)
int main() {
    long long N;
    scanf("%lld", &N);
    long long M;
    scanf("%lld", &M);
    std::vector<long long> a(N);
    std::vector<long long> b(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &a[i]);
        scanf("%lld", &b[i]);
    }
    std::vector<long long> c(M);
    std::vector<long long> d(M);
    for (int i = 0; i < M; i++) {
        scanf("%lld", &c[i]);
        scanf("%lld", &d[i]);
    }
    solve(N, M, std::move(a), std::move(b), std::move(c), std::move(d));
    return 0;
}


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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int n, m;
// string s;

int main() {
    cin >> n;
    Vi s(n);
    REP(i, n) cin >> s[i];
    cin >> m;
    int cnt = 0;
    REP(i, m) {
        int x; cin >> x;
        if (binary_search(ALL(s), x)) cnt++;
    }
    std::cout << cnt << '\n';

    return 0;
}



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

using namespace std;

int main()
{
	int n, a[3000];
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	int ans = 0;
	for (int i = 0; i < n; i++)
		ans += a[i] - 1;
	cout << ans << endl;

	return 0;
}


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

int main() {
  int N, a, b, c, d;
  cin >> N;
  a = N / 100;
  b = N - 100 * a;
  c = b / 10;
  d = b - 10 * c;
  
  if(a == 7 || c == 7 || d == 7)
  {
    cout << "Yes" << endl;
  }
  else
  {
cout << "No" << endl;
  }
}


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

int main() {
    int x, y;

    while(true) {
        cin >> x >> y;

        if(x == 0 && y == 0) {
            break;
        }

        cout << min(x, y) << " " << max(x, y) << endl;
    }

    return 0;
}



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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

ll N,M;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	if(N>M) swap(N,M);
	ll ret=N*M;
	
	if(N==1&&M>1) {
		ret-=2;
	}
	else if(N>1) {
		ret-=2*(N-1)+2*(M-1);
	}
	
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define reps(i, n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define repi(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<vector<int>> abc(100010,vector<int>(3));
    reps(i,n) cin>>abc.at(i).at(0)>>abc.at(i).at(1)>>abc.at(i).at(2);
    
    vector<vector<int>> dp(100010,vector<int>(3,0)); //dp[i][j]->i日目までの幸福度の総和のmax,i日目の活動はj
    rep(i,n){
        rep(j,3){
            rep(k,3){
                if(k==j) continue;
                dp.at(i+1).at(k)=max(dp.at(i+1).at(k),dp.at(i).at(j)+abc.at(i+1).at(k));
            }
        }
    }
                                     
    int ans=-1;
    rep(i,3) ans=max(ans,dp.at(n).at(i));
    cout<<ans<<endl;
        
}


Measured memory_bytes: 11136
#(6,6)周期
#36種の希望

import numpy as np
N,K = map(int,input().split())
KK = 2*K
hope = np.zeros((KK,KK),dtype=np.int32)

for _ in range(N):
  x,y,c  = input().split()
  x = int(x)
  y = int(y)
  if c == 'B':
    x -= K
  hope[x%KK,y%KK] += 1
# (x,y)を希望された場合、[x,x+K), [y,y+K)に終点があるべき
# 区間の重なってる枚数を集計。1,0,0,-1, cumsum
A = np.zeros((KK+K,KK+K),dtype=np.int32)
A[:-K,:-K] = hope[:]
A[K:,:-K] += -hope[:]
A[:-K,K:] += -hope[:]
A[K:,K:] += hope[:]
A = A.cumsum(axis = 0).cumsum(axis = 1)

# 実質同じ場所をまとめる
B = A[:,:KK]
B[:,:K] += A[:,KK:] #(3K,2K)
A = B[:KK,:]
A[:K,:] += B[KK:,:] #(2K,2K)
B = A[:K,:] #(K,2K)
B[:,:K] += A[K:,K:]
B[:,K:] += A[K:,:K]

answer = B.max()
print(answer)


Measured memory_bytes: 219520
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//using ll = long long;
using P = pair<int,int>;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+9;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int n,q;
	string s;
	cin >> n >> s >> q;
	for(int i = 0;i < q;i++){
		int k,ans = 0,d = 0,m = 0,c = 0,dm = 0,mc = 0;
		cin >> k;
		for(int j = 0;j < n;j++){
			if(j >= k){
				if(s[j - k] == 'D'){
					d--;
					dm -= m;
				}
				else if(s[j - k] == 'M'){
					m--;
					mc -= c;
				}
				else if(s[j - k] == 'C'){
					c--;
				}
			}
			if(s[j] == 'D'){
				d++;
			}
			else if(s[j] == 'M'){
				m++;
				dm += d;
			}
			else if(s[j] == 'C'){
				c++;
				mc += m;
				ans += dm;
			}
		}
		cout << ans << endl;
	}

}

Measured memory_bytes: 1412
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int mod = 998244353;
const int IMAX = 300300;
constexpr ll modpow(ll A, ll B) {
	ll kotae = 1;
	while (B > 0) {
		if (B & 1) kotae = kotae * A % mod;
		A = A * A % mod;
		B >>= 1;
	}
	return kotae;
}
class unko {
public:
	int fac[IMAX + 1], ifac[IMAX + 1], inv[IMAX + 1];
	constexpr unko() : fac(), ifac(), inv() {
		fac[0] = 1;
		rep1(i, IMAX) fac[i] = ll(fac[i - 1]) * i % mod;
		ifac[IMAX] = modpow(fac[IMAX], mod - 2);
		for (int i = IMAX; i > 0; i--) ifac[i - 1] = ll(ifac[i]) * i % mod;
		inv[0] = 1;
		rep1(i, IMAX) inv[i] = ll(ifac[i]) * fac[i - 1] % mod;
	}
	int comb(int A, int B) {
		return ll(fac[A]) * ifac[B] % mod * ifac[A - B] % mod;
	}
} f;

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


	ll N, A, B, K;
	scanf("%lld %lld %lld %lld", &N, &A, &B, &K);

	if (K == 0) {
		printf("1\n");
		return 0;
	}

	ll GCD = __gcd(A, B);
	if (K % GCD) {
		printf("0\n");
		return 0;
	}

	A /= GCD;
	B /= GCD;
	K /= GCD;

	if (A < B) swap(A, B);

	ll hajime = max(0ll, (K - N * B + A - 1) / A);
	ll owari = min(N, K / A);
	const int b = B;

	ll kotae = 0;
	if (A == 1) {
		ll k = min(K, 2 * N - K);
		if (k < 0) {
			printf("0\n");
			return 0;
		}
		ll kari = 1;
		ll tmp = 2 * N;
		rep(i, k) kari = kari * tmp-- % mod;
		kari = kari * f.ifac[k] % mod;
		printf("%lld\n", kari);
		return 0;
	}

	K -= hajime * A;
	if (b != 1) {
		for (int i = hajime; i <= owari; i++) {
			if (K % b == 0) {
				int j = K / b;
				kotae += ll(f.ifac[N - i]) * f.ifac[i] % mod * f.ifac[N - j] % mod * f.ifac[j] % mod;
			}
			K -= A;
		}
	}
	else {
		for (int i = hajime; i <= owari; i++) {
			kotae += ll(f.ifac[N - i]) * f.ifac[i] % mod * f.ifac[N - K] % mod * f.ifac[K] % mod;
			K -= A;
		}
	}

	kotae %= mod;
	kotae *= f.fac[N];
	kotae %= mod;
	kotae *= f.fac[N];
	kotae %= mod;

	printf("%lld\n", kotae);

	Would you please return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()
{	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
		int n;cin>>n;
    	int a[n],b[n];
    	for(int i=0;i<n;i++){
    		cin>>a[i];
    	}
    	for(int i=0;i<n;i++){
    		cin>>b[i];
    	}
    	int ans=0;
    	for(int i=0;i<n;i++){
    		ans+=max(0,(a[i]-b[i]));
    	}
    	cout<<ans;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	const long long mod = 1e9 + 7;
	int n;
	cin >> n;
	string s, t;
	cin >> s >> t;
	vector<int> res;
	for (int i = 0; i < n; i++) {
		if (i == n - 1) {
			res.push_back(0);
			continue;
		}
		if (s[i] == s[i + 1]) {
			res.push_back(1);
			i++;
		}
		else {
			res.push_back(0);
		}
	}
	long long ans = 0;
	for (int i = 0; i < (int) res.size(); i++) {
		if (i == 0) {
			if (res[i]) ans = 6;
			else ans = 3;
			continue;
		}
		if (res[i]) {
			if (res[i - 1] == 0) ans *= 2;
			else ans *= 3;
		} else {
			if (res[i - 1] == 0) ans *= 2;
		}
		ans %= mod;
	}
	cout << ans << endl;
	return 0;	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,m,k,h,t;
int dp[505][505];
bool vis[505][505];
ll ans;
struct node{
	int x,y;
};
node q[505*505];
bool b[505*505];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)
	for(int j=1;j<=n;j++)
	dp[i][j]=min({i-1,j-1,n-i,n-j}),vis[i][j]=1;
	for(int i=1;i<=n*n;i++){
		cin>>k;
		int x=(k-1)/n+1,y=(k-1)%n+1; 
		ans+=dp[x][y];vis[x][y]=0;
		h=0;q[t=1]={x,y};
		while(h<t){
			node u=q[++h];
			if(u.x>1&&dp[u.x-1][u.y]>dp[u.x][u.y]+vis[u.x][u.y])
			dp[u.x-1][u.y]=dp[u.x][u.y]+vis[u.x][u.y],q[++t]={u.x-1,u.y};

			if(u.x<n&&dp[u.x+1][u.y]>dp[u.x][u.y]+vis[u.x][u.y])
			dp[u.x+1][u.y]=dp[u.x][u.y]+vis[u.x][u.y],q[++t]={u.x+1,u.y};

			if(u.y>1&&dp[u.x][u.y-1]>dp[u.x][u.y]+vis[u.x][u.y])
			dp[u.x][u.y-1]=dp[u.x][u.y]+vis[u.x][u.y],q[++t]={u.x,u.y-1};
			
			if(u.y<n&&dp[u.x][u.y+1]>dp[u.x][u.y]+vis[u.x][u.y])
			dp[u.x][u.y+1]=dp[u.x][u.y]+vis[u.x][u.y],q[++t]={u.x,u.y+1};
		}
	}
	cout<<ans;
    return 0;
}








Measured memory_bytes: 6704
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin>>N;
  int a[N][3];
  for(int i=0;i<N;i++)for(int j=0;j<3;j++)cin>>a[i][j];
 
  int h[3][N+1];
  h[0][0] = h[1][0]=h[2][0]=0;
  for (int i=1; i<=N; i++){
      h[0][i]=max(h[1][i-1], h[2][i-1])+a[i-1][0];
      h[1][i]=max(h[0][i-1], h[2][i-1])+a[i-1][1];
      h[2][i]=max(h[0][i-1], h[1][i-1])+a[i-1][2];
  }  
 
 
  cout << max(max(h[0][N], h[1][N]), h[2][N]);
  return 0;
}

Measured memory_bytes: 2560
N = int(input())
V = [int(a) for a in input().split()]
C = [int(a) for a in input().split()]

diff = [v - c for v, c in zip(V, C)]

# 差分が大きい順にソート
diff.sort(reverse=True)

ans = 0
max_ = 0
for d in diff:
    ans += d
    if ans > max_:
        max_ = ans 

print(max_)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
#include <utility>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
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 int INF = INT_MAX;
const long long LLINF = 1LL<<60;
template <typename T_char>
char ToUpper (char cX) { return toupper(cX); }
//g++ -std=c++1z temp.cpp
//./a.exe
int digit(int a){
    int count = 0;
    for (int i = 0; i < a; i++)
    {   if (a == 0)
        {
            break;
        }else
        {
            a = a/10;
            count++;
        }     
    }
    return count;
}
//pow(x,n) == x^n

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

string s1,s2,s3;
cin >> s1 >> s2 >> s3;
transform(s1.begin(), s1.end(), s1.begin(), ToUpper<char>);
transform(s2.begin(), s2.end(), s2.begin(), ToUpper<char>);
transform(s3.begin(), s3.end(), s3.begin(), ToUpper<char>);
cout << s1.at(0) << s2.at(0) << s3.at(0) << endl;
//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
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;}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int const MAX_w = 305;
ll dp[101][101][MAX_w + 5];

int main()
{
    int n; ll W;
    cin >> n >> W;
    vl w(n),v(n);
    rep(i,n) cin >> w[i] >> v[i];

    Fill(dp, 0);
    rep(i,n) rep(j,n) rep(k,MAX_w) {
        chmax(dp[i+1][j+1][k+w[i]-w[0]], dp[i][j][k] + v[i]);
        chmax(dp[i+1][j][k], dp[i][j][k]);
    }

    ll res = 0;
    rep(j,n+1) rep(k,MAX_w) {
        if(k <= W - j*w[0]) chmax(res, dp[n][j][k]);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 28320
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define clr(a,b) memset(a,b,sizeof(a))
#define all(v) ((v).begin()),((v).end())
double const EPS = 1e-8, PI = acos(-1);
const int N = 1e5 + 9, OO = 1e9;

int arr[26];

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i)
    cin >> arr[i];
  int ans = 0;
  for (int i = 1; i < n-1; ++i) {
    int mx = max(arr[i], max(arr[i-1], arr[i+1])), mn = min(arr[i], min(arr[i-1], arr[i+1]));
    if(arr[i] != mx && arr[i] != mn)
      ++ans;
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>                                                         
                                                                          
int main(void){                                                           
                                                                          
  int a,b,c;                                                              
                                                                          
  scanf("%d %d %d",&a,&b,&c);                                             
                                                                          
  if(a < b && b < c) {                                                    
    printf("Yes\n");                                                      
  } else {                                                                
    printf("No\n");                                                       
  }                                                                       
                                                                          
  return 0;                                                               
} 

Measured memory_bytes: 2596
#include<iostream>
#include <bits/stdc++.h>
#include <cstdio>
#include<set>
using namespace std;
int main()
{
    int N, K, Q;
    
    int sum = 0;
    
    cin >> N;
    cin >> K;
    cin >> Q;
    vector<int> A(Q);
    vector<int> win(N);
    
    for (int i = 0; i < N; i++){
        win[i] = 0;
    }
    
    for (int i = 0; i < Q; ++i) { 
        cin >> A[i];
        win[A[i] - 1]++;
        
    }
    
    for (int i = 0; i < N; i++){
        if (K - (Q - win[i]) >= 1){
            cout << "Yes\n";
        } else {
            cout << "No\n";
        }
    }
    return 0;
}


Measured memory_bytes: 1408
#include <stdio.h>
#include <string.h>

int main(void){
    int n;
    scanf("%d\n",&n);
    char name[n][101];
    char flag = '0';
    for(int i = 0;i<n;i++){
        fgets(name[i],sizeof(name[i]),stdin);
        if(i != 0 && name[i][0] != name[i-1][strlen(name[i-1])-2]){
            flag++;
            break;
        }
        for(int j = 0;j<i;j++){
            if(strcmp(name[j],name[i]) == 0){
                flag++;
                break;
            }
        }
        if(flag != '0'){
            break;
        }
    }
    if(flag == '0'){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
}

Measured memory_bytes: 128
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

class ADividingAString {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      string s; cin >> s;
      int n = s.size();
      char c = '%';
      int ans = 0;
      rep(i, n) {
        if (s[i] != c) {
          ans++;
          c = s[i];
        } else {
          i++;
          debug(i);
          if (i<n) ans++;
          c = '%';
        }
      }
      cout << ans << endl;
    }
};


signed main() {
  ADividingAString solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 720
#include <iostream>
#include <queue>

using namespace std;

int main()
{
    int N, NQ;
    cin >> N >> NQ;
    
    queue<int> Q[N];
    
    for(int i = 0; i < NQ; ++i)
    {
        int Command; cin >> Command;
        int t; cin >> t;
        
        if(Command == 0)
        {
            int val; cin >> val;
            Q[t].push(val);
        }
        else if(Command == 1)
        {
            if(Q[t].size())
              cout << Q[t].front() << endl;
        }
        else if(Command == 2)
        {
            if(Q[t].size())
              Q[t].pop();
        }
    }
    
    return 0;
}


Measured memory_bytes: 4320
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>


using namespace std;

#define ll long long
#define debug(n) cerr << #n << ':' << n << endl;
#define MP make_pair
#define pll pair<ll, ll>


void outset(string&out,ll a,ll b){
  out += to_string(a);
  out += ' ';
  out += to_string(b);
  out += '\n';
}
int main(){
  ll n;cin >> n;
  vector<ll> v(n);
  for(auto&&e:v)cin>>e;
  sort(v.begin(),v.end());
  int l = 0, r = n - 1;
  string out;
  while(l < r - 1){
    if(v[r] <= 0){
      outset(out,v[r],v[l]);
      v[r] -= v[l++];      
    }
    else{
      if(v[r-1]>=0){
	outset(out,v[l],v[r]);
	v[l] -= v[r--];
      }
      else{
	outset(out,v[r],v[l]);
	v[r] -= v[l++];
      }
    }
  }
  outset(out,v[r],v[l]);
  int ans = v[r] - v[l];  
  cout << ans << endl << out;
  return 0;
}


Measured memory_bytes: 4480
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}
void print(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cout<<ara[i]<<" ";
    cout<<endl;
}


int main()
{

   fastread();

   ll i,j,n,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r,ans=0;

      bool flag=false;

      string str;

cin>>str;

    n=str.size();

    for(i=0; i<n;++i)
    {
        cnt=0;

        while(i<n && (str[i]=='A' || str[i]=='C' || str[i]=='G' || str[i]=='T'))
        {
            cnt++;
            i++;
        }

        ans=max(ans,cnt);
    }

    cout<<ans<<endl;






}



Measured memory_bytes: 3588
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
string p[7]={"J","O","I","JI","JO","IO","JOI"};
int dp[1001][7]={{0},{0}};
int d;string s;//d日、s責任者

bool ok(int a,int b,char c){
	string f=p[a],se=p[b];
	bool flag1=false,flag2=false;
	for(int i=0;i<se.size();i++){
		if(se[i]==c)flag1=true;
	}
	for(int i=0;i<f.size();i++){
		for(int j=0;j<se.size();j++){
			if(f[i]==se[j])flag2=true;
		}
	}
	if(flag1&&flag2)return true;
	else return false;
}
int main(){
	cin>>d>>s;
	for(int i=0;i<7;i++)(ok(0,i,s[0]))?dp[0][i]=1:dp[0][i]=0;
//	for(int j=0;j<7;j++)if(ok(4,j,s[1]))dp[1][j]+=1;
	//	for(int j=0;j<7;j++)if(ok(6,j,s[1]))dp[1][j]+=1;
	
	for(int i=0;i<d-1;i++){
		for(int j=0;j<7;j++){//i+1日目のjパターン
			int x=0;
			for(int k=0;k<7;k++){//i日目
				if(ok(k,j,s[i+1])&&dp[i][k])dp[i+1][j]=(dp[i+1][j]+dp[i][k])%10007;
			}
		}
	}
	
	/*for(int i=0;i<d;i++){
	for(int j=0;j<7;j++)cout<<dp[i][j]<<" ";
	cout<<endl;
	}*/
	int ans=0;
	for(int i=0;i<7;i++)ans+=dp[d-1][i];
	cout<<ans%10007<<endl;
	return 0;
}

Measured memory_bytes: 1248
package main

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

var sc *bufio.Scanner

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	var s, t string
	fmt.Scan(&s, &t)
	rs, rt := []rune(s), []rune(t)
	ans := 0
	for i := 0; i < 3; i++ {
		if rs[i] == rt[i] {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
#include<iostream>
#include<bits/stdc++.h>
#define MAX 100;

using namespace std;
int N,M,K;
int a[20];
int b[20];

typedef pair<int,int> ii;

void input(){
  cin>>N>>M>>K;
  
  vector<ii> vec(N);
  for(int i=0;i<N;i++){
    cin>>a[i];
    vec[i].first = a[i];
  }
  for(int i=0;i<N;i++){
    cin>>b[i];
    vec[i].second = b[i];
  }
  sort(vec.begin(),vec.end());
  for(int i=0;i<N;++i) {
    a[i] = vec[i].first;
    b[i] = vec[i].second;
  }
}
int field[3];
int array[100000];
int main(){
  int spa=0;
  input();
  int maxi = M;
  if( K == 1 ) {
    for(int k=0;k<N;k++){
      int ans=0;
      int las_Imo=M;
      field[0]=k;
      for(int i=0;i>=0;i--){
	for(int t=0;t<b[field[i]];t++){
	  if( las_Imo ) {
	    las_Imo--;
	    ans=ans+a[field[i]];
	  }
	}
      }
      ans = ans + ((las_Imo>=0)?las_Imo:0);
      maxi = max(maxi,ans);
    }
  } else if( K == 2 ) {
    for(int k=0;k<N;k++){
      for(int l=k+1;l<N;l++){
	int ans=0;
	int las_Imo=M;
	field[0]=k;
	field[1]=l;
	for(int i=1;i>=0;i--){
	  for(int t=0;t<b[field[i]];t++){
	    las_Imo--;
	    if(las_Imo<0) break;
	    ans=ans+a[field[i]];
	  }
	}
	ans = ans + ((las_Imo>=0)?las_Imo:0);
	maxi = max(maxi,ans);
      }
    }
  } else {
    for(int k=0;k<N;k++){
      for(int l=k+1;l<N;l++){
	for(int m=l+1;m<N;m++){
	  int ans=0;
	  int las_Imo=M;
	  field[0]=k;
	  field[1]=l;
	  field[2]=m;
	  for(int i=2;i>=0;i--){
	    for(int t=0;t<b[field[i]];t++){
	      las_Imo--;
	      if(las_Imo<0) break;
	      ans=ans+a[field[i]];
	    }
	   
	  }
	
	  ans = ans + ((las_Imo>=0)?las_Imo:0);
	  array[spa++]=ans;
	  maxi = max(maxi,ans);
	}
      }
    }
  }
  //sort(array,array+100000,greater<int>());
  //cout<<array[0]<<endl;			
  cout << maxi << endl;
  return 0;
}

Measured memory_bytes: 1204
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
    int N;
    cin >> N;
    ll d[N];
    for(int i = 0; i < N; i++){
        cin >> d[i];
    }

    ll ans = 0;
    for(int i = 0; i < N - 1; i++){
        for(int j = i + 1; j < N; j++){
            ans += d[i] * d[j];
        }
    }

    cout << ans << endl;
    return 0;
}


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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    string s;
    cin >> s;
    
    ll k = 0;
    rep (i, s.size()) {
        if (s[i] == 'x') {
            k++;
        }
    }

    if (k <= 7) {
        YES;
    } else {
        NO;
    }
    return 0;
}

Measured memory_bytes: 256
//Name: List of Top 3 Hills
//Level: 1
//Category: ????????????
//Note:

#include <stdio.h>

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

int main()
{
    int x[10], i;

    for (i = 0; i < 10; i++)
      scanf("%d", &x[i]);

    qsort (x, 10, sizeof(int), compare_int);

    for (i = 0; i < 3; i++)
      printf("%d\n", x[9-i]);

    return 0;
}

Measured memory_bytes: 604
n = int(input())
s=[]

for i in range(n):
  sl = int(input())
  s.append(sl)
  
s.sort()
ans = sum(s)

i = 0
while ans>0 and i<n:
  if ans%10!=0:
    print(ans)
    exit()
  else:
    if s[i]%10!=0:
      ans = ans-s[i]
    i += 1
      
print(ans%10)
      

Measured memory_bytes: 9128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstdio>
using namespace std;
int main(void) {
    int n, k, d, b, a[101] = { 0 }, i, j;
    cin >> n;
    cin >> k;
    for (i = 0; i < k; i++) {
        cin >> d;
        for (j = 0; j < d; j++) {
            cin >> b;
            a[b] = 1;
        }
    }
    b = 0;
    for (i = 1; i <= n; i++) {
        //cout << a[i] << " ";
        if (a[i] == 0)b++;
    }
    cout << b << endl;
    return 0;
}

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

typedef long long ll;
typedef long double ld;
#define pi 3.14159265359;
#define inf (1 << 21);
#define mod 1000000007;

int main() {
    int N, M; cin >> N >> M;
    vector<int> K(N), like(M, 0);
    vector<vector<int>> A(N);
    for (int i = 0; i < N; i++) {
        cin >> K.at(i);
        for (int j = 0; j < K.at(i); j++) {
            int a; cin >> a;
            A.at(i).push_back(a);
            like.at(a - 1)++;
        }
    }
    int ans = 0;
    for (int i = 0; i < M; i++) {
        if (like.at(i) == N) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

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

typedef long long LL;
typedef vector<int> VI;

int main() {
  int N;
  cin >> N;
  vector<vector<int>> c(10, vector<int>(10, 0));
  for (int i = 1; i <= N; i++) {
    string s = to_string(i);
    int l = s.at(0)-'0';
    int m = s.at(s.length()-1)-'0';
    c[l][m]++;
  }
  LL cnt = 0;
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      cnt += c[i][j]*c[j][i];
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace B___YYMM_or_MMYY
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();

            int AA = int.Parse(new string(S.Where((e, i) => i < 2).ToArray()));
            int BB = int.Parse(new string(S.Where((e, i) => 2 <= i).ToArray()));

            if (MM(AA) && YY(BB))
                Console.WriteLine(YY(AA) && MM(BB) ? "AMBIGUOUS" : "MMYY");
            else if (YY(AA) && MM(BB))
                Console.WriteLine("YYMM");
            else
                Console.WriteLine("NA");
        }

        static bool MM(int XX) => 1 <= XX && XX <= 12;
        static bool YY(int XX) => 0 <= XX && XX <= 99;
    }
}


Measured memory_bytes: 13268
// Problem : D - Sum of Divisors
// Contest : AtCoder - AtCoder Beginner Contest 172
// URL : https://atcoder.jp/contests/abc172/tasks/abc172_d
// Memory Limit : 1024 MB
// Time Limit : 3000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize "trapv"//  WA to RE int!!
#include <bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORR(i,n) for(int i=n;i>=0;i--)
#define pb push_back
#define vlli vector<int>
#define slli set<int>
#define mlli map<int,int>
#define int long long int 
#define test int tt1234; cin>>tt1234;while(tt1234--)
#define endl "\n"
#define all(zz) zz.begin(),zz.end()
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define error(x) cerr << #x <<" is " << x << endl;
#define Error(a,b) cerr<<"( "<<#a<<" , "<<#b<<" ) = ( "<<(a)<<" , "<<(b)<<" )\n";
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fint fast;test
#define SI(a,n) int a[n];FOR(i,n) cin>>a[i];
#define input(a,n) int n;cin>>n; SI(a,n)
#define set(a,x) memset(a,x,sizeof(a))
#define L(x)	((x)<<1)
#define R(x)	(((x)<<1)+1)
#define ft first
#define se second
#define MOD 1000000007
using namespace std;

void solve(){
	int n;
	cin>>n;
	int arr[n+1]={0};
	for(int i=1;i<=n;i++){
		for(int j=i;j<=n;j+=i){
			arr[j]++;
		}
	}
	int ans=0;
	rep(i,1,n+1){
		ans+=(i*arr[i]);
	}
	cout<<ans<<endl;
		return;	
}


int32_t main() {
    // fint{
    	fast;
    	solve();
    // }
    return 0;
}


Measured memory_bytes: 81684
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>

using namespace std;

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

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

using ll = long long;
using p = pair<ll, ll>;
constexpr ll INF = 1LL << 62;
constexpr ll MOD = 1e9 + 7;

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

  vector<ll> A(N);
  for (auto&& a : A) {
    cin >> a;
  }

  if (K == N) {
    cout << accumulate(A.begin(), A.end(), 1, [](ll l, ll r) { return ((l * r) % MOD + MOD) % MOD; });
    return 0;
  }

  vector<ll> pos, neg;
  for (auto a : A) {
    if (a >= 0) {
      pos.emplace_back(a);
    } else {
      neg.emplace_back(a);
    }
  }

  sort(pos.begin(), pos.end(), greater<ll>());
  sort(neg.begin(), neg.end());

  if (pos.size() == 0 && (K % 2)) {
    ll ans = 1;
    for (ll i = 0; i < K; i++) {
      ans *= neg[N - 1 - i];
      ans = (ans + MOD) % MOD;
    }

    cout << ans << endl;
    return 0;
  }

  ll pptr = 0, mptr = 0;
  ll ans = 1;

  while (pptr + mptr < K) {
    if (pptr + mptr + 2 <= K) {
      if (pptr >= pos.size()) {
        ans *= (neg[mptr] * neg[mptr + 1]) % MOD;
        mptr += 2;
      } else if (mptr + 1 >= neg.size()) {
        ans *= pos[pptr++];
      } else {
        ll ppair = pos[pptr] * pos[pptr + 1];
        ll mpair = neg[mptr] * neg[mptr + 1];
        if (ppair > mpair) {
          ans *= pos[pptr++];
        } else {
          ans *= mpair % MOD;
          mptr += 2;
        }
      }
    } else {
      ans *= pos[pptr++];
    }
    ans = (ans + MOD) % MOD;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6864
#include <stdio.h>

void print(int *array, int slong);

int main(void){
    /*宣言部*/
    int slong, key, sindex, x;    /*slong:数列の長さ key:検索キー sindex:検索用添字 x:ループ変数*/
    int sequence[100]={0};    /*sequence:数列*/
    
    /*入力部*/
    scanf("%d", &slong);    /*数列の長さを受け取る*/
    for(x=0; slong>x; x++){
        scanf("%d", &sequence[x]);    /*数列を受け取る*/
    }
    
    print(sequence, slong);    /*ソート前の状態を表示*/
    
    /*ソート・出力部*/
    for(x=1; slong>x; x++){    /*ソート対象は数列の前から2番目以降のため、数列の長さ-1回ループする*/
        key = sequence[x];    /*数列の前から2番目より後ろが検索キーになる*/
        sindex = x-1;    /*検索キーの一つ前の添字をを検索用添字とする*/
        
            /*検索用添字が前に行ききる（-1）か、検索キー以下である数列の要素に当たるまでループ*/
        while(sindex >= 0 && sequence[sindex] > key){
            sequence[sindex+1] = sequence[sindex];    /*検索対象は検索キーを超える大きさの要素なので数列の一つ後ろにどいてもらう*/
            sindex--;    /*検索用添字を前にずらす*/
        }
        
        sequence[sindex+1] = key;    /*検索用添字は、数列の最初よりひとつ前（-1）or検索キー以下である数列の要素が持つ添字
                                        となってるはずなのでその箇所の後ろに検索キーを挿入する*/
        
        print(sequence, slong);    /*ソート状況表示*/

    }
    
    return 0;
}

void print(int *array, int arraylong){
    int y;    /*y:ループ変数*/
    
    /*数列のソート状況を表示する*/
    for(y=0; arraylong>y; y++){
        printf("%d", array[y]);
        if(arraylong-1 == y){    /*表示形式調整*/
            printf("\n");
        }else{
            printf(" ");
        }
    }
}

Measured memory_bytes: 604
#include<iostream>
#include<cstdio>
using namespace std;
const int MAX_SIZE = 100001;
const int MOD = 1000000000+7;
int n,t[MAX_SIZE],a[MAX_SIZE],T[MAX_SIZE],A[MAX_SIZE];
long long sum = 1;
int main(){
	cin >> n;
	for(int i=0;i<n;i++){
		scanf("%d",&t[i]);
	}
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	T[0] = -1*t[0];
	A[n-1] = -1*a[n-1];
	for(int i = 1;i<n;i++){
		if(t[i] > t[i-1]){
			T[i] = t[i]*(-1);
		}
		else T[i] = t[i];
		if(a[n-1-i] > a[n-i]){
			A[n-1-i] = a[n-1-i]*(-1);
		}
		else A[n-1-i] = a[n-1-i]; 
	}
	for(int i=0;i<n;i++){
		if(A[i]>0 && T[i]>0){
			sum *= A[i]>T[i] ? T[i] : A[i];
		}
		else if ( A[i]>0 && T[i] < 0){
			if(A[i] < T[i]*(-1)) sum *= 0;
		}
		else if(A[i] < 0 && T[i] > 0){
			if(A[i]*(-1) > T[i]) sum *= 0;
		}
		else if(A[i] < 0 && T[i] < 0){
			if(A[i]!= T[i]) sum*=0;
		}
		sum %= MOD;
	}
	cout << sum;
	return 0;
}

Measured memory_bytes: 1792