akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;


int main(void)
{
    IOS

    int n,m;
    cin >> n >> m;
    vector<ll> a(m);
    vector<ll> c(m);
    bitset<12> ca = 0;
    REP(i,m) {
        cin >> a[i];
        int b; cin >> b;
        REP(j,b) {
            uint d; cin >> d;
            c[i] += 1LL << (d-1);
            ca[d-1] = true;
        }
    }

    ll bmax = pow(2,n);
    cerr << bmax << endl;
    vector<vector<ll>> dp(m,vector<ll>(bmax,1LL << 20)); 
    dp[0][0] = 0;
    dp[0][c[0]] = a[0];


    if (ca.count() == n) {
        FOR(i,1,m) {
            REP(j,bmax) {
                //cerr << j << " ";
                //cerr << j << " " << dp[i][j] << " ";
                dp[i][j | c[i]] = min(dp[i][j | c[i]],min(dp[i-1][j | c[i]],dp[i-1][j]+a[i]));
                dp[i][j] = min(dp[i][j],dp[i-1][j]);
                //cerr << (j | c[i]) << " " << dp[i][j | c[i]] << endl;
            }
        }

        cout << dp[m-1][bmax-1] << endl;
    } else cout << -1 << endl;


    return 0;
}

Measured memory_bytes: 32384
package main

import "fmt"

func main() {
	var n, p int
	var s string
	fmt.Scan(&n, &p, &s)

	if p == 2 || p == 5 {
		res := 0
		for i := 0; i < n; i++ {
			if int(s[i]-'0')%p == 0 {
				res += i + 1
			}
		}
		fmt.Println(res)
		return
	}

	r := make([]int, n+1)
	d := 1
	for i := n - 1; i >= 0; i-- {
		x := int(s[i]-'0') * d % p
		r[i] = (x + r[i+1]) % p
		d *= 10
		d %= p
	}

	res := 0
	cnt := make(map[int]int)
	for i := n; i >= 0; i-- {
		res += cnt[r[i]]
		cnt[r[i]]++
	}

	fmt.Println(res)
}


Measured memory_bytes: 4352
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

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

		int n = Integer.parseInt(br.readLine());

		int f[][] = new int[n][10];
		int p[][] = new int[n][11];

		for (int i = 0; i < n; i++) {
			String str[] = br.readLine().split(" ");

			for (int j = 0; j < 10; j++) {
				f[i][j] = Integer.parseInt(str[j]);
			}
		}
		for (int i = 0; i < n; i++) {
			String str[] = br.readLine().split(" ");

			for (int j = 0; j < 11; j++) {
				p[i][j] = Integer.parseInt(str[j]);
			}
		}

		long ans = Long.MIN_VALUE;
		for (int bit = 0; bit < Math.pow(2, 10); bit++) {
			boolean flag[] = new boolean[10];

			boolean tf = false;
			for (int i = 0; i < 10; i++) {
				if ((bit & (1 << i)) != 0) {
					flag[i] = true;
					tf = true;
				}
			}

			if (!tf) {
				continue;
			}

			long sum = 0;
			for (int i = 0; i < n; i++) {
				int count = 0;
				for (int j = 0; j < 10; j++) {
					if (!flag[j])
						continue;
					if (f[i][j] == 1) {
						count++;
					}
				}
				sum += p[i][count];
			}
			ans = Math.max(ans, sum);
		}

		System.out.println(ans);
	}
}


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

int n, a, b;

int isValid(int i){
    int sum = 0;
    int inicial = i;
    while(i > 0){
        sum += i %10;
        i /= 10;
    }
    if(sum >= a && sum <= b){
       
        return inicial;
    }
    else return 0;
}

