akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int main(void){
    int h,n,a[1000000],al = 0;
    int i;
    scanf("%d", &h);
    scanf("%d", &n);
    for(i = 0;i < n;i ++){
        scanf("%d", &a[i]);
    }
    for(i = 0;i < n;i ++){
        al += a[i];
    }
    if(h <= al){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 2432
#include<stdio.h>
int main(void)
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a<=c && b<=c){
		printf("%d\n",a+b);
	}
	else if(a<=b && c<=b){
		printf("%d\n",a+c);
	}
	else{
		printf("%d\n",b+c);
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
const long long INF = 1LL << 60;
using pll = pair<long long, long long>;

int main() {
  // 標準入力が早くなる。Cスタイルの入出力とC++スタイルの入出力を混合させてはならない。
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int A, B, C, D;
  cin >> A >> B >> C >> D;

  while (true) {
    C -= B;
    if (C <= 0) {
      cout << "Yes" << endl;
      break;
    }

    A -= D;
    if (A <= 0) {
      cout << "No" << endl;
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 3636
#include<stdio.h>
#include<string.h>
int main()
{
    char a;
    int i,x;
    scanf("%c",&a);
    int l=(int)a;
    for(i=0;i<1;i++)
    {
        l++;
    }
    printf("%c\n",l);
    return 0;
}


Measured memory_bytes: 128
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def roundUp(a, b):
        return -(-a // b)

    @staticmethod
    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    @staticmethod
    def toLowerMultiple(a, x):
        return (a // x) * x

    @staticmethod
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    @staticmethod
    def sign(n):
        if n == 0:
            return 0
        if n < 0:
            return -1
        return 1

    @staticmethod
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


class PriorityQueue:
    def __init__(self, l=[]):
        self.__q = l
        heapq.heapify(self.__q)
        return

    def push(self, n):
        heapq.heappush(self.__q, n)
        return

    def pop(self):
        return heapq.heappop(self.__q)


sys.setrecursionlimit(1000000)
MOD = int(1e09) + 7
INF = int(1e30)


def main():
    # sys.stdin = open("Sample.txt")
    Q = Scanner.int()
    L = [0] * Q
    R = [0] * Q
    for i in range(Q):
        L[i], R[i] = Scanner.map_int()
    MAX = int(1e05) + 10
    sums = [0] * MAX
    for n in range(MAX - 1):
        sums[n+1] = sums[n]
        if n % 2 == 1 and Math.isPrime(n) and Math.isPrime((n + 1) // 2):
            sums[n+1] += 1
    for i in range(Q):
        print(sums[R[i] + 1] - sums[L[i]])
    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 52568
n, m, k = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

a = [0]
b = [0]
for i in range(n):
    a.append(a[i]+A[i])
for i in range(m):
    b.append(b[i]+B[i])

ans = 0
best = m
for i in range(n+1):
    if a[i]>k:
        break
    else:
        for j in range(best, -1, -1):
            if b[j]<=k-a[i]:
                best = j
                break
    ans = max(ans, i+j)
print(ans)

Measured memory_bytes: 47380
a=list(map(int,input().split()))
takahashi=0
takahashicount=0
aoki=0
aokicount=0

for i in range(a[2]):
    aoki+=a[1]
    if (a[2]-aoki)>0:
        aokicount+=1
    elif (a[2]-aoki)==0:
        break
    else:
        break
        
for i in range(a[0]):
    takahashi+=a[3]
    if (a[0]-takahashi)>0:
        takahashicount+=1
    elif (a[0]-takahashi)==0:
        break
    else:
        break
if takahashicount==aokicount:
    print("Yes")
elif takahashicount>aokicount:
    print("Yes")
elif takahashicount<aokicount:
    print("No")

Measured memory_bytes: 9144
#include<cstdio>
#include<cmath>
using namespace std;
double a,b,x;
int main(){
	scanf("%lf%lf%lf",&a,&b,&x);
	if(x>a*a*b/2){
		double xx=(a*a*b-x)*2/(a*a);
		printf("%.10lf",atan(xx/a)*180/acos(-1.0));
	}else if(2*x==a*a*b)printf("45");
	else{
		double xx=(2*x)/(a*b);
		printf("%.10lf",atan(b/xx)*180/acos(-1.0));
	}
}

Measured memory_bytes: 384
package main

// Solution for https://atcoder.jp/contests/aising2020/tasks/aising2020_d

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

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

func f(x int) int {
	if x == 0 {
		return 0
	}
	p := x
	p = ((p & 0xaaaaaaaa) >> 1) + (p & 0x55555555)
	p = ((p & 0xcccccccc) >> 2) + (p & 0x33333333)
	p = ((p & 0xf0f0f0f0) >> 4) + (p & 0x0f0f0f0f)
	p = ((p & 0xff00ff00) >> 8) + (p & 0x00ff00ff)
	p = ((p & 0xffff0000) >> 16) + (p & 0x0000ffff)
	return 1 + f(x%p)
}

func (con *contest) main() error {
	var N int
	var X string
	con.Scan(&N, &X)
	C := 0
	for i := 0; i < N; i++ {
		if X[i] == '1' {
			C++
		}
	}
	b1 := make([]int, N)
	b2 := make([]int, N)
	b1[0] = 1 % (C + 1)
	if C > 1 {
		b2[0] = 1 % (C - 1)
	}
	for i := 1; i < N; i++ {
		b1[i] = b1[i-1] * 2
		b1[i] %= C + 1
		if C > 1 {
			b2[i] = b2[i-1] * 2
			b2[i] %= C - 1
		}
	}
	x1, x2 := 0, 0
	for i := 0; i < N; i++ {
		if X[N-1-i] == '1' {
			x1 += b1[i]
			x1 %= C + 1
			if C > 1 {
				x2 += b2[i]
				x2 %= C - 1
			}
		}
	}
	for i := 0; i < N; i++ {
		z := 0
		if X[i] == '0' {
			z = x1 + b1[N-1-i]
			z %= C + 1
			z = 1 + f(z)
		} else if C > 1 {
			z = x2 - b2[N-1-i]
			if z < 0 {
				z += C - 1
			}
			z = 1 + f(z)
		} else {
			z = 0
		}
		con.Println(z)
	}
	return nil
}


Measured memory_bytes: 7032
#include <iostream>

using namespace std;

int main(void) {
    int c[3][3];
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            cin >> c[i][j];
        }
    }

    int c_1 = 0, c_2 = 0, c_3 = 0;
    for (int i = 0; i < 3; ++i) {
        c_1 += c[i][0];
        c_2 += c[i][1];
        c_3 += c[i][2];
    }

    bool correct = false;
    for (int i = -100; i <= 100; ++i) {
        for (int j = -100; j <= 100; ++j) {
            for (int k = -100; k <= 100; ++k) {
                if ((i + j + k - c_1) % 3 == 0) {
                    if ((i + j + k - c_2) % 3 == 0) {
                        if ((i + j + k - c_3) % 3 == 0) {
                            correct = true;
                        }
                    }
                }
            }
        }
    }

//    cout << c_1 << " " << c_2 << " " << c_3 << endl;
    if (correct) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include<functional>
#include <tuple>
#include <map>
#include<set>
#include <cmath>
#include <stack>
#include<cstdio>
#include<stdio.h>
using namespace std;

int main() {
	int n, ans=1, mx=0;
	cin >> n;
	for (int i = 1;i<= n;i++) {
		int a=i,cnt=0;
		while (a % 2 == 0) {
			a = a / 2;
			cnt += 1;
		}
		if (mx < cnt) {
			mx = cnt;
			ans = i;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
from collections import defaultdict
from math import gcd
MOD = 1000000007
inpl = lambda: list(map(int,input().split()))
groups = defaultdict(int)
null = 0
N = int(input())
for _ in range(N):
    A, B = inpl()
    if A == 0 and B == 0:
        null += 1
    elif A == 0:
        groups[(0,1)] += 1
    elif B == 0:
        groups[(1,0)] += 1
    else:
        g = gcd(A,B)
        A //= g
        B //= g
        if A < 0:
            A *= -1
            B *= -1
        groups[(A, B)] += 1
ans = 1
for k in list(groups.keys()):
    A, B = k
    if B <= 0:
        C, D = -B, A
    else:
        C, D = B, -A
    groups[(C,D)]
for k, v in groups.items():
    A, B = k
    if B <= 0:
        continue
    u = groups[(B,-A)]
    p = pow(2,v,MOD) + pow(2,u,MOD) - 1
    ans *= p
    ans %= MOD
ans -= 1
ans += null
print(ans % MOD)


Measured memory_bytes: 166564
//Sequence Sum 

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define nnn "\n"
#define spa " "
using P = pair<ll,ll>;
using graph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

//n=元の数,p=乗数,m=mod
ll repsqr(ll n,ll p,ll m){
    if(p==0)return 1;
    if(p%2==0){
        ll t=repsqr(n,p/2,m);
        return t*t%m;
    }
    return n*repsqr(n,p-1,m)%m;
}

signed main (){
    int n,x,m;cin>>n>>x>>m;
    map<int,int>t;
    int l=x;t[l]++;
    while(t[repsqr(l,2,m)]<2){
        l=repsqr(l,2,m);
        t[l]++;
    }
    int r=0,rk=0,ok=0;
    if(t.size()==1){
        for(auto i:t)cout<<n*i.first<<nnn;
        return 0;
    }
    for(auto i:t){
        if(i.second==2)r+=i.first,rk++;
        else ok++;
    }
    int ans=0;
    if(ok<n)ans+=((n-ok)/rk)*r;
    int o=((n-ok)%rk)+ok;
    ans+=x;l=x;
    rep(i,1,o){
        l=repsqr(l,2,m);
        ans+=l;
    }
    cout<<ans<<nnn;
    return 0;
}

Measured memory_bytes: 6620
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
 int a, b, c, n = 0;
    cin >> a >> b >> c;
    for (int i = a; i <= b; i++) {
        if (c%i == 0)n++;
    }
    cout << n << endl;

return 0;
}


Measured memory_bytes: 3084
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

ll mod(ll a){
  return (a % 1000000007);
}

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

ll nCr(ll n,ll r){
  if(r == 1) return n;
  else if(r == 0) return 1;
  else return nCr(n-1,r-1)*n/r;
}

int main(){
  vector<char> string(9);
  
  rep(i,9){
    cin >> string[i];
  }
  
  cout << string[0] << string[4] << string[8] << endl;
  
}
                                         

Measured memory_bytes: 384
from collections import defaultdict
n = int(input())

d = defaultdict(int)
nums = []
for num in input().split():
    num = int(num)
    d[num] += 1
    # 同じ長さの棒が4本ある場合に対応するためこのような方法をとる
    if d[num] == 2:
        d.pop(num)
        nums.append(num)

nums = sorted(nums)
if len(nums) >= 2:
    print(nums[-1] * nums[-2])
else:
    print(0)


Measured memory_bytes: 24104
def main():
    N, M, K=map(int, input().split())
    friend_or_block = [0] * N
    parent = [-1] * N

    def root(x):
        p, s = parent[x], list()
        while p >= 0:
            s.append(x)
            x, p = p, parent[p]
        for c in s: parent[c] = x
        return x

    def same(x, y): return root(x) == root(y)

    def count(x): return -parent[root(x)]

    def unite(x, y):
        xr, yr = root(x), root(y)
        if xr == yr: return
        if parent[xr] > parent[yr]: xr, yr = yr, xr
        parent[xr] += parent[yr]
        parent[yr] = xr

    for _ in range(M):
        a, b = map(int, input().split())
        a, b = a-1, b-1
        unite(a, b)
        friend_or_block[a] += 1
        friend_or_block[b] += 1

    for _ in range(K):
        c, d = map(int, input().split())
        c, d = c-1, d-1
        if same(c, d):
            friend_or_block[c] += 1
            friend_or_block[d] += 1

    print(*[count(i) - friend_or_block[i] - 1 for i in range(N)])

if __name__ == '__main__':
    main()



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

typedef long long int ll;
#define rep(i,n) for (i = 0; i < n; ++i) 
#define REP(i,k,n) for (i = k; i < n; ++i) 
#define REPR(i,k,n) for (i = k; i >= n; --i) 
#define WATCH(x) cout << (#x) << " is " << (x) << endl

#define PB push_back
#define N 300101
#define SZ 3001
#define LB lower_bound
const int M= 1e9 + 7;
#define UB upper_bound
#define MP make_pair
#define LD long double
#define F first
#define S second

typedef vector< long long int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;

#define sz(a) int((a).size())
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i=c.begin() ; i != c.end() ; i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end()
#define flash ios_base::sync_with_stdio(false); cin.tie(NULL),cout.tie(NULL);

int main()
{   
    ll n , k , l;
  cin >> n >> k;
  ll i;
  map<ll , ll>mp;
  vector<ll>d(n+1);
  d[0] =1;
  d[1] =1;
  rep(i , k)
  {
    cin >> l;
    mp[l] = 1;
    if(l ==1 )
    {
        d[1] = 0;
    }
  }
  
  
  REP(i , 2, n+1)
  {
      d[i] = (d[i-1]+ d[i-2])%M;
      
      if(mp.find(i) != mp.end())
      {
          d[i] = 0;
      }
  }
  cout << d[n] << endl;
  return 0;
}


Measured memory_bytes: 7296
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main(void){
    int n,flag,tag;
    vector<int> prime;
    vector<int> prime_c;
    long long res = 1;
    cin >> n;
    for(int i=2;i<=n;i++){
        tag = i;
        flag = 0;
        for(int j=2;j<=(int)sqrt(i);j++){
            if(i % j == 0){
                flag = 1;
                break;
            }
        }
        if(!flag){
            prime.push_back(i);
            prime_c.push_back(1);
        }else{
            for(int j=0;j<prime.size();j++){
                while(tag % prime[j] == 0){
                    tag = tag / prime[j];
                    prime_c[j]++; 
                }
            }
        }
    }
    for(int i=0;i<prime_c.size();i++){
        res = res * (prime_c[i] + 1) % 1000000007;
    } 
    cout << res << endl;
}

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

int main() {
    int n;cin>>n;
    int a[n+2];a[0]=0;
    for(int i=1;i<n+1;i++){
        cin>>a[i];
    }
    a[n+1]=0;
    a[n+2]=0;
    int dif[n+1];
    string sym[n+1];
    int sum=0;
    for(int i=0;i<n+1;i++){
        dif[i]=abs(a[i]-a[i+1]);
        sum+=abs(a[i]-a[i+1]);
        if(a[i]<a[i+1]) sym[i]="+";
        if(a[i]>a[i+1]) sym[i]="-";
        if(a[i]==a[i+1]) sym[i]="0";
    }
    for(int i=0;i<n;i++){
        if(sym[i]==sym[i+1] || sym[i]=="0" || sym[i+1]=="0") cout<<sum<<endl;
        else {
            cout<<sum-dif[i]-dif[i+1]+abs(a[i+2]-a[i])<<endl;
        }
    }

}

Measured memory_bytes: 7424
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

int main() {
    int n;
    cin >> n;
    vi p(n);
    for (int i = 0; i < n; ++i) {
        cin >> p[i];
    }
    vi sorted = p;
    sort(sorted.begin(), sorted.end());
    ll diff = 0;
    for (int i = 0; i < n; ++i) {
        if (p[i] != sorted[i])
            diff++;
    }
    if (diff == 0 || diff == 2) {
        cout << "YES"
             << "\n";
    } else {
        cout << "NO"
             << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long i = 1;
        long j = 1;
        long s = 0;
        long t = 0;
        for (long e = 0; e < 1000000; e++) {
            if (s < t) {
                s = a * i;
                i++;
            } else {
                t = b * j;
                j++;
            }
            if (s == t) {
                break;
            }
        }
        System.out.println(s);
    }
}

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

using namespace std;

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

    vector<pair<int, int>> vp;

    for (int i = 0; i < n; ++i) {
        int ci, ti;
        cin >> ci >> ti;

        if (ti > t)
            continue;
        vp.push_back(make_pair(ci, ti));
    }
    sort(vp.begin(), vp.end());
    if (vp.empty())
        cout << "TLE" << endl;
    else
        cout << vp[0].first << endl;
}

Measured memory_bytes: 256
N = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for i in range(N):
    s = input()
    if s == 'AC': ac += 1
    if s == 'WA': wa += 1
    if s == 'TLE': tle += 1
    if s == 'RE': re += 1
print('AC x ' + str(ac))
print('WA x ' + str(wa))
print('TLE x ' + str(tle))
print('RE x ' + str(re))

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

int main(){

    long long a, b, c;
    cin >> a >> b >> c;

    if(a + b >= c){
        cout << b + c << endl;
    }
    else{
        cout << b + a + b + 1<< endl;
    }


}

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

int main(void)
{
    int64_t a, b;

    std::cin >> a >> b;

    auto func = [&](){ return ((a*b)%2==0) ? "Even" : "Odd"; };

    std::cout << func() << std::endl;

    return 0;
}

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

void read(int &x) {
    x=0;int f=1;char ch=getchar();
    for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-f;
    for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';x*=f;
}

void print(int x) {
    if(x<0) putchar('-'),x=-x;
    if(!x) return ;print(x/10),putchar(x%10+48);
}
void write(int x) {if(!x) putchar('0');else print(x);putchar('\n');}

#define lf double
#define ll long long 

#define pii pair<int,int >
#define vec vector<int >

#define pb push_back
#define mp make_pair
#define fr first
#define sc second

#define FOR(i,l,r) for(int i=l,i##_r=r;i<=i##_r;i++)

const int maxn = 1e6+10;
const int inf = 1e9;
const lf eps = 1e-8;
const int mod = 1e9+7;

int n,k;
char s[maxn];

int solve(int l,int r) {
    int t=1,res=0;
    for(int i=l+1;i<=r;i++)
        if(s[i]==s[i-1]) t++;
        else res+=t/2,t=1;
    res+=t/2;return res;
}

int main() {
    scanf("%s",s+1);read(k);n=strlen(s+1);int p=0;
    for(int i=2;i<=n;i++) if(s[i]!=s[i-1]) p=i;
    if(!p) return printf("%lld\n",1ll*k*n/2),0;
    for(int i=n+1;i<=n+p-1;i++) s[i]=s[i-n];
    printf("%lld\n",1ll*solve(p,p+n-1)*(k-1)+solve(1,n));
    return 0;
}


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

using namespace std;

using ll = long long;
#define all(x) begin(x), end(x)

int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
int n; cin >> n;
vector<int> arr(n);
int cnt = 0;
for(int i{}; i<n; ++i) cin >> arr[i];
sort(all(arr));

for(int i{}; i<n; i++){
	for(int j=i+1; j<n; j++){
		for(int k=j+1; k<n; k++){
			if(arr[i]+arr[j]>arr[k] && arr[i]!=arr[j] && arr[i]!=arr[k] && arr[j]!=arr[k]) ++cnt;
		}
	}
}
cout << cnt << "\n";
}

  



Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int main()
{char a[10000],b[10000];
cin>>a;
cin>>b;
int x=strlen (a);
int y=strlen (b);
if(x!=y){
	if(x>y)
	cout<<"GREATER";
	else
	cout<<"LESS";
	
}
else 
{
	for(int i=0;i<x;++i){
		if(a[i]!=b[i])
{
	if(a[i]>b[i])
	cout<<"GREATER";
	else
	cout<<"LESS";
	break;
	}
	if(i+1==x)
	cout<<"EQUAL";
	continue;	
	}
}
	return 0;
}

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

typedef long long ll;
typedef double db;

#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

const ll LINF = LLONG_MAX, MOD = 1e9 + 7, N = 1e5 + 5, LG = 20;
const int INF = INT_MAX;
const db PI = acos(-1), EPS = 1 / db(1e6);

void test() {
    int n = 5;
    int a[n], idx;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        if (a[i] == 0) idx = i + 1;
    }
    cout << idx << "\n";
}

int main() {
      fast_io();
      #ifdef HOME
            freopen("input.txt", "r", stdin);
            freopen("output.txt", "w", stdout);
      #endif
      cout << fixed << setprecision(15);
      int t = 1;
      // cin >> t;
      for (int i = 1; i <= t; ++i) {
          test();
      }
      #ifdef HOME
          cout << "Time: " << (int)(clock() * 1000. / CLOCKS_PER_SEC) << "ms";
      #endif
      return 0;
}


Measured memory_bytes: 3580
import sys
from bisect import *
from collections import *
from copy import deepcopy
from heapq import *
from itertools import *
from math import *
from operator import *
import numpy as np

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

def main():
    """ main """
    N = int(input())
    AS = list(map(int, input().split()))
    BS = list(map(int, input().split()))
    CS = list(map(int, input().split()))

    ans = 0
    prev = -2
    for a in AS:
        plus = BS[a-1]
        if 1 < a and prev == a-1-1:
            plus += CS[a-2]
        ans += plus
        prev = a-1
    print(ans)


if __name__ == '__main__':
    main()

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

using namespace std;

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

    unsigned long long x,y;

    cin >> x >> y;

    int cnt = 0;
    unsigned long long now = x;

    for (cnt;now <= y;cnt++){
        now *= 2;
    }

    cout << cnt << endl;

    return 0;

}

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

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

  int str_len = (int)S.size();
  int bit_len = str_len - 1;
  long long ans = 0;

  // Bit全検索で全パターンを加算する
  for (int tmp = 0; tmp < (1 << bit_len); tmp++) {
    bitset<10> bs(tmp);

    // ビット列の特定の桁に 1 が立っている場合、+ 記号の挿入とみなす
    string num_string;
    for (int i = 0; i < str_len; i++) {
      num_string += S.at(i);

      // それまでに登場した左の文字列を数字とみなして、加算する
      // num_string は初期化する
      if (i < bit_len && bs.test(i)) {
        ans += stoll(num_string);
        num_string = "";
      }
    }
    // + 記号が最後に登場した後の数字文字列を加算する
    ans += stoll(num_string);
  }

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

Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int MAX_N = 2e5 + 5;

int arr [MAX_N];
int pos [MAX_N];

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

  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
    pos[arr[i]] = i;
  }

  int ans = 1, cur = 1;
  for (int i = 2; i <= n; i++) {
    if (pos[i] < pos[i - 1]) {
      cur = 1;
    } else {
      cur++;
    }
    ans = max(ans, cur);
  }

  cout << n - ans << endl;
}


Measured memory_bytes: 5192
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

int con[2][2100];

signed main(){
	cout<<fixed<<setprecision(10);
	
	int S;
	int sum = 0;
	
	cin>>S;
	
	con[0][0] = 1;
	
	for(int i = 0; i < S; i++){
		for(int j = i * 3; j <= S; j++){
			int x = S - 3 * i;
			for(int k = 3; k + j <= S; k++){
				con[(i+1)%2][k+j] += con[(i)%2][j];
				con[(i+1)%2][k+j] %= MOD;
			}
		}
		sum += con[(i+1)%2][S];
		sum %= MOD;
		
		for(int j = i * 3; j <= S; j++){
			con[i%2][j] = 0;
		}
		
	}
	
	
	
	cout<<sum<<endl;
	
	
	return 0;
}

Measured memory_bytes: 3668
import numpy as np

N,W = map(int,input().split())
wv = np.array([list(map(int,input().split())) for _ in range(N)])
dp=np.zeros([N+1,W+1])

#　繰り返し回数節約
for i in range(1,N+1):
    dp[i][:wv[i-1][0]] = dp[i-1][:wv[i-1][0]]
    dp[i][wv[i-1][0]:] = np.maximum(dp[i-1][wv[i-1][0]:],dp[i-1][:W+1-wv[i-1][0]]+wv[i-1][1])
print(int(dp[-1,-1]))

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

public class Main {

    public static void main(final String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        long A;
        A = sc.nextLong();
        long B;
        B = sc.nextLong();
        long K;
        K = sc.nextLong();

        final Solver solver = new Solver();
        solver.solve(A, B, K);
    }
}

class Solver {
    public void solve(long A, long B, long K) {
        long a = Math.max(0, A - K);
        long b = Math.max(0, B - Math.max(0, K - A));
        System.out.println(a + " " + b);
    }
}



Measured memory_bytes: 23124
#include<iostream>
#include<algorithm>
using namespace std;
#define INF ( 1 << 30 )
int main(){
  bool a[31] = {};
  int b;
  for(int i = 0 ; i < 28 ; i++ ) cin >> b, a[b] = true;
  for(int i = 1 ; i < 31 ; i++ ) if(!a[i]) cout << i << endl;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> //gp_hash_table

using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define pb push_back

ll choose2(ll x) { return (x * (x - 1)) / 2; }

const int N = 200100;
int n;
vector<int> v;
vector<int> freq(N);

void solve() {
    cin >> n;
	v.resize(n);
	for(int i = 0 ; i < n ; i++) {
		cin >> v[i];
		freq[v[i]]++;
	}
	ll res = 0;
	for(int i = 0 ; i < N ; i++)
		res += choose2(freq[i]);
	for(int i = 0 ; i < n ; i++)
		cout << (res - (freq[v[i]] - 1)) << "\n";
}

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

Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
vector<int>g[100005];
int dis[100005][3];
int main(){
	int n,m,s,t,u,v;
	memset(dis,-1,sizeof(dis));
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++){
		scanf("%d%d",&u,&v);
		g[u].push_back(v);
	}
	scanf("%d%d",&s,&t);
	queue<pair<int,int> >q;
	q.push({s,0});
	dis[s][0]=0;
	while(!q.empty()){
		int v=q.front().first;
		int l=q.front().second;
		q.pop();
		for(int i=0;i<g[v].size();i++){
			int ll=(l+1)%3;
			if(dis[g[v][i]][ll]>=0)
				continue;
			dis[g[v][i]][ll]=dis[v][l]+1;
			q.push({g[v][i],ll});
		}
	}
	if(dis[t][0]>=0)
		dis[t][0]/=3;
	printf("%d\n",dis[t][0]);
} 

Measured memory_bytes: 10404
#include <iostream>
#include <string>
#include <vector>
using namespace std;
 
int main() {
	int h;
	cin >> h;
	int w;
	cin >> w;
	vector<string> a(h);
	for (int i = 0; i < h; i++) {
		cin >> a[i];
	}
 
	vector<bool> row(h, false);
	vector<bool> col(w, false);
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (a[i][j] == '#') {
				row[i] = true;
				col[j] = true;
			}
		}
	}
 
	for (int i = 0; i < h; i++) {
		if (row[i]) {
			for (int j = 0; j < w; j++) {
				if (col[j]) {
					cout << a[i][j];
				}
			}
			cout << endl;
		}
	}
}

Measured memory_bytes: 3652
N = int(input())
A = list(map(int, input().split()))
flg = 1
for i in range(N):
  if A[i] % 2 == 0:
    if A[i] % 3 != 0 and A[i] % 5 != 0:
      flg = 0
if flg == 1:
  print("APPROVED")
else:
  print("DENIED")

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

int main(){
  //vector<char> S(100);
  //int i = 0;
  //cin >> S.at(0);
  //while(S.at(i) !=EOF){
  //  i++;
  //  cin >> S.at(i);
  //}
  //
  string S;
  cin >> S;

  int min = 1000;
  for(int j=0; j< S.size() - 2; j++){
    int number = abs((S.at(j) - '0') *100 + (S.at(j+1) -'0')*10 + (S.at(j+2)- '0')- 753);
    if(min > number)
      min = number;
    }
  cout << min << endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
root_dic = {}
for i in range(N):
    root_dic[i+1] = 0
for i in range(M):
    root = list(map(int, input().split()))
    for i in range(2):
        root_dic[root[i]] += 1
for i, v in sorted(root_dic.items()):
    print(v)

Measured memory_bytes: 3060
#include "iostream"

using namespace std;

#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2 +2],R[MAX/2 +2];
int cnt;

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

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

int main(){
  int A[MAX],n,i;
  cnt = 0;

  cin >> n;
  for( i = 0;i < n; i++) cin >> A[i];

  mergeSort(A,n,0,n);

  for( i = 0; i < n; i++){
    if(i) cout << " ";
    cout << A[i];
  }
  cout << endl;
  cout << cnt << endl;
  return 0;
}



Measured memory_bytes: 6988
# coding: utf-8

# https://atcoder.jp/contests/abc110


def main():
    S = input()
    T = input()
    N = len(S)

    memo1 = {}
    memo2 = {}
    for i in range(N):
        if S[i] not in memo1:
            memo1[S[i]] = T[i]
        else:
            if memo1[S[i]] != T[i]:
                return "No"
        if T[i] not in memo2:
            memo2[T[i]] = S[i]
        else:
            if memo2[T[i]] != S[i]:
                return "No"

    return "Yes"


print(main())


Measured memory_bytes: 3632
using System;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] NX = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            int N = NX[0];
            int X = NX[1];
            int[] L = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            int cnt = 0;
            for(int i = 0; i < N; i++)
            {
                X -= L[i];
                if(X < 0)
                {
                    break;
                }
                else if(X == 0)
                {
                    cnt++;
                    break;
                }
                cnt++;
            }
            Console.WriteLine(cnt + 1);
        }
    }
}



