akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <math.h>
int main(){
    int i;
    char bunsan[3]={'d','o','x'};
    while(1){
        int result=0;
        char input[10];
        if(scanf("%s",input)==EOF)break;
        for(i=0;i<=2;i++){
            if(bunsan[i]==input[0]){
                if(bunsan[i]==input[1]&&bunsan[i]==input[2])result=i;//yoko
                if(bunsan[i]==input[3]&&bunsan[i]==input[6])result=i;//tate
                if(bunsan[i]==input[4]&&bunsan[i]==input[8])result=i;//naname
            }
            if(bunsan[i]==input[1]){
                if(bunsan[i]==input[4]&&bunsan[i]==input[7])result=i;//tate
            }
            if(bunsan[i]==input[2]){
                if(bunsan[i]==input[5]&&bunsan[i]==input[8])result=i;//tate
                if(bunsan[i]==input[4]&&bunsan[i]==input[6])result=i;//naname
            }
            if(bunsan[i]==input[3]){
                if(bunsan[i]==input[4]&&input[5]==bunsan[i])result=i;//yoko
            }
            if(bunsan[i]==input[6]){
                if(bunsan[i]==input[7]&&input[8]==bunsan[i])result=i;//yoko
            }
            
        }
        printf("%c\n",bunsan[result]);
    }
    return 0;
}

Measured memory_bytes: 540
ch = ['a','b','c','d','e','f','g','h','i','j','k','l','m',
      'n','o','p','q','r','s','t','u','v','w','x','y','z']

n = int(input())

import queue
q=queue.Queue()
l = 1
q.put(["a", 0])

while True:
  temp = q.get()
  l=len(temp[0])
  if l==n:
    break
    
  for i in range(temp[1]+2):
    ne = temp[0]+ch[i]
    nn = max(temp[1], i)
    q.put([ne, nn])

print(temp[0])
while not q.empty():
  print(q.get()[0])
  


Measured memory_bytes: 27092
package main

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

func main() {
	N := ReadInt()
	divs := Divisors(N)
	ans := 0
	for _, d := range divs {
		if d == 1 {
			continue
		}
		m := d - 1
		if N/m == N%m {
			ans += m
		}
	}
	fmt.Println(ans)
}

func Divisors(n int) []int {
	nums := []int{}
	for i := 1; i*i <= n; i++ {
		if n%i == 0 {
			nums = append(nums, i)
			if i*i != n {
				nums = append(nums, n/i)
			}
		}
	}
	return nums
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }


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

int main()
{
    int a[3][3]={},n;
    for(int i=0; i<3; i++)
    {
        for(int j=0; j<3; j++)
        {
            cin>>a[i][j];
        }
    }
    cin>>n;
    for(int i=0; i<n; i++)
    {
        int k;
        cin>>k;
        for(int i=0; i<3; i++)
        {
            for(int j=0; j<3; j++)
            {
                if(k==a[i][j])
                    a[i][j]=-1;
            }
        }
    }
    bool flag=false;
    for(int i=0; i<3; i++)
    {
        if(a[i][0]==a[i][1]&&a[i][1]==a[i][2]&&a[i][0]==-1)
            flag=true;
        if(a[0][i]==a[1][i]&&a[1][i]==a[2][i]&&a[0][i]==-1)
            flag=true;
    }
    if(a[0][0]==a[1][1]&&a[1][1]==a[2][2]&&a[0][0]==-1)
        flag=true;
    if(a[0][2]==a[1][1]&&a[1][1]==a[2][0]&&a[1][1]==-1)
        flag=true;
    if(flag)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}



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