int main(){
    cin >> n >> a >> b;
    int sum = 0;
    for(int i = a; i <= n; i++){
        sum += isValid(i);
        //cout << "sum: " << sum << endl;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
/*  
   |\_/|
   |* *|
   \_+_/
          */
#include<bits/stdc++.h>

#define endl '\n'

using namespace std;

int main(){

  cin.tie(0);     // cout と cin の同期を切る
  ios::sync_with_stdio(false);  /* cの stdioストリーム (printfとか)と*/

  int a,b,h;

  cin>>a>>b>>h;

  cout<<((a+b)*h)/2<<endl;

  return 0;

}


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

int main(){
    ll N;
    cin >> N;
    vector<ll> a(N);
    rep(i, 0, N) cin >> a[i];
    ll ans = 0;
    ll R = 0, sum = 0;
    rep(L, 0, N){
        while(R < N && (sum ^ a[R]) == (sum + a[R])){
            sum += a[R];
            R++;
        }
        ans += R - L;
        if(L == R) R++;
        else {
            sum -= a[L];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
//#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000007;
ll comb[100][100];
ll cnt(vector<ll> v,int k,double m){
    double sm=0;
    int n=v.size();
    rep(i,k)sm+=v[i];
    //if(sm!=m*k)return 0;
    ll res=0;
    int N=0;
    int K=0;
    rep(i,n){
        if(v[i]==v[k-1]){
            ++N;
        }
        if(v[i]==v[k-1]&&i<k){
            ++K;
        }
    }
    res=comb[N][K];
    return res;
}
signed main(){
  int n,a,b;cin>>n>>a>>b;
  //n=50;a=1;b=50;
  rep(i,100){
      comb[i][0]=1;
  }
  rep1(i,n){
      rep1(j,i){
          comb[i][j]=comb[i-1][j]+comb[i-1][j-1];
      }
  }
  vector<ll> v(n);
  rep(i,n)cin>>v[i];
  double mx=0.0;
  sort(v.begin(),v.end());
  reverse(ALL(v));
  for(int i=a;i<=b;++i){
      double sm=0;
      rep(j,i){
          sm+=v[j];
      }
      sm/=(double)i;
      mx=max(mx,sm);
  }
  ll res=0;
  for(int i=a;i<=b;++i){
      if(i>a){
          if(v[0]!=v[i-1])break;
      }
      res+=cnt(v,i,mx);
  }
  printf("%.12lf\n",mx);
  cout<<res<<"\n";
  return 0;
}


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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define all(c) begin(c),end(c)
const ll INF = 1e10;
int main() {
	cin.sync_with_stdio(false);
	int a, b, c, d;
	string s;
	cin >> s;
	a = s[0] - '0', b = s[1] - '0', c = s[2] - '0', d = s[3] - '0';
	int sum = 0;
	rep(i, 2) {
		if (i == 0)sum=a + b;
		else sum = a - b;
		rep(j, 2) {
			int sum1 = sum;
			if (j == 0)sum1 += c;
			else sum1 -= c;
			rep(k, 2) {
				int sum2 = sum1;
				if (k == 0)sum2 += d;
				else sum2 -= d;
				if (sum2 == 7) {
					cout << a << (i == 0 ? '+' : '-') << b << (j == 0 ? '+' : '-') << c << (k == 0 ? '+' : '-') << d << '=' << 7 << endl;
					return 0;
				}
				
			}
		}
	}

	return 0;
}


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

int main()
{
    long long n;
    cin >> n;
    vector<long long> a(n,0);
    for (int i = 0; i < n; i++)
    {
        cin >> a.at(i);
    }
    long long min = *min_element(a.begin(), a.end());
    long long max = *max_element(a.begin(), a.end());
    long long sum = accumulate(a.begin(), a.end(), 0LL);
    cout << min << ' ' << max << ' ' << sum << endl;
}



Measured memory_bytes: 3188
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String alpha = sc.next();
		String regex = "[A-Z]";
		if(alpha.matches(regex)){
			System.out.println("A");
		}else {
			System.out.println("a");
		}

	}
}



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

int main(void) {
    int N;
    cin >> N;
    vector< int > A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    vector< int > B(N);
    for (int i = 0; i < N; i++) {
        B[A[i] - 1] = i + 1;
    }
    for (int i = 0; i < N - 1; i++) {
        printf("%d ", B[i]);
    }
    printf("%d\n", B[N - 1]);
    return 0;
}


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

typedef pair<LL,LL>PII;

/*
题意：
给你n个数，求区间有多少对除数和被除数的对数

思路：
线段树 区间和/ 树状数组 前缀和
2e5的数的除数最多才81个
对于一个数的贡献，我最好是区间的贡献，也就是1-n的贡献。

C(N-1,LEN)+[C(N-1,LEN-1)*2-C(N-DIS-1,LEN-1)]+C(N-1,LEN-2)
*/
const LL mod = 1e9+7;
const int N=1e6+10;
int a[N],id[N],v[N];
LL f[N];

LL cal(LL g,LL x)
{
    LL ans=1;
    while(g){
        if(g&1) ans=ans*x%mod;
        x=x*x%mod;
        g>>=1;
    }
    return ans;
}

LL C(int m,int n)
{
    if(n<m) return 0;
    return (f[n]*cal(mod-2,f[n-m])%mod*cal(mod-2,f[m])%mod);
}

void init()
{
    f[0]=1;
    for(LL i=1;i<=1000000;i++)
        f[i]=f[i-1]*i%mod;
}

void solve(){
    int x,n;
    scanf("%d",&n);
    memset(v,0,sizeof(v));
    for(int i=1;i<=n+1;i++){
        scanf("%d",&a[i]);
        v[a[i]]++;
        if(v[a[i]]==2) x=i;
        else id[a[i]]=i;
    }
    int dis=id[a[x]]-1+n+1-x;
    printf("%d\n",n);
    for(int i=2;i<=n;i++){
        LL ans = C(i,n+1);
        ans = (ans-C(i-1,dis)+mod)%mod;
        printf("%lld\n",ans);
    }
    puts("1");
}

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


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

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

  sort(p.rbegin(), p.rend());
  int ans = p[0] / 2;
  for (int i = 1; i < n; ++i) ans += p[i];

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


Measured memory_bytes: 256
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let lr: Vec<(i64, i64)> = (0..n)
        .map(|_| {
            let l = input();
            let r = input();
            (l, r)
        })
        .collect();
    println!("{}", lr.iter().map(|&(l, r)| r - l + 1).sum::<i64>());
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	vector<int> vi;
	for(int i=0;i<n;i++)
	{int a;cin>>a;
		vi.push_back(a);
	}
	int min33 = 1e9;
	for(int i=0;i<n;i++)
	{
		int a=0,b=0;
		for(int j=0;j<n;j++)
		{
			if(j+1<=i)
				a+=vi[j];
			else
				b+=vi[j]; 
		}
		min33 = min(abs(a-b),min33);
	}
	cout<<min33<<endl;
 } 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
  ll n;
  cin>>n;
  if(n%2==0)
  {
      cout<<(double)((1.0*n)/(n*2));
  }
  else
  {
      cout<<(double)(1.0*((n/2)+1))/n;
  }
}


Measured memory_bytes: 256
n, m = map(int, input().split())
h = list(int(i) for i in input().split())
ans = [0] * n

for i in range(m):
    a, b = map(int, input().split())
    ref = []
    if h[a - 1] <= h[b - 1]:
        ref.append(a)
    if h[a - 1] >= h[b - 1]:
        ref.append(b)
    for i in ref:
        ans[i - 1] += 1
    ref.clear()

# print(ans)
print(ans.count(0))


Measured memory_bytes: 20128
# dpC - Vacation
# 貰うDP
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    A = tuple(tuple(map(int, input().rstrip().split())) for _ in range(n))
    dp = [[0] * 3 for _ in range(n)]
    dp[0] = A[0]
    for i in range(1, n):  # i-th day
        for j in range(3):  # yesterday
            for k in range(3):  # today
                if j != k:
                    dp[i][k] = max(dp[i][k], dp[i - 1][j] + A[i][k])
    print(max(dp[-1]))


if __name__ == "__main__":
    main()

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

using namespace std;
const int MAXN = 1e5+10;

int n, m;
int x[MAXN];

void solve() {
  sort(x, x + m);
  vector<int> dist;
  for (int i=0;i<m-1;i++) {
    dist.push_back(x[i+1] - x[i]);
  }
  sort(dist.begin(), dist.end());
  int distSum = 0;
  int size = static_cast<int>(dist.size()) - n + 1;
  for (int i=0;i<size;i++) {
    distSum += dist[i];
  }
  cout << distSum << endl;
}

int main() {
  cin >> n >> m;
  for (int i=0;i<m;i++) {
    cin >> x[i];
  }
  solve();
}


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

using namespace std;

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

#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long int
#define mod 1000000007
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define prec(n) fixed << setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int>>
#define PI 3.1415926535897932384626
#define INF 1000000000
#define bits(n) __builtin_popcount(n)

void solve()
{
    ll a[4];
    for(int i=0;i<4;i++)
    {
        cin>>a[i];
    }
    ll maxi=LONG_MIN;
    for(int i=0;i<2;i++)
    {
        for(int j=2;j<4;j++)
        {
            if(a[i]*a[j]>maxi)
            maxi=a[i]*a[j];
        }
    }
    cout<<maxi;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input1.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output1.txt", "w", stdout);
#endif

    int t = 1;
    //cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}


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

int main() {
  int year, month, day;
  scanf("%d/%d/%d", &year, &month, &day);

  if (year <= 2019 && month <= 4 && day <= 30) {
    printf("Heisei\n");
  }
  else {
    printf("TBD\n");
  }

  return 0;
}


Measured memory_bytes: 256
import bisect
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

a.sort()
c.sort()
ans = 0

for i in b:
  ans += bisect.bisect_left(a, i) * (n - bisect.bisect_right(c, i))

print(ans)


Measured memory_bytes: 105400
#include <iostream>

using namespace std;

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


int main(void)
{
  int l, r;
  cin >> l >> r;

  ll m = 2020;
  rep(i, 2019) rep(j, 2019) {
    if (i >= j) continue;
    if (l + i > r || l + j > r) continue;
    ll g = ((l + i) % 2019) * ((l + j) % 2019) % 2019;
    m = g < m ? g : m;
  }
  cout << m << endl;
  return 0;
}



Measured memory_bytes: 256
N = int(input())

A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

satisfy = 0

for i in range(N):
	satisfy += B[A[i] - 1]
	if i != 0 and A[i] == A[i - 1] + 1:
		satisfy += C[A[i - 1] - 1]
		
print(satisfy)

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

#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define forn(i,n) for(ll i=0;i<n;i++)
#define fore(i,a,b) for(ll i=a;i<=b;i++)
#define ford(i,n) for(ll i=n-1;i>=0;i--)
#define fi first
#define se second
#define endl "\n"
#define all(a) a.begin(),a.end()
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PI 3.14159265

/*************************************************************************************/
void file(){
	#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
}
/*************************************************************************************/

const ll maxn=2e5+1,mod=1e9+7;



int main(){

    sync
  //  file();
    
    int n,d;
    cin>>n>>d;
    int ok = 2*d+1;
    if(n%ok==0){
    	cout<<n/ok;
    }
    else{
    	cout<<n/ok+1;
    }


  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n,player,card[2],teki,all[11],bell;
  while(cin >> card[0] >> card[1] >> teki){
    bell=0;
    for(int i=0;i<11;i++){
      all[i]=0;
    }
    all[card[0]]++;
    all[card[1]]++;
    all[teki]++;
    player=card[0]+card[1];//手持ちカード合計数。
    player=20-player;//これ以上の数ひいたらだめ。
    for(int i=1;i<=10;i++){
      if(all[i]==0){
	if(player<=i){//カードが規定より大きい数字だったら。
	  bell++;
	}
      }
    }
    if(bell<5){
      cout << "YES" << endl;
    }
    else{
      cout << "NO" << endl;
    }
  }
}

Measured memory_bytes: 1152
import math
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

X,Y = map(int, input().split()) 
mod = 10**9+7 #出力の制限
N = 10**4
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

if (X+Y)%3!=0:
  print(0)
else:
  N=(X+Y)//3
  if X>=N and Y>=N:
    a=X-N
    b=Y-N
    
    for i in range( 2, N + 1 ):
	    g1.append( ( g1[-1] * i ) % mod )
	    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
	    g2.append( (g2[-1] * inverse[-1]) % mod )

    C = cmb(a+b,a,mod)
    print(C)
  else:
    print(0)

Measured memory_bytes: 82316
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var s = Console.ReadLine().Trim();
        var k = long.Parse(Console.ReadLine());

        var c = s.Select(x => x).Take((int)Math.Min(s.Length, k)).FirstOrDefault(x => x != '1');
        if (c == default(char))
        {
            c = '1';
        }
        Console.WriteLine(c);
    }
}