//int n = int.Parse(Console.ReadLine());
//int[] N = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();

Measured memory_bytes: 13268
a1,a2 = map(int,input().split())
a3,a4 = map(int,input().split())
a5,a6 = map(int,input().split())
x = [0,0,0,0,0]
x[a1]+=1
x[a2]+=1
x[a3]+=1
x[a4]+=1
x[a5]+=1
x[a6]+=1
del x[0]
if 0 in x or 3 in x:
    print('NO')
else:
    print('YES')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int const mod=998244353;
int const maxn=1e5+5;
int dis[maxn];
typedef long long ll;
ll quick(ll x,ll y)
{
    ll ans=1;
    while(y)
    {

        if(y&1)
        {

            ans*=x;ans%=mod;
        }
        x*=x;x%=mod;y>>=1;
    }
    return ans;
}
int main(){
    int n;
    bool rc=0;int maxr=0;
    scanf("%d",&n);int x;
    for(int i=1;i<=n;i++) {
        scanf("%d",&x);
        if((i==1&&x!=0)||(i!=1&&x==0)) rc=1;
        dis[x]++;
        maxr=max(maxr,x);
    }
    long long res=1;long long tmp=1;
    if(dis[0]!=1) rc=1;
    //cout<<rc<<endl;
    for(int i=1;i<=maxr;i++)
    {
        if(dis[i]==0)
        {
            rc=1;break;
        }
        else{
            res=res*quick(tmp,dis[i])%mod;
            tmp=dis[i];
        }
    }
    if(rc) printf("0\n");
    else{
        printf("%lld\n",res);
    }

}

