akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>

int main()
{
	int n,a[100002];
	scanf("%d",&n);
	int num_2 = 0,num_4 = 0;
	int flag = 0;
	for(int i = 0;i < n;i ++)
	{
		scanf("%d",&a[i]);
		if(a[i] %4 == 0)
		num_4 ++;
		else if(a[i] % 2 == 0)
		num_2 ++;
	}
	if(num_4 + num_2/2 >= n/2)
	flag = 1;
    printf("%s\n",flag?"Yes":"No");
}

Measured memory_bytes: 512
import scala.io.{ StdIn => in}

object Main extends App {
  val n = in.readInt
  val ans = in.readLine.toCharArray
    .take(n)
    ./:(0,0)((acc,ch) => {
      val x = if(ch == 'I') acc._2 + 1 else acc._2 - 1
      (math.max(acc._1, x), x)
    })._1
  println(ans)
}

Measured memory_bytes: 27436
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int h1,h2,m1,m2,k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  int p1 = h1 * 60 + m1;
  int p2 = h2 * 60 + m2;
  cout << p2-k-p1 << endl;

  return 0;
}


Measured memory_bytes: 3624
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h,w;
  cin >> h >> w;
  vector<string> vs(h);
  FOR(i,0,h) cin >> vs[i];
  FOR(i,0,h) {
    bool del = true;
    FOR(j,0,w) {
      if(vs[i][j] == '#') del = false;
    }
    if(del) {
      FOR(j,0,w) vs[i][j] = 'X';
    }
  }
  FOR(j,0,w) {
    bool del = true;
    FOR(i,0,h) {
      if(vs[i][j] == '#') del = false;
    }
    if(del) {
      FOR(i,0,h) vs[i][j] = 'X';
    }
  }
  FOR(i,0,h) {
    FOR(j,0,w) {
    	if(vs[i][j] != 'X') {
          cout << vs[i][j];
        }
    }
    cout << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define dd double
#define MOD 1000000007
#define nl cout<<endl
#define rt ll Q[100005]={0}
#define mp make_pair
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define ff first	
#define ss second
#define all(v) v.begin(),v.end()
#define s(ar,n) sort(ar,ar+n)
#define rs(ar,n) sort(ar, ar+n, greater<ll>()) 
#define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define ov(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define maxa(ar,N) *max_element(ar,ar+N)
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;
    x = x % p;
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p;  
        y = y>>1;
        x = (x*x) % p; 
    } 
    return res; 
} 
ll modInverse(ll n, ll p) 
{ 
    return power(n, p-2, p); 
} 
ll nCrModPFermat(ll n, ll r, ll p) 
{ 
    if(r<0||r>n)
    return 0;
   if (r==0) 
      return 1ll; 
    ll fac[n+1]; 
    fac[0] = 1; 
    for (int i=1 ; i<=n; i++) 
        fac[i] = fac[i-1]*i%p; 
  
    return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
} 
int main() 
{
    fastio();
    ll N,M;
    cin>>N>>M;
    ll j=N+M;
    if(j%3==0)
    {
        j/=3;
        //cout<<j<<" "<<M-j<<" "<<MOD<<endl;
        ll kj=nCrModPFermat(j,M-j,MOD);
        cout<<kj;
    }
    else
        cout<<0;
	return 0;
}

Measured memory_bytes: 5504
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    //cout.precision(10);
    int n;
    cin >> n;
    if(n % 2 == 1){
        n *= 2;
    }
    cout << n << endl;

    return 0;
}

Measured memory_bytes: 384
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val A, B, H, M = sc.nextDouble()
  val sideLength = (angle: Double) =>
    math.sqrt(A * A + B * B - 2 * A * B * math.cos(math.toRadians(angle)))
  val hourHandAngle = ((360.0 / (12 * 60.0)) * (H * 60 + M)) % 360.0
  val minuteHandAngle = ((360.0 / 60.0) * M) % 360.0
  println {
    math.abs(hourHandAngle - minuteHandAngle) match {
      case 0.0 => math.abs(A - B)
      case 180.0 => A + B
      case angle if 180.0 < angle => sideLength(360.0 - angle)
      case angle => sideLength(angle)
    }
  }
}


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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int n, d;
	cin >> n >> d;

	vector<vector<int> > x(n, vector<int> (d));
	for(int i = 0; i < n; ++i) {
		for(int j = 0; j < d; ++j) {
			cin >> x[i][j];
		}
	}

	auto dis = [&] (int i, int j) -> int {
		int ret = 0;
		for(int k = 0; k < d; ++k) {
			ret += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
		}
		return ret;
	};	

	int ans = 0;
	for(int i = 0; i < n; ++i) {
		for(int j = i + 1; j < n; ++j) {
			int d = dis(i, j);
			int v = sqrt(d);
			if(v * v == d) {
				ans += 1;
			}
		}
	}

	cout << ans << '\n';

	return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	ll A, B, C, K;
	cin >> A >> B >> C >> K;

	if(K%2==0){
		cout << A-B << endl;
	}else{
		cout << B - A << endl;
	}
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,q,a,t,x;
	cin >> n >> q;
	vector< queue<int> > st(n+1);
	for(int i=0;i<q;i++){
		cin >> a;
		if(a==0){
			cin >> t >> x;
			st[t].push(x);
		}else if(a==1){
			cin >> t;
			if(!st[t].empty()){
				cout << st[t].front() << endl;
			}
		}else{
			cin >> t;
			if(!st[t].empty()){
				st[t].pop();
			}
		}
	}
}