Measured memory_bytes: 11220
#include <stdio.h>

int main(void){
	int x,t,diff=0;
	scanf("%d %d",&x,&t);
	if(x<t){
		diff=0;
	}else if(x>t){
		diff=x-t;
	}
	if(x==t){
		diff=0;
	}

	printf("%d",diff);
	return 0;
}

Measured memory_bytes: 128
package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	mx := 1000
	imos := makeGrid(mx+1, mx+1)
	for i := 0; i < n; i++ {
		sx := getNextInt(scanner)
		sy := getNextInt(scanner)
		tx := getNextInt(scanner)
		ty := getNextInt(scanner)
		imos[sy][sx]++
		imos[sy][tx]--
		imos[ty][sx]--
		imos[ty][tx]++
	}
	for y := 0; y < mx+1; y++ {
		for x := 0; x < mx; x++ {
			imos[y][x+1] += imos[y][x]
		}
	}
	for x := 0; x < mx+1; x++ {
		for y := 0; y < mx; y++ {
			imos[y+1][x] += imos[y][x]
		}
	}
	var ans cint
	for y := 0; y < mx+1; y++ {
		for x := 0; x < mx+1; x++ {
			ans.maxAs(cint(imos[y][x]))
		}
	}
	fmt.Fprintln(writer, ans)
}