Measured memory_bytes: 640
#include <stdio.h>
#define N 100

int main(void){
    int M[N][N]={0};
    int n,u,k,v,i,o;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d %d",&u,&k);
        u--;
        for(o=0;o<k;o++){
            scanf("%d",&v);
            v--;
            M[u][v]=1;
        }
    }
    for(i=0;i<n;i++){
        for(o=0;o<n;o++){
            printf("%d%s",M[i][o],o==n-1?"":" ");
        }
        puts("");
    }
    return 0;
}

Measured memory_bytes: 660
#include<bits/stdc++.h>
using namespace std;
int num[500000]={0};
int main(){
  for(int i=2;i<sqrt(500000);i++){
    for(int j=i;j<500000;j+=i){
      if(num[j]==0 && j!=i){
	num[j]=1;
      }
    }
  }
  while(1){
    int n;
    cin>>n;
    if(n==0) break;
    int cnt=0;
    long long sum=0;
    for(int i=2;i<500000;i++){
      if(cnt==n){
	break;
      }
      if(num[i]==0){
	cnt++;
	sum+=i;
	if(cnt == n){
	  break;
	}
      }
    }
    cout<<sum<<endl;
  }
  return 0;
}
    

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

// I/O
int get_uint() {
    int n = 0;
    int c = getchar_unlocked();
    if(c < 48 || 57 < c) return c;
    while(47 < c && c < 58) n = 10 * n + (c & 0xf), c = getchar_unlocked();
    return n;
}
void put_uint(int n) {
    if(!n) {
        putchar_unlocked('0');
        return;
    }
    char buf[11];
    int i = 0;
    while(n) buf[i++] = (char)(n % 10 + '0'), n /= 10;
    while(i--)putchar_unlocked(buf[i]);
}