Measured memory_bytes: 4416
#include <stdio.h>

char *
to_relationship(int a, int b)
{
	if (a == b) return "a == b";
	if (a < b)  return "a < b";
	if (a > b)  return "a > b";
	return "";
}

int
main()
{
	int a, b;
	scanf("%d %d", &a, &b);

	char *relation = to_relationship(a, b);
	printf("%s\n", relation);

	return 0;
}

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

int main() {
  int N ; 
  cin >> N ; 
  string S , T  ; 

    cin >> S ; 

    cin >> T; 

  
  
  for (int i = 0 ; i < N ; i++){
    cout << S.at(i) << T.at(i) ; 
    
  }
  
  cout << endl ; 

  
  
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

vector<ll> construct_suffix_array(const string &S) {
  ll n = S.length(), k = 1;
  vector<ll> sa(n + 1), rnk(n + 1), tmp(n + 1);

  auto compare_sa = [&](const ll &i, const ll &j) {
    if(rnk[i] != rnk[j]) return rnk[i] < rnk[j];
    ll ri = i + k <= n ? rnk[i + k] : -1;
    ll rj = j + k <= n ? rnk[j + k] : -1;
    return ri < rj;
  };

  REP(i, 0, n + 1) sa[i] = i;
  REP(i, 0, n + 1) rnk[i] = i < n ? S[i] : -1;

  for(; k <= n; k *= 2) {
    sort(sa.begin(), sa.end(), compare_sa);
    tmp[sa[0]] = 0;
    REP(i, 1, n + 1) tmp[sa[i]] = tmp[sa[i - 1]] + (compare_sa(sa[i - 1], sa[i]) ? 1 : 0);
    REP(i, 0, n + 1) rnk[i] = tmp[i];
  }

  return sa;
}

int main(void) {
  ll N, H;
  string S;
  cin >> N >> H >> S;

  vector<ll> a(N, 0);
  REP(i, 0, N - 1) if(S[i] == '0') a[i + 1] += a[i] + 1;

  vector<ll> imos(N + 2, 0);
  REP(i, 0, N) {
    if(S[i] != '0') {
      imos[1] += a[i] + 1;
      imos[N - i + 1] -= a[i] + 1;
    } else {
      imos[1] += a[i] + 1;
      imos[2] -= a[i] + 1;
    }
  }
  REP(i, 0, N + 1) imos[i + 1] += imos[i];

  ll x = 1, cnt = 1;
  while(1) {
    if(cnt <= H && H < cnt + imos[x]) break;
    cnt += imos[x];
    x++;
  }

  vector<ll> sa = construct_suffix_array(S);
  REP(i, 1, N + 1) {
    ll j = sa[i];
    if((x == 1 || S[j] != '0') && j + x <= N) {
      if(cnt <= H && H < cnt + a[j] + 1) {
        cout << S.substr(j, x) << endl;
        break;
      }
      cnt += a[j] + 1;
    }
  }
}



Measured memory_bytes: 6908
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

n = ns()
if n[-1] in '24579':
    print('hon')
elif n[-1] in '0168':
    print('pon')
else:
    print('bon')


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

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, m, n) for (ll i = (m); i < (n); i++)
#define FORR(i, m, n) for (ll i = (m); i >= (n); i--)
#define INF 1e9
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((ll)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl

int main(int argc, char const *argv[])
{
    ll a, b;
    cin >> a >> b;
    ll res = 0;
    FOR(i, a, b + 1)
    {
        string s = to_string(i);
        string s_rev = s;
        reverse(ALL(s));
        if (s == s_rev)
            res++;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
#include <random>
#include <time.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
int main() {
	ll n, d, x, a;
	cin >> n >> d >> x;
	for (int i = 0; i < n; i++) {
		cin >> a;
		x++;
		x += (d - 1) / a;
	}
	cout << x << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		int count = 0;
		
		for(int n = a; n <= b; n++) {
			if (c % n == 0) {
				count++; 
			}
		}
		
		System.out.println(count);
	}
}



Measured memory_bytes: 26344
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

a_tot = [0] * (n+1)
b_tot = [0] * (m+1)

for i,ai in enumerate(a,1):
    a_tot[i] = a_tot[i-1] + ai

for i,bi in enumerate(b,1):
    b_tot[i] = b_tot[i-1] + bi

# print(a_tot)

b_num = m
ans = 0
for a_num in range(n+1):
    rem = k - a_tot[a_num]
    if(rem < 0):
        break
    if(b_num==0):
        ans = max(ans,a_num)
    else:
        while(b_tot[b_num] > rem):
            b_num -= 1
        ans = max(ans,a_num+b_num)

print(ans)

Measured memory_bytes: 111100
a,b,c,k=map(int,input().split())
count=0
if k<=a:
    count=1*k
elif a<k and k<=(a+b):
    count=1*a
elif (a+b)<k and k<=(a+b+c):
    count=1*a+(-1)*(k-a-b)
print(count)


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

#define ll long long
ll MAX = 1000000000+7;

using namespace std;

ll modF(ll a) {
    if (a<0) return modF((a%MAX)+MAX);
    else return (a%MAX);
}

int main() {
    ll t;
    t=1;
    while (t--) {
        ll n, k, i, a, po=0, ni=0, ans=1;
        vector<ll> vcp, vcn;
        cin >> n >> k;
        for (i=0;i<n;i++) {
            cin >> a;
            if (a<0) {
                a=-a;
                ni++; vcn.push_back(a);
            }
            else {
                po++; vcp.push_back(a);
            }
        }
        if (po>0) sort(vcp.begin(),vcp.end());
        if (ni>0) sort(vcn.begin(),vcn.end());

        if (po==0) {
            if (k%2==0) {
                for (i=0;i<k;i++) {
                    ans = ans * (-vcn[ni-1]);
                    ans = modF(ans);
                    ni--;
                }
            }
            else {
                for (i=0;i<k;i++) {
                    ans = ans * (-vcn[i]);
                    ans = modF(ans);
                }
            }
        }
        else if (ni==0) {
            for (i=0;i<k;i++) {
                ans = ans * vcp[po-1];
                ans = modF(ans);
                po--;
            }
        }
        else {
            if (k%2==1) {
                ans = vcp[po-1];
                po--; k--;
            }
            while (k>1 && (po>=2 || ni>=2)) {
                ll propo = 0;
                if (po>=2) propo = vcp[po-1]*vcp[po-2];
                ll proni = 0;
                if (ni>=2) proni = vcn[ni-1]*vcn[ni-2];

                if (propo>proni) {
                    propo = modF(propo);
                    ans = ans*propo;
                    ans = modF(ans);
                    po = po-2;
                }
                else {
                    proni = modF(proni);
                    ans = ans*proni;
                    ans = modF(ans);
                    ni = ni-2;
                }
                k=k-2;
            }
            while (k>0) {
                if (po>0) {
                    ans = ans*vcp[po-1];
                    ans = modF(ans);
                    po--; k--;
                }
                else if (ni>0) {
                    ans = ans*(-vcn[ni-1]);
                    ans = modF(ans);
                    ni--; k--;
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 5388
#include<bits/stdc++.h>
#define LL long long
#define db double

using namespace std;
const int N=100+10,M=N*N;
int rd()
{
    int x=0,w=1;char ch=0;
    while(ch<'0'||ch>'9'){if(ch=='-') w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+(ch^48);ch=getchar();}
    return x*w;
}
int mod;
void ad(int &x,int y){x+=y,x-=x>=mod?mod:0;}
int fpow(int a,int b){int an=1;while(b){if(b&1) an=1ll*an*a%mod;a=1ll*a*a%mod,b>>=1;}return an;}
int ginv(int a){return fpow(a,mod-2);}
vector<int> e[N];
int n,m,k,c[N][N],pw[N][M],f[2][N][N],g[N][N];

int main()
{
    n=rd(),m=rd(),k=rd(),mod=rd();
    for(int i=0;i<=N-5;++i)
    {
	c[i][0]=1;
	for(int j=1;j<=i;++j) c[i][j]=(c[i-1][j]+c[i-1][j-1])%mod;
    }
    for(int i=0;i<=N-5;++i)
    {
	pw[i][0]=1;
	for(int j=1;j<=M-5;++j) pw[i][j]=1ll*pw[i][j-1]*i%mod;
    }
    int nw=1,la=0,dx;
    f[la][0][0]=1;
    for(int h=1;h<=k;++h)
	for(int o=0;o<=1;++o)
	{
	    for(int j=0;j<=m;++j)
		for(int l=0;l<=n;++l)
		    g[j][l]=1ll*pw[k-h+1-o][l*j]*pw[h][l*(m-j)]%mod;
	    for(int i=0;i<=n;++i)
		for(int j=0;j<=m;++j)
		{
		    if(!f[la][i][j]) continue;
		    for(int l=0;i+l<=n;++l)
		    {
			dx=1ll*f[la][i][j]*c[n-i][l]%mod*g[j][l]%mod;
			ad(f[nw][i+l][j],(o&l&1)?mod-dx:dx);
		    }
		    f[la][i][j]=0;
		}
	    nw^=1,la^=1;
	    for(int i=0;i<=n;++i)
		for(int l=0;l<=m;++l)
		    g[i][l]=1ll*pw[k-h+1-o][l*i]*pw[h][l*(n-i)]%mod;
	    for(int i=0;i<=n;++i)
		for(int j=0;j<=m;++j)
		{
		    if(!f[la][i][j]) continue;
		    for(int l=0;j+l<=m;++l)
		    {
			dx=1ll*f[la][i][j]*c[m-j][l]%mod*g[i][l]%mod;
			ad(f[nw][i][j+l],(o&l&1)?mod-dx:dx);
		    }
		    f[la][i][j]=0;
		}
	    nw^=1,la^=1;
	}
    printf("%d\n",f[la][n][m]);
    return 0;
}


Measured memory_bytes: 5504
#include<cstdio>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
const int mod=1e9+7;
long long n,k,x,y,ans;
int main()
{
  cin>>n>>k>>x>>y;
  if(n<k)
  ans=n*x;
  else
  ans=k*x+(n-k)*y;
  cout<<ans<<endl; 
  
}

Measured memory_bytes: 256
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	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 getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(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
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 3
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	x := getNextInt64(scanner)
	aa := make([]int64, n)

	cc := makeInts(n, n)

	for i := 0; i < n; i++ {
		aa[i] = getNextInt64(scanner)
		cc[i][0] = aa[i]
		for j := 1; j < n; j++ {
			cc[i][j] = math.MaxInt64
		}
	}

	for i := 0; i < n; i++ {
		for j := 1; j < n; j++ {
			cc[i][j] = cc[i][j-1]
			if cc[i][j] > aa[(i+n-j)%n] {
				cc[i][j] = aa[(i+n-j)%n]
			}
		}
	}

	var ans, min int64
	ans = math.MaxInt64
	for i := 0; i < n; i++ {
		min = 0
		for j := 0; j < n; j++ {
			min += cc[j][i]
		}
		if ans > min+x*int64(i) {
			ans = min + x*int64(i)
		}
	}
	fmt.Fprintln(writer, ans)
}

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


Measured memory_bytes: 34944
d, g = map(int, input().split())
pc = [list(map(int, input().split())) for _ in range(d)]

def dfs(i, sum, count, nokori):
   global ans
   if (i == d):
      if (sum < g):
         use = max(nokori)
         n = min(pc[use-1][0], -(-(g-sum) // (use*100)))
         count += n
         sum += n * use * 100

      if (sum >= g):
         ans = min(ans, count)

   else:
      dfs(i+1, sum, count, nokori)
      dfs(i+1, sum+pc[i][0]*(i+1)*100+pc[i][1], count+pc[i][0], nokori-{i+1})


ans = float('inf')
dfs(0, 0, 0, set(range(1, d+1)))
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>

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

using namespace std;

void make_map(vector<long> &sum, map<long, int> &map)
{
	for(int i=1; i<(int)sum.size(); i++){
		for(int j=0; i+j<(int)sum.size(); j++){
			if (map.count(sum[i+j]-sum[j]) == 0){
				map.insert(make_pair(sum[i+j]-sum[j], 1));
			}else{
				map[sum[i+j]-sum[j]]++;
			}
		}
	}
	return;
}

int main(void)
{
	int N, M;
	while(cin >> N >> M, N > 0){
		map<long, int> h_map;
		map<long, int> w_map;
		vector<long> h_sum;
		vector<long> w_sum;
		long result = 0;
		//hの累積和配列を作成
		h_sum.push_back(0);
		rep(i, N){
			int h;
			cin >> h;
			h_sum.push_back(h_sum.back() + h);
		}
		//h_mapの構成
		make_map(h_sum, h_map);
		//wの累積和配列を作成
		w_sum.push_back(0);
		rep(i, M){
			int w;
			cin >> w;
			w_sum.push_back(w_sum.back() + w);
		}
		//w_mapの構成
		make_map(w_sum, w_map);

		//h_mapのイテレータを回して，同じキー値をもつw_mapの要素数だけresultを加算
		for(auto itr = h_map.begin(); itr != h_map.end(); itr++){
			result += (*itr).second * w_map[(*itr).first];
		}

		//出力
		cout << result << endl;
	}
	return 0;
}


Measured memory_bytes: 44596
import java.util.*;

class Main{
    void solve(){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] x = new int[n];
        for(int i = 0; i < n; i++) x[i] = scan.nextInt();
        int sum = 0;
        int out = Integer.MAX_VALUE;
        for(int i = 1; i <= 100; i++){
            for(int j = 0; j < n; j++){
                sum += Math.pow(x[j] - i, 2);
            }
            out = Math.min(sum, out);
            sum = 0;
        }
        System.out.println(out);
        scan.close();
    }
    public static void main(String[] args){
        new Main().solve();
    }
}


Measured memory_bytes: 27112
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n;
  cin >> n;
  long long a[2*n];
  for(long long i=0;i<2*n;i++){
    cin >> a[i];
  }
  sort(a,a+2*n);
  long long ans=0;
  for(long long i=0;i<2*n;i=i+2){
    ans=ans+min(a[i],a[i+1]);
  }
  cout << ans;
}


Measured memory_bytes: 256
import java.util.Scanner;

/**
 * ROT N
 */
public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();
            char[] S = sc.next().toCharArray();

            for (int i = 0; i < S.length; i++) {
                int c = S[i] - 'A';
                S[i] = (char) ((c + N) % 26 + 'A');
            }

            System.out.println(String.valueOf(S));
        }
    }

}


Measured memory_bytes: 23892
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef unsigned int uint;
typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 19;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

const int MX = 5005;
const int MM = 998244353;

int C[MX][MX];

ll H(ll n, ll k){ 
	return n+k-1 < 0 || k < 0? 0 : C[n+k-1][k];
}

int N, K;
ll solve(int n, int k, int K){
	ll ans = 0;
	for(int i = 0; i <= k; i++){
		ll v = H(K, n - 2*i) * C[k][i] % MM;
		if(i%2 == 0) ans = (ans + v) % MM;
		else ans = (ans + MM - v) % MM;
	}
	return ans;
}

int main()
{
	C[0][0] = 1;
	for(int i = 1; i < MX; i++){
		C[i][0] = 1;
		for(int j = 1; j <= i; j++) C[i][j] = (C[i-1][j-1] + C[i-1][j]) % MM;
	}
	scanf("%d%d", &K, &N);
	if(K == 1) return !printf("0\n");
	for(int k = 2; k <= 2*K; k++){
		ll ans = 0;
		int v = min((k-1)/2, (2*K-k+1)/2);
		if(k%2 == 0) ans = (solve(N-1, v, K-1) + solve(N, v, K-1)) % MM;
		else ans = solve(N, v, K);
		printf("%lld\n", ans);
	}
}


Measured memory_bytes: 96512
N = int(input())
A = list(map(int, input().split()))

bitlist = [0] * 60

for i in A:
    for index, num in enumerate(reversed(bin(i)[2:])):
        if num == "1":
            bitlist[index] += 1
ans = 0
for bit, num in enumerate(bitlist):
    ans += num * (N-num) * (2 ** bit)
    ans %= (10**9+7)
print(ans)

Measured memory_bytes: 122936
let n = read_int ()
let ss = Array.init n @@ fun _ -> read_line ()
let m = read_int ()
let ts = Array.init m @@ fun _ -> read_line ()
let _ = Array.(fold_left (fun a u -> max a @@ fold_left (fun p s -> if u = s then p + 1 else p) 0 ss + fold_left (fun p t -> if u = t then p - 1 else p) 0 ts) 0 ss) |> Printf.printf "%d\n"

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

int main ()
{
    double a, b, p, c, d, q, x, y;
    while (scanf ("%lf %lf %lf %lf %lf %lf", &a, &b, &p, &c, &d, &q)!=EOF){
        x = (p*d - b*q) / (a*d - b*c);
        y = (a*q - p*c) / (a*d - b*c);
        if (x == 0){
            x = abs(x);
        }
        if (y == 0){
            y = abs(y);
        }
        printf ("%0.3lf %0.3lf\n", x, y);
    }
    return 0;
}

Measured memory_bytes: 1784
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <stack>
#include <queue>
#include <string.h>

#define MAX_N 1000

using namespace std;

int N;
char form[MAX_N+1][10000];
char res[MAX_N+1][10000];

int dfs(int level, int pnum){
	int prenum = pnum;
	if(level > 0){
		res[prenum][level-1] = '+';
		//res[pnum][level+1] = '\0';
	}
	strcpy(&res[prenum][level], &form[prenum][level]);
	
	int i, nexti;
	for (i = prenum+1; i < N; )
	{
		if(level < strlen(form[i]) && form[i][level] == '.' && form[i][level+1] != '.'){
			nexti = dfs(level+1, i);
			//cout << nexti << endl;
			for (int j = prenum+1; j < i; j++)
			{
				res[j][level] = '|';
			}
			prenum = i;
			i = nexti;
		}else{
			break;
		}
	}
	return i;
}

int main(){
	while(1){
		cin >> N;
		if(N == 0) break;
		for (int i = 0; i < N; i++)
		{
			cin >> form[i];
			for (int j = 0; j < strlen(form[i]); j++)
			{
				res[i][j] = ' ';
			}
			//res[i][strlen(form[i])] = '\0';
			//res[i][strlen(form[i])+1] = '\0';
		}
		dfs(0,0);
		for (int i = 0; i < N; i++)
		{
			cout << res[i] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 19048
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int c=0;
  int m=0;
  for(int _=0;_<n;_++){
    int d1,d2;
    cin>>d1>>d2;
    if(d1==d2)
      c++;
    else
      c=0;
    m=max(m,c);
  }
  cout<<(m>=3?"Yes":"No")<<endl;
}

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

const double pi = acos(-1.0);

inline void deg_to_rad(double& arg) {
    arg = arg * pi / 180.0L;
}

int main() {
    double r_H, r_M;
    int H, M;
    cin >> r_H >> r_M >> H >> M;

    double arg_H = 30.0L * H + M / 2.0L;
    double arg_M = 6.0L * M;

    deg_to_rad(arg_H);
    deg_to_rad(arg_M);

    complex<double> z_H = polar(r_H, arg_H);
    complex<double> z_M = polar(r_M, arg_M);

    cout << fixed << setprecision(20);
    cout << abs(z_H - z_M);
}

Measured memory_bytes: 4108
#include <iostream>
#include <iomanip>
#include <string>

using namespace std;  //このネームスペースを使う

int main(){
  int M[1];
 
  cin >> M[0] >> M[1] ;
  
  if(M[0] % 2 == 0 || M[1] % 2 == 0 ){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }
  
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>

#define MAX_N 1000000

using namespace std;

int n, q;
struct Task {
	string name;
	int time;
} queue[MAX_N];
int head, tail;

void initialize() {
	head = tail = 0;
}

bool isEmpty() {
	return head == tail;
}

void enqueue(Task task) {
	queue[(tail ++) % n] = task;
}

Task dequeue() {
	return queue[(head ++) % n];
}

int main() {
	cin >> n >> q;
	string name; int time;
	initialize();
	for (int i = 0; i < n; i ++) { cin >> name >> time;  Task task = {name, time}; enqueue(task); }

	int sum_time = 0;
	while (!isEmpty()) {
		Task task = dequeue();
		if (task.time <= q) {
			sum_time += task.time;
			cout << task.name << " " << sum_time << endl;
		} else {
			sum_time += q;
			task.time -= q;
			enqueue(task);
		}
	}

	return 0;
}


Measured memory_bytes: 21128
#include <iostream>
#include <algorithm>

using namespace std;

#define INF 2000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;


int main()
{
	int n;
	cin >> n;
	ll a[n];
	ll b[n];

	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}
	ll tmp = 0;
	for (int i = n-1; i >= 0; i--) {
		a[i] += tmp;
//		cout << "a[i]: " << a[i] << " b[i] : " << b[i]<< "\n";
		if (a[i]%b[i]!=0) {
			if (a[i] > b[i]) {
				tmp += b[i] - (a[i] % b[i]);
			} else {
				tmp += b[i] - a[i];
			}
//			cout << "tmp: " << tmp << "\n";
		}
	}

	cout << tmp << endl;

}


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

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define INF (1 << 30)
#define REP(i, m, n) for(int i = (int)m; i < (int)n; ++i)
#define rep(i, n) REP(i, 0, n)


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

    int n, a, b; cin >> n >> a >> b;
    int tmp = n-b;
    a += tmp, b += tmp;
    cout << (abs(a-b)&1 ? "Borys" : "Alice") << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>

typedef long long ll;
using namespace std;
int n,a[3],b[3];
int main(){
	scanf("%d",&n);
	scanf("%d%d%d",a,a+1,a+2);
	scanf("%d%d%d",b,b+1,b+2);
	ll ans=n;
	for(int i=0;i<5001;++i){
		int g=i*a[0];
		if(g>n)break;
		for(int j=0;j<5001;++j){
			int s=j*a[1];
			if(g+s>n)break;
			int nb=0,sb;
			if(a[2]<b[2]){
				nb=(n-g-s)/a[2];
			}
			sb=nb*a[2];
			ll now=1ll*i*b[0]+j*b[1]+nb*b[2]+(n-g-s-sb);
			if(ans<now)ans=now;
			if(a[1]>=b[1])break;
		}
		if(a[0]>=b[0])break;
	}
	ll m=ans;
	if(m==n)//All three get this orientation
	for(int i=0;i<123456789;++i){
		int g=i*b[0];
		if(g>m)break;
		for(int j=0;j<123456789;++j){
			int s=j*b[1];
			if(g+s>m)break;
			int nb=0,sb;
			if(a[2]>b[2]){
				nb=(m-g-s)/b[2];
			}
			sb=nb*b[2];
			ll now=1ll*i*a[0]+j*a[1]+nb*a[2]+(m-g-s-sb);
			if(ans<now)ans=now;
			if(a[1]<=b[1])break;
		}
		if(a[0]<=b[0])break;
	}else{//At least one get opposite orientation
		if(a[0]<b[0]){
			swap(a[0],a[2]);swap(b[0],b[2]);
		}
		if(a[1]<b[1]){
			swap(a[1],a[2]);swap(b[1],b[2]);
		}
		for(int i=0;i<31234567;++i){
			ll g=i*b[0];
			if(g>m)break;
			ll s=0,ss;
			if(a[1]>b[1]){
				s=(m-g)/b[1];
			}
			ss=s*b[1];
			ll now=i*a[0]+s*a[1]+(m-g-ss);
			if(ans<now)ans=now;
			if(a[0]<=b[0])break;
		}
	}
	printf("%lld\n",ans);
	return 0;
} 

Measured memory_bytes: 888
import math
MOD = 10 ** 9 + 7

N, M = map(int, input().split())

if N == M:
    ans = math.factorial(N) * math.factorial(M) * 2 % MOD
elif abs(N - M) == 1:
    ans = math.factorial(N) * math.factorial(M) % MOD
else:
    ans = 0
print(ans)


Measured memory_bytes: 5184
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
//constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

int main(void){
    string T;
    cin >> T;
    int N=T.length();
    rep(i,N){
        if(T[i]=='?') cout << "D";
        else cout << T[i];
    }
    cout << endl;
}

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

int h[1000005];
int day[1000005];

int main(){
  int n;
  cin>>n;
  vector<int> g[1000005];
  rep(i,n){
    int from;
    cin>>from; from--;
    rep(j,n-2){
      int to;
      cin>>to; to--;
      int a=i*n+from;
      if(i>from) a=from*n+i;
      int b=i*n+to;
      if(i>to) b=to*n+i;
      g[a].push_back(b);
      h[b]++;
      from=to;
    }
  }

  queue<int> q;
  rep(i,n*n) if(h[i]==0){
    q.push(i);
    day[i]=1;
  }
  while(q.size()){
    int p1=q.front(); q.pop();
    for(int p2:g[p1]){
      h[p2]--;
      if(h[p2]==0){
	day[p2]=day[p1]+1;
	q.push(p2);
      }
    }
  }
  int ans=0;
  rep(i,n*n){
    if(day[i]==0){
      cout<<-1<<endl;
      return 0;
    }
    ans=max(ans,day[i]);
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 49152
void main() {
	auto ip = readAs!(long[]), N = ip[0], P = ip[1];
	auto A = readAs!(long[]);
	if(A.all!"a % 2 == 0") writeln(P == 0 ? 2^^N : 0);
	else writeln(2^^(N-1));
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


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

using namespace std;

int d,m,n;

vector<int> shop;
vector<int> home;

int main(){
	int self;
	while(1){
		shop.clear();
		home.clear();
		
		scanf("%d",&d);
		if(d == 0){break;}
		scanf("%d %d",&n,&m);
		for(int i=0;i<n - 1;i++){
			scanf("%d",&self);
			shop.push_back(self);
		}
		shop.push_back(0);
		shop.push_back(d);
		for(int i=0;i<m;i++){
			scanf("%d",&self);
			home.push_back(self);
		}
		sort(shop.begin(),shop.end());
		vector<int>::iterator it;
		int ans = 0;
		int a;
		for(int i=0;i<m;i++){
			it = lower_bound(shop.begin(),shop.end(),home[i]);
		
			if(it == shop.begin()){
				a = abs(home[i] - *it);
			}else{
				a = abs(home[i] - *it) < abs(home[i] - *(it - 1)) ? abs(home[i] - *it) : abs(home[i] - *(it - 1));
			}
			//printf("%d -> %d : %d\n",home[i],*it,a);
			ans += a;
		}
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 1436
#include <stdio.h>

int main(void){

  char c;
	scanf("%c", &c);
	if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {
		printf("vowel\n");
	} else {
		printf("consonant\n");
	}

  return 0;
}

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

using namespace std;

typedef long long ll;

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

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

int main(){
    ll X,ANS=1;
    cin>>X;
    for(int i=1;i<=X;i++){
        for(int j=2;j<=X;j++){
            if(pow(i,j)<=X)if(ANS<pow(i,j))ANS=pow(i,j);
        }
    }
    cout<<ANS<<endl;
    return 0;
}

//a=97,z=122

Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>

using namespace std;

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

  int sum = 0;
  vector<int> score;
  for (int i = 0; i < n; i++) {
    int s;
    cin >> s;
    sum += s;
    if (s % 10 != 0) {
      score.push_back(s);
    }
  }
  sort(score.begin(), score.end());

  if (sum % 10 != 0) {
    cout << sum << endl;
  } else {
    if (score.size() == 0) {
      cout << 0 << endl;
    } else {
      cout << sum - score[0] << endl;
    }
  }
  return 0;
}

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

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    int h, w;
    cin >> h >> w;
    vector< vs32 > c(10, vs32(10));
    rep (i, 10) rep (j, 10) cin >> c[i][j];

    rep (k, 10)
    {
        rep (i, 10)
        {
            rep (j, 10)
            {
                c[i][j] = MIN(c[i][j], c[i][k] + c[k][j]);
            }
        }
    }

    int ans = 0;
    int a;
    rep (i, h)
    {
        rep (j, w)
        {
            cin >> a;
            if (a != -1)
            {
                ans += c[a][1];
            }
        }
    }
    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 256
#include<iostream>

using namespace std;

typedef long long ll;

int main(){
  int N;
  cin >> N ;
  ll A[N];
  ll X[N+1];
  ll S;
  for (int i = 0; i < N; i++){
    cin >> A[i];
  }
  for (int i = 0; i < N ; i++){
    S+=A[i];
  }
  X[0] = S;
  for(int i = 1; i < N; i+=2){
    X[0] -= 2*A[i];
  }
  cout << X[0] << " ";
  for(int i = 1; i < N; i++){
    X[i] = 2*A[i-1] - X[i-1];
    cout << X[i] << " ";
  }
  cout << endl;
}


Measured memory_bytes: 2816
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_imports)]
use std::collections::HashSet;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::collections::VecDeque;
use std::cmp::{max, min};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        k: i64,
        x: i64
    }
    for i in x - k + 1..x + k {
        print!("{} ", i);
    }
    println!();
}

Measured memory_bytes: 4352
#include <iostream>
#include  <algorithm>
#include <vector>
#include <utility>
using namespace std;
typedef long long ll;

ll ary[200010];
int main(){
	ll N,K,tmp;
	cin>>N>>K;
	for(ll i=1;i<=N;i++){
		cin>>tmp;
		ary[tmp]++;
	}

	vector<pair<ll,ll> > vec;
	for(ll i=1;i<=N;i++) vec.push_back(make_pair(ary[i],i));
	sort(vec.begin(),vec.end());

	ll res=0,va=vec.size();
	for(ll i=1;i<=va-K;i++) res+=vec[i-1].first;
	cout<<res<<endl;
	return 0;
}



Measured memory_bytes: 7664
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using namespace std;
using ll = long long int;

const ll MOD = 1e9 + 7;

ll pow_fast(ll n, ll k) {
  if (k == 0) {
    return 1LL;
  }
  if (k == 1) {
    return n;
  }

  if (k % 2 == 0) {
    ll tmp = pow_fast(n, k / 2);
    return tmp * tmp % MOD;
  } else {
    ll tmp = pow_fast(n, (k - 1) / 2);
    tmp *= tmp;
    tmp %= MOD;
    return tmp * n % MOD;
  }
}

template <typename T>
class stack {
 private:
  vector<T> _vec;

 public:
  stack(){};

  void push(T n) {
    _vec.push_back(n);
    return;
  }

  void pop() {
    if (this->empty()) {
      return;
    }
    _vec.erase(_vec.end() - 1);
    _vec.shrink_to_fit();
    return;
  }

  size_t size() { return _vec.size(); }

  T top() { return _vec[this->size() - 1]; }
  bool empty() { return _vec.empty(); }
};

int main() {
  ll N;
  cin >> N;
  map<ll, ll> button;
  for (ll i = 0; i < N; i++) {
    ll ai;
    cin >> ai;
    button[i + 1] = ai;
  }

  ll cur = 1;
  for (ll i = 0; i < 1e6; i++) {
    cur = button[cur];
    if (cur == 2) {
      cout << (i + 1) << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}

Measured memory_bytes: 9852
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

#define INX(x) (cin >> x)
#define OUTX(x) (cout << x << endl)

#define ADD emplace_back
#define MP make_pair
#define VVEC(type) vector<vector<type>>


int main()
{
    ll N, X, T;
    cin >> N >> X >> T;

    if(N % X == 0)
    {
        cout << (N / X) * T << endl;
    }
    else
    {
        cout << (N / X + 1) * T << endl;
    }

    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
using namespace std;

#define PI 3.14159265358979323846264338327950L

long long int res;

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

    long double A;
    long double B;
    //double floor(double);
    cin >> A;
    cin >> B;
    res = A * B;
    res = (long long int)res;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3752
#include <iostream>
#include <vector>
#include<algorithm>
#include<map>
#include<cmath>
using namespace std;
#define rep(i,n) for(int i =0;i < n;i++)
int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int r = a % b;
    int l = r;int k = 0;
    bool P = false;
    while (r != c || k == 0 ) {
        r = (r + l) % b;
        if (r == c) {
            P = true;
        }
        if (r == l)
            break;
        k++;
    }
    if (P)  cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 2e5 + 10;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1);
const ll mod = 1e9 + 7;
int n, c[N], cnt[N], siz[N];
ll cal(int x) {
	return 1ll * x*(x - 1) / 2 + x;
}
ll ans[N];
vector<int>G[N];
void dfs(int u, int _fa) {
	siz[u] = 1;
	int tmp = cnt[c[u]];
	for (int v : G[u]) {
		if (v == _fa)continue;
		cnt[c[u]] = 0;
		dfs(v, u);
		siz[u] += siz[v];
		ans[c[u]] += cal(siz[v] - cnt[c[u]]);
	}
	cnt[c[u]] = tmp + siz[u];
}
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)scanf("%d", &c[i]);
	for (int i = 1; i < n; i++) {
		int u, v;
		scanf("%d%d", &u, &v);
		G[u].push_back(v);
		G[v].push_back(u);
	}
	dfs(1, 0);
	for (int i = 1; i <= n; i++) {
		printf("%lld\n", cal(n) - ans[i] - cal(n - cnt[i]));
	}
	return 0;
}

Measured memory_bytes: 34196
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	long long int a,b,c;
	cin>>a>>b>>c;
	if(c-a-b<0 || 4*a*b>=(c-a-b)*(c-a-b))cout<<"No";
	else cout<<"Yes"; 
	return 0;
}

Measured memory_bytes: 256
n = int(input())
s = [input() for i in range(n)] 
d = {'AC': 0, 'WA': 0, 'TLE': 0, 'RE': 0}

for i in s:
    d[i] += 1

for i in d.keys():
    print(i + ' x ' + str(d[i]))


Measured memory_bytes: 16332
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define scan(arg) cin>>arg
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
using namespace std;
typedef long long ll;
const int NMAX=1<<17;
int n;
int x[110],y[110],h[110];
int main(){
  scan(n);
  rep(i,n){
    scan(x[i]);scan(y[i]);scan(h[i]);
  }
  rep(i,n){
    if(h[i]!=0){
      int tx=x[i],ty=y[i],th=h[i];
      x[i]=x[0];y[i]=y[0];h[i]=h[0];
      x[0]=tx;y[0]=ty;h[0]=th;
      break;
    }
  }
  
  int cx,cy,H;
  bool f=true;
  rep(i,101){
    rep(j,101){
      H=abs(x[0]-i)+abs(y[0]-j)+h[0];
      rep1(k,n-1){
	if(h[k]==max(H-abs(x[k]-i)-abs(y[k]-j),0)){
	  f=true;
	}
	else{
	  f=false;
	  break;
	}
      }
      if(f){
	cx=i;cy=j;
	goto OUT;
      }
    }
  }
 OUT:
  cout<<cx<<" "<<cy<<" "<<H<<"\n";

  
  
  return 0;
}


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

int main() {
  ll mod = 1000000007;
  ll n, k, ans;
  cin >> n >> k;
  vector<ll> tmp(n+1);
  ans = 0;
  rep(j, n + 1) {
    tmp[j] = j >= 1 ? (tmp[j - 1] + (n - j - j)) : (n - j - j);
  }
  for(int i = k; i <= n + 1; i++) {
    ans += (tmp[i - 1] + 1);
  }
  cout << ans % mod << endl;
  return 0;
}

Measured memory_bytes: 4820
#include <algorithm>
#include <iostream>
#include <math.h>
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <stack>
#include <map>
#define maxn 100000 + 5
#define INF 0x3f3f3f3f
#define xin(a) scanf("%d", &a)
#define ffr(i,m, n) for (i = m; i < n; i++)
#define clr(a, b) memset(a, b, sizeof(a));
#define pi acos(-1,0)
typedef double db;
typedef long long ll;
using namespace std;
void t(void)
{
    int t, n;
    xin(t);
    while (t--)
    {

    }
}
void n(void)
{
    int n, i,d;
    while(~xin(n))
    cout<<(n%1000?1000-n%1000:0)<<endl;
}
int main(void)
{
    #ifndef ONLINE_JUDGE
    long _begin_time = clock();
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    #endif
    n();
    #ifndef ONLINE_JUDGE
    long _end_time = clock();
    printf("time = %ld ms\n", _end_time - _begin_time);
    fclose(stdin);
    fclose(stdout);
    #endif
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    int m1, d1, m2, d2;
    cin >> m1 >> d1 >> m2 >> d2;
    if ( m2 == m1 ) cout << 0 << endl;
    else            cout << 1 << endl;
    return 0;
}


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

using ll = long long;

using namespace std;

using P = pair<double, double>;

int main() {
    int n;
    cin >> n;
    P en[n];
    for (auto &ei:en) cin >> ei.first >> ei.second;
    double best = 0;
    for (int i=0; i<1000000; i++) {
        double theta = 2 * M_PI * i / 1000000;
        double x = cos(theta), y = sin(theta),
               sum = 0;
        for (auto &ei:en)
            sum += max(0., x * ei.first + y * ei.second);
        best = max(best, sum);
    }
    cout << setprecision(15) << best << '\n';
    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

int n, k;
char str[100];

int main(void)
{
	scanf("%d %d%*c", &n, &k);
	int i;
	for(i=0;i<n;i++)
		scanf("%c", &str[i]);
	str[n] = '¥0';

	str[k-1] += 32;
	
	
	//printf("%s", str);
	for(i=0;i<n;i++) printf("%c", str[i]);
	return 0;
}


Measured memory_bytes: 128