func makeGrid(h, w int) [][]int {
	index := make([][]int, h, h)
	data := make([]int, h*w, h*w)
	for i := 0; i < h; i++ {
		index[i] = data[i*w : (i+1)*w]
	}
	return index
}

type cint int64

func (ct *cint) minAs(x cint) *cint {
	*ct = ct.min(x)
	return ct
}
func (ct *cint) maxAs(x cint) *cint {
	*ct = ct.max(x)
	return ct
}
func (ct cint) min(x cint) cint {
	if ct > x {
		return x
	}
	return ct
}
func (ct cint) max(x cint) cint {
	if ct < x {
		return x
	}
	return ct
}



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

#define crap ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define CY cout<<"Yes\n"
#define CN cout<<"No\n"
#define MOD 1000000007
using namespace std;
using ll = long long;
vector<ll> dp(100005,-1);

void solve()
{
    int x,y; cin>>x>>y;
    if(y%2==1||y>4*x||y<2*x) {CN;return;}
    int k2=y/2-x;
    int k1=2*x-(y/2);
    if(k1+k2==x){CY;}
    else CN;
}
int main() {
    crap;
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r", stdin) ;
        freopen("output.txt","w", stdout) ;
        freopen("error.txt","w", stderr) ;
    #endif
    ll t;t=1;
  //cin>>t;
    while(t--) solve();
}

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

//Function Macros:
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

//Type Definitions:
typedef long long ll;
typedef unsigned long long ull;

//Constants:
const int INF = 2e9;
const int MOD = 1e9 + 7;

//Global Variables:

//Prototype Declarations:
int gcd(int, int);

//================ Main Loop ================
int main()
{
    int A, B;
    cin >> A >> B;
    if(A>9 || B>9){
        cout << -1 << endl;
    }else{
        cout << A*B << endl;
    }
    return 0;
}
//===========================================

//Functions:
int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0;i < n;i++)
#define REP(i,n,k) for(int i = n;i < k;i++)
#define P(p) cout << (p) << endl;
#define sP(p) cout << setprecision(15) << fixed << p << endl;
#define vi vector<int>
#define printv(v) for(int i = 0;i < v.size();i++)P(v[i]);
#define printt(a,b) cout << a << " " << b << endl; 
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0};
int dy[] = { 0,  0,  1, -1};
int MOD = 1e9 + 7;

void solve() {
    int n;
    cin >> n;
    P(pow(n,3));
}

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


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

using namespace std;

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

    int n,k,d,num;
    cin>>n>>k;

    int arr[n]={};

    for(int i=0;i<k;i++){
        cin>>d;
        for(int j=0;j<d;j++){
            cin>>num;
            arr[num-1]=1;
        }
    }

    num=0;

    for(int i=0;i<n;i++){
        num+=arr[i];//cout<<arr[i]<<" ";
    }
    //cout<<"\n";

    cout<<n-num<<"\n";


    return 0;
}


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

import numpy as np