int main(){
string S;
cin>>S;
if(S[5]=='0'){
  if(S[6]=='1'||S[6]=='2'||S[6]=='3'||S[6]=='4'){
    printf("Heisei\n");
    return 0;
  }

}

printf("TBD\n");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;

//INSERT ABOVE HERE
signed main(){
  int n;
  cin>>n;
  for(int b=0;b<(1<<n);b++){
    cout<<b<<":";
    for(int i=0;i<n;i++)
      if((b>>i)&1) cout<<" "<<i;
    cout<<"\n";
  }
  cout<<flush;
  return 0;
}



Measured memory_bytes: 3172
num, bricks = int(input()), [int(x) for x in input().split(" ")]
count = 1
smash = 0
for x in bricks:
    if count == x:
        count += 1
    else:
        smash += 1
print(smash if smash != len(bricks) else 0 if len(bricks) == 1 else -1)


Measured memory_bytes: 24744
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#define MAXA 100000
#define MAX 20000000000
#define s(i) scanf("%d", &(i))
#define p(i) printf("%d", (i))
#define ps() printf(" ") 
#define rer(i,j,k) for((i)=(j);(i)<(k);++(i))
#define ret(i,j,k) for((i)=(j);(i)>(k);--(i))
using namespace std;
int main(){
	int i;
	double k,x;
	cin >> k >> x;
	for(i=x-k+1;i<=x+k-1;i++)
	{
		cout << i;
		if(i!=x+k-1){
			cout<< " ";
		}
	} 
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define _rep(i,m,n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){
    int n,k; cin >> n >> k;
    vector<int> x(n);
    rep(i,n) cin >> x[i];
    int sum = 0;
    rep(i,n){
        sum += 2 * min(x[i], abs(k - x[i]));
    }
    cout << sum << endl;


    /*int n; cin >> n;
    string s; cin >> s;
    vector<int> white(n, 0);
    vector<int> white_sum(n + 1);
    vector<int> black(n, 0);
    vector<int> black_sum(n + 1);

    
    rep(i,n){
        if(s[i] == '.')white[i] = 1;
        if(s[i] == '#')black[i] = i;
    }
    _rep(i, 1, n + 1){
        white_sum[i] = white[i - 1] + white_sum[i - 1];
        black_sum[i] = black[i - 1] + black_sum[i - 1];
        cout << white_sum[i] << endl;
    }
    int ans_min = N;
    rep(i,n + 1){
        int ans = white_sum[n] - white_sum[i];
        ans_min = min(ans, ans_min);
    }
    cout << ans_min << endl;*/
}

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

result = sum(input_list)

# 入力の総和が10の倍数でないときは、それが成績となる
if result % 10 != 0:
    print(result)
# 入力の総和が10の倍数のとき
else:
    for i in input_list:
        if i % 10 != 0:
            print(result-i)
            break
    else:
        print(0)

Measured memory_bytes: 3060
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#define FOR(i,a,b) for(int i=a;i<b;i++)
typedef long long ll;
using namespace std;
const int MOD = 1e9 + 7;
int N;
ll ans = 0;
int main(void) {
	cin >> N;
	FOR(i, 0, N) {
		int x;
		cin >> x;
		while (1) {
			if (x % 2 == 1)break;
			ans++;
			x /= 2;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int a,b[1000],min=1000,ans=0,d=0;
	cin>>a;
	for(int i=0;i<a;i++){
		cin>>b[i];
		if(b[i]%10!=0){
			d++;
			if(min>b[i]){
				min=b[i];
			}
		}
		ans=ans+b[i];
	}
	if(d==0){
		cout<<0<<endl;
	}else if(ans%10==0){
		cout<<ans-min<<endl;
	}else{
		cout<<ans<<endl;
	}

}

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

int main()
{
    long long a,b,c;
    scanf("%lld%lld%lld",&a,&b,&c);
    (a&1&&b&1&&c&1)?printf("%lld\n",min(a*b,min(b*c,a*c))):printf("0\n");
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 500000
#define SEN 2000000000
void merge(int *,int,int,int,int);
void mergesort(int *,int,int,int);

int cnt = 0;
int main(){
  int n;

  int S[MAX];
  int i;
  scanf("%d",&n);
  for(i = 0;i < n;i++){
    scanf("%d",&S[i]);
  }
  mergesort(S,n,0,n);

  for(i = 0;i < n;i++){
    printf("%d",S[i]);
    if(i != n-1){
      printf(" ");
    }
  }
  printf("\n");
  printf("%d\n",cnt);
  return 0;
}


void merge(int S[],int n,int left,int mid,int right){
  int L[MAX],R[MAX];
  int n1 = mid - left;
  int n2 = right - mid;
  for(int i = 0;i < n1;i++){
    L[i] = S[left + i];
  }
  for(int i = 0;i < n2;i++){
    R[i] = S[mid + i];
  }
  L[n1] = R[n2] = SEN;
  int i = 0,j = 0;
  for(int k = left;k<right;k++){
    cnt++;
    if(L[i] < R[j]){
      S[k] = L[i++];
    }else{
      S[k] = R[j++];
    }
  }
}


void mergesort(int S[],int n,int left,int right){
  if(left+1<right){
    int mid = (left + right)/2;
    mergesort(S,n,left,mid);
    mergesort(S,n,mid,right);
    merge(S,n,left,mid,right);
  }
}



Measured memory_bytes: 5632
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
def A():
    return

#B
def B():
    return

#C
def C():
    n,k = LI()
    h = IR(n)
    h.sort()
    ans = float("inf")
    for i in range(n-k+1):
        ans = min(ans,h[i+k-1]-h[i])
    print(ans)

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == "__main__":
    C()


Measured memory_bytes: 45552
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var n, k, q string
	fmt.Scan(&n)
	fmt.Scan(&k)
	fmt.Scan(&q)
	N, _ := strconv.Atoi(n)
	K, _ := strconv.Atoi(k)
	Q, _ := strconv.Atoi(q)
	A := make([]int, N)
	var ai string
	var a int
	for i := 0; i < Q; i++ {
		fmt.Scan(&ai)
		a, _ = strconv.Atoi(ai)
		A[a-1]++
	}
	for i := 0; i < N; i++ {
		if K+A[i]-Q > 0 {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}
}


Measured memory_bytes: 5888
import math
import sys
input = sys.stdin.readline


def main():
    sc = Scan()
    n = sc.intarr()[0]
    d = sc.intarr()
    d.sort()
    print(d[n//2] - d[n//2 - 1])


class Scan():

    def intarr(self):
        line = input()
        array = line.split(' ')
        num_array = [int(n) for n in array]
        return num_array

    def strarr(self):
        line = input()
        array = line.split(' ')
        array[-1] = array[-1].strip('\n')
        return array


main()


Measured memory_bytes: 14452
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793

int main(){
 ll n,a,b,c,d,e;
 cin >> n >> a >> b >> c >> d >> e ;
 ll mn=min(a,b);
 mn=min(c,mn);
 mn=min(d,mn);
 mn=min(e,mn);
 ll t;
 if(n%mn==0)t=(n/mn)-1;
 else{
      t=n/mn;
 }
 cout << 5+t << endl;
}

Measured memory_bytes: 3596
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ms(x) memset(x,0,sizeof(x));
#define forn(i,a,b) for(int i=(a);i<=(b);++i)
#define rev(i,a,b) for(int i=(a);i>=(b);--i)
#define sc(x) scanf("%d",&x)
#define bug(x) cerr<<#x<<":"<<(x)<<endl
using namespace std;
typedef long long ll;
const int M = 500000;
ll a[M];
int n;
bool ok(ll x){
    ll w=x;
    forn(i,1,n) w=(a[i]<<1)-w;
    return w>x;
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    forn(i,1,n) {
        cin>>a[i];
//        a[i]<<=1;
    }
    ll lo=0,hi=a[1]<<1;
    ll mid=(lo+hi)>>1;
    while(lo<hi){
        if(ok(mid)) lo=mid+1;
        else hi=mid;
        mid=(lo+hi)>>1;
    }
    cout<<lo;
    forn(i,1,n-1){
        lo = (a[i]<<1)-lo;
        cout<<" "<<lo;
    }
    cout<<endl;
    return 0;
}

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

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

  bool n = direction.find('N') != string::npos;
  bool s = direction.find('S') != string::npos;
  bool w = direction.find('W') != string::npos;
  bool e = direction.find('E') != string::npos;
  cout << (n == s && w == e ? "Yes" : "No") << endl;

  return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def SMI(): return input().split()
def SLI(): return list(input())

def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')

# from math import ceil, floor, log2
# from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np
# from numpy import cumsum  # accumulate

def solve():
    S = SLI()
    l = len(S)
    MOD = 1000000007
    dp = [[0]*13 for _ in range(l+1)]
    dp[0][0] = 1
    mul = 1
    R = S[::-1]
    for i in range(l):
        s = S[-(i + 1)]
        if s == '?':
            for q in range(10):
                for j in range(13):
                    dp[i+1][(q*mul + j)%13] += dp[i][j]
                    dp[i+1][(q*mul + j)%13] %= MOD
        else:
            for j in range(13):
                k = int(s)
                dp[i+1][(k*mul + j)%13] += dp[i][j]
                dp[i+1][(k*mul + j)%13] %= MOD

        mul = mul * 10 % 13
    # print(dp[-1])
    print(dp[-1][5] % MOD)

if __name__ == '__main__':
    solve()


Measured memory_bytes: 66040
import math
n, a, b =map(int,input().split())
x=a+b
#yはn/(a+b)の商
quotient=math.floor(n/x)
#zはn/(a+b)の余り
rmd=n%x
if rmd==0:
  blue=quotient*a
  print(blue)
elif rmd<=a:
  blue=quotient*a+rmd
  print(blue)
else:
  blue=quotient*a+a
  print(blue)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define Mp make_pair
#define pb push_back

using ll = long long;
using db = double;
using pii = pair<int, int>;
using vi = vector<int>;
mt19937 mrand(time(0));
ll get(ll r) { return ((ll)mrand() * mrand() % r + r) % r; }
ll get(ll l, ll r) { return get(r - l + 1) + l; }

int k, A[600][600];
signed main() {
	// freopen("my.out", "w", stdout);
	scanf("%d", &k);
	if(k <= 500) {
		printf("%d\n", k);
		for(int i = 1; i <= k; i++, puts(""))
			for(int j = 1; j <= k; j++)
				printf("%d ", i);
		return 0;
	}
	int n = 500, N = 0; k -= n;
	printf("500\n");
	for(int i = 1; i <= n; i++) {
		int a = ++N, b = k ? ++N : N;
		k -= b - a;
		for(int x = 1, y = i; x <= n; x++, y = y % n + 1)
			A[x][y] = x & 1 ? a : b;
	}
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= n; j++)
			printf("%d%c", A[i][j], " \n"[j == n]);
	fprintf(stderr, "time=%.4f\n", (db)clock()/CLOCKS_PER_SEC);
	return 0;
	/* 取模直接除，爆零两行泪
	 * 不开ll见祖宗
	 */
}

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int r; cin>>r;
	if (r<1200) cout<<"ABC\n";
	else if (r<2800) cout<<"ARC\n";
	else cout<<"AGC"<<endl;
	return 0;
}


Measured memory_bytes: 256
import sys
import numpy as np
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

H, W, D = map(int, readline().split())
A = [list(map(int, readline().split())) for _ in range(H)]
Q = int(readline())
LR = map(int, read().split())

a = [(0, (0, 0))]
for i in range(H):
    a.extend([(element, [i, w]) for w, element in enumerate(A[i])])

a.sort()
tmp, number = zip(*a)
number = np.array(number)
x = np.resize(number[:, 0], (H * W // D + 1, D))
y = np.resize(number[:, 1], (H * W // D + 1, D))

magic = np.abs(x[1:] - x[:-1]) + np.abs(y[1:] - y[:-1])
np.cumsum(magic, axis=0, out=magic)

for L, R in zip(LR, LR):
    if L != R:
        q1 = R // D - 1
        q2 = L // D - 1
        r = R % D
        if q2 == -1:
            print(magic[q1][r])
        else:
            print(magic[q1][r] - magic[q2][r])
    else:
        print(0)

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

ll dist[310][310];

// ワーシャルフロイド
void warshall_floyd(int n) {
  for (int k = 0; k < n; k++){       // 経由する頂点
    for (int i = 0; i < n; i++) {    // 始点
      for (int j = 0; j < n; j++) {  // 終点
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
}

ll fact(ll n){
    if(n ==1) return 1;
    return n * fact(n-1);
}

int main()
{
    cout << fixed << setprecision(15);
    ll N, M, R;
    cin >> N >> M >> R;

    vector<ll> r(R);

    REP(i, R){
        cin >> r[i];
        r[i]--;
    }
    Fill(dist, INF);

    REP(i, M){
        ll a, b, c;
        cin >> a >> b >> c;
        dist[a-1][b-1] = c;
        dist[b-1][a-1] = c;
    }

    warshall_floyd(N);
     
    vector<ll> nums(R);
    REP(i, R){
        nums[i] = i;
    }

    ll p = fact(R);
    ll ans = INF;
    REP(i, p){
        ll temp = 0;
        REP(j, R-1){
            // cout << nums[j];
            temp += dist[r[nums[j]]][r[nums[j+1]]];
        }
        ans = min(ans, temp);
        // cout << endl;
        // 順列の遷移処理
        next_permutation(nums.begin(), nums.end());
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
    int x, a, b;
    cin >> x >> a >> b;

    if(b <= a)        cout << "delicious" << endl;
    else if(b <= x+a) cout << "safe" << endl;
    else              cout << "dangerous" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
 
int main(void)
{
  long a=0, m=0, r=0, c=0, h=0,i,num;
  long answer;
  scanf("%ld", &num);
  char array[10];
  for(i=1; i<=num; i++)
  {
    scanf("%s", array);
    if(array[0]=='M')m++;
    if(array[0]=='A')a++;
    if(array[0]=='R')r++;
    if(array[0]=='C')c++;
    if(array[0]=='H')h++;
  }
  
   answer=m*a*r+m*a*c+m*a*h+m*r*c+m*r*h+m*c*h+a*r*c+a*c*h+r*c*h+a*r*h;
   printf("%ld", answer);
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define MAX 200002
typedef long long ll;
ll N, a[MAX], psum[MAX];
vector<int> val;

int main(){
    scanf("%lld", &N);
    for(int i = 1; i <= N; i++){
        scanf("%lld", a + i);
        val.push_back(a[i]);
    }
    sort(val.begin(), val.end());
    for(int i = 1; i <= N; i++){
        if(a[i] < val[(N + 1) / 2]){
            printf("%d\n", val[(N + 1) / 2]);
        }
        else
            printf("%d\n", val[(N + 1) / 2 - 1]);
    }
    return 0;
}

Measured memory_bytes: 4724
#include<cstdio>
#include<algorithm>
#include<map>
using namespace std;
map<int,int>g;
int main()
{
	int n,m,sum=0;
	long long ans=0;
	scanf("%d%d",&n,&m);
	g[0]=1;
	for(int i=1;i<=n;i++)
	{
		int x;
		scanf("%d",&x);
		sum=(sum+x)%m;
		ans+=1ll*g[sum];
		g[sum]++;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 3328
import java.io.*;
import java.util.*;

public class Main {
	static int mod = (int)1e9+7;
	static Comparator<Integer> lower_bound = (x, y) -> x.compareTo(y) >= 0 ? 1 : -1;
	static Comparator<Integer> upper_bound = (x, y) -> x.compareTo(y) > 0 ? 1 : -1;

	public static void main(String[] args){
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		solve(sc,out);

		out.flush();
	}

	public static void solve(FastScanner sc, PrintWriter out) {
		int r = sc.nextInt();
		
		out.println((int)(3*Math.pow(r, 2)));
	}

	public static long gcd(long a, long b) {
		if(a < b) return gcd(b, a);
		if(b == 0) return a;
		return gcd(b, a % b);
	}

	public static long lcm(long a, long b) {
		return a / gcd(a, b) * b;
	}

	public static long factorial(int n) {
		long a;

		if(n > 0) {
			a = n * factorial(n - 1);
		}else{
			a = 1;
		}

		return a;
	}
}

class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {

    public Pair(K key, V value) {
        super(key, value);
    }

    public Pair<V, K> swap() {
    	return new Pair<V, K>(getValue(), getKey());
    }
 }

class UnionFind {
	int[] par;

	public UnionFind(int n) {
		par = new int[n];

		Arrays.fill(par, -1);
	}

	int root(int x) {
		if(par[x] < 0) return x;
		return par[x] = root(par[x]);
	}

	boolean unite(int x,int y) {
		x = root(x);
		y = root(y);

		if(x == y) return false;

		if(size(x) < size(y)) {
			int tmp = x;
			x = y;
			y = tmp;
		}

		par[x] += par[y];
		par[y] = x;

		return true;
	}

	boolean same(int x,int y) {
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}

	int size(int a) {
		return -par[root(a)];
	}
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

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

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

        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

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

    public double nextDouble() {
         return Double.parseDouble(next());
     }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

Measured memory_bytes: 28628
require 'pp'

# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
  gets.chomp.split(" ").map(&:to_i)
end

N, X = gets_i_list
x_list = gets_i_list

gcd = X - x_list[0]
x_list.each do |x|
  gcd = gcd.gcd((X - x).abs)
end

puts gcd


Measured memory_bytes: 9724
#include <iostream>
#include <vector>
#include <climits>
using namespace std;
#define fr second.first
#define to second.second
#define co first
const int INF=INT_MAX;
typedef pair<int,int> P;
typedef pair<int,P> Edge;
long long edmonds(vector<Edge> edges,int v,int st) {

  vector<P> mins(v,P(INF,-1));
  for(int i=0;i<(int)edges.size();i++) {
    Edge edge=edges[i];
    mins[edge.to]=min(mins[edge.to],P(edge.co,edge.fr));
  }
  mins[st]=P(-1,-1);

  vector<int> gr(v,0);
  vector<bool> tfc(v,false),f(v,false);
  int cnt=0;

  for(int i=0;i<v;i++){
    if(f[i]) continue;
    vector<int> ch;
    int cu=i;
    for(;cu!=-1&&!f[cu];){
      f[cu]=true;
      ch.push_back(cu);
      cu=mins[cu].second;
    }
    if(cu!=-1){
      bool tfc2=false;
      for(int j=0;j<(int)ch.size();j++) {
    gr[ch[j]]=cnt;
    if(ch[j]==cu){
      tfc[cnt]=true;
      tfc2=true;
    }
    if(!tfc2) cnt++;
      }
      if(tfc2) cnt++;
    }
    else for(int j=0;j<(int)ch.size();j++,cnt++) gr[ch[j]]=cnt;
  }

  if(cnt==v){
    long long ans=1;
    for(int i=0;i<v;i++) ans+=mins[i].co;
    return ans;
  }

  long long res=0;
  for(int i=0;i<v;i++) if(i!=st&&tfc[gr[i]]) res+=mins[i].co;

  vector<Edge> nedges;
  for(int i=0;i<(int)edges.size();i++) {
    Edge edge=edges[i];
    int fto=edge.to,gfr=gr[edge.fr],gto=gr[edge.to];
    if(gfr==gto) continue;
    else if(tfc[gto]) nedges.push_back(make_pair(edge.co-mins[fto].co,P(gfr,gto)));
    else nedges.push_back(make_pair(edge.co,P(gfr,gto)));
  }

  return res+edmonds(nedges,cnt,gr[st]);

}

int main(){
  int v,e,r;
  cin>>v>>e>>r;
  vector<Edge> es;
  for(int i=0,s,t,w;i<e&&cin>>s>>t>>w;i++) es.push_back(make_pair(w,P(s,t)));
  cout<<edmonds(es,v,r)<<endl;
  return 0;
}



Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <queue>
#include <deque>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <bitset>

#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define FILL(x, y) memset(x, y, sizeof(x))
#define pb push_back
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

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

using namespace std;
using ll = long long;

const int kInf = 2e9;
const ll kLInf = 2e18;

int gcd (int a, int b) {
   return b ? gcd(b, a % b) : a;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

string S;
ll h[500010];
ll v[500010];
vector<ll> vValue;
int main()
{
   cout << fixed << setprecision(10);
   cin >> S;
   ll cnt = 0;
   ll prev = -1;
   ll minVValue = kInf;
   REP(i, SZ(S)) {
      v[i] = cnt;
      if (S[i] == '<') {
         h[i + 1] = h[i] + 1;
         if (prev == 1 || !i) {
            vValue.push_back(h[i]);
            if (h[i] < minVValue) {
               minVValue = h[i];
            }
         }
         prev = 0;
      } else {
         h[i + 1] = h[i] - 1;
         if (prev == 0) {
            cnt++;
            v[i] = -1;
         }
         if (i == SZ(S) - 1) {
            vValue.push_back(h[i + 1]);
         }
         prev = 1;
      }
      if (i == SZ(S) - 1) {
         v[i + 1] = cnt;
      }

      eprintf("%d %d\n", h[i], v[i]);
   }
   eprintf("%d %d\n", h[SZ(S)], v[SZ(S)]);
   
   cnt = 0;
   REP(i, SZ(vValue)) {
      eprintf("vValue: %d\n", vValue[i]);
   }
   REP(i, SZ(S) + 1) {
      if (v[i] == -1) {
         v[i] = vValue[prev] < vValue[prev + 1] ? prev : prev + 1;
      }
      prev = v[i];
      h[i] -= vValue[v[i]];
      cnt += h[i];
      eprintf("+= %d\n", h[i]);
   }
   cout << cnt << endl;
   return 0;
}



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

using namespace std;

#define MOD 1000000007
#define HALF 500000004

int n, m, x[3005];
long long f[3005][31005], ans, mul = 1;

int ta, tb;

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; i++)
		scanf("%d", x + i);
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			f[i][j] = x[i] < x[j];
	while (m--) {
		mul = (mul << 1) % MOD;
		scanf("%d%d", &ta, &tb);
		ta--;
		tb--;
		f[ta][tb] = f[tb][ta] = HALF * (f[ta][tb] + f[tb][ta]) % MOD;
		for (int i = 0; i < n; i++)
			if (i != ta && i != tb) {
				f[i][ta] = f[i][tb] = HALF * (f[i][ta] + f[i][tb]) % MOD;
				f[ta][i] = f[tb][i] = HALF * (f[ta][i] + f[tb][i]) % MOD;
			}
	}
	for (int i = 0; i < n; i++)
		for (int j = i + 1; j < n; j++)
			ans += f[j][i];
	printf("%lld\n", ans % MOD * mul % MOD);
	return 0;
}


Measured memory_bytes: 725504
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.lang.Integer.parseInt;

/**
 * Jogging
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			int n = parseInt(line);
			if (n == 0) break;

			long[] d = new long[n];
			long[] v = new long[n];

			for (int i = 0; i < n; i++) {
				line = br.readLine();
				d[i] = parseInt(line.substring(0, line.indexOf(' ')));
				v[i] = parseInt(line.substring(line.indexOf(' ') + 1));
			}

			//?´????
			for (int i = 0; i < n; i++) {
				long gcd = gcd(d[i], v[i]);
				d[i] /= gcd;
				v[i] /= gcd;
			}

			//??????
			long lcm = lcm(d[0], d[1]);
			for (int i = 2; i < n; i++) {
				lcm = lcm(lcm, d[i]);
			}

			for (int i = 0; i < n; i++) {
				v[i] *= lcm / d[i];
			}

			//
			long gcd = gcd(v[0], v[1]);
			for (int i = 2; i < n; i++) {
				gcd = gcd(gcd, v[i]);
			}

			for (int i = 0; i < n; i++) {
				System.out.println(v[i] / gcd);
			}
		}
	}

	static long gcd(long a, long b) {
		if (b == 0) return a;
		return gcd(b, a % b);
	}

	static long lcm(long a, long b) {
		return a * (b / gcd(a, b));
	}
}

Measured memory_bytes: 30240
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::map;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  ui N; cin >> N;
  ll X; cin >> X;
  vector<ll> x(N);
  for(auto& i : x) cin >> i;

  for(auto& i : x)
  {
    i = std::abs(i - X);
  }

  ll res{ x[0] };
  for(size_t i = 1; i < N; ++i)
  {
    res = boost::integer::gcd(res, x[i]);
  }
  cout << res << CRLF;
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define ll long long
#define endl "\n"
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
const int N = 2e5 + 10;
const ll inf = 1e18 + 10, mod = 1e9 + 7;
int n, m, sum, a[N];
int main()
{
    //ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen("lca_rmq.in", "r", stdin);
    //freopen("lca_rmq.out", "w", stdout);
    cin >> n >> m;
    for(int i = 1; i <= n; i++)
    {
        cin >> a[i];
        sum += a[i];
    }
    sort(a + 1, a + 1 + n);
    reverse(a + 1, a + 1 + n);
    for(int i = 1; i <= m; i++)
    {
        if((double)a[i] / double(sum) < (double)1 / double(4 * m))
        {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";


}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 10e15+9
#define EPS 1e-10
#define MAX_N 100100
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int k;
int n;
int x, y, w, h;
int posx, posy;

int main(){
	cin >> k;
	REP(i, k){
		int ans = 0;
		cin >> x >> y >> w >> h;
		cin >> n;
		REP(i, n){
			cin >> posx >> posy;
			posx -= x; posy -= y;
			if (0 <= posx&&posx <= w && 0 <= posy&&posy <= h)ans++;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1160
#include <cstdio>
int c[4];
double dp[310][310][310];
int main() {
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		int x;
		scanf("%d", &x);
		c[x]++;
	}
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n; j++) {
			for (int k = 0; k <= n; k++) {
				int r = n - i - j - k;
				if (r == n || r < 0) continue;
				dp[i][j][k] = 1;
				if (k) dp[i][j][k] += dp[i][j][k-1] * k / n;
				if (j) dp[i][j][k] += dp[i][j-1][k+1] * j / n;
				if (i) dp[i][j][k] += dp[i-1][j+1][k] * i / n;
				dp[i][j][k] /= 1 - 1. * r / n;
			}
		}
	}
	printf("%.12f\n", dp[c[3]][c[2]][c[1]]);
	return 0;
}


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

typedef long long ll;

main()
{
    int n, sz1, sz2;
    cin >> n;
    vector<int> v, v1, v2;
    v.push_back(n);
    v1.push_back(n);
    while(1){
        sort(v1.begin(), v1.end());
        sz1 = v.size();
        sz2 = unique(v1.begin(), v1.end()) - v1.begin();
        if(sz2 < sz1){
            break;
        }
        else if(n % 2 == 0){
            n = n / 2;
            v.push_back(n);
            v1.push_back(n);
        }
        else{
            n = (3 * n) + 1;
            v.push_back(n);
            v1.push_back(n);
        }
    }
    cout << v.size();

}





///promy_pompom
//hello world


Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define pans cout<<ans<<endl;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;

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

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>
#include<tuple>
using namespace std;
const int MAX = 100000 + 10;
vector<tuple<int,int,long long>> v;

long long siz[MAX];

int p[MAX];
long long rec[MAX];
int cnt[MAX];

int find(int x) {
    return x==p[x]? x : p[x] = find(p[x]);
}

bool cmp(tuple<int,int,int> a, tuple<int,int,int> b) {
    return get<2>(a) < get<2>(b);
}

int main () {
    int n, m;
    scanf("%d %d", &n, &m);
    for(int i = 0 ; i < n ; i++) {
        scanf("%lld", &rec[i]);
    }
    for(int i = 0 ; i < m ; i++) {
        int x, y;
        long long val;
        scanf("%d %d %lld", &x, &y, &val);
        x--, y--;
        v.push_back(make_tuple(x,y,val));
    }
    sort(v.begin(), v.end(), cmp);
    for(int i = 0 ; i < n ; i++) {
        p[i] = i;
        siz[i] = rec[i];
    }
    int ans = m;
    for(auto emt: v) {
        int x = get<0>(emt);
        int y = get<1>(emt);
        long long val = get<2>(emt);
        int px = find(x);
        int py = find(y);
        if(px != py) {
            siz[px] += siz[py];
            cnt[px] += cnt[py];
            p[py] = px;
        }
        cnt[px]++;
        if(siz[px] >= val) {
            ans -= cnt[px];
            cnt[px] = 0;
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 4208
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define lowbit(a) ((a) & -(a))
#define clean(a, b) memset(a, b, sizeof(a))
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int maxn = 2e6 + 9;

int _;

//========================================================================
int c[maxn],a[maxn],last[maxn],pre[maxn],n,ans[maxn];
struct node
{
    int l,r,num;
}x[maxn];
int cmp(node a,node b)
{
    if(a.r==b.r) return a.l<b.l;
    return a.r<b.r;
}
void update(int x,ll y,int n)///One point update
{
    for(int i=x; i<=n; i+=lowbit(i))
        c[i] += y;
}
ll get_sum(int x)///Interval query
{
    ll ans = 0;
    for(int i=x; i; i-=lowbit(i))
        ans += c[i];
    return ans;
}
//========================================================================
int main()
{
    int q;
    scanf("%d%d",&n,&q);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        if(last[a[i]])
        {
            pre[i]=last[a[i]];
            last[a[i]]=i;
        }
        else 
        {
            pre[i]=maxn+1;
            last[a[i]]=i;
        }
    }
    for(int i=1;i<=q;i++)
    {
        scanf("%d%d",&x[i].l,&x[i].r);
        x[i].num=i;
    }
    sort(x+1,x+1+q,cmp);
    int j=1;
    for(int i=1;i<=q;i++)
    {
        for(;j<=x[i].r;j++)
        {
            update(pre[j],-1,n);
            update(j,1,n);
        }
        ans[x[i].num]=get_sum(x[i].r)-get_sum(x[i].l-1);
    }
    for(int i=1;i<=q;i++) printf("%d\n",ans[i]);
    return 0;
}


Measured memory_bytes: 19416
//{{{
#include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printw) FUNC(printwe) FUNC(printb) FUNC(printbe) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> hs(n); cin >> hs;
    int ans = 1;
    int maxi = hs[0];
    for(int i = 1; i < n; i++){
        ans += maxi <= hs[i];
        maxi = max(maxi, hs[i]);
    }
    cout << ans << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  
int main() {
  int A, B, T;
  cin >> A >> B >> T;
  
  float time = T + 0.5;
  int cropped_time = time / A;
  int count = cropped_time * B;
  
  cout << count << endl;
 }


Measured memory_bytes: 256
package main

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

var (
	N int
	P []int
)

func readVariables() {
	N = nextInt()
	P = make([]int, N)
	for i := 0; i < N; i++ {
		P[i] = nextInt()
	}
}

func main() {
	readVariables()
	minValue := N + 100 //INF
	answer := 0
	for _, v := range P {
		if v <= minValue {
			answer++
			minValue = v
		}
	}
	fmt.Println(answer)
}

var scanner *bufio.Scanner

func init() {
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
}
func nextInt() int {
	if !scanner.Scan() {
		panic("No more token.")
	}
	num, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic("nextInt(): cannot convert to int: " + scanner.Text())
	}
	return num
}


Measured memory_bytes: 3584
#include <iostream>
#include <vector>

int main(){
	const int MAX = 20;
	const int MIN = 0;
	
	int num;
	std::cin >> num;

	std::vector< std::vector<long long int> > equation((num - 1), std::vector<long long int>((MAX + 1), 0));
	int value;
	std::cin >> value;
	equation[0][value] = 1;	//最初数字の等式の数を1とセットする．
	for(int i = 0; i < (num - 2); ++i){
		std::cin >> value;
		for(int j = 0; j <= MAX; ++j){
			if((j + value) <= MAX){
				equation[i + 1][j] += equation[i][j + value];
			}
			if((j - value) >= MIN){
				equation[i + 1][j] += equation[i][j - value];
			}
		}
	}
	std::cin >> value;
	std::cout << equation[num - 2][value] << std::endl;
	return 0;
}

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

int main(){
  int N,M;
  cin>>N>>M;
  if(N>=M){
    cout<<0<<endl;
    return 0;
  }
  vector<int> X(M);
  for(int &i:X)
    cin>>i;
  sort(X.begin(),X.end());
  vector<int> A(M-1);
  for(int i=0;i<M-1;i++)
    A[i]=X[i+1]-X[i];
  sort(A.begin(),A.end());
  long long j=0;
  for(int i=0;M-N>i;i++){
    j+=A[i];
  }
  cout<<j<<endl;
}

Measured memory_bytes: 1024
(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());
  console.log(' ' + buildMaxHeap(lines.shift().split(' ').map(Number)).join(' '));
})();

function buildMaxHeap(arr) {
  const n = arr.length;
  const maxHeapify = (i) => {
    let left, right, largest;
    left = 2 * i + 1;
    right = 2 * i + 2;
    if (left < n && arr[left] > arr[i]) largest = left;
    else largest = i;
    if (right < n && arr[right] > arr[largest]) largest = right;
    if (largest != i) {
      arr[largest] = [arr[i], arr[i] = arr[largest]][0];
      maxHeapify(largest);
    }
    return;
  };

  for (let i = Math.floor(arr.length / 2); i >= 0; i--) maxHeapify(i);
  return arr;
}



Measured memory_bytes: 110720
#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 K; string S; cin>>K>>S;
  if(S.size() <= K) cout << S << endl;
  else{
    for(int i=0;i < K+1;i++){
      if(i == K){
        cout << "..." << endl;
        break;
      }
      cout << S[i];
    }
  }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}


int main() {
    int N,M;
    cin >> N >> M;
    //　可能性がある
    vector<pair<bool,int>> v(N+1,pair<bool,int>(false,1));
    v[1] = make_pair(true,1);

    REP(_,M) {
        int x,y;
        cin >> x >> y;
        if(!v[x].first) {
            v[x].second--;
            v[y].second++;
        }
        if (v[x].first) {
            v[y].first = true;
            if (v[x].second == 1) v[x].first = false;
            v[x].second--;
            v[y].second++;
        }
    }

    ll c = 0;
    for(const auto &it: v) {
        if(it.first) c++;
    }
    cout << c << endl;

    return 0;
}


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

const int MAXN = 1000 * 1000 + 10;
const long long INF = 1LL * 1000 * 1000 * 1000 * 1000 * 1000 * 1000 + 10;

int n;
long long dp[MAXN][3];


int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    //cout << fixed << setprecision(10);

    cin >> n;

    cin >> dp[0][0] >> dp[0][1] >> dp[0][2];

    for(int i = 1; i < n; i++){
        cin >> dp[i][0] >> dp[i][1] >> dp[i][2];

        dp[i][0] += max(dp[i - 1][1], dp[i - 1][2]);
        dp[i][1] += max(dp[i - 1][0], dp[i - 1][2]);
        dp[i][2] += max(dp[i - 1][1], dp[i - 1][0]);
    }

    long long ans = max(dp[n - 1][0], dp[n - 1][1]);
    cout << max(ans, dp[n - 1][2]) << endl;

    return 0;
}



Measured memory_bytes: 5960
#include <bits/stdc++.h>
#define ll long long
#define ls id << 1
#define rs id << 1 | 1
#define mem(array, value, size, type) memset(array, value, ((size) + 5) * sizeof(type))
#define memarray(array, value) memset(array, value, sizeof(array))
#define pb(x) push_back(x)
#define st(x) (1LL << (x))
#define pii pair<int, int>
#define mp(a, b) make_pair((a), (b))
#define Flush fflush(stdout)
using namespace std;
const int N = 500050;
const int inf = 0x3f3f3f3f;
const ll llinf = 0x3f3f3f3f3f3f;
const ll mod = 998244353LL;
clock_t TIME_START, TIME_END;
void program_end()
{
#ifdef ONLINE
    printf("\nTime used: %.6lf(s)\n", ((double)TIME_END - TIME_START) / CLOCKS_PER_SEC);
    system("pause");
#endif
}
ll mi(ll a, ll b, ll nowmod)
{
    if (nowmod == 0)
        return 0;
    ll ret = 1;
    while (b)
    {
        if (b & 1)
            ret = ret * a % nowmod;
        a = a * a % nowmod;
        b >>= 1;
    }
    return ret;
}
int f(ll x)
{
    int ret = 0;
    while (x)
    {
        x %= __builtin_popcount(x);
        ret++;
    }
    return ret;
}
int n;
char a[N];
int one;
ll sum1, sum2;
void pre1()
{
    for (int i = 0; i < n; ++i)
    {
        if (a[i] == '0')
            continue;
        ll now = mi(2, n - i - 1, one + 1);
        sum1 += now, sum1 %= one + 1;
    }
}
void pre2()
{
    for (int i = 0; i < n; ++i)
    {
        if (a[i] == '0')
            continue;
        ll now = mi(2, n - i - 1, one - 1);
        sum2 += now;
        if (one - 1)
            sum2 %= one - 1;
    }
}

void solve()
{
    cin >> n;
    scanf("%s", a);
    for (int i = 0; i < n; ++i)
        if (a[i] == '1')
            one++;
    if (one == 0)
    {
        for (int i = 1; i <= n; ++i)
        {
            printf("1\n");
        }
        return;
    }
    pre1();
    pre2();
    for (int i = 0; i < n; ++i)
    {
        if (a[i] == '0')
        {
            a[i] = '1';
            ll tmp = mi(2, n - i - 1, one + 1);
            sum1 += tmp;
            sum1 %= one + 1;
            ll ans = 1;
            ans += f(sum1);
            sum1 -= tmp;
            sum1 += one + 1, sum1 %= one + 1;
            a[i] = '0';
            cout << ans << '\n';
        }
        else
        {
            a[i] = '0';
            ll tmp = mi(2, n - i - 1, one - 1);
            sum2 -= tmp;
            sum2 += one - 1;
            if (one - 1)
                sum2 %= one - 1;
            ll ans = (one - 1 > 0);
            ans += f(sum2);
            sum2 += tmp;
            sum2 += one - 1;
            if (one - 1)
                sum2 %= one - 1;
            a[i] = '1';
            cout << ans << '\n';
        }
    }
}

int main()
{
    TIME_START = clock();
    int Test = 1;
    // cin >> Test;
    while (Test--)
        solve();
    TIME_END = clock();
    program_end();
    return 0;
}

Measured memory_bytes: 3832
n = gets.to_i
march = { M: 0, A: 0, R: 0, C: 0, H: 0} 
n.times do
  name = gets.chomp.to_s[0]
  case name
    when 'M', 'A', 'R', 'C', 'H' then
      march[name.to_sym] += 1
  end
end

ans = 0
combination = ['M', 'A', 'R', 'C' ,'H'].combination(3).to_a
combination.each do |com|
  ans += march[com[0].to_sym] * march[com[1].to_sym] * march[com[2].to_sym]
end

p ans


Measured memory_bytes: 14244
#input
K = int(input())

#output
S = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(S[K-1])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
// gcd: 最大公約数, lcm: 最小公倍数
template<typename T>
T euclidean(T a, T b){
    if(a < b) swap(a, b);
    T r = a % b;
    while(r != 0){
        a = b; b = r; r = a % b;
    }
    return b;
}
template<typename T>
T gcd(T a, T b){
    return euclidean(a, b);
}
template<typename T>
T lcm(T a, T b){
    T g = gcd(a, b);
    return a / g * b;
}
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

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

    int d = gcd(a, b);
    if(c % d == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(m)]
b = [0]*n
for i in range(m):
  b[a[i][0]-1] += 1
  b[a[i][1]-1] += 1
for i in range(n):
  print(b[i])

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s1,s2;
	cin>>s1>>s2;
	int n=s1.size(),m=s2.size();
	sort(s1.begin(),s1.end());
	sort(s2.begin(),s2.end(),greater<char>());
	if(s1<s2)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256