// Node
typedef struct NodeKey {
    int board[16];
    int space;
    // heuristic: manhattan distance
    int est;
} NodeKey;


// solve
int dfs(const int lim, const int depth, const int prev, const NodeKey *node, const int M, const int L1[][16]) {
    if(node->est == 0) return 1;
    if(depth + node->est > lim) return 0;

    static const int dx[] = {-1, 0, 1, 0};
    static const int dy[] = {0, -1, 0, 1};
    const int x = node->space % M;
    const int y = node->space / M;

    for(int i = 0; i < 4; ++i) {
        const int nx = x + dx[i];
        const int ny = y + dy[i];
        if(nx < 0 || M <= nx || ny < 0 || M <= ny) continue;
        if(abs(prev - i) == 2) continue;

        const int next_space = nx + ny * M;
        NodeKey next_node = *node;
        next_node.est -= L1[next_space][next_node.board[next_space] - 1];
        next_node.est += L1[next_node.space][next_node.board[next_space] - 1];
        next_node.board[next_node.space] = next_node.board[next_space];
        next_node.board[next_space] = 0;
        next_node.space = next_space;
        if(dfs(lim, depth + 1, i, &next_node, M, L1)) return 1;
    }
    return 0;
}

int iterative_deepening(NodeKey *node) {
    const int N = 16;
    const int M = 4;
    int L1[N][N];
    for(int i = 0; i < N; ++i)
        for(int j = 0; j < N; ++j) L1[i][j] = abs(i % M - j % M) + abs(i / M - j / M);

    int min = 0;
    for(int i = 0; i < N; ++i)
        if(i != node->space) min += L1[i][node->board[i] - 1];
    node->est = min;
    for(const int lim = 46; min < lim; ++min)
        if(dfs(min, 0, 9, node, M, L1)) return min;
    return -1;
}