N = int(input())
L,R = np.array([input().split() for _ in range(N)],dtype=np.int64).T

# 両方とるものは自明に最適にならない。よって独立に考えられる
L.sort(); L = L[::-1]
R.sort()
Lcum = L.cumsum()
Rcum = R.cumsum()

x = (Lcum - Rcum).max()
y = (Lcum[1:] - Rcum[:-1]).max()
z = (Lcum[:-1] - Rcum[1:]).max()
answer = 2*max(x,y,z)
print(answer)

Measured memory_bytes: 48660
def dev(y,x):
    if y<x:
        return 2*(x-y)-1
    else:
        return 2*(y-x)


x,n=map(int,input().split())
p=[int(y) for y in input().split()]
q=[dev(y,x) for y in p]
q.sort()
r=0
while r<len(q):
    if q[r]!=r:
        break
    r+=1
if r%2==0:
    print(x+r//2)
else:
    print(x-(r+1)//2)

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

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define lb lower_bound
#define ub upper_bound

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b ? gcd(b,a%b) : a;}

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

	double l;
	cin >> l;
	l /= 3;
	cout << setprecision(10);
	cout << (l)*l*l << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <queue>
#include <vector>

using namespace std;

typedef long long ll;

ll n, m;
vector<ll> ve[100005];
ll s, e;
queue<ll> qi, qu;
ll d[3][100005];

int main()
{
    scanf("%lld%lld", &n, &m);
    for(ll i = 0; i < m; i++)
    {
        ll t1, t2;
        scanf("%lld%lld", &t1, &t2);
        ve[t1].push_back(t2);
    }
    scanf("%lld%lld", &s, &e);
    qi.push(s), qu.push(0);
    for(ll i = 1; i <= n; i++) d[0][i] = d[1][i] = d[2][i] = -1;
    d[0][s] = 0;
    while(!qi.empty())
    {
        ll t1 = qi.front(), t2 = qu.front();
        qi.pop(), qu.pop();
        for(ll i = 0; i < ve[t1].size(); i++)
        {
            if(d[(t2 + 1) % 3][ve[t1][i]] > -1) continue;
            d[(t2 + 1) % 3][ve[t1][i]] = t2 + 1;
            qi.push(ve[t1][i]), qu.push(t2 + 1);
        }
    }
    if(d[0][e] == -1) cout<<-1<<endl;
    else cout<<d[0][e] / 3<<endl;
    return 0;
}


Measured memory_bytes: 8064
#include <iostream>

using namespace std;

string s, t, u;
int a, b;

int main()
{
    cin >> s >> t >> a >> b >> u;
    if(u == s)
    {
        a--;
    }
    else if(u == t)
    {
        b--;
    }
    cout << a << " " << b;
    return 0;
}


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

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

  sort(a.begin(), a.end());
  sort(c.begin(), c.end());
  ll ans=0;
  rep(i, n) {
    ll s=lower_bound(a.begin(), a.end(), b[i])-a.begin();
    ll t=n-(upper_bound(c.begin(), c.end(), b[i])-c.begin());
    ans+=s*t;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1408
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.buffer.readline

    class SegmentTree:
        def __init__(self, A, initialize=True, segfunc=min, ident=2000000000):
            self.N = len(A)
            self.LV = (self.N - 1).bit_length()
            self.N0 = 1 << self.LV
            self.segfunc = segfunc
            self.ident = ident
            if initialize:
                self.data = [self.ident] * self.N0 + A + [self.ident] * (self.N0 - self.N)
                for i in range(self.N0 - 1, 0, -1):
                    self.data[i] = segfunc(self.data[i * 2], self.data[i * 2 + 1])
            else:
                self.data = [self.ident] * (self.N0 * 2)

        def update(self, i, x):
            i += self.N0 - 1
            self.data[i] = x
            for _ in range(self.LV):
                i >>= 1
                self.data[i] = self.segfunc(self.data[i * 2], self.data[i * 2 + 1])

        # open interval [l, r)
        def query(self, l, r):
            l += self.N0 - 1
            r += self.N0 - 1
            ret_l = self.ident
            ret_r = self.ident
            while l < r:
                if l & 1:
                    ret_l = self.segfunc(ret_l, self.data[l])
                    l += 1
                if r & 1:
                    ret_r = self.segfunc(self.data[r - 1], ret_r)
                    r -= 1
                l >>= 1
                r >>= 1
            return self.segfunc(ret_l, ret_r)

        # return smallest i(l <= i < r) s.t. check(A[i]) == True
        def binsearch(self, l, r, check):
            if not check(self.query(l, r)):
                return r
            l += self.N0 - 1
            val = self.ident
            while True:
                if check(self.segfunc(val, self.data[l])):
                    break
                if l & 1:
                    val = self.segfunc(val, self.data[l])
                    l += 1
                l >>= 1
            while l < self.N0:
                newval = self.segfunc(val, self.data[l * 2])
                if not check(newval):
                    val = newval
                    l = (l << 1) + 1
                else:
                    l <<= 1
            return l - self.N0 + 1

    N, Q = map(int, input().split())
    ST1 = SegmentTree([N] * N)
    ST2 = SegmentTree([N] * N)
    ans = (N-2) * (N-2)
    for _ in range(Q):
        t, x = map(int, input().split())
        if t == 1:
            k = ST1.query(x, N + 1)
            ans -= k-2
            if x < ST2.query(k, k+1):
                ST2.update(k, x)
        else:
            k = ST2.query(x, N + 1)
            ans -= k - 2
            if x < ST1.query(k, k + 1):
                ST1.update(k, x)
        #print(ans)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 108752
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<array>

using namespace std;
 
int main(){
#include<iostream>

using namespace std;
  int a,b=1;
  cin >> a;
  for(int i = 0;b <= a;i++){
    b *= 2;
  }
  cout << b/2 << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#define N 44

int fibonacci(int);

int main(){

  int i,n;

  scanf("%d",&n);

  printf("%d\n",fibonacci(n));
  return 0;
}

int fibonacci(int n){

  int F[n],i;
  F[0]=1;
  F[1]=1;

  for( i=2 ; i<=n ; i++)
    F[i] = F[i-2] + F[i-1]; 

  return F[n];
 

}

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

using namespace std;

#define inf 1<<30
#define llong long long
#define usd unsigned
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef pair<int, int> P;
typedef struct data{
	int now;
	int cost;
}data;
int nw[9] = {0, 1, 0, -1, -1, 1, 1, -1, 0};
int nh[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};
int a,b,c,d, A[100], B[100], C[100][100], D[100][100][100];
string s, t, r;




int main(){
	cin >> a >> b >> c;
	cout << (a-c)/(b+c) << endl;
	return 0;
}

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

int64_t luca(int x){
    long long int num1 = 2;
    long long int num2 = 1;
    long long int tmp = 1;

    for(int i = 1; i < x; i++){
    	tmp = num1 + num2;
      	num1 = num2;
      	num2 = tmp;
    }
  	return tmp;
}

int main() {
    int x;
    cin >> x;
  
  	printf("%lld\n", luca(x));
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// const ll INF = 1LL <<60;
// const int INF = 10000;

//最大公約数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

const int MAX = 1e6+1;
const int MOD = 1e9+7;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}

long long modpow(long long res,long long a, long long n, long long mod) {
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//sieve(MAX);でベクトルIsPrimeに「MAXまでの数値の素数の真偽」を格納する。
vector<bool> IsPrime;
void sieve(size_t max){
    if(max+1 > IsPrime.size()){     // resizeで要素数が減らないように
        IsPrime.resize(max+1,true); // IsPrimeに必要な要素数を確保
    } 
    IsPrime[0] = false; // 0は素数ではない
    IsPrime[1] = false; // 1は素数ではない

    for(size_t i=2; i*i<=max; ++i) // 0からsqrt(max)まで調べる
        if(IsPrime[i]) // iが素数ならば
            for(size_t j=2; i*j<=max; ++j) // (max以下の)iの倍数は
                IsPrime[i*j] = false;      // 素数ではない
}
// ここから開始
int main(){
  int n,m,k;
  cin>>n>>m>>k;
  bool ansflg = false;
  for(int i = 0; i <= n; i++){
    for(int j = 0; j <= m; j++){
      if(m*i+n*j-i*j*2==k) ansflg = true;
    }
  }
  if(ansflg) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}



Measured memory_bytes: 256
# coding: utf-8
#-------------------------------------------------------------------
import sys
def p(*a):
  s=" ".join(map(str,a))
  #print(s)
  sys.stderr.write(s+"\n")
#-------------------------------------------------------------------

R,G,B,N = map(int, input().split())


r=g=b=0
ans=0

#p(N//R+2)
#p(N//G+2)
#X=[]
#p(r,g,b)

for r in range(N//R+2):
	if (R*r)>N: break

	for g in range(N//G+2):
		if (R*r)+(G*g)>N:
			break
			X.append("break")
		
		b = (N-(R*r)-(G*g))//B
		n = (R*r)+(G*g)+(B*b)
		if n==N:
			ans+=1
#			X.append([r,g,b])
#		p(r,g,b,n,N,ans)

print(ans)
#p(X)


Measured memory_bytes: 40812
// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// contancer library
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

using ll = long long;
using ld = long double;

template <class T>
ostream& operator<<(ostream& os, vector<T> v) {
    os << "[";
    for (auto vv : v) os << vv << ",";
    return os << "]";
}

template <class T>
ostream& operator<<(ostream& os, set<T> v) {
    os << "{";
    for (auto vv : v) os << vv << ",";
    return os << "}";
}

template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> p) {
    return os << "(" << p.first << "," << p.second << ")";
}

template <class K, class T>
ostream& operator<<(ostream& os, map<K, T> v) {
    os << "{";
    for (auto vv : v) os << vv << ",";
    return os << "}";
}

template <class T>
ostream& operator<<(ostream& os, queue<T> q) {
    os << "[";
    while (!q.empty()) {
        os << q.front() << ",";
        q.pop();
    }
    return os << "]";
}

template <class T>
ostream& operator<<(ostream& os, priority_queue<T> q) {
    os << "{";
    while (!q.empty()) {
        os << q.top() << ",";
        q.pop();
    }
    return os << "}";
}

const ll MOD = 1000000007;
// const ll MOD = 998244353;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const ld PI = acos(-1);
// const ld EPS = 1e-10;
// mt19937 mt(ll(time(0)));

template <class T>
vector<T> Vec(size_t l, T v) { return vector<T>(l, v); }

template <class T, class... Ts>
auto Vec(size_t l, Ts... ts) {
    return vector<decltype(Vec<T>(ts...))>(l, Vec<T>(ts...));
}

template <typename T>
inline T sq(T a) { return a * a; }

template <typename T>
inline T iceil(T n, T d) { return (n + d - 1) / d; }

template <typename T>
T gcd(T a, T b) {
    while (b > 0) {
        a %= b;
        swap(a, b);
    }
    return a;
}

template <typename T, typename U>
T ipow(T b, U n) {
    T ret = 1;
    while (n > 0) {
        if (n & 1) ret *= b;
        n >>= 1;
        b *= b;
    }
    return ret;
}

template <typename T, typename U>
T mpow(T b, U n) {
    T ret = 1;
    while (n > 0) {
        if (n & 1) ret = ret * b % MOD;
        n >>= 1;
        b = b * b % MOD;
    }
    return ret;
}

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    cout << min(B / A, C) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,x;
    cin>>n>>x;
    int d[n+1],l[n+1];
    d[0]=0;

    for(int i=0; i<n; i++)
    {
        cin>>l[i];
    }

    for(int i=1; i<n+1; i++)
    {
        d[i]=d[i-1]+l[i-1];
    }

    int ans=0;
    for(int i=0; i<n+1; i++)
    {
        if(d[i]<=x)
            ans++;
    }
    cout<<ans<<endl;
    return 0;
}
/*
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,x,a;
    cin>>n>>x;
    int sum=0,ans=1;
    for(int i=0; i<n; i++)
    {
        cin>>a;
        sum+=a;
        if(sum<=x)
            ans++;
    }
    cout<<ans<<endl;
    return 0;
}
*/


Measured memory_bytes: 3612
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if(s.compareTo("2019/04/30") <= 0){
            System.out.println("Heisei");
        } else {
            System.out.println("TBD");
        }
    }
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define erep(i,a,n) for(int i = a;i<=n;i++)
typedef long long ll;
#define int long long
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define P pair<int,int>
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

signed main(){
  string s,t;
  cin >> s >> t;
  int n = s.size();
  bool flag = true;
  rep(i,0,n){
    if(s[i] != t[i]) flag = false;
  }
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

using namespace std;

#define K 600001

int n;
long long a[K], b[K];

int main() {
    scanf("%d", &n);
    long long ret = 0, tot = 0;
    for (int i = 1; i <= n; i++) {
        scanf("%lld%lld", &a[n - i + 1], &b[n - i + 1]);
    }

    for (int i = 1; i <= n; i++) {
        a[i] += ret;
        long long bar = a[i] % b[i];
        long long val = (b[i] - bar) % b[i];
        ret += val;
    }

    printf("%lld\n", ret);
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
int a[252521];
ll sum[252521];

int main(){
  scanf("%d",&n);
  REP(i,n)scanf("%d",a+i);
  sum[0] = 0;
  REP(i,n)sum[i+1] = sum[i] + a[i];
  ll ans = 0;
  map<ll,ll> cnt;
  cnt[0] = 1ll;
  REP(i,n){
    ll v = sum[i+1];
    ans += cnt[v];
    cnt[v]++;
  }
  printf("%lld\n",ans);
  return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> l(2*n);
    rep(i, 2*n) cin >> l[i];
    sort(l.begin(), l.end());
    int ans = 0;
    rep(i, n) ans += l[2*i];
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  string a, s, c;
  cin >> a >> s;
  cout << "A" << s.at(0) << "C" << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
Taro_point = 0
Hanako_point = 0
for i in range(N):
    list = input().split()
    if list[0] == list[1]:
        Taro_point += 1
        Hanako_point += 1
    elif list == sorted(list):
        Hanako_point += 3
    else:
        Taro_point += 3
print(Taro_point,Hanako_point)


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

#define ll long long
#define mtv(kit) cout<<#kit<<" - "<<kit<<"\n";
#define ff first
#define ss second
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define pii pair<ll , ll>
#define nl "\n"
#define ump unordered_map<ll , ll>

void doit(){
	ll n,m,i,j,k,c,ans=0,x;
	cin >> n >> k;
	vector< ll >v(n);
	for(i = 0; i < n; i++)cin>>v[i];
	sort( v.begin(), v.end() );
	rep(i,0,k)ans+=v[i];
	cout << ans << nl;
}


int main() {
#ifndef ONLINE_JUDGE
	freopen("input1.txt","r",stdin);
	freopen("output1.txt","w",stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t = 1;
	// cin >> t;
	for(ll i = 1; i <= t; i++){
		doit();
	}
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
using namespace std;
int main()
{
	string s;
	cin>>s;
	int ans=0;
	rep(i,4)
		if(s[i]-'0'==2)
			ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

using namespace std;

int without_tax(int rate, int value) {
    int q = ((value + 1) * 100) / (100 + rate);
    int r = ((value + 1) * 100) % (100 + rate);
    return q - (r ? 0 : 1);
}

int add_tax(int rate, int value) {
    return (value * (100 + rate)) / 100;
}

int main(void) {
    for (;;) {
        int x, y, s;
        scanf("%d%d%d", &x, &y, &s);

        if (!x && !y && !s) { break; }

        int m = 0;
        for (int i = 1; i < s; i++) {
            int j = s - i;

            int a = without_tax(x, i);
            int b = without_tax(x, j);

            if (add_tax(x, a) + add_tax(x, b) != s) { continue; }

#if 0
            printf("debug a b: %d %d\n", a, b);
            printf("debug i j: %d %d\n", add_tax(x, a), add_tax(x, b));
            printf("debug s  : %d\n", add_tax(x, a) + add_tax(x, b));
            printf("debug s2 : %d\n", add_tax(y, a) + add_tax(y, b));
#endif

            m = max(m, add_tax(y, a) + add_tax(y, b));
        }

        printf("%d\n", m);
    }

    return 0;
}

Measured memory_bytes: 1028
#include <stdio.h>
#include <stdlib.h>

#define MAX 2000001
#define VMAX 10000

int main(void)
{
  unsigned short *A, *B;
  
  int C[VMAX+1];
  int n, i, j;
  scanf("%d",&n);
  
  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);
  
  for(i=0;i<=VMAX;i++) C[i] = 0;
  
  for(i=0;i<n;i++) {
    scanf("%hu",&A[i+1]);
    C[A[i+1]]++;
  }
  
  for(i=1;i<=VMAX;i++) C[i] = C[i] + C[i-1];
  
  for(j=1;j<=n;j++) {
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
  
  for(i=1;i<=n;i++) {
    if(i>1) printf(" ");
    printf("%d",B[i]);
  }
  printf("\n");
  
  return 0;
}



Measured memory_bytes: 9604
N, K = gets.split.map(&:to_i)
goods = N.times.map { gets.split.map(&:to_i) }

cand = []
cand << K

30.downto(1) do |i|
  next if K[i] == 0

  mask = (K ^ (1 << i)) | ((1 << i) - 1)

  cand << mask
end

ans = 0

cand.each do |mask|
  ret = 0

  goods.each do |a, b|
    next if (mask | a) != mask

    ret += b
  end

  ans = ret if ans < ret
end

puts ans


Measured memory_bytes: 11668
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) throws IOException {
		new Main().solve();
	}

	private void solve() throws IOException {
		try {
			solveA();
			// solveB();
			// solveC();
			// solveD();
			// solveE();
			// solveF();
		} finally {
			if (in != null) {
				in.close();
			}
			if (out != null) {
				out.flush();
				out.close();
			}
		}

	}

	private void solveA() {
		String wk = next();
		if (wk.equals("A")) {
			System.out.println("T");
		} else if (wk.equals("T")) {
			System.out.println("A");
		} else if (wk.equals("G")) {
			System.out.println("C");
		} else if (wk.equals("C")) {
			System.out.println("G");
		}

	}

	private void solveB() {
		int numN = nextInt();

		out.println("");
	}

	private void solveC() {
		int numN = nextInt();

		out.println("");
	}

	private void solveD() {
		int numN = nextInt();

		out.println("");
	}

	private void solveE() {
		int numN = nextInt();

		out.println("");
	}

	private void solveF() {
		int numN = nextInt();

		out.println("");
	}

	private final PrintWriter out = new PrintWriter(System.out);
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

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

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
}

Measured memory_bytes: 22100
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <numeric>

#define rep(i, j) for(int i = 0; i < j; i++)
#define all(i) i.begin(), i.end()

using namespace std;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M; while (cin >> N >> M && N != 0 && M != 0)
	{
		int r; cin >> r;
		vector<vector<int>> dat(M + 2, vector<int>(722, 0));
		vector<vector<int>> ttmp(M + 2, vector<int>(N + 2, 0));
		rep(i, r)
		{
			int t, n, m, s; cin >> t >> n >> m >> s;
			if (s == 1){ ttmp[m][n] = t - 540; }
			else if (s == 0) { fill(dat[m].begin() + ttmp[m][n], dat[m].begin() + (t - 540), 1); }
		}
		int q; cin >> q;
		rep(i, q)
		{
			int ts, te, m; cin >> ts >> te >> m;
			printf("%d\n", accumulate(dat[m].begin() + (ts - 540), dat[m].begin() + (te - 540), 0));
		}
	}
	return 0;
}

Measured memory_bytes: 60628
#include<cstdio>
#include<iostream>
#include<cstring>
#define RG register
using namespace std;
int k,t,a[102],maxx,sum;
template<typename I> inline void read(I &ot){
	I ch=getchar(), x=0, f=1;
	while(ch<'0' || ch>'9'){if(ch=='-') f=-1; ch=getchar();	}
	while(ch>='0' && ch<='9'){x=x*10+ch-'0'; ch=getchar();	}
	ot=x*f;}
template<typename I, typename... U> inline void read(I &x,U&... y){read(x); read(y...);}
template<typename I>inline I mx(const I&a,const I&b){return a>b ? a : b;}
int main()
{
	//freopen("K Cakes.in","r",stdin);
	read(k,t);
	for(RG int i=1;i<=t;i++) 
	{
		read(a[i]);
		maxx=mx(maxx,a[i]); sum+=a[i];
	}
	if(sum-maxx>=maxx) printf("0\n");
	else printf("%d\n",maxx-(sum-maxx)-1);
	return 0;
}

Measured memory_bytes: 256