akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int main(void){
    int n;
    scanf ("%d",&n) ;
    int p=0,q=n ;
    while (q>0) {
        p+=q%10 ;
        q/=10 ;
    }
    if (n%p==0) {
        printf ("Yes\n") ;
    } else {
        printf ("No\n") ;
    }
    return 0 ;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
#include <set>
#include <random>
using namespace std;

int main() {
  string S, T;
  cin >> S >> T;
  vector <int> cs(26, 0);
  vector <int> ct(26, 0);
  for (int i = 0; i < S.length(); i++) {
	  cs[S[i] - 'a']++;
	  ct[T[i] - 'a']++;
	}
  sort(cs.begin(), cs.end());
  sort(ct.begin(), ct.end());
  bool ans = true;
  for (int i = 0; i < 26; i++) {
	  if (cs[i] != ct[i]) {
		  ans = false;
		}
	}
  if (ans) {
	  cout << "Yes" << endl;
	} else {
	  cout << "No" << endl;
	}
  return 0;
}


Measured memory_bytes: 776
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		string[] str = Console.ReadLine().Split();
		int[]A = new int[N];
		for(var i=0;i<N;i++){
			A[i] = int.Parse(str[i]);
		}
		Array.Sort(A,(x,y)=>y-x);
		long ans = 0;
		ans += A[0];
		int c = 1;
		int d = 2;
		bool flag = true;
		while(true){
			for(var i=d;i<d+c*2;i++){
				if(i>=N){
					flag = false;
					break;
				}
				ans += A[i/2];
			}
			if(!flag){
				break;
			}
			d = d+c*2;
			c *= 2;
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 43368
S = input()

s0 = S[:len(S)//2]
s1 = S[len(S)//2+1:]

def f(s):
    n = len(s)
    halfn = n//2
    result = True
    for i in range(halfn):
        if s[i] != s[-(i+1)]:
            result = False

    return result

ans = 'Yes'
if not f(S):
    ans = 'No'
elif not f(s0):
    ans = 'No'
elif not f(s1):
    ans = 'No'
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>

int main()
{
  std::string str;
  std::cin >> str;
  int ans = 0;
  int zeroCnt = 0;
  int oneCnt = 0;

  for (auto& val: str)
  {
    if (val == '0')
    {
      if (oneCnt)
      {
        --oneCnt;
        ++ans;
      }
      else
        ++zeroCnt;
    }
    else
    {
      if (zeroCnt)
      {
        --zeroCnt;
        ++ans;
      }
      else
        ++oneCnt;
    }
  }

  std::cout << ans * 2 << std::endl;

  return 0;
}



Measured memory_bytes: 512
#include <iostream>
#include <cstdio>

using namespace std;

const int Maxn = 100010;

int n , l;
int a[Maxn];

int main() {
	
	scanf("%d%d",&n,&l);
	for(register int i=1; i<=n; i++)
		scanf("%d",&a[i]);
	
	register int tmp = -1;
	for(register int i=1; i<n; i++) {
		if(a[i] + a[i+1] >= l) {
			tmp = i;
			break;
		}
	}
	
	if(tmp == -1) {
		puts("Impossible");
		return 0;
	}
	
	puts("Possible");
	
	for(register int i=1; i<=tmp-1; i++)
		printf("%d\n",i);
	for(register int i=n-1; i>=tmp+1; i--)
		printf("%d\n",i);
	
	printf("%d\n",tmp);
	
	return 0;
	
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
//登録しよう！→ https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define gre greater //sortを降順にする
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示

void solve(long long N){
  ll ans = 0;
  for (ll i = 1; i <= N; i++) {
    if(to_string(i).length()%2 == 1)ans++;
  }
  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);
    solve(N);
}


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

int main() 
{
	int i,n,a,b,c,d,q[105],ans=0; 
	for(i=0;i<102;i++)
		q[i]=0;
	cin>>a>>b>>c>>d;
	for(i=a;i<b;i++)
		q[i]++;
	for(i=c;i<d;i++)
		q[i]++;
	for(i=0;i<101;i++)
		if(q[i]==2)
			ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
s = input()

r = 0
w = 0
for i in range(n):
    if(s[i] == "R"): r += 1
    else: w += 1

ngr = 0
ngw = 0
for i in range(n):
    if(i < r and s[i] == 'W'): ngw += 1
    if(i >= r and s[i] == 'R'): ngr += 1

print(min(ngw, ngr) + abs(ngw-ngr))

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

int main(void){
int n;
int a[200005];
int ans[200005];
scanf("%d",&n);
for(int i=0;i<n-1;i++){
    scanf("%d",&a[i]);
}
for(int i=0;i<n;i++){
    ans[i]=0;
}
for(int i=0;i<n-1;i++){
    ans[a[i]-1]++;
}
for(int i=0;i<n;i++){
    printf("%d\n",ans[i]);
}


}

Measured memory_bytes: 3268
// finish date: 2018/01/24
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define bigmod 1000000007
#define INF 500000000

int N, M;
vi a, b;
vvb graph;
vb visited;

void dfs(int v) {
    visited[v] = true;
    rep(i, N) {
        if (!graph[v][i]) continue;
        if (visited[i]) continue;
        dfs(i);
    }
}

int main() {
    cin >> N >> M;
    a = vi(M);
    b = vi(M);
    graph = vvb(N, vb(N, false));
    visited = vb(N);
    int ans = 0;

    rep(i, M) {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
    }

    rep(i, M) {
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;
        rep(i, N) visited[i] = false;
        dfs(0);
        rep(i, N) {
            if (!visited[i]) {
                ans++;
                break;
            }
        }
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>    //C++の標準ライブラリのヘッダを全て読み込む
 
int main() {
    using std::cout;
    using std::endl;
    using std::cin;

    int sss = 0, s[3] = {0};
    cin >> sss;
    s[0] = sss/100;
    if(s[0] == 1){
        sss -= 100;
    }
    s[1] = sss/10;
    if(s[1] == 1){
        sss -= 10;
    }
    s[2] = sss/1;
    cout << s[0]+s[1]+s[2] << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1LL<<60;
const double EPS = 1e-10;
const ll mod=1000000007;
//const ll mod=998244353;
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
ll n,a[1000010];
bool s[1000010]={};

template <typename T>
struct PrimeFact {
    vector<T> spf;
    PrimeFact(T N) { init(N); }
    void init(T N) { // 前処理。spf を求める
        spf.assign(N + 1, 0);
        for (T i = 0; i <= N; i++) spf[i] = i;
        for (T i = 2; i * i <= N; i++) {
            if (spf[i] == i) {
                for (T j = i * i; j <= N; j += i) {
                    if (spf[j] == j) {
                        spf[j] = i;
                    }
                }
            }
        }
    }
    map<T, T> get(T n) { // nの素因数分解を求める
        map<T, T> m;
        while (n != 1) {
            m[spf[n]]++;
            n /= spf[n];
        }
        return m;
    }
};

bool pairwise(){
  PrimeFact<ll> P(1000010);
  P.init(1000010);
  bool ans=true;
  for(int i=0;i<n;i++){
    map<ll,ll> m=P.get(a[i]);
    for(auto x:m){
      if(s[x.first]){
        ans=false;
        break;
      }
      else s[x.first]=true;
    }
  }
  return ans;
}

bool setwise(){
  ll x=a[0];
  for(int i=1;i<n;i++){
    x=gcd(x,a[i]);
  }
  if(x==1) return true;
  return false;
}

int main(void){
  cin>>n;
  for(int i=0;i<n;i++) cin>>a[i];
  if(pairwise()) cout<<"pairwise coprime"<<endl;
  else if(setwise()) cout<<"setwise coprime"<<endl;
  else cout<<"not coprime"<<endl;
}

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

int main() {
  int s1, s2, s3, a, b, c;
  cin >> s1;
  s2 = s1 % 100;
  s3 = s2 % 10;
  a = s1 / 100;
  b = s2 / 10;
  c = s3 / 1;
  cout << a + b + c << endl;
}

Measured memory_bytes: 384
import java.util.*;
public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        long X = sc.nextLong();
        for(long A=0;A<1000;A++){
            for(long B=-1000;B<1000;B++){
                if(A*A*A*A*A - B*B*B*B*B == X){
                    System.out.println(A + " " + B);
                    return;
                }
            }
        }
    }

}


Measured memory_bytes: 39004
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;

#define len length()
#define sz size()
#define rep(i, n) for(int i = 0; i < n; i++)
#define srt(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define veci(a, n) vector<int> a(n)
#define vecs(a, n) vector<string> a(n)
#define psb(a) push_back(a)
#define ppb pop_back()
#define sp(n) cout << setprecision(n) << fixed
#define fst(s) s.at(0)
#define lst(s) s.at(s.len - 1)

int main(){
    int N;
    cin >> N;
    int d[N];
    rep(i, N) cin >> d[i];
    sort(d, d+N);
    int ans=0;
    for(int i=0; i<N-1; i++) if(d[i]==d[i+1]) ans++;
    cout << N-ans << endl;
    return 0;
}



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

using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
const int MAXN = 234567;
int a[MAXN];

LL solve(deque<LL> &line, int cnt, LL ans) {
   sort(line.begin(), line.end());
   LL prev = 0;
   while (int(line.size()) > cnt) {
          LL cur = line.front();
          // printf("cur = %lld ", cur);
          line.pop_front();
          cur -= prev;
          prev += cur;
          // printf("val = %lld ", cur);
          ans -= cur * (int(line.size()) + 1 - cnt);
          cnt++;
          // printf("ans = %lld\n", ans);
   }
   return ans;
}

int main() {
    int N;
    scanf("%d", &N);
    int neg_cnt = 0, pos_cnt = 0;
    deque<LL> pos, neg;
    LL ans = 0;
    for (int i = 1; i <= N; i++) {
        scanf("%d", &a[i]);
        LL tmp = a[i] - i;
        if (tmp == 0) neg_cnt++, pos_cnt++;
        else if (tmp < 0) {
           tmp *= -1;
           neg_cnt++;
           neg.push_back(tmp);
        } else {
           pos_cnt++;
           pos.push_back(tmp);
        }
        ans += tmp;
    }
    LL pos_ans = solve(pos, neg_cnt, ans);
    LL neg_ans = solve(neg, pos_cnt, ans);
    // printf("pos = %lld neg = %lld\n", pos_ans, neg_ans);
    printf("%lld\n", min(pos_ans, neg_ans));
    return 0;
}


Measured memory_bytes: 2688
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
If I'm the sun, you're the moon
Because when I go up, you go down
*******************************
I'm working for the day I will surpass you
https://www.a2oj.com/Ladder16.html
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class Main
   {
      public static void main(String omkar[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         String input = st.nextToken();
         String res = "No";
         if(input.charAt(0) != input.charAt(1) || input.charAt(1) != input.charAt(2))
            res = "Yes";
         System.out.println(res);
      }
   }

Measured memory_bytes: 21076
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i = (a); i < (n); ++i)
#define repk(i,a,n) rep(i,a,n+1)
#define all(v) (v).begin(),(v).end()
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9 + 7;
void sol() {
	int cnt = 0;
	int n; scanf("%d", &n);
	int a[n + 1];
	repk(i, 1, n)scanf("%d", &a[i]);
	repk(i, 1, n) {
		if (i % 2 != 0 && a[i] % 2 != 0)
			cnt++;
	}
	cout << cnt;
}

int main() {
	int _ = 1;
	// for (scanf("%d", &_); _; _--)
	sol();

	return 0;
}

Measured memory_bytes: 3616
n,m = map(int,input().split())
box = []
for _ in range(m):
    denki = list(map(int,input().split()))
    box.append(denki)
p = list(map(int,input().split()))
ans = 0
for i in range(2**n):
    flag = 0
    for u in range(m):
        now_box = box[u]
        now_box = now_box[1:]
        cnt = 0
        for j in range(n):
            if ((i>>j)&1) and (j+1) in now_box:
                cnt += 1
        if cnt%2 == p[u]:
            pass
        else:
            flag = 1
            break
    if flag == 0:
        ans += 1
print(ans)

Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>
#include<string>
#include<vector>
#include<map>
#include<cmath>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long ll;
const int maxn = 2e5+5;
const int ff = 0x3f3f3f3f;

/*int main()
{
	int n;
	cin>>n;
	int flag = 0;
	while(n)
	{
		if(n%10 == 9)
		{
			flag = 1;
			break;
		}
		n/= 10;
	}
	if(flag)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	
	
	return 0;
}*/

/*int main()
{
	int t;
	int ans = 0;
	cin>>t;
	while(t--)
	{
		int l,r;
		cin>>l>>r;
		ans+= (r-l+1);
	}
	cout<<ans<<endl;
	
	
	return 0;
}*/

int main()
{
	int t;
	cin>>t;
	int ans = 0;
	map<int ,int> mp;
	mp.clear();
	while(t--)
	{
		int a;
		scanf("%d",&a);
		if(mp[a] == 0)
			mp[a] = 1,ans++;
		else
			mp[a] = 0,ans--;
	}	
	cout<<ans<<endl;
	
	return 0;
}

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

int main(){
  
	int N,K;
	cin >> N >> K;
	int l[N];
  	for(int i = 0; i < N ; i++)cin >> l[i];
	sort(l,l+N,greater<int>());
  	int sum = 0;
  	for(int i = 0; i < K ; i++)sum +=l[i];
  	cout << sum <<endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <map>
#include <queue>
#include <vector>
#include <cmath>
#include <limits>
#define ll long long
using namespace std;
int main(){
    ll a,b;
    cin >> a >> b;
    if(a<=b){
        cout << a << endl;
    }else{
        cout << a - 1 << endl;
    }
}

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

int main() {
  int n;
  cin >> n;
  int a = n / 1000;
  int b = (n - a * 1000) / 100;
  int c = (n - a * 1000 - b * 100) / 10;
  int d = n - a * 1000 - b * 100 - c * 10;

  if ((a == b && b == c) || (b == c && c == d)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3652
#include <stdio.h>

void merge(int *p, int n)
{
    int *left = NULL;
    int *right = NULL;
    int i = 0;
    if (n == 1)
    {
        return;
    }
    else
    {
        i = n / 2;
        left = (int *)calloc(i, sizeof(int));
        right = (int *)calloc(n-i, sizeof(int));
        int k1 = 0, k2 = 0;
        for (k1 = 0; k1 < i; k1++)
        {
            left[k1] = p[k1];
        }
        for (k2 = i; k2 < n; k2++)
        {
            right[k2-i] = p[k2];
        }
        merge(left, i);
        merge(right, n-i);
        k1 = 0;
        k2 = 0;
        int count = 0;
        while (k1 < i && k2 < n-i)
        {
            if (left[k1] > right[k2])
            {
                p[count] = left[k1];
                k1++;
            }
            else
            {
                p[count] = right[k2];
                k2++;
            }
            count++;
        }
        if (k1 == i)
        {
            while (k2 < n-i)
            {
                p[count] = right[k2];
                count++;
                k2++;
            }
        }
        if (k2 == n-i)
        {
            while (k1 < i)
            {
                p[count] = left[k1];
                count++;
                k1++;
            }
        }
        free(left);
        free(right);
    }
    return;
}
int search(int *p, int n)
{
    int i = 0, j = 0, k = 0, count = 0;
    if (n < 3) return 0;
    if (p[0] > p[1] + p[2]) return search(p+1, n-1);
    if (p[n-1] + p[n-2] < p[n-3]) return search(p, n-1);
    for (i = 0; i < n-2; i++)
    {
        for (j = i+1; j < n-1; j++)
        {
            for (k = n-1; k > j; k--)
            {
                if (p[j] + p[k] > p[i])
                {
                    count += k-j;
                    break;
                }
            }
        }
    }
    return count;
}


int main()
{
    int n = 0, sum = 0, i = 0;
    int *p = NULL;
    scanf("%d", &n);
    p = (int *)calloc(n, sizeof(int));
    for(i = 0; i < n; i++)
    {
        scanf("%d", &p[i]);
    }
    merge(p, n);
    sum = search(p, n);
    free(p);
    printf("%d", sum);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include <cstring>
using namespace std;
#define ll  long long
#define endl '\n'
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
using namespace std;
int a[100009];
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int ans=0,x,y;
    cin>>x;
    for (int i=0;i<x;i++){
        cin>>y;
        if (y<=100000)
            a[y]++;
        else
            ans++;
    }
    for (int i=1;i<=100000;i++){
        if (a[i]<i)
            ans+=a[i];
        else if (a[i]>i)
            ans+=a[i]-i;
    }
    cout<<ans<<endl;
    return 0;
}


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

int main(){
    int n ;
    cin >> n ;
    string s;
    cin >> s ;
    int ans = 1 ;
    for (size_t i = 0; i < n-1; i++)
    {
        /* code */
        if (s.at(i) != s.at(i+1))
        {
            /* code */
            ans ++ ;
        }
        
    }
    cout << ans << endl ;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;

int main()
{
    int N;
    float A, sum = 0;
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cin >> A;
        sum += 1 / A;
    }
    cout << 1 / sum << endl;
    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;
/*
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
		//List<Integer> list=new ArrayList<Integer>();
		//Long[] array = new Long[6];
		int a = sc.nextInt();
		int b = sc.nextInt();
	}
}
*/
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long m = in.nextLong();
        long n = in.nextLong();
        System.out.print(lcm(m, n));
    }

    private static long gcd(long m, long n) {
        if(m < n) return gcd(n, m);
        if(n == 0) return m;
        return gcd(n, m % n);
    }

    private static long lcm(long m, long n) {
        return m * n / gcd(m, n);
    }
}

Measured memory_bytes: 23764
#include <iostream>

using namespace std;

const int NIL = -1;

typedef struct {
	int parent;
	int left;
	int right;
} Node;

Node *Tree; //树

int *Depth; //深度 

//计算深度 
void setDepth(int node,int dep) {
	Depth[node] = dep;
	if (Tree[node].left != NIL) {
		setDepth(Tree[node].left,dep+1);
	} 
	
	if (Tree[node].right != NIL) {
		setDepth(Tree[node].right,dep);
	}
}

void printTree(int node) {
	cout << "node " << node << ": parent = " << Tree[node].parent << ", depth = " << Depth[node] << ", ";
	if (Tree[node].parent == NIL) {
		cout << "root";
	} else if (Tree[node].left != NIL) {
		cout << "internal node";
	} else {
		cout << "leaf";
	}
	cout << ", [";
	bool flag = 1;
	for (int nod = Tree[node].left;nod != NIL;nod = Tree[nod].right) {
		if (!flag) {
			cout << ", ";
		}
		cout << nod;
		flag = 0;
	}
	cout << "]" << endl;
}

int main() {
	int n;
	cin >> n;
	Tree = new Node[n];
	Depth = new int[n];
	
	for (int i=0;i<n;i++) {
		Tree[i].parent = Tree[i].left = Tree[i].right = NIL;
	}
	for (int i=0;i<n;i++) {
		int p,degree;;
		cin >> p >> degree;
		int index;
		for (int i=0;i<degree;i++) {
			int x;
			cin >> x;
			if (i == 0) {
				Tree[p].left = x;
				index = x;
			} else {
				Tree[index].right = x;
				index = x;
			}
			Tree[x].parent = p;
		}
	}
	
	int root;
	for (int i=0;i<n;i++) {
		if (Tree[i].parent == NIL) {
			root = i;
		}
	}
	setDepth(root,0);
	for (int i=0;i<n;i++) {
		printTree(i);
	}
	delete[] Tree;
	delete[] Depth;
	return 0;
}



Measured memory_bytes: 4328
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    int K = scanner.nextInt();
    long M = 1_000_000_007;

    long[][][] dp = new long[N + 1][N + 1][K + 1];
    dp[0][0][0] = 1;
    for (int i = 1; i <= N; i++)
      for (int j = 0; j <= i; j++)
          for (int k = 2 * j; k <= K; k++) {
              if (j > 0) dp[i][j][k] = dp[i - 1][j - 1][k - 2 * j];
              dp[i][j][k] += (2 * j + 1) * dp[i - 1][j][k - 2 * j] % M;
              if (dp[i][j][k] >= M) dp[i][j][k] -= M;
              if (j < N) dp[i][j][k] += (j + 1) * (j + 1) * dp[i - 1][j + 1][k - 2 * j] % M;
              if (dp[i][j][k] >= M) dp[i][j][k] -= M;
            }
    System.out.println(dp[N][0][K]);
  }
}


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

template<class T> inline bool UpdateMin(T& a, T b) {
  if (a > b) { a = b; return 1; } return 0;
}

template<class T> inline bool UpdateMax(T& a, T b) {
  if (a < b) { a = b; return 1; } return 0;
}

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

  int n, m;
  cin >> n >> m;
  vector<int> xs(n);
  for (int i = 0; i < n; i++) {
    cin >> xs[i];
    xs[i]--;
  }

  auto distance_fn = [&](int a, int b) -> int {
    if (b > a) return b - a;
    else return b + m - a;
  };

  // Returns tue if x in [l, r).
  auto in_range_fn = [&](int l, int r, int x) -> int {
    if (l <= r) {
      return l <= x && x < r;
    } else {
      return l <= x || x < r; 
    }
  };

  int delta = 0;
  vector<vector<int>> i_to_es(m);
  for (int i = 0; i + 1 < n; i++) {
    int x1 = xs[i];
    int x2 = xs[i + 1];
    int d = distance_fn(x1, x2);
    if (d >= 2) {
      i_to_es[(x1 + 2) % m].push_back(-1);
      i_to_es[(x2 + 1) % m].push_back(d - 1);
      if (in_range_fn((x1 + 2) % m, (x2 + 1) % m, 0)) {
        delta--;
      }
    }
  }

  int64 sum = 0;
  for (int i = 0; i + 1 < n; i++) {
    int x1 = xs[i];
    int x2 = xs[i + 1];
    if (x1 < x2) {
      sum += x2 - x1;
    } else {
      sum += 1 + x2;
    }
  }

  if (DEBUG) {
    cout << "i: " << 0 << " sum: " << sum << " delta: " << delta << endl;
  }

  int64 ans = sum;

  for (int i = 1; i < m; i++) {
    for (int e : i_to_es[i]) {
      if (e > 0) {
        sum += e;
        delta++;
      } else {
        delta--;
      }
    }
    sum += delta;

    if (DEBUG) {
      cout << "i: " << i << " sum: " << sum << " delta: " << delta << endl;
    }

    UpdateMin(ans, sum);
  }
  cout << ans << endl;
}

Measured memory_bytes: 6016
from fractions import gcd
mod = pow(10, 9)+7
n = int(input())
A = list(map(int, input().split()))
m = A[0]
for i in range(1, n):
  m = m // gcd(m, A[i]) * A[i]
ans = 0
for i in A:
  ans += m//i
print(ans%mod)

Measured memory_bytes: 6112
#include <bits/stdc++.h>
#define int long long
using namespace std;
void solve()
 {
     int n;
     cin>>n;
     int cnt=0;
     for(int i=1;i<=n;i++)
     {
            int x;
            cin>>x;
            if(i&1 && x&1)
                cnt++;
     }
     cout<<cnt;
 }
        
main()
{
   //int t;
   //cin>>t;
   int t=1;
   while(t){
    t--;
    solve();
   }
   
   return 0;
}

Measured memory_bytes: 3628
//       Author: Mostafa Mounir Shehab
 
#include <bits/stdc++.h>
using namespace std;
 
#define PI  3.14159265  // PI = acos(-1)
#define EPS (1e-10)
#define endl "\n"
#define SZ(v) (int)(v.size())
typedef long long ll;
typedef long double ld;
//template <class Type>
 
 
void Fast(){
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(NULL); cerr.tie(NULL);
}
 
inline int D(){
	int t;
	scanf("%d",&t);
	return t;
}
inline ll llD(){
	ll t;
	scanf("%lld",&t);
	return t;
}
 
 
ll MOD=1e9 + 7; 
const int N=1e4 + 5;
int arr[N];


ll n,m,k,cnt,SU,idx,T;
ll l,r,mid;
ll a,b,c,d;


int BS(int val,int idx){
	l=idx,r=n-1,mid;
	while(l<r){
		mid=(l+r+1)>>1;
		if(arr[mid] <= val)
			l=mid;
		else
			r=mid-1;
	}
	
	return l;
	
}

 
 
int main(){
	
	scanf("%d",&n);
	for(int i=0;i<n;++i)
		scanf("%d",arr+i);
	
	sort(arr,arr+n);
	
	for(int i=0;i<n;++i)
		for(int j=i+1;j<n;++j)
			cnt+=BS(arr[i]+arr[j]-1,j)-j;
		
	
	printf("%lld\n",cnt);

			
	
 
	
		
 
}
 
 
 
 
 
 
 
 
 

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

vector<int> v;
int main() {
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		int a;
		scanf("%d",&a);
		v.push_back(a);
	}
	sort(v.begin(),v.end());
	printf("%d\n",-v[0]+v[v.size()-1]);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int main(){
    map<char, int> mp;
    string s; cin >> s;
    for(int i=0; i<s.size(); i++) mp[s[i]]++;

    bool ok = true;
    for(auto itr=mp.begin(); itr!=mp.end(); itr++){
        if((itr->second)%2 == 1) ok = false;
    }

    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

struct Card{char suit,value;};

void bubble(struct Card A[],int N){
  int i,j;
  struct Card t;
  for(i=0;i<N;i++){
    for(j=N-1;j>=i+1;j--){
      if(A[j].value < A[j-1].value){
	t = A[j];
	A[j] = A[j-1];
	A[j-1] = t;
      }
    }
  }
}

void selection(struct Card A[],int N){
  int i,j,minj;
  struct Card t;
  for(i = 0;i<N;i++){
    minj = i;
    for (j = i;j<N;j++){
      if(A[j].value < A[minj].value)minj = j;
    }
    t = A[i];
    A[i] = A[minj];
    A[minj] = t;
  }
}

void print(struct Card A[],int N){
  int i;
  for(i = 0;i<N-1;i++){
    printf("%c%c ",A[i].suit,A[i].value);
  }
  printf("%c%c\n",A[N-1].suit,A[i].value);
}

int isStable(struct Card C1[],struct Card C2[],int N){
  int i;
  for(i=0;i<N;i++){
    if(C1[i].suit != C2[i].suit)return 0;
  }
  return 1;
}

int main(){
  struct Card C1[100],C2[100];
  int i,N;
  char ch;

  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf(" %c",&C1[i].suit);
    scanf("%c",&C1[i].value);
    
  }

  for(i=0;i<N;i++)C2[i] = C1[i];

  bubble(C1,N);
  selection(C2,N);
  print(C1,N);
  printf("Stable\n");
  print(C2,N);
  if(isStable(C1,C2,N)==1){
      printf("Stable\n");
    }
    else{
      printf("Not stable\n");
    }

    return 0;
}
  
			



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

namespace BC114
{
    class Program
    {
        static void Main(string[] args)
        {
            var obj = new Q1();
            obj.Solver();
        }
    }
    class Q1
    {
        public void Solver()
        {
            var age = int.Parse(Console.ReadLine());

            Console.WriteLine((age == 3 || age == 5 || age == 7) ? "YES" : "NO");

        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x,y;
  cin>>x>>y;
  for(int i=0;i<x;i++){
    int cou=-1;
    for(int j=0;j<y;j++){
      char x;
      cin>>x;
      if(x=='c'){
	cou=0;
      }
      else if(cou>=0) cou++;
      if(j!=0) cout<<" ";
      cout<<cou;
    }
    cout<<endl;
  }
  
  return 0;
}



Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  string S;
  cin >> S;
  int N = S.size();
  rrep(i, N/2+1) {
    if(2*i != N && S.substr(0, i) == S.substr(i, i)) {
      cout << i*2 << endl;
      return 0;
    }
  }
  return 0;
}


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

using namespace std;

typedef long long ll;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	string s;
	cin >> s;

	string ret = "";
	for (int i = 0; i < s.length(); i++) {
		if (s[i] != 'B') ret += s[i];
		else ret = ret.substr(0, ret.length() - 1);
	}
	
	cout << ret << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int  n;
	cin >> n;
	
	int ans =0;
	for(int i=0; i<n; i++){
		int l, r;
		cin >> l >> r;
		ans += r - l + 1;
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func eratos(n int) (r []bool) {
	if n <= 1 {
		return nil
	}
	r = make([]bool, n+1)
	for i := 2; i <= n; i++ {
		r[i] = true
	}
	for i := 2; i*i <= n; i++ {
		if r[i] {
			for j := i * 2; j <= n; j += i {
				r[j] = false
			}
		}
	}
	return r
}

func main() {
	var q int
	fmt.Scan(&q)
	l := make([]int, q)
	r := make([]int, q)
	for i := 0; i < q; i++ {
		fmt.Scan(&l[i], &r[i])
	}
	N := 1000000
	pn := eratos(N) // pn[2] == true, pn[4] == false, ...
	cs := make([]int, N+1)
	for i := 1; i < N; i++ {
		t := 0
		if pn[i] && pn[(i+1)/2] { // Like 2017 number?
			t = 1
		}
		cs[i+1] = cs[i] + t
	}
	for i := 0; i < q; i++ {
		fmt.Println(cs[r[i]+1] - cs[l[i]])
	}
}


Measured memory_bytes: 13824
#include<bits/stdc++.h>//////////////////////////////////////////
#define deb(...)/////////////////////////////////////////////////
#define DBP(...)/////////////////////////////////////////////////
#ifdef LOC///////////////////////////////////////////////////////
#include"debuglib.h"/////////////////////////////////////////////
#endif///////////////////////////////////////////////////////////
#define x first//////////////////////////////////////////////////
#define y second/////////////////////////////////////////////////
#define pb push_back/////////////////////////////////////////////
#define sz(x)int((x).size())/////////////////////////////////////
#define each(a,x)for(auto&a:(x))/////////////////////////////////
#define all(x)(x).begin(),(x).end()//////////////////////////////
#define rep(i,b,e)for(int i=(b);i<(e);i++)///////////////////////
using namespace std;using ll=long long;using Pii=pair<int,int>;//
using Vi=vector<int>;void run();int main(){cin.sync_with_stdio///
(0);cin.tie(0);cout<<fixed<<setprecision(18);run();return 0;}////
//-------------------------------------------------------------//

void run() {
	string s; cin >> s;
	int ans[2] = {0, 0};
	rep(i, 0, sz(s)) {
		int k = s[i]-'0';
		ans[k^(i%2)]++;
	}
	cout << min(ans[0], ans[1]) << endl;
}


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

int main()
{
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (a + b == c + d)
  {
    cout << "Balanced" << endl;
  }
  else if (a + b < c + d)
  {
    cout << "Right" << endl;
  }
  else
  {
    cout << "Left" << endl;
  }
}

Measured memory_bytes: 256
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0

using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

/*-----------------------------------------ここからコード-----------------------------------------*/


int main() {
	
	int a[3];
	scanf("%d%d", &a[0], &a[1]);
	printf("%d\n", (a[0] - 1) * (a[1] - 1));
	
	Please AC;
}


Measured memory_bytes: 504
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>;
using namespace std;
string s;
int main(){
    cin>>s;
    int k=s.size();
    if(k%2!=0){
        printf("No");
        return 0;
    }
    for(int i=0;i<k/2;i++){
        int u=abs(s[i]-s[k-i-1]);
        if(u!=1&&u!=2){
            printf("No");
            return 0;
        }
    }
    printf("Yes");
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
using namespace std;

void solve()
{
    string s;
    cin >> s;
    ll sum=0;
    for(int i=0;i<s.size();i++)
        sum+=(s[i]-'0');
    if(sum%9)
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
}

int main()
{
    int t=1;
    //cin >> t;
    while(t--)
    solve();

    return 0;
}



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

int main(){
	int a,b;
	cin >> a >> b;
	int x = max(a,b);
	int y = min(a,b);

	while(y != 0){
		x = x % y;
		int z = x;
		x = y;
		y = z;
	}
	cout << x << endl;
}


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

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

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int dp[2][2019+1];

int main(){
  string s;cin>>s;
  int n=s.size();
  if(s.size()<4) { cout<<0; return 0; }

  vector<int>num(n);
  int d10 = 1;
  rep(i, n){
    num[i]=s[n-1-i]-'0';
    num[i] = (num[i]*d10)%2019;
    d10 = (d10*10)%2019;
  }

  int *now, *nex;
  now=dp[0];
  nex=dp[1];
  int result=0;
  for(auto c:num){
    rep(i, 2020)nex[(i+c)%2019] += now[i];

    result+=nex[0];

    nex[c]++;
    swap(now, nex);
    rep(i, 2020)nex[i]=0;
  }

  cout<<result<<endl;

  return 0;
}


Measured memory_bytes: 4448
#include <iostream>
#include <map>

using namespace std;

typedef map<int, int> mii;

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

    mii f;
    int s = 0;
    f[0] = 1;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        s = (s + a) % m;
        f[s]++;
    }

    long long int r = 0;
    for (auto i : f) {
        int a = i.second;
        r += 1ll * a * (a - 1) / 2;
    }

    cout << r << endl;
    
    return 0;
}

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

#define cf ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define fox(i,n) for(int i=0;i<n;i++)
#define srtar(a,n) sort(a,a+n)
#define srtvec(v) sort(v.begin(),v.end())
#define fauto(x,t) for(auto x: t)
#define mem(n,x) memset(n, x, sizeof(n))
const ll mac=2e5;
bool cum[mac+10];
vector<ll>acn,prit;
void siv()
{
    ll i, j, k ;
    mem(cum,true);
    cum[0]=cum[1]=false;
    for(i=2; i<=mac; i++)
    {
        if(cum[i])
        {
            prit.push_back(i);
            for(j=i*i; j<=mac; j+=i)
            {
                cum[i]=false;
            }
        }
    }
}
map<ll,ll>mp;
void pf(ll n)
{
    ll i, j, p=0 ;
    for(i=0; i<prit.size(); i++)
    {
    //	 cout << p << "  p  ";
        p=prit[i];
       //  cout << p << "  p  ";
        if(p*p>n)
            break;
        if(n%p==0)
        {
            while(n%p==0)
            {
                n/=p;
            }
         //   cout << p << "  popk  ";
            mp[p]++;
        }
     //   cout << p << "  p  ";
    }
    if(n!=1)
        mp[n]++;
}
int main()
{
	 siv();
    ll t, m, g,n;
    cin >> n ;
    ll a[n];
    fox(i,n)
    {
        cin >> a[i];
        pf(a[i]);
        if(i==0)
            g=a[0];
        else
        {
            g=__gcd(g,a[i]);
        }
    }
    int y=1;
    for(auto x : mp)
    {
    //	cout << x.second << " " << x.first  << " , ";
        if (x.second != 1)
        {
        //	cout << x.second << " " << x.first ;
            y = 0;
            break;
        }
    }
    if(y)
        cout << "pairwise coprime" << endl;
    else if(g==1) cout <<"setwise coprime" << endl;
    else
        cout << "not coprime" << endl;
    return 0;
}

Measured memory_bytes: 17476
n, m = map(int, input().split())
students = [list(map(int,input().split())) + [float('inf'), -1] for _ in range(n)]
for i in range(m):
    x, y = map(int,input().split())
    for stu in students:
        dist = abs(stu[0]-x) + abs(stu[1]-y) 
        if dist < stu[2]: stu[2], stu[3] = dist, i+1
for stu in students: print(stu[3])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;

int N, M, X, Y;
vi x, y;

int main() {
  scanf("%d %d %d %d", &N, &M, &X, &Y);
  x = vi(N);
  y = vi(M);
  for (int i = 0; i < N; ++i) scanf("%d", &x[i]);
  for (int i = 0; i < M; ++i) scanf("%d", &y[i]);
  
  sort(x.begin(), x.end());
  sort(y.begin(), y.end());
  
  int Z = min(y[0], Y);
  if (x[N-1] < Z && X < Z) printf("No War\n");
  else printf("War\n");
  return 0;
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }
void Taka() { cout << "Takahashi" << endl; }
void Aoki() { cout << "Aoki" << endl; }
void digit(int d) { cout << fixed << setprecision(d); }
void IOup() { cin.tie(0); ios::sync_with_stdio(false); }

int main() {
	int a[3];
	for (int i = 0; i < 3; ++i)
		cin >> a[i];
	sort(a, a + 3);
	if (a[0] == a[1])
		cout << a[2] << endl;
	else
		cout << a[0] << endl;

	return 0;
}

Measured memory_bytes: 888
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	long long a, b, x; cin >> a >> b >> x;
	if (a == 0) { cout << (b - (b % x))/x + 1 << endl; }
	else{
		a--;
		cout << (b - b % x) / x - (a - a % x) / x << endl;
	}
	char c; cin >> c;
}

Measured memory_bytes: 256
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);

void main()
{
    auto n = lread();
    auto h = aryread();
    long cnt;
    foreach (i; 0 .. n - 1)
    {
        if (h[i] < h[i + 1])
        {
            h[i + 1] -= 1;
        }
        // writeln(h);
    }
    foreach (i; 0 .. n - 1)
    {
        if (h[i] > h[i + 1])
        {
            writeln("No");
            return;
        }
    }
    writeln("Yes");
}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}


Measured memory_bytes: 7048
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pop pop_back
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
//template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
signed main(){
  int a,b,c=1,answer=0;
  cin>>a>>b;
  for(int i=0;1;i++){
    if(c>=b)
      break;
    c+=a-1;
    answer++;
  }
  cout<<answer<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    #include<chrono>
                
    using namespace std;
    using namespace std::chrono;
    typedef long long ll;
    typedef vector<int> vi;
    typedef pair<int,int> pi;
    #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)    
    #define F first
    #define S second
    #define PB push_back
    #define EB emplace_back
    #define MP make_pair
    #define REP(i,a,b) for(i=a;i<=b;i++)
    #define RAP(i,a,b) for(i=a;i>=b;i--)
   // ll mod=1000000007;
    const int MX=0x3f3f3f3f;

    ll printNcR(int n, int r) 
    { 
  
    // p holds the value of n*(n-1)*(n-2)..., 
    // k holds the value of r*(r-1)... 
    ll p = 1, k = 1; 
  
    // C(n, r) == C(n, n-r), 
    // choosing the smaller value 
    if (n - r < r) 
        r = n - r; 
  
    if (r != 0) { 
        while (r) { 
            p *= n; 
            k *= r; 
            n--; 
            r--; 
        } 
    } 
    else
        p = 1; 
    return p/k;
    } 
    int main(){
        IOS;
        int n,i;
        cin>>n;
        int a[n];
        vi v(n+1);
        REP(i,0,n-1) cin>>a[i],v[a[i]]++;
        ll ans=0;
        REP(i,1,n)
            if(v[i]>1)
             ans+=printNcR(v[i],2);
        //cout<<ans<<"\n";
        ll temp=ans;
        REP(i,0,n-1){
            if(v[a[i]]>1) ans-=printNcR(v[a[i]],2);
            if(v[a[i]]>2) ans+=printNcR(v[a[i]]-1,2);
            cout<<ans<<"\n";
            ans=temp;
        }

        return 0;
    }

 

Measured memory_bytes: 4224
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

//mod演算ライブラリ
//mod=1000000007

LL add(LL a,LL b){
  return (a+b)%mod;
}

LL sub(LL a,LL b){
  return (a+mod-b)%mod;
}

LL mul(LL a,LL b){
  return ((a % mod) * (b % mod)) % mod;
}

LL power(LL x,LL y){//繰り返し二乗法 単品利用可
  if(y==0)return 1;
  else if(y==1)return x%mod;
  else if(y%2==0){
    LL tmp=power(x, y/2) % mod;
    return tmp*tmp%mod;
  }else {
    LL tmp=power(x, y/2) % mod;
    return ((tmp*tmp)%mod)*x%mod;
  }
}

LL dvs(LL a,LL b){
  return mul(a,power(b,mod-2));
}

const int SIZE_mod=200005;
int invfact[SIZE_mod];
int fact[SIZE_mod];

LL factset(int a){//aまでの階乗%mod表を作成
  fact[0]=1;
  FORQ(i,1,a){
    fact[i]=mul(fact[i-1],i);
  }
}

LL cmbset(int a){//1~aまでの階乗と階乗数の逆元のmod(mod)を用意 O(a)
  factset(a);
  invfact[a]=power(fact[a],mod-2);
  invfact[0]=1;
  FORD(i,a,1){
    invfact[i]=mul(invfact[i+1],i+1);
  }

}

LL cmb(int n,int r){//nCr%mod  (cmbset後に使用)
  if(n<r||r<0||n<0)return 0;
  return mul(fact[n],mul(invfact[r],invfact[n-r]));
}

LL prm(int n,int r){//nPr%mod
    return mul(cmb(n,r),fact[n]);
}

LL homo(int n,int r){//nHr%mod
  return cmb(n+r-1,r);
}


int main(){
	int n,m;
	int x[101010]={},y[101010]={};
	//int xs[101010]={},ys[101010]={};
	cin>>n>>m;
	LL h=0,w=0;
	FOR(i,0,n)cin>>x[i];
	FOR(i,0,m)cin>>y[i];
	n--;m--;
	FOR(i,0,n){
		int a=n-i-1,b=n-1-a;
		LL t=(n+1LL)*n/2-(a+1LL)*a/2-(b+1LL)*b/2;
		h=add(h,mul((x[i+1]-x[i]),t*1LL));
	}
	FOR(i,0,m){
		int a=m-i-1,b=m-1-a;
		LL t=(m+1LL)*m/2-(a+1LL)*a/2-(b+1LL)*b/2;
		w=add(w,mul((y[i+1]-y[i]),t*1LL));
	}
	cout<<mul(h,w)<<endl;

    return 0;
}


Measured memory_bytes: 1024
N, K = map(int, input().split())

num = [0] * K

for i in range(1, N + 1):
    num[i % K] += 1  # num[x] = Kで割ってx余る数が1以上N以下に何個あるか
ans = 0
for a in range(K):

    b = (K - a) % K
    c = (K - a) % K
    if (b + c) % K != 0:
        continue
    ans += num[a] * num[b] * num[c]
print(ans)


Measured memory_bytes: 10328