akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
//void IO(){
//	#ifndef ONLINE_JUDGE
//	    freopen("input.txt", "r", stdin);
//	    freopen("output.txt", "w", stdout);
//	#endif
//}
// end of Template

int ans,a,b;
int main(){
	//IO();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>a>>b;
    ans = (a+b)/2;
    if((a+b)%2==1)ans++;
    cout<<ans<<newl;
}


Measured memory_bytes: 256
#!/usr/bin/python
# -*- coding: utf-8 -*-

n=int(raw_input())
maxv=n
for a in xrange(1,n):
  b=n-a
  if a>b: break
  sa=sum([int(x) for x in str(a)])
  sb=sum([int(x) for x in str(b)])
  maxv=min(maxv, sa+sb)
print(maxv)

Measured memory_bytes: 2568
package main

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

var sc *bufio.Scanner

const BufferSize = 1024

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

var production bool

func debugf(format string, v ...interface{}) {
	if !production {
		fmt.Printf(format, v...)
	}
}

/*
3-8+7-5+5
2
8-7+5-5+3
4
7-5+5-3+8
12
5-5+3-8+7
2
5-3+8-7+5
8
*/

func answer(reader io.Reader, writer io.Writer) {
	sc = bufio.NewScanner(reader)
	buf := make([]byte, BufferSize)
	sc.Buffer(buf, 1e+6)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	a := make([]int, n)
	x := make([]int, n)

	for i := range a {
		a[i] = nextInt()
	}

	for i := 0; i < n; i++ {
		flag := i % 2
		if flag == 0 {
			x[0] += a[i]
		} else {
			x[0] -= a[i]
		}
	}
	for i := 1; i < n; i++ {
		x[i] = -x[i-1] + a[i-1]*2
	}

	/*
		for i := 0; i < n; i++ {
			for j := 0; j < n; j++ {
				idx := (i + j) % n
				flag := j % 2
				if flag == 0 {
					x[i] += a[idx]
				} else {
					x[i] -= a[idx]
				}
			}
		}
	*/
	debugf("%v\n", x)

	for i := 0; i < n; i++ {
		_, _ = fmt.Fprintf(writer, "%d", x[i])
		if i < n-1 {
			_, _ = fmt.Fprint(writer, " ")
		}
	}
}

func main() {
	production = true
	answer(os.Stdin, os.Stdout)
}


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

int main() {
    long long N, K;
    cin >> N >> K;
    vector<long long> A(N + 1);
    for (long long i = 1; i <= N; i++) {
        cin >> A[i];
    }

    long long a = 1, b = 1;
    long long loopcnt = 0;
    for (;;) {
        loopcnt++;
        a = A[A[a]];
        b = A[b];
        if (a == b) {
            break;
        }
    }
    long long lambda = 0;
    a = 1;
    for (;;) {
        loopcnt++;
        lambda++;
        a = A[a];
        b = A[b];
        if (a == b) {
            break;
        }
    }
    long long l = loopcnt - lambda;

    if (K <= lambda) {
        long long next = 1;
        for (long long i = 0; i < K; i++) {
            next = A[next];
        }
        cout << next << endl;
        return 0;
    }
    K -= lambda;
    K = K % l;
    long long next = 1;
    for (long long i = 0; i < lambda; i++) {
        next = A[next];
    }

    for (long long i = 0; i < K; i++) {
        next = A[next];
    }
    cout << next << endl;
    return 0;
}


Measured memory_bytes: 4844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b+1;i++)
#define Per(i,b,a) for(int i=b;i>=a;i--)
int main(){
    int N;
    cin>>N;
    ll a;
    vector<ll> vec;
    rep(i,N){
        cin>>a;
        vec.push_back(a);
    } 
    sort(vec.begin(),vec.end());
    reverse(vec.begin(),vec.end());
    int count = 0;
    ll ans = 0;
    rep(i,N){
        if(i == 0){
            ans+=vec[i];
            count++;
        }else{
            if(count<N-2){
                ans+=vec[i]*2;
                count+=2;
            }else{
                ans+=vec[i];
                count+=1;
            }
        }
        if(count==N-1)break;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5372
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
long long d[110000];
pair<long long,int> p[110000];
int sz[110000];
int L[110000];
int R[110000];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++){
		scanf("%lld",d+i);
		p[i]=make_pair(d[i],i);
	}
	std::sort(p,p+a);
	int ind=0;
	long long sum=0;
	for(int i=0;i<a;i++)sz[i]=1;
	for(int i=a-1;i>=1;i--){
		int at=p[i].second;
		long long C=p[i].first;
		int ad=a-2*sz[at];
		if(ad<=0){
			printf("-1\n");return 0;
		}
		int in=lower_bound(p,p+a,make_pair(C-ad,0))-p;
		if(p[in].first!=C-ad){
			printf("-1\n");return 0;
		}
		L[ind]=p[i].second;
		R[ind++]=p[in].second;
		sum+=(long long)sz[at]*(a-sz[at])*2;
	//	printf("%d %d\n",L[ind-1],R[ind-1]);
		sz[p[in].second]+=sz[at];
	}
	long long dsum=0;
	for(int i=0;i<a;i++){
		dsum+=d[i];
	}
	if(sum!=dsum){
		printf("-1\n");return 0;
	}
	for(int i=0;i<ind;i++){
		printf("%d %d\n",L[i]+1,R[i]+1);
	}
}


Measured memory_bytes: 4864
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=2e9;