int main(int argc, char **argv) {
    NodeKey initial;
    for(int i = 0; i < 16; ++i) {
        int x = get_uint();
        initial.board[i] = x;
        if(x == 0) initial.space = i;
    }
    put_uint(iterative_deepening(&initial));
    putchar_unlocked('\n');
    return 0;
}



Measured memory_bytes: 2108
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//pair sort
bool compare_by_b(pair<LL, LL> a, pair<LL, LL> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}


void solve(long long N, long long K, std::vector<long long> A){
    int cnt=1;
    N-=K;
    cnt+=ceil(N/(float)(K-1));
    cout<<cnt<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, K, std::move(A));
    return 0;
}


Measured memory_bytes: 1024
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rep3(var, min, max) for (ll (var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll (var) = (max) - 1; (var) + 1 > (min); --(var))
#define Mp(a,b) make_pair((a),(b))
#define F first
#define S second
#define CIN(s) int (s);cin>>(s);
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll MOD = 1e9 + 7;
ll INF =1e18;

int main(){
    ll n,z,w;
    cin>>n>>z>>w;
    V vec(n);
    rep(i,n)cin>>vec[i];
    ll res=abs(vec[n-1]-w);
    if(n>=2)chmax(res,abs(vec[n-1]-vec[n-2]));
    cout<<res<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
long long n,n1,ans,num,s;
int main()
{
	scanf("%lld",&n);
	n1=n;
	for(;n/10;n/=10) num=num*10+9,ans+=9;
	if(n1==num+n*(num+1)) ans+=n;
	else ans+=n-1;
	printf("%lld\n",ans);
}

Measured memory_bytes: 128
n, m = map(int, input().split())

k0 = list(map(int, input().split()))
k0.pop(0)
le = len(k0)
aut = []

for i in range(n-1):
    ka = list(map(int, input().split()))
    ka.pop(0)
    for j in range(le):
        num = k0[j]
        if num not in ka:
            aut.append(num)

print(le-len(set(aut)))

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>

#include <atcoder/all>
using namespace atcoder;

using namespace std;
int main() {
    int t;
    cin >> t;
    for (int i = 0; i < t; i++) {
        long long n, m, a, b;
        cin >> n >> m >> a >> b;
        cout << floor_sum(n, m, a, b) << endl;
    }
    return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#include<stdio.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<double> VL;
typedef vector<string> VS;
typedef vector<PLL> VP;
typedef vector<ll> VLL;
const static int INF = 1000000000;
const static int MOD = 1000000007;
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int K;
    cin >> K;
    int ans=0;
    ll sum=0;
    rept(i,1,K+1){
        rept(j,1,K+1){
            rept(k,1,K+1){
                ans=gcd(i,j);
                ans=gcd(ans,k);
                sum+=ans;                
            }
        }
    }
    printf("%llu\n",sum);    
}


Measured memory_bytes: 3792
#include <bits/stdc++.h>
#define ld long double
#define F first
#define S second
#define pb push_back
#define pii pair <int, int>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define reunique(x) (x).resize(std::unique(all(x)) - (x).begin())
#define roflan ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long
using namespace std;

signed main(){
  roflan;
  int n;
  cin >> n;
  vector <vector <int>> a(n, vector <int> (3));
  for (int i = 0; i < n; i++){
    for (int j = 0; j < 3; j++){
      cin >> a[i][j];
    }
  }
  vector <vector <int>> dp(n, vector <int> (3));
  for (int i = 0; i < 3; i++){
    dp[0][i] = a[0][i];
  }
  for (int i = 1; i < n; i++){
    for (int was = 0; was < 3; was++){
      for (int now = 0; now < 3; now++){
        if (was == now) continue;
        dp[i][now] = max(dp[i][now], dp[i - 1][was] + a[i][now]);
      }
    }
  }
  int ans = -1;
  for (int i = 0; i < 3; i++){
    ans = max(ans, dp[n - 1][i]);
  }
  cout << ans;
  return 14 / 88;
}

Measured memory_bytes: 11264
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		char[] array = scanner.next().toCharArray();
		
		int count = 0;
		
		for(int i = 0; i < array.length; i++) {
			for(int l = 0; l < array.length; l++) {
				if(i == l) {
					continue;
				}
				count += array[i] == array[l] ? 1 : 0;
			}
		}
		
		System.out.println(count == 4 ? "Yes" : "No");
		
		scanner.close();
	}
}

Measured memory_bytes: 21204
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    if (a + b >= c) {
      cout << "Yes" << '\n';
    } else {
      cout << "No" << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    x = f()[0]
    y = x//11 * 2
    if x%11:
        y+=1
    if x%11>6:
        y +=1
    print(y)

solve()


Measured memory_bytes: 3064
N = int(input())
li = list(map(int, input().split()))
tmp = li[0]
for i in range(1, N):
  if li[i] - tmp == 0:
    tmp = li[i]
  elif li[i] - tmp >= 1:
    tmp = li[i] - 1
    continue
  else:
    print('No')
    exit()
print('Yes')

Measured memory_bytes: 15020
#include <bits/stdc++.h>
using namespace std;
#define ll          long long int
#define pb          push_back
#define pll         pair<ll,ll>
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mode        998244353
#define mod         1000000007
#define inf         1000000000000000000LL
#define vl          vector<ll>
#define F           first
#define S           second
#define db          long double
#define sz(x)       (ll)x.size()
#define fix(n)      cout<<fixed<<setprecision(n)
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define all(x)      x.begin(),x.end()
#define mset(x)     memset(x,0,sizeof x)
#define pi          3.14159265358979323



void solve()
{
       string s;
       cin>>s;
       ll ans=0;
       ll n = sz(s);
       for(ll i=0; i<n-1; i++)
       {
              if(s[i+1]==s[i])
              {
                     ans++;
                     s[i+1]='1' - s[i] + '0';
              }

       }
       cout<<ans;
}



int main() {
	ll T = 1;
	speed_up
	//cin>>T;
	while(T--)
	    solve();
	return 0;
}


Measured memory_bytes: 512