int main(){
    int n,T;
    cin>>n>>T;
    int t[200010];
    for(int i=0;i<n;i++)cin>>t[i];
    t[n]=2e9+10;
    int ans=0;
    for(int i=0;i<n;i++){
        ans+=min(T,t[i+1]-t[i]);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
//my vegetable has exploded. :(
#include<bits/stdc++.h>
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define MM(x,y) memset(x,y,sizeof(x))
#define MCPY(a,b) memcpy(a,b,sizeof(b))
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=b;i>=a;i--)
#define fi first
#define se second
using namespace std;
#define int long long
inline int quickpow(int m,int n,int p){int b=1;while(n){if(n&1)b=b*m%p;n=n>>1;m=m*m%p;}return b;}
inline int getinv(int x,int p){return quickpow(x,p-2,p);}
inline int read(void){
    int x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){f=ch=='-'?-1:1;ch=getchar();}
    while(isdigit(ch)){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
    return x * f;
}
bitset<4000010>f;
int n,k,ret = 0;
///------------------head------------------
signed main(signed argc, char *argv[]){
    n=read();
    f[0] = 1;
    while(n--){
        int x = read();
        f=f|(f<<x);
        ret += x;
    }
    for (k = (ret+1)>>1; !f[k]; ++k);
    printf("%lld\n",k);
    return 0;
}

/* Examples: */
/*

*/

/*

*/


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

#define all(n) n.begin(),n.end()
#define ll long long

#define pb push_back
#define eb emplace_back
#define endl "\n"
#define pll pair<ll,ll>
#define ff first
#define ss second

using namespace std;
const ll maxn=5e5+2;
const ll maxx=1e16;
const ll mod=1e9+7;
const ll mod1=998244353;
vector<ll> adj[maxn];
ll a[maxn];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    if (fopen("TEAMS.INP","r"))
    {
        freopen("TEAMS.INP", "r", stdin);
        freopen("TEAMS.OUT", "w", stdout);
    }
   ll x , n;
    cin>>x>> n;
     for (int i=1;i<=n;i++)
     {
         ll y;
          cin>>y;
          a[y]=1;
     }
      ll mn=1e15;
      ll ans;
      for (int i=x-200;i<=x+200;i++)
      {
          if (a[i]) continue;
          ll t= abs(x-i);
          if (t<mn)
          {
              mn=t;
              ans=i;
          }
      }
      cout <<ans;
}


Measured memory_bytes: 15372
#include<iostream>
using namespace std;
int main(){
	int cnt2=0;
	while(true){
		int a,b;
		cin>>a>>b;
		if(a==0 && b==0){break;}
		if(cnt2>=1){cout<<endl;}
		cnt2++;
		int cnt=0;
		for(int i=a;i<=b;i++){
			if(i%400==0){cout<<i<<endl;cnt++;}
			else if(i%4==0 && i%100>=1){cout<<i<<endl;cnt++;}
		}
		if(cnt==0){cout<<"NA"<<endl;}
	}
}

Measured memory_bytes: 1160
# -*- coding: utf-8 -*-
N = int(input())
S = str(input())
K = int(input())

Sk = S[K-1]
a = []

for i,char in enumerate(S):
  if char != Sk:
    a.append(str('*'))
  else:
    a.append(char)

print(''.join(a))

Measured memory_bytes: 3060
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func vi(n int, args ...int) []int {
	res := make([]int, n)
	if len(args) == 0 {
		return res
	}
	v := args[0]
	if v == 0 {
		return res
	}
	for i := 0; i < n; i++ {
		res[i] = v
	}
	return res
}

func vvi(n int, args ...int) [][]int {
	res := make([][]int, n)
	m := n
	if len(args) > 0 {
		m = args[0]
	}
	v := 0
	if len(args) > 1 {
		v = args[1]
	}
	for i := 0; i < n; i++ {
		res[i] = vi(m, v)
	}
	return res
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
func gcd(a, b int64) int64 {
	if a < b {
		return gcd_r(b, a)
	}
	return gcd_r(a, b)
}

func gcd_r(a, b int64) int64 {
	if b == 0 {
		return a
	}
	return gcd_r(b, a%b)
}

func main() {
	defer stdout.Flush()
	n := readInt64()
	ans := readInt64()
	for i := int64(1); i < n; i++ {
		t := readInt64()
		g := gcd(ans, t)
		ans *= (t / g)
	}
	println(ans)
}


Measured memory_bytes: 640
#include<stdio.h>
int main(void){
  int height[10];
  int h;
  int i;
  for(i=1;i<=10;i++){
     scanf("%d",&h);
	 height[i-1]=h;
	 }
  int j=0,k=0,tmp=0;
  for(;j<=8;j++){
    for(k=0;k<=8;k++){
	   if(height[k]<height[k+1]){
	     tmp=height[k+1];
		 height[k+1]=height[k];
		 height[k]=tmp;
		 }
		 }
		 }
  printf("%d\n%d\n%d\n",height[0],height[1],height[2]);
return 0;
}

Measured memory_bytes: 600
package main

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

//=====I/O=====

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//=====main=====

func main() {
	sc.Split(bufio.ScanWords)

	h, w := scanInt(), scanInt()

	a := make([][]int, h+1)
	b := make([][]int, h+1)

	for i := 1; i < h+1; i++ {
		a[i] = make([]int, w+1)
		for j := 1; j < w+1; j++ {
			a[i][j] = scanInt()
		}
	}

	for i := 1; i < h+1; i++ {
		b[i] = make([]int, w+1)
		for j := 1; j < w+1; j++ {
			b[i][j] = scanInt()
		}
	}

	dp := [81][81][160*80]bool{}

	dp[0][1][0], dp[1][0][0] = true, true

	for i := 1; i<w+1 && i<h+1; i++ {
		for j := i; j < w+1; j++ {
			for k := 0; k < (w+h)*80; k++ {
				if dp[i-1][j][k] || dp[i][j-1][k] {
					diff := abs(a[i][j] - b[i][j])
					if k + diff < (w+h)*80 {
						dp[i][j][k+diff] = true
					}

					if k - diff < 0 {
						dp[i][j][diff-k] = true
					} else {
						dp[i][j][k-diff] = true
					}
				}
			}
		}

		for j := i; j < h+1; j++ {
			for k := 0; k < (w+h)*80; k++ {
				if dp[j-1][i][k]|| dp[j][i-1][k] {
					diff := abs(a[j][i] - b[j][i])
					if k + diff < (w+h)*80 {
						dp[j][i][k+diff] = true
					}
					if k - diff < 0 {
						dp[j][i][diff-k] = true
					} else {
						dp[j][i][k-diff] = true
					}
				}
			}
		}
	}

	var ans int
	for i := 0; i < (w+h)*80; i++ {
		if dp[h][w][i] {
			ans = i
			break
		}
	}

	fmt.Println(ans)
}

func abs(a int) int {
	if a<0 {
		return -a
	}
	return a
}


Measured memory_bytes: 85504
# -*- coding:utf-8 -*-

def solve():
    N, A = list(map(int, input().split()))
    X = list(map(int, input().split()))

    dp = [[[0 for _ in range(50*50+1)] for __ in range(N+1)] for ___ in range(N+1)]
    dp[0][0][0] = 1  # 何も選んでない初期値

    """
    dp[i][j][k] := 左からi+1枚目までに、j枚のカードを選んで、選んだカードの総和がkになる選び方の総数
    i: 左からi+1枚目のカード
    j: j枚のカードを選んだ
    k: 選んだカードの総和
    """
    for i in range(0, N):
        for j in range(0, N):
            for k in range(50*50+1):
                dp[i+1][j][k] += dp[i][j][k]  # i枚目を選ばない
                if k-X[i] >= 0:
                    dp[i+1][j+1][k] += dp[i][j][k-X[i]]  # i枚目を選んだ

    ans = 0
    for j in range(1, N+1):  # 1枚以上選ぶ必要がある
        ans += dp[N][j][j*A]
    print(ans)


if __name__ == "__main__":
    solve()


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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if(a + b + c >= 22) cout << "bust" << endl;
  else cout << "win" << endl;
}


Measured memory_bytes: 764
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		String[] temp = scanner.nextLine().split(" ");
		int n = Integer.parseInt(temp[0]);
		int m = Integer.parseInt(temp[1]);
		int a = 0;
		int b = 0;

		Map<Integer, Integer> map = new HashMap<Integer,Integer>();

		for(int i = 0; i < m; i++) {

			String[] tmp = scanner.nextLine().split(" ");
			a = Integer.parseInt(tmp[0]);
			b = Integer.parseInt(tmp[1]);
			if(map.containsKey(a)) {

				if(map.get(a) != b) {

					System.out.println("-1");
					return;
				}
			}else {

				map.put(a, b);

			}
		}



		StringBuilder sb = new StringBuilder();


		if(map.containsKey(1)) {
			if(map.get(1) == 0 && n != 1) {
				System.out.println("-1");
				return;
			}else {
				sb.append(map.get(1));
			}
		}else if(n == 1){
			System.out.println("0");
			return;
		}else if(n != 1) {
			sb.append("1");
		}

		for(int i = 2; i < n + 1; i++) {

			if(map.containsKey(i)) {

				sb.append(map.get(i));

			}else {
				sb.append("0");
			}

		}

		System.out.println(sb.toString());

	}
}

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

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

    long long ans = 1e12;
    for (int i = 1e6; i >= 1; i--) {
        if (n % i == 0) {
            ans = min(ans, (i - 1) + (n / i - 1));
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
# define BUFSIZE 10000

int  main(void){
char S_hoge[BUFSIZE]={0};
char T_hoge[BUFSIZE]={0};
int N=0;
scanf("%d",&N);

for(int i=0;i<N;i++){
	scanf(" %c",&S_hoge[i]);
	}
for(int i=0;i<N;i++){
	scanf(" %c",&T_hoge[i]);
	}
for(int i=0;i<N;i++){
	printf("%c%c",S_hoge[i],T_hoge[i]);
	}
}
	
	
	


	
	



Measured memory_bytes: 128
#include <stdio.h>
int main(void)
{
	int i,j;
	int H,W;
	
	while(1)
	{
	scanf("%d %d",&H,&W);//縦と横の長さの入力
	
		if(H==0&&W==0)
		{
			break;
		}
		for(i=0;i<H;i++)
		{
			for(j=0;j<W;j++)
			{
				if((j+i)%2==0)
				{
					printf("#");
				}
				else
				{
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2000
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long h = sc.nextLong();
        if (h < 2) {
            System.out.println(h);
            return ;
        }
        // how 2:pow
        int p = 0;
        while (true) {
            double p1 = Math.pow(2, p);
            double p2 = Math.pow(2, p+1);
            if (p1 <= h && h < p2) {
                break;
            }
            p++;
        }

        long[] memo = new long[p+1];
        memo[1] = 3;
        for (int i=2;i<=p;i++) {
            memo[i] = (memo[i - 1] - 1) * 2 + 3;
        }

        System.out.println(memo[p]);

    }
}


Measured memory_bytes: 23764
n,m=gets.chomp.split.map(&:to_i)
x=gets.chomp.split.map(&:to_i).sort
y=gets.chomp.split.map(&:to_i).sort

MOD=10**9+7
s=0
1.upto(n) do |i|
  s += -(n-i)*x[i-1] + (i-1) * x[i-1]
  s %= MOD
end
t=0
1.upto(m) do |i|
  t += -(m-i)*y[i-1] + (i-1) * y[i-1]
  t %= MOD
end
puts s*t%MOD


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

typedef long long ll;
#define ar array
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define all(x) (x).begin(), (x).end()
#define en '\n'
#define FILL(x, v) memset(x, v, sizeof(x))
#define pb push_back
#define fast                     \
	ios::sync_with_stdio(false); \
	cin.tie(NULL);               \
	cout.tie(NULL);
#define F_OR(i, a, b, s) for (int i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...)       \
	F_ORC(__VA_ARGS__) \
	(__VA_ARGS__)

#define E_ACH2(x, a) for (auto &x : a)
#define E_ACH3(x, y, a) for (auto &[x, y] : a)
#define E_ACH4(x, y, z, a) for (auto &[x, y, z] : a)
#define E_ACHC(...) GET5(__VA_ARGS__, E_ACH4, E_ACH3, E_ACH2)
#define EACH(...)       \
	E_ACHC(__VA_ARGS__) \
	(__VA_ARGS__)

template <typename A, typename B>
inline void chmin(A &a, B b)
{
	if (a > b)
		a = b;
}
template <typename A, typename B>
inline void chmax(A &a, B b)
{
	if (a < b)
		a = b;
}

int main()
{
	fast;
	int n, ans = 0;
	cin >> n;
	vi a(n);
	FOR(n)
		cin >> a[i];
	for (int i = 1; i <= n; i++)
		if (i & 1 && a[i - 1] & 1)
			ans++;
	cout << ans;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <cstring>
#include <queue>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cstdlib>
#include <sstream>
#include <bitset>

using namespace std;

//#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i=0;i<n;i++)

//static const ll MOD = 1000000007;
//static const ll INF = 100000000;
//#define PI 3.14159265359


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

    ll d;

    // process
    ll ans = N;
    vector<ll> sunuke(N, 0);

    rep(i, K) {
        cin >> d;
        rep(j, d) {
            ll a;
            cin >> a;
            if (sunuke[a-1] == 0) {
                ans--;
                sunuke[a-1] = 1;
            }
        }
    }

    cout << ans;
    return 0;
}


Measured memory_bytes: 3192
#include <iostream>
using namespace std;
int a,b;
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>a>>b;
	b*=2;
	if (b>=a) cout<<"0";
	else cout<<a-b;
	return 0;
}

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

int main()
{
    string s;
    int i;
    int judge[4] = {0};
    
    cin >> s;
    
    for(i = 0; i < s.length(); i++) {
        if(s[i] == 'E') {
            judge[0] = 1;
        } else if(s[i] == 'W') {
            judge[1] = 1;
        } else if(s[i] == 'S') {
            judge[2] = 1;
        } else {
            judge[3] = 1;
        }
    }
    
    if((judge[0] != judge[1]) || (judge[2] != judge[3])) {
        cout << "No\n";
    } else {
        cout << "Yes\n";
    }
    return 0;
}

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

#define pb push_back
#define vi vector < int >
#define ii pair < int, int >
#define vii vector < pair < int, int > >
#define vvi vector < vector < int > >
#define ll long long
#define X first
#define Y second
#define mp make_pair
#define FOR( i, lo, hi ) for( int i = (lo);i < (hi);i++ )
#define DFOR( i, hi, lo ) for( int i = (hi);i >= (lo);i-- )
#define pqueue priority_queue

using namespace std;

const int MAXN = 1e5 + 10, MOD = 1e9 + 7;

int A[ 6 ] = { 1, 10, 9, 12, 3, 4 };
int n;
string s;
int dp[ MAXN ][ 20 ];

int ADD( int a, int b )
{
	ll ret = (ll)a + (ll)b;
	if ( ret < 0 )
		ret += MOD;
	if ( ret >= MOD )
		ret -= MOD;
	return ret;
}

int rek( int dig, int mod, int place )
{
	if ( dp[ dig ][ mod ] != -1 )
		return dp[ dig ][ mod ];
	
	//cout << dig << ' ' << mod << ' ' << place << "\n";
	if ( dig == 0 )
	{
		return dp[ dig ][ mod ] = ( ( mod ) == 5 );
	}
	
	int ret = 0;
	if ( s[ dig - 1 ] != '?' )
	{
		int x = ( int )s[ dig - 1 ] - 48;
		ret = ADD( ret, rek( dig - 1, ( x * A[ ( place + 1 ) % 6 ] + mod ) % 13, ( place + 1 ) % 6 ) );
	}
	else
	{
		FOR( i, 0, 10 )
		{
			//cout << i << ' ' << A[ ( place + 1 ) % 6 ] << ' ' << ( i * A[ ( place + 1 ) % 6 ] + mod ) % 13 << "\n";
			ret = ADD( ret, rek( dig - 1, ( i * A[ ( place + 1 ) % 6 ] + mod ) % 13, ( place + 1 ) % 6 ) );
		}
	}	
	//cout << ret << "\n";
	return dp[ dig ][ mod ] = ret;
}

int main()
{
	cin >> s;
	n = s.size();
	
	memset( dp, -1, sizeof dp );
	cout << rek( n, 0, -1 ) << "\n";
	return 0;
}


Measured memory_bytes: 16128
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using namespace std;

int main(){
    while(true){
        int n;
        scanf("%d", &n);
        if(n == 0) break;
        int ans = 0;
        int d = 5;
        while(true){
            ans += n / d;
            d *= 5;
            if(d > n) break;
        }
        printf("%d\n", ans);
    }
    
    return 0;
}

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

public class Main{
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String[] matSize = in.readLine().split(" ");
		int n = Integer.parseInt(matSize[0]);
		int m = Integer.parseInt(matSize[1]);
		int[][] matrix = new int[n][m];
		int[] vectorB = new int[m];
		for (int i = 0; i < n; i += 1) {
			String[] input = in.readLine().split(" ");
			for (int j = 0; j < m; j += 1) {
				matrix[i][j] = Integer.parseInt(input[j]);
			}
		}
		for (int s = 0; s < m; s += 1) {
			vectorB[s] = Integer.parseInt(in.readLine());
		}
		for (int t = 0; t < n; t += 1) {
			int ans = 0;
			for (int u = 0; u < m; u += 1) {
				ans += matrix[t][u] * vectorB[u];
			}
			System.out.println(ans);
		}
	}
}

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

using namespace std;

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

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

	if(a > 8 || b > 8) cout << ":(" << endl;
	else cout << "Yay!" << endl;	

	return 0;

}


Measured memory_bytes: 256
A = int(input().strip())
B = int(input().strip())
C = int(input().strip())
X = int(input().strip())

count = 0

for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            if a*500 + b*100 + c*50 == X:
                count += 1

print(count)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
    int N, X, T, A=0, B=0, s=0, i;
        cin >> N>>X>> T;
        
        for (i=0;A < N;i++) {
        B = i / T;
        A = X * B;
        //B = A * i;
        //s+=1;
       // cout << T;
    }
    cout <<B*T;
}


Measured memory_bytes: 3592
#include<stdio.h>
int main(){

  int a[100][100],b[100],c[100],ac,bc,m,n,i,j;

  for(i=0;i<100;i++){
    for(j=0;j<100;j++){
      a[i][j]=0;
      b[i]=0;
      c[i]=0;
    }
  }

  scanf("%d%d",&m,&n);

  for(i=0;i<m;i++){
    for(j=0;j<n;j++){
      scanf("%d",&ac);
      a[i][j]=ac;
    }
  }
  
  for(i=0;i<n;i++){
    scanf("%d",&bc);
    b[i]=bc;
  }

  for(i=0;i<m;i++){
    for(j=0;j<n;j++){
      c[i]+=a[i][j]*b[j];
    }
  }
  for(i=0;i<m;i++){
    printf("%d\n",c[i]);
  }
  
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <functional>
#include <queue>
#include <map>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const int INF = 1e9 +7;

int main(){
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    REP(i, n){
        cin >> a[i];
    }
    int count1 = 0;
    REP(i, n){
        cin >> b[i];
        count1 += b[i];
    }
    REP(i, n-1){
        cin >> c[i];
    }
    int count2 = 0;
    REP(i, n){
        if(a[i+1] - a[i] == 1){
            count2 += c[a[i] - 1];
        }
    }

    cout << count1 + count2 << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

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

using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;

const int INF = 1001001001;

int main()
{
    int n;
    cin >> n;
    
    vi a(n);
    rep(i, n){
        cin >> a[i];
        a[i]--;
    }
    
    int cnt = 0;
    rep(i, n){
        if(a[a[i]] == i) ++cnt;
    }
    
    cout << cnt/2 << endl;
}


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

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

int INF = 1000000000;

typedef pair<int, int> P;
#define fs first
#define sc second

int main(){
    int h, w, K;
    cin >> h >> w >> K;

    string s[h];
    for(int i = 0; i < h; i++) cin >> s[i];

    int sx, sy;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(s[i][j] == 'S'){
                sx = i;
                sy = j;
            }
        }
    }

    //sから一回だけbfs
    vector<vector<int>> d(h, vector<int>(w, INF));
    queue<P> que;
    que.push(P(sx, sy));
    d[sx][sy] = 0;
    while(que.size()){
        P p = que.front();
        que.pop();

        for(int k = 0; k < 4; k++){
            int nx = p.fs + dx[k];
            int ny = p.sc + dy[k];

            if(0 <= nx && nx < h && 0 <= ny && ny < w){
                if(s[nx][ny] == '.' && d[nx][ny] == INF){
                    que.push(P(nx, ny));
                    d[nx][ny] = d[p.fs][p.sc] + 1;
                }
            }
        }
    }

    int dis = INF; //端までの距離
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(d[i][j] <= K){
                dis = min(dis, i);
                dis = min(dis, h - 1 - i);
                dis = min(dis, j);
                dis = min(dis, w - 1 - j);
            }
        }
    }

    cout << (dis + K - 1) / K + 1 << endl;
    return 0;
}


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

int main()
{
    int a,b,c,d,e,m;
    cin>>m;
    a=m/1000;
    m%=1000;
    b=m/100;
    m%=100;
    c=m/10;
    d=m%10;
    e=a+b+c+d;
    if(e==7)
    {
        printf("%d+%d+%d+%d=7",a,b,c,d);
        return 0;
    }
    e=a+b+c-d;
    if(e==7)
    {
        printf("%d+%d+%d-%d=7",a,b,c,d);
        return 0;
    }
    e=a+b-c+d;
    if(e==7)
    {
        printf("%d+%d-%d+%d=7",a,b,c,d);
        return 0;
    }
    e=a-b+c+d;
    if(e==7)
    {
        printf("%d-%d+%d+%d=7",a,b,c,d);
        return 0;
    }
    e=a-b-c+d;
    if(e==7)
    {
        printf("%d-%d-%d+%d=7",a,b,c,d);
        return 0;
    }
    e=a+b-c-d;
    if(e==7)
    {
        printf("%d+%d-%d-%d=7",a,b,c,d);
        return 0;
    }
    e=a-b+c-d;
    if(e==7)
    {
        printf("%d-%d+%d-%d=7",a,b,c,d);
        return 0;
    }
    e=a-b-c-d;
    if(e==7)
    {
        printf("%d-%d-%d-%d=7",a,b,c,d);
        return 0;
    }
}

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

int main()
{
  int n;
  cin >> n;
  vector<int> a(n + 1), b(n + 1);
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = n; i > 0; i--) {
    int x = 0;
    for (int j = i * 2; j <= n; j += i) {
      x ^= b[j];
    }
    b[i] = a[i] xor x;
  }
  vector<int> ans;
  for (int i = 1; i <= n; i++) {
    if (b[i] != 0) {
      ans.push_back(i);
    }
  }
  int s = ans.size();
  cout << s << endl;
  for (int i = 0; i < s; i++) {
    cout << ans[i];
    cout << (i == s - 1 ? '\n' : ' ');
  }
}


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define EPS 1e-6
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int a[11];
int len[11];
int len2[11];
int ord[11];
double ans=0.0;

double C(int n,double deg){
	double sum=deg;
	for(int i=1;i<n;i++){
		double cosi=(double)(len2[0]*len2[1])/(len2[i]*len2[(i+1)%n])*cos(deg);
		if(cosi>1.0){
			return 0.0;
		}
		if(cosi<-1.0){
			return 720;
		}
		sum+=acos(cosi);
	}
	return sum;
}

double calc(int n,double deg){
	double sum=0;
	for(int i=0;i<n;i++){
		double cosi=(double)(len2[0]*len2[1])/(len2[i]*len2[(i+1)%n])*cos(deg);
		//printf("%.5f ",cosi);
		double degi=acos(cosi);
		//printf("%.5f ",degi*180.0/M_PI);
		sum+=len2[i]*len2[(i+1)%n]*sin(degi);
	}
	//printf("\n");
	return sum;
}

double func(int n){
	for(int i=0;i<n;i++){
		len2[i]=len[ord[i]];
	}
	double l=EPS,r=M_PI;
	for(int i=0;i<50;i++){
		double mid=(l+r)/2.0;
		if(C(n,mid)<2*M_PI){
			l=mid;
		}else{
			r=mid;
		}
	}
	return calc(n,l);
}

void solve(int n){
	for(int i=0;i<n;i++){
		len[i]=a[i];
	}
	for(int i=0;i<n;i++){
		ord[i]=i;
	}
	do{
		ans=max(ans,func(n));
	}while(next_permutation(ord+1,ord+n));
}

int main(void){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	sort(a,a+n);
	reverse(a,a+n);
	for(int i=3;i<=n;i++){
		solve(i);
	}
	printf("%.9f\n",ans/2.0);
	return 0;
} 


Measured memory_bytes: 3700
#include <iostream>
#include <stdio.h>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <limits.h>
#include <assert.h>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <math.h>
#include <stack>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long int
#define db double
#define ldb long double
#define MOD 1000000007
#define Fi first
#define Se second
#define INF INT_MAX
#define NINF INT_MIN
#define L_INF LLONG_MAX
#define L_NINF LLONG_MIN
#define gc getchar
#define sz(x) (int)(x).size()
#define pii pair<int,int>
#define pll pair<ll,ll>

void fsscan(){ios_base::sync_with_stdio(false);cin.tie(NULL);}

void scani(int &x)
{
    register int c = gc();x = 0;int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = gc());
    if(c=='-') {neg=1;c=gc();}
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}

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

int main()
{
    fsscan();
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    
    ll max1 = max(a,b);
    ll max2 = max(c,d);
    
    ll min1 = min(a,b);
    ll min2 = min(c,d);
    
    /*if(max1>0 && max2>0) {
        cout<<max1*max2;
        return 0;
    }
    
    if(max1<0 && max2<0) {
        cout<<max1*max2;
        return 0;
    }*/
    //cout<<"hi";
    cout<<max(max(max1*min2,max2*min1),max(max1*max2,min1*min2));
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <fstream>

#include <cmath>
#include <string>

#include <algorithm>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

long arr[200000];
long dp[200000];

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

	int n, k;
	cin >> n >> k;
	for (int i = 1; i < n+1; i++) cin >> arr[i];

	arr[0] = 10000000;
	dp[0] = dp[1] = 0;
	for (int i = 2; i < n+1; i++) {
		dp[i] = dp[i-1] + abs(arr[i] - arr[i-1]);
		for (int j = i-1; (j > 0) && (j >= i-k); j--) {
			dp[i] = min(dp[i], dp[j] + abs(arr[i] - arr[j]));
		}
	}

	cout << dp[n] << endl;

	return 0;
}


Measured memory_bytes: 1792
from itertools import product

n, m = map(int, input().split())
KS = [
  list(map(int, input().split()))
  for _ in range(m)
]
P = list(map(int, input().split()))

count = 0
for S in product((0, 1), repeat=n):
  if all(sum(S[s - 1] for s in ks[1:]) % 2 == p for p, ks in zip(P, KS)):
    count += 1
print(count)
    

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

int main(){
    int n;
    while(cin >> n, n){
        vector<int> c(n);
        rep(i, 0, n){
            char s;
            cin >> s;
            c[i] = s - 'A';
        }
        int ans = n;
        vector<int> d(26);
        rep(i, 0, n){
            d[c[i]]++;
            vector<int> e = d;
            sort(e.begin(), e.end());
            reverse(e.begin(), e.end());
            if(e[0] > e[1] + n - i - 1){
                ans = i + 1;
                break;
            }
        }
        vector<int> e = d;
        sort(e.begin(), e.end());
        reverse(e.begin(), e.end());
        int res = -1, cnt = 0;
        rep(i, 0, 26){
            if(e[0] == d[i]){
                cnt++;
                res = i;
            }
        }
        if(cnt != 1) cout << "TIE" << endl;
        else{
            char x = 'A' + res;
            cout << x << " " << ans << endl;
        }
    }
}

Measured memory_bytes: 3124
N, T = map(int, input().split())
t = list(map(int, input().split()))

interval = [0] * N
for i in range(1, N):
    interval[i] = t[i] - t[i - 1]

ans = 0
for i in range(1, N):
    if interval[i] >= T:
        ans += T
    else:
        ans += interval[i]
#ans += T
print(ans + T)

Measured memory_bytes: 26708
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;
ll NUM = pow(10,9) + 7;

vector<ll> fact, fact_inv;
// 繰り返し二乗法
ll power(ll a, ll b){
	ll res=1;
	while(b>0){
		if(b&1) res=res*a%NUM;
		a=a*a%NUM;
		b>>=1;
	}
	return res;
}
void make_fact(int n){
	fact.resize(n+1);
	fact_inv.resize(n+1);
	fact[0] = fact[1] = 1;
	for(int i(2);i<=n;++i){
		fact[i] = (fact[i-1] * i)%NUM;
	}
	fact_inv[n]=power(fact[n], NUM-2);
    for(int i(n-1);i>0;--i){
		fact_inv[i]=fact_inv[i+1]*(i+1)%NUM;
	}
}

ll nCr(ll n, ll r){
	if(n == r || r == 0){
		return 1;
	}
	return (fact[n]*fact_inv[r])%NUM*fact_inv[n-r]%NUM;
}


int main(){
	int x,y;
	cin >> x >> y;
	if((x+y)%3 != 0){
		cout << 0 << endl;
		return 0;
	}
	if(2*y < x){
		cout << 0 << endl;
		return 0;
	}
	if(y > 2 * x){
		cout << 0 << endl;
		return 0;
	}
	int n = (x+y)/3;
	make_fact(2*n);
	ll ans = nCr(ll(n),ll(2*n-x));
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 21120
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

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



///////////////////////////



int main() {

	string s;
	cin >> s;
	rep(i, s.size()) cout << "x";
	

	
	

	
	system("PAUSE");

}


Measured memory_bytes: 504
#include <stdio.h>

int function(int i){
	if(i%5==0){
		return function(i/5)+1;
	}else{
		return 0;
	}
}

int main(){
	int i,j;
	int a,b;
	int n;
	while(1){
		scanf("%d",&a);
		if(a==0){
			break;
		}
		n=0;
		for(i=5;i<=a;i+=5){
			n+=function(i);
		}
		printf("%d\n",n);
	}
	return 0;
}

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

int main() {
	string s; cin >> s;
	for (int i = 0; i < (int) s.size(); i++) {
		if ((i % 2 && s[i] == 'R') || (i % 2 == 0 && s[i] == 'L')) {
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
}


Measured memory_bytes: 3568
import sys
import math
n = list(map(int, input().split()))
x = [list(map(int, input().split())) for i in range(n[0])]

len_x = 0
youso = 0
count = 0
for i in range(1, n[0]+1):
  for j in range(i+1, n[0]+1):
    youso = 0
    for k in range(0, n[1]):
      t = x[i-1][k]+(-1)*x[j-1][k]
      youso += t*t
    youso = math.sqrt(youso)
    if str(youso)[-1] == '0':
      count += 1
print(count)

Measured memory_bytes: 3064
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))
#define Endl endl

using namespace std;
using ll      = long long;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

int ceil_(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); }
int mod(int a, int b) { return a >= 0 ? a % b : a - (b * ceil_(a, b)); }
int bpm(int x, unsigned int y) {
  if (x == 0) return 0;
  if (y == 0) return 1;
  int ans   = 1;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  x %= MOD;
  for (int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) ans = ans * x % MOD;
    x = x * x % MOD;
  }
  return ans;
}
template <class T>
void cumulative_sum(T &container) {
  for (int i = 0; i < container.size() - 1; i++) container[i + 1] += container[i];
}

class BPickingUp {
public:
  static void solve(std::istream &cin, std::ostream &cout) {
    int N;
    cin >> N;
    vector<pair<int, int>> grid(N);
    rep(i, N) {
      cin >> grid[i].first >> grid[i].second;
    }
    int ans = N;
    rep(i, N - 1) {
      FOR(j, i + 1, N) {
        int temp_ans = N;
        int p        = grid[i].first - grid[j].first;
        int q        = grid[i].second - grid[j].second;
        rep(k, N) {
          rep(l, N) {
            if (grid[k].first - grid[l].first == p and grid[k].second - grid[l].second == q) {
              temp_ans--;
            }
          }
        }
        ans      = min(ans, temp_ans);
        temp_ans = N;
        p        = grid[i].first - grid[j].first;
        q        = grid[i].second - grid[j].second;
        p *= -1;
        q *= -1;
        rep(k, N) {
          rep(l, N) {
            if (grid[k].first - grid[l].first == p and grid[k].second - grid[l].second == q) {
              temp_ans--;
            }
          }
        }
        ans = min(ans, temp_ans);
      }
    }
    cout << ans << endl;
  }
};


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


Measured memory_bytes: 256
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    A = []
    xy = []
    for _ in range(N):
        A.append(I())
        xy.append([LI() for _ in range(A[-1])])

    ans = 0
    for i in range(2 ** N):
        # まず正直者を仮定し、正直者の証言に矛盾がないか判定
        is_ok = True
        num = 0
        for j in range(N):
            if i >> j & 1:
                num += 1
                for k in xy[j]:
                    x, y = k
                    x -= 1
                    if i >> x & 1 != y:
                        is_ok = False
        if is_ok:
            ans = max(num, ans)

    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10040
from sys import stdin,stdout 
from bisect import bisect,bisect_left,bisect_right
def gt(): return map(int, stdin.readline().split())
def gi(): return int(stdin.readline())
def gl(): return list(map(int, stdin.readline().split())) 
def gs(): return stdin.readline()
def getmax(BITTree,i): 
    s = 0
    i = i+1
    while i > 0:
        s = max(s,BITTree[i])
        i -= i & (-i) 
    return s 

def updatebit(BITTree , n , i ,v): 
    i += 1
    while i <= n: 
        BITTree[i] = max(v,BITTree[i]) 
        i += i & (-i) 
def construct( n): 
    BITTree = [0]*(n+1) 
    # for i in range(n): 
    #     updatebit(BITTree, n, i, arr[i])
    return BITTree 
n=gi()
h=gl()
a=gl() 
m=max(h)
BITTree = construct(m+1)
for i in range(n):
    updatebit(BITTree,m+1,h[i],getmax(BITTree,h[i]-1)+a[i])
ans=0
print(getmax(BITTree,m))
    

Measured memory_bytes: 115796
/*
    author : Divyansh Gupta
*/

#include <iostream>
#include <iomanip>
#include <cstring>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <utility>
#include <map>

using namespace std;

void print_err() {
	cerr<<"\n";
}

template <class T,class... Arg>
void print_err(T x,Arg&&... args) {
	cerr<<x<<" ";
	print_err(args...);
}

#ifdef local
#define debug(...) print_err(__VA_ARGS__)
#else
#define debug(...)
#endif

#define test_case int test_cases;\
                cin>>test_cases;\
                while(test_cases--)
#define lu(var,l,r) for(var=l;var<r;var++)
#define ld(var,r,l) for(var=r;var>=l;var--)
#define ll long long
#define mp make_pair
#define pb push_back
#define vi vector<int>
#define vvi vector<vector<int> >
#define vll vector<ll>
#define vvll vector<vector<ll> >;               	
#define pii pair<int,int>                	
#define br cout<<"\n"
#define sp cout<<" "
#define pr cout<<
#define in cin>>
#define f first
#define s second                    
#define mod 1000000007
            
void solve(){
	int n,k,i,j,x,l;
	ll ans;
	vi A;
	in n;
	in k;
	A.pb(0);

	lu(i,0,n) {
		in x;
		A.pb(x);
	}

	int dp[n+1][k+1];

	lu(i,0,k + 1) {
		dp[0][i] = 1;
	}

	lu(i,0,n) {
		dp[i][0] = 1;
	}

	lu(i,1,n) {
		lu(j,1,k + 1) {
			ans = 0ll;
			if(j - A[i] > 0) {
				ans = mod + dp[i-1][j] - dp[i - 1][j - A[i] - 1];
			} else {
				ans = dp[i-1][j];
			}
			dp[i][j] = (ans + dp[i][j-1])%mod;
		}
	}

	ans = 0;
	if(k - A[n] > 0) {
		ans = mod + dp[n-1][k] - dp[n - 1][k - A[n] - 1];
	} else {
		ans = dp[n-1][k];
	}
	pr ans % mod;
	br;
}

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

Measured memory_bytes: 39296
#include<bits/stdc++.h>
using namespace std;
#define debug(a) cout << #a << ": " << a << endl
int main(){
	//freopen("input.txt", "r",stdin);
	int h, a; cin>>h>>a;
	int cnt = 0;
	while(h > 0){
		h -= a;
		cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}
	


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <limits.h>
#include <cmath>
#include <map>
using namespace std;
using ll=long long;
const int INF=INT_MAX;
struct edge{
    int to,cap,rev;
};
vector<edge> G[210];
vector<bool> used(210);
void add_edge(int from,int to,int cap){
    G[from].emplace_back((edge){to,cap,(int)G[to].size()});
    G[to].emplace_back((edge){from,0,(int)G[from].size()-1});
}
int dfs(int v,int t,int f){
    if(v==t)return f;
    used[v]=true;
    for(int i=0;i<G[v].size();i++){
        edge &e=G[v][i];
        if(!used[e.to]&&e.cap>0){
            int d=dfs(e.to,t,min(f,e.cap));
            if(d>0){
                e.cap-=d;
                G[e.to][e.rev].cap+=d;
                return d;
            }
        }
    }
    return 0;
}
int max_flow(int s,int t){
    int flow=0;
    while(1){
        fill(used.begin(),used.end(),false);
        int f=dfs(s,t,INF);
        if(f==0)return flow;
        flow+=f;
    }
}
int main(){
    int v,e;
    cin>>v>>e;
    for(int i=0;i<e;i++){
        int u,vv,c;
        cin>>u>>vv>>c;
        add_edge(u,vv,c);
    }
    cout<<max_flow(0,v-1)<<endl;
}



Measured memory_bytes: 3180
fn main() {
    let mut stdin = String::new();

    std::io::Read::read_to_string(
        &mut std::io::stdin(),
        &mut stdin).unwrap();

    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();

    macro_rules! get {
        () => (get().parse::<i64>().unwrap());
    }

    let n = get!() as usize;

    let mut sum = vec![0; n+1];
    for i in 0..n {
        sum[i+1] = sum[i] + get!();
    }
    sum.sort();

    let mut p = sum[0];
    let mut c = 1_i64;
    let mut ans = 0_i64;
    for i in 1..n+1 { 
        if p == sum[i] {
            c += 1;
        } else {
            if c > 1 {
                ans += c * (c-1) / 2;
            }
            c = 1;
            p = sum[i];
        }
    }

    if c > 1 {
        ans += c * (c-1) / 2;
    }

    println!("{}", ans);

}


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

int main() {
    int N, K;
    int d[110], A[110][110];
    cin >> N >> K;
    for (int i = 0; i < K; ++i) {
        cin >> d[i];
        for (int j = 0; j < d[i]; ++j) {
            cin >> A[i][j];
        }
    }

    set<int> values; // insert するときに重複を取り除いてくれます
    for (int i = 0; i < K; ++i) {
        for (int j = 0; j < d[i]; ++j) {
            values.insert(A[i][j]);
        }
    }

    // set のサイズを出力します
    cout << (N - values.size()) << endl;
}

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

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

    map<char, int> points;
    points['r'] = P;
    points['s'] = R;
    points['p'] = S;

    ll ans = 0;
    rep(i, N) {
        if (i < K) {
            ans += points[T[i]];
        } else {
            if (T[i - K] != T[i])
                ans += points[T[i]];
            else
                T[i] = '?';
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 512
#!/usr/local/gnu/bin/bash
read n
read -a a
read -a b
read -a c
s=0
p=-140
for i in `seq 0 $((n-1))`
do
    ((p+1==a[i])) && s=$((s+b[a[i]-1]+c[p-1])) || s=$((s+b[a[i]-1]))
    p=${a[i]}
done
echo $s


Measured memory_bytes: 1308