akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include <vector>
#include <cmath>
#include<string>
#define REP(i,n) for(int i=0;i<int (n);i++)
using namespace std;

int main(){
    int n;
    int ans=0;
    cin>>n;
    if (n<105){
        cout<<0<<endl;
        return 0;
    }
    for (int i=105;i<=n;i+=2){
        int cnt=0;
        for (int j=1;j<=i;j++){
            
            if (i %j ==0){
                cnt++;
            } 
        }
        if (cnt==8) ans++;
    }
    cout<<ans<<endl; 
    
    return 0;
}


Measured memory_bytes: 256
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val K, X = sc.nextInt()

    val left = (X - (K - 1)) max -1000000
    val right = (X + (K - 1)) min 1000000

    println((left to right).mkString(" "))
  }

}

Measured memory_bytes: 25932
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	vector<string> s,t;
	cin>>n;
	for(int i=0;i<n;i++){
		string st;
		cin>>st;
		s.push_back(st);
	}
	cin>>m;
	for(int i=0;i<m;i++){
		string st;
		cin>>st;
		t.push_back(st);
	}
	map<string,int> ma;
	for(int i=0;i<n;i++){
		ma[s[i]]++;
	}
	for(int i=0;i<m;i++){
		ma[t[i]]--;
	}
	int maxx=0;
	for(auto it=ma.begin();it!=ma.end();it++){
		if(it->second>maxx) maxx=it->second;
	}
	cout<<maxx<<endl;
	return 0;
}

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

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}

#define MAXN   1000001

// stores smallest prime factor for every number
int spf[MAXN];

// Calculating SPF (Smallest Prime Factor) for every
// number till MAXN.
// Time Complexity : O(nloglogn)
void sieve()
{
    spf[1] = 1;
    for (int i=2; i<MAXN; i++)

        // marking smallest prime factor for every
        // number to be itself.
        spf[i] = i;

    // separately marking spf for every even
    // number as 2
    for (int i=4; i<MAXN; i+=2)
        spf[i] = 2;

    for (int i=3; i*i<MAXN; i++)
    {
        // checking if i is prime
        if (spf[i] == i)
        {
            // marking SPF for all numbers divisible by i
            for (int j=i*i; j<MAXN; j+=i)

                // marking spf[j] if it is not
                // previously marked
                if (spf[j]==j)
                    spf[j] = i;
        }
    }
}

// A O(log n) function returning primefactorization
// by dividing by smallest prime factor at every step
set<int> getFactorization(int x)
{
    set<int> ret;
    while (x != 1)
    {
        ret.insert(spf[x]);
        x = x / spf[x];
    }
    return ret;
}

void code() {
    int n;
    cin>>n;
    int ans=0;
    vector<int> A(n);
    for(int i=0; i<n; i++) {
        cin>>A[i];
    }
    int p = A[0];
    for(int i=1; i<n; i++) {
        p = __gcd(p, A[i]);
    }
    if(p>1) {
        cout << "not coprime\n";
        return;
    }
    sieve();
    set<int> factors;
    for(int i:A) {
        set<int> pf = getFactorization(i);
        for(int x:pf) {
            if(factors.find(x)!=factors.end()) {
                cout << "setwise coprime\n";
                return;
            }
            factors.insert(x);
        }
    }


    cout << "pairwise coprime" << "\n";
}

signed main() {
    std::ios_base::sync_with_stdio(false);
    int t=1;
    // cin>>t;
    for(int i=0; i<t; i++) {
        code();
    }
}


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

int main() {
  int K, N;
  cin >> K >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  
  int before, after=0;
  for(int i=1;i<N;i++){
    before = A.at(i) - A.at(i-1);
    if(before > after){
      after = before;
    }
  }
  if(after < K - A.at(N-1) + A.at(0)){
    after = K - A.at(N-1) + A.at(0);
  }
  
  cout << K - after << endl;
}


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

const int MOD = 1000000007;

enum { A, C, G, T };
int dp[101][4][4][4];

int main(void) {
  int N;
  cin >> N;

  REP(i, 0, 4) REP(j, 0, 4) REP(k, 0, 4) {
    if (i == A && j == G && k == C) continue;
    if (i == A && j == C && k == G) continue;
    if (i == G && j == A && k == C) continue;
    dp[3][i][j][k] = 1;
  }

  REP(t, 3, N) REP(i, 0, 4) REP(j, 0, 4) REP(k, 0, 4) REP(l, 0, 4) {
    if (j == A && k == G && l == C) continue;
    if (j == A && k == C && l == G) continue;
    if (j == G && k == A && l == C) continue;

    if (i == A && k == G && l == C) continue;
    if (i == A && j == G && l == C) continue;

    dp[t + 1][j][k][l] += dp[t][i][j][k];
    dp[t + 1][j][k][l] %= MOD;
  }

  int ans = 0;
  REP(i, 0, 4) REP(j, 0, 4) REP(k, 0, 4) {
    ans += dp[N][i][j][k];
    ans %= MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
use std::collections::HashMap;

#[test]
fn test() {
//    assert_eq!(green_bin(3, ['a', 'c', ]), -10);
//    assert_eq!(green_bin(1, -33), 34);
//    assert_eq!(green_bin(13, 3), 39);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
            .bytes()
            .map(|c| c.expect("failed to read char") as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
    token.parse().ok().expect("failed to parse token")
}

fn green_bin(n: usize, s: Vec<Vec<char>>) -> u64 {
    let mut ans = 0;
    let mut map = HashMap::new();
    for i in 0..n {
        *map.entry(&s[i]).or_insert(0) += 1;
    }
//    println!("{:?}", map);
    for (_, n) in map {
        ans += n * (n - 1) / 2;
    }
    ans
}
fn main() {
    let n: usize = read();
    let mut s = Vec::new();
    for _i in 0..n {
        let mut si: Vec<char> = read::<String>().chars().collect();
        si.sort();
        s.push(si);
    }
    println!("{}", green_bin(n, s));
}



Measured memory_bytes: 22780
using namespace std;

#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <utility>
#include <functional>
#include <queue>
#include <cmath>
using namespace std;


int main(void){
	long long int N;

	cin >> N;
	auto a = sqrt(N*2);
	auto ai = (int)floor(a);

	if (ai * (ai + 1) != N * 2) {
		cout << "No" << endl;
		return 0;
	}
	
	vector<vector<int>> ret(ai+1);

	for (auto& i : ret)
		i.resize(ai);

	int now = 1;

	for (int i = 0; i < ai; i++) {
		for (int j = i; j < ai; j++) {
			ret[i][j] = ret[j+1][i] = now++;
		}
	}

	cout << "Yes" << endl << ai + 1 << endl;
	for (long long int i = 0; i < ai+1; i++) {
		cout << ret[i].size();
		for (auto j : ret[i])
			cout << " " << j;
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 2176
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

public class Main {

    private static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Map<Integer, Integer> nodeConnections = new HashMap<Integer, Integer>();
        for(int i = 0 ; i <6; ++i) {
            int temp = sc.nextInt();
            int value = 0;
            if(nodeConnections.get(temp) == null) {
                value = 1;
                nodeConnections.put(temp, value);
            }else {
                value = nodeConnections.get(temp);
                nodeConnections.put(temp, ++value);
            }
            //System.out.println(temp +" ="+value);
        }
        Set<Integer> nodes = nodeConnections.keySet();
        int conn_one = 0;
        int conn_two = 0;
        for(Integer n :nodes){
            int value = nodeConnections.get(n);
            //System.out.println(n +" ="+value);
            if(value == 1) {
                conn_one ++;
            }else if (value==2){
                conn_two ++;
            }
        }
        //System.out.println("conn_one="+conn_one +" conn_two="+conn_two);
        if(conn_one == 2 && conn_two == 2) {
            System.out.println("YES");
        }else {
            System.out.println("NO");
        }
    }

}


Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
int n, q, A[20], m;
bool res[40001];
void Brute_Force() {
	for (int i = 0; i < (1 << n); i++) {
		int sum = 0;
		for (int j = 0; j < n; j++) {
			if (i & (1 << j)) {
				sum += A[j];
			}
		}
		res[sum] = true;
	}
}

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> A[i];
	Brute_Force();
	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> m;
		cout << (res[m] ? "yes" : "no") << endl;
	}
	return 0;
}

Measured memory_bytes: 3096
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<deque>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<iomanip>
#include<sstream>
using namespace std;
#define pi acos(-1.0) 
#define ms(x,n) memset(x,n,sizeof(x));
#define pb push_back
typedef long long ll;//string::npos
typedef long long iint;
ll gcd(ll a,ll b){ return a%b==0?b:gcd(b,a%b); }
const int inf=0x3f3f3f3f;
const int maxn=2e5+5;
const int mod=998244353;
//priority_queue<ll,vector<ll>,greater<ll> > q;//小根堆 
//vector<int> vt;
//pair<int,int> p;
//map<int,int> m; 
int main() {
	ios::sync_with_stdio(false);
	
	int n;
	long long sum=0;
	cin>>n;
	char a[4005];
	cin>>a+1;
	int r[4005]={0};
	int g[4005]={0};
	int b[4005]={0};
	for(int i=2;i<=n+1;i++){//当前位置前面RGB个数 ,不包括当前位置 
		r[i]=r[i-1];
		g[i]=g[i-1];
		b[i]=b[i-1];
		if(a[i-1]=='R'){
			r[i]=r[i-1]+1;
		}else if(a[i-1]=='G'){
			g[i]=g[i-1]+1;
		}else{
			b[i]=b[i-1]+1;
		}
	}
//	cout<<r[n+1]<<" "<<g[n+1]<<" "<<b[n+1]<<endl;
	for(int i=1;i<=n;i++){
		if(a[i]=='R'){
			for(int j=i+1;j<=n;j++){
				if(a[j]=='G'){
					sum+=(b[n+1]-b[j]);
					if(j-i+j<=n&&a[j-i+j]=='B'){
						sum--;
					}
				}else if(a[j]=='B'){
					sum+=(g[n+1]-g[j]);
					if(j-i+j<=n&&a[j-i+j]=='G'){
						sum--;
					}
				}
			}
		}else if(a[i]=='G'){
			for(int j=i+1;j<=n;j++){
				if(a[j]=='R'){
					sum+=(b[n+1]-b[j]);
					if(j-i+j<=n&&a[j-i+j]=='B'){
						sum--;
					}
				}else if(a[j]=='B'){
					sum+=(r[n+1]-r[j]);
					if(j-i+j<=n&&a[j-i+j]=='R'){
						sum--;
					}
				}
			}
		}else{
			for(int j=i+1;j<=n;j++){
				if(a[j]=='R'){
					sum+=(g[n+1]-g[j]);
					if(j-i+j<=n&&a[j-i+j]=='G'){
						sum--;
					}
				}else if(a[j]=='G'){
					sum+=(r[n+1]-r[j]);
					if(j-i+j<=n&&a[j-i+j]=='R'){
						sum--;
					}
				}
			}
		}
	}
	cout<<sum<<endl;
	
		
}

Measured memory_bytes: 3704
n=int(input())
a = list(map(int,input().split()))
def p(val):
    print(val)
 
sho = 10**9 +7
a1 = sum(a)**2
b1 = list(map(lambda y:y**2,a))
b2=sum(b1)
result = ((a1-b2)//2)% sho
p(result)

Measured memory_bytes: 31392
N = int(input())
n = N//15
a = n*(120+(n-1)*120)/2
b = N%15
c = 0
if b == 1:
    c = 15*n+1
elif b == 2 or b == 3:
    c = 15*n*2+3
elif b == 4 or b == 5 or b == 6:
    c = 15*n*3+7
elif b == 7:
    c = 15*n*4+14
elif b == 8 or b == 9 or b == 10:
    c = 15*n*5+22
elif b == 11 or b == 12:
    c = 15*n*6+33
elif b == 13:
    c = 15*n*7+46
elif b == 14:
    c =15*n*8+60
print(int(a+c))
    

Measured memory_bytes: 9216
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/quo.hpp
#ifndef QUO_H
#define QUO_H

/*
a == tools::quo(a, b) * b + tools::mod(a, b)
0 <= tools::mod(a, b) < std::abs(b)
*/

namespace tools {
  template <typename T>
  constexpr T quo(const T& lhs, const T& rhs) {
    return lhs > static_cast<T>(0)
      ? lhs / rhs
      : rhs > static_cast<T>(0)
        ? -((-lhs - 1 + rhs) / rhs)
        : (-lhs - 1 + -rhs) / -rhs;
  }
}

#endif

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


using i64 = ::std::int_fast64_t;
using u64 = ::std::uint_fast64_t;
using i32 = ::std::int_fast32_t;
using u32 = ::std::uint_fast32_t;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// lib/mod.hpp
#ifndef MOD_HPP
#define MOD_HPP


/*
a == tools::quo(a, b) * b + tools::mod(a, b)
0 <= tools::mod(a, b) < std::abs(b)
*/

namespace tools {
  template <typename T>
  constexpr T mod(const T& lhs, const T& rhs) {
    return lhs - ::tools::quo(lhs, rhs) * rhs;
  }
}

#endif

// main.cpp

int main() {
  i64 X, K, D;
  std::cin >> X >> K >> D;

  if (tools::quo(X, D) >= K) {
    std::cout << X - K * D << std::endl;
    return 0;
  }

  if (tools::quo(-X, D) >= K) {
    std::cout << -X - K * D << std::endl;
    return 0;
  }

  i64 answer = tools::mod(tools::mod(X, 2 * D) + tools::mod<i64>(K, 2) * D, 2 * D);
  if (answer > D) answer = 2 * D - answer;
  std::cout << answer << std::endl;
  return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char c;
    cin>>c;
    if(c=='A') cout<<"T"<<endl;
    else if(c=='C') cout<<"G"<<endl;
    else if(c=='T') cout<<"A"<<endl;
    else cout<<"C"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define M 205
using namespace std;
int m,nmin,nmax,p[M],maxp,ans;

int main(){
  while(1){
    cin>>m>>nmin>>nmax;
    if(!m&&!nmin&&!nmax)break;
    maxp=ans=0;
    for(int i=0;i<m;i++)cin>>p[i];
    for(int i=nmax-1;i>=nmin-1;i--)
      if(p[i]-p[i+1]>maxp)
	maxp=p[i]-p[i+1],ans=i+1;
    cout<<ans<<endl;
  }
  return 0;
}

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


int main(void)
{
    int N;
    cin >> N;
    long long A[110000];
    for(int i = 0; i < N; i++) cin >> A[i];
    
    int Q;
    cin >> Q;
    long long B[110000],C[110000];


    for(int i = 0; i < Q; i++){
        cin >> B[i] >> C[i];
    }

    vector<long long> hist(110000, 0);
     for(int i = 0; i < N; i++){
         hist[A[i]] += 1;
     }

    long long sum = 0;
    for(int j=0; j<N; j++){
        sum += A[j];
    }
    
    for(int i = 0; i < Q; i++){
        sum -= hist[B[i]]*B[i];
        long long temp = hist[B[i]];
        hist[B[i]] = 0;
        sum += temp*C[i];
        hist[C[i]] += temp;
        cout << sum << endl;
    }
}


Measured memory_bytes: 6424
<>;
$z=@L=1..(@A=glob<>);
($j=--$L[--$_])<0or$z-=!$B[$j]++for@A;
map{
	($X,$Y)=split;
	($j=$L[$A[--$X]]++)<0or$z+=!--$B[$j];
	($j=--$L[$A[$X]=--$Y])<0or$z-=!$B[$j]++;
	print$z,$/
}<>


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

public class Main {

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

  public void run() {

    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      String op;
      String[] words;
      Tree tree = new Tree();
      StringBuilder buf = new StringBuilder();

      for(int i=0,k=0; i<n; i++,k=0){
        words = br.readLine().split(" ");
        op  = words[k++];
        if ( op.equals("insert") ) { 
          tree.insert(Integer.parseInt(words[k++]));
        }
        else {
          buf.append(tree.getRoundPath());
        }
      }

      System.out.print(buf);

    }
    catch(IOException e) {
      System.out.println("IOException!");
    }
  }
}

class Tree {

  static final BTreeNode NIL = new BTreeNode();
  BTreeNode root;
  StringBuilder buf;

  public Tree() {
    root = NIL;
    buf = new StringBuilder();
  }

  public void insert(int val) {
    BTreeNode y = NIL;
    BTreeNode x = root;
    BTreeNode z = new BTreeNode();
    z.key = val;

    while( !x.equals(NIL) ) {
      y = x;
      if( z.key < x.key )
        x = x.left;
      else
        x = x.right;
    }
    z.parent = y;

    if( y.equals(NIL) ){
      root = z;
    }
    else if( z.key < y.key )
      y.left = z;
    else
      y.right = z;
  } 
  void preParse(BTreeNode u) {
    if( !u.equals(NIL) ) {
      buf.append(" ").append(u.key);
      preParse(u.left);
      preParse(u.right);
    }
  }
  void inParse(BTreeNode u) {
    if( !u.equals(NIL) ) {
      inParse(u.left);
      buf.append(" ").append(u.key);
      inParse(u.right);
    }
  }

  String getRoundPath() {
    buf.setLength(0);

    inParse(root);
    buf.append("\n");
    preParse(root);
    buf.append("\n");

    return buf.toString();
  }
}

class BTreeNode {
  int key;
  BTreeNode parent,left,right;

  public BTreeNode() {
    this.key = -1;
    this.parent =
    this.left =
    this.right = Tree.NIL;
  }

  @Override
  public boolean equals(Object o) {
    if(o == this) return true;
    if(o == null) return false;
    if(!(o instanceof BTreeNode)) return false;

    BTreeNode node = (BTreeNode)o;
    if(!(this.key == node.key)) return false;

    return true;
  }
}


Measured memory_bytes: 126640
#!/usr/bin/env python3
import sys
import math

def solve(A: int, B: int, H: int, M: int):
    A_angle = (360 * H) // 12 + (30 * M) / 60
    B_angle = 360 * M / 60
    theta = 2*math.pi * (abs(A_angle - B_angle)/ 360)
    ans = math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(theta))
    print(ans)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    H = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    solve(A, B, H, M)

if __name__ == '__main__':
    main()


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


#define mx 100005
#define ll long long 

void IO()
{
  #ifndef ONLINE_JUDGE
  freopen("in.txt","r",stdin);
  freopen("out.txt","w",stdout);
  #endif
}


int ar[mx][2];
char ch[mx];
int m,n,k,ii;

void solve()
{
   cin>>n;
   for(int i=1;i<=n;i++)cin>>ar[i][0]>>ar[i][1];
    for(int i=1;i<=n-2;i++)
    {
        int cnt=0;
        for(int j=i;j<=n;j++)
        {
            if(ar[j][0]==ar[j][1])cnt++;
            else break;
            if(cnt==3)
            {
                printf("Yes\n");
                return;
            }
        }
    }
    cout<<"No\n";
}

int main()
{
   IO();
  int t=1;
 // scanf("%d",&t);
  while(t--)
  {
    solve();
  }
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cassert>
#include <queue>

using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long LL;
typedef pair<int,int> PII;
typedef queue<int> QI;

const LL mod=1000000007;
LL powmod(LL a,LL b) {LL res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// head

char c,s[233333];
int t;

int main(){
 //   freopen("in.txt","r",stdin);
    s[0]='A';
    t=1;LL ans=0,now=0;
    while(~scanf("%c",&c)){
        now++;
        if(c=='T'){
            if(s[t-1]=='S'){ans++;t--;continue;}
            s[t++]=c;
        }else{
            s[t++]=c;
        }
    }
    cout<<now-2*ans-1;
	return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		long N = sc.nextLong();
		long K = sc.nextLong();
		
	long ans;
	ans=N-K+1;
	
	System.out.println(ans);
	}
}

Measured memory_bytes: 21588
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long int
#define reus ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int main()
{
	reus;
	ll x,a=100,b,c=0;
	cin>>x;
	while(a<x)
	{
		if(x>a)
		{
			b=a/100;
			a+=b;
			c++;
		}
	}
	cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 3652
//#pragma GCC optimize("Ofast")
#include <set>
#include <map>
#include <stack>
#include <cmath>
#include <queue>
#include <bitset>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <tr1/unordered_map>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define bql 2147483647
#define ll long long
#define ull unsigned long long
using namespace std::tr1;
using namespace std;
const int N=2e5+5;
const int mod=998244353;
const int fx[5]={0,-1,0,1,0};
const int fy[5]={0,0,-1,0,1};
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while (ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while (ch>='0' && ch<='9'){x=(x<<3)+(x<<1);x+=(ch-'0');ch=getchar();}
    return x*f;
}

void write(int x)
{
    if (x<0) putchar('-'),x=-x;
    if (x>10) write(x/10);
    putchar(x%10+'0');
}

int n,a[105],minn=bql,sum;
int main()
{
  fast;
  cin>>n;
  for (int i=1;i<=n;i++)
      cin>>a[i];
  
  for (int i=0;i<=100;i++)
  {
  	for (int j=1;j<=n;j++)
  	    sum+=(a[j]-i)*(a[j]-i);
  	if (sum<minn)
  	    minn=sum;
  	sum=0;
  }
  cout<<minn<<endl;
  return 0;
}

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

class F
{
	static int[] Read() => Console.ReadLine().Split().Select(int.Parse).ToArray();
	static void Main()
	{
		var z = Read();
		int h = z[0], w = z[1];
		var a = new int[h].Select(_ => Console.ReadLine()).ToArray();

		var s = (i: 0, j: 0);
		var t = (i: 0, j: 0);

		var dag = new List<long[]>();
		for (int i = 0; i < h; i++)
			for (int j = 0; j < w; j++)
				if (a[i][j] == 'o')
				{
					dag.Add(new[] { i + 1, h + j + 1, 1L });
					dag.Add(new[] { h + j + 1, i + 1, 1L });
				}
				else if (a[i][j] == 'S')
				{
					s = (i, j);
					dag.Add(new[] { 0, i + 1, 1L << 60 });
					dag.Add(new[] { 0, h + j + 1, 1L << 60 });
				}
				else if (a[i][j] == 'T')
				{
					t = (i, j);
					dag.Add(new[] { i + 1, h + w + 1, 1L << 60 });
					dag.Add(new[] { h + j + 1, h + w + 1, 1L << 60 });
				}

		if (s.i == t.i || s.j == t.j) { Console.WriteLine(-1); return; }
		Console.WriteLine(MaxFlow(h + w + 1, 0, h + w + 1, dag.ToArray()));
	}

	static long MaxFlow(int n, int sv, int ev, long[][] dag)
	{
		var map = Array.ConvertAll(new int[n + 1], _ => new List<long[]>());
		foreach (var r in dag)
		{
			map[r[0]].Add(new[] { r[1], r[2], map[r[1]].Count });
			map[r[1]].Add(new[] { r[0], 0, map[r[0]].Count - 1 });
		}

		long Bfs()
		{
			var from = new long[n + 1][];
			var u = new bool[n + 1];
			var minFlow = Enumerable.Repeat(long.MaxValue, n + 1).ToArray();
			var q = new Queue<long>();
			q.Enqueue(sv);

			while (q.TryDequeue(out var v))
			{
				if (v == ev) break;
				foreach (var r in map[v])
				{
					if (u[r[0]] || r[1] == 0) continue;
					from[r[0]] = r;
					u[r[0]] = true;
					minFlow[r[0]] = Math.Min(minFlow[v], r[1]);
					q.Enqueue(r[0]);
				}
			}

			if (from[ev] == null) return 0;
			long tv = ev;
			while (true)
			{
				from[tv][1] -= minFlow[ev];
				var rev = map[from[tv][0]][(int)from[tv][2]];
				rev[1] += minFlow[ev];
				if ((tv = rev[0]) == sv) break;
			}
			return minFlow[ev];
		}

		long M = 0, t;
		while ((t = Bfs()) > 0) M += t;
		return M;
	}
}


Measured memory_bytes: 34164
#include <iostream>

using namespace std;

int n;
int ans = 0;
void check(int x){
  bool f3=false,f5=false,f7=false;
  while(x != 0){
    if(x > n)
       break;

    int a = x % 10;
    if(a == 3) f3 = true;
    else if(a == 5) f5 = true;
    else if(a == 7) f7 = true;
    x  /= 10;
  }
  if(f3 && f5 && f7)
    ans++;
}

void dfs(int x){
  check(x);
  if(x <= 100000000){
    dfs((10*x)+ 3);
    dfs((10*x)+ 5);
    dfs((10*x)+ 7);
  }
}

int main(){
  cin >> n;
  dfs(0);
  cout << ans << endl;
  return 0;
}


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

int ret,n;



void dfs(int x,int x3=0,int x5=0,int x7=0){
	if (x>n)return;

		if(x3>0 && x5>0 && x7>0)ret++;		
		dfs(10*x+3,x3+1,x5,x7);
		dfs(10*x+5,x3,x5+1,x7);
		dfs(10*x+7,x3,x5,x7+1);

}

signed main(){
	cin>>n;
	ret=0;
	dfs(0);
	cout<<ret<<endl;	

	}	



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        boolean ans = isPalind(str, 0, str.length()) &&
                isPalind(str, 0, (str.length() - 1) / 2) &&
                isPalind(str, (str.length() + 3) / 2 - 1, str.length());
        System.out.println(ans ? "Yes" : "No");
    }

    static boolean isPalind(String str, int s, int e) {
        StringBuilder rsb = new StringBuilder();
        char[] C = str.toCharArray();
        for(int i = s; i < e - s; i++) {
            if(C[i] != C[e - i - 1]) return false;
        }
        return true;
    }
}


Measured memory_bytes: 23124
x, y, z, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ab = []

for s in a:
    for t in b:
       ab.append(s + t)

ab.sort(reverse=True)
c.sort(reverse=True)

ans = []

for i in range(min(k, len(ab))):
    for u in c:
        ans.append(ab[i] + u)

ans.sort(reverse=True)

for i in range(k):
    print(ans[i])


Measured memory_bytes: 151768
import java.util.Scanner;

public class Main{
    public static void main(String[]argc){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if(a<b){
            if(b<c){
                System.out.printf("%d %d %d\n",a,b,c);
            }else if(a<c){
                System.out.printf("%d %d %d\n",a,c,b);
            }else{
                System.out.printf("%d %d %d\n",c,a,b);
            }
        }  else if(b<a){
            if(a<c){
                System.out.printf("%d %d %d\n",b,a,c);
            }else if(b<c){
                System.out.printf("%d %d %d\n",b,c,a);
            }else{
                System.out.printf("%d %d %d\n",c,b,a);
            }
        }
    }
}




Measured memory_bytes: 26244
s = input()
lenS = len(s)
MOD = 10 ** 9 + 7

dp = [[0] * 4] * (lenS + 1)
dp[0] = [1, 0, 0, 0]

for i in range(1, lenS + 1):
    if s[i - 1] == 'A':
        l = dp[i-1]
        dp[i] = [l[0], l[0] + l[1], l[2], l[3]]
    if s[i - 1] == 'B':
        l = dp[i-1]
        dp[i] = [l[0], l[1], l[1] + l[2], l[3]]
    if s[i - 1] == 'C':
        l = dp[i-1]
        dp[i] = [l[0], l[1], l[2], l[2] + l[3]]
    if s[i - 1] == '?':
        l = dp[i-1]
        dp[i] = [(l[0] * 3) % MOD, (l[0] + l[1] * 3) %MOD, (l[1] + l[2] * 3) % MOD, (l[2] + l[3] * 3) % MOD]
    
print(dp[lenS][3] % MOD)

Measured memory_bytes: 27616
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  int ans;
  if(a == b)  ans = c;
  if(b == c)  ans = a;
  if(c == a)  ans = b;
  cout << ans << endl;
}


Measured memory_bytes: 256
//I Guds namn
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

typedef long long ll;

const ll MAXN = 2 * 100 * 1000 + 13;

ll d[MAXN];

queue<ll> bfsq;

vector<ll> adj[MAXN];

int main()
{
    ios::sync_with_stdio(false);
    ll n, m; cin >> n >> m;
    for(ll i = 0;i < m;i++)
    {
	ll u, v; cin >> u >> v; u--; v--;
	adj[u].push_back(v); adj[v].push_back(u);
    }
    d[0] = 0;
    bfsq.push(0);
    while(bfsq.size())
    {
	ll u = bfsq.front(); bfsq.pop();
	for(auto v : adj[u])
	{
	    if(d[v] <= 0)
	    {
		d[v] = d[u] + 1;
		bfsq.push(v);
	    }
	}
    }
    if(d[n - 1] == 2)
    {
	cout << "POSSIBLE";
    }
    else
    {
	cout << "IMPOSSIBLE";
    }
    cout << endl;
    return 0;
}

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

static const int MAX = 200000;

int main(void){
    int R[MAX], n;
    cin >> n;
    for(int i=0; i<n; i++) cin >> R[i];
    
    int maxv = -2000000000, minv = R[0];
    for(int i=1; i<n; i++){
        if(maxv < R[i] - minv) maxv = R[i] - minv;
        if(minv > R[i]) minv = R[i];
    }
    
    cout << maxv << endl;
    return 0;
    
}

Measured memory_bytes: 3840
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<string>
#include<cmath>
#include<queue>
#include<vector>
#include<sstream>
#include<algorithm>
#include<stack>
#include<bitset>
#include<map>
#include<unordered_map>
#include<set>
#define rep(i,n) for(int i=0;(i)<(n);i++)
#define rep1(i,n) for(int i=1;(i)<=(n);i++)
#define mst(a,b) memset(a,b,sizeof(a))
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define dbg(a) cout<<"* "<< #a <<" : "<<a<<endl
#define fr first
#define se second
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ls x<<1
#define rs x<<1|1
#define lowbit(x) x&(-x)
#define ac cout<<ans<<endl
//#define DEBUG 0
using namespace std;
const double pi=acos(-1.0);
const double eps=1e-6;
const ull hashp=1e7+19;
const ll INF=0x3f3f3f3f3f3f3f3fll;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;
const int maxn=2e5+100;

void solve()
{
	int n;scd(n);
	cout<<n*n<<endl;
}
int main(){
    //IOS;
    //freopen("D://data.txt","r",stdin);
    solve();
    return 0;
}


Measured memory_bytes: 256
using System;
class swap{
    public static void Main(){
        String[] str;
        int a,b;
        while(true){
            str = Console.ReadLine().Split(' ');
            a = int.Parse(str[0]);
            b = int.Parse(str[1]);
            if(a+b == 0){
                break;
            }
            else{
                if(a > b){
                    Console.WriteLine("{0} {1}",b,a);
                }
                else{
                    Console.WriteLine("{0} {1}",a,b);
                }
            }
        }
    }
}


Measured memory_bytes: 15864
n=int(input())
if n < 10:
	print(n)
else:
	erg = 0
	if len(str(n)) % 2 == 1:
		erg += n - 10**(len(str(n))-1) + 1
	#print(erg)
	for k in range(1, len(str(n)), 2):
		erg += 10**k - (10**(k-1))
	print(erg)


Measured memory_bytes: 3060
N = int(input())
T,A = map(int,input().split())
H = list(map(int,input().split()))
_min = 0
for i in range(N):
	#print(abs(A - (T - H[i]*0.006)))
	if abs(A - (T - H[_min]*0.006))   >= abs(A - (T - H[i]*0.006)):

		_min = i
	
print(_min+1)

Measured memory_bytes: 3060
import itertools

N, X, Y = map(int, input().split())
answers = [0 for _ in range(N - 1)]
# print(answers)

def min_distance(a, b):
    global X, Y
    simple = b - a
    a_to_x = abs(X - a)
    x_to_y = 1
    y_to_b = abs(Y - b)
    return min(simple, a_to_x + x_to_y + y_to_b)

G = [(i + 1) for i in range(N)]
# print(G)
for v in itertools.combinations(G, 2):
    # print(v[0], v[1])
    # print(v[0], v[1], min_distance(v[0], v[1]))
    answers[min_distance(v[0], v[1]) - 1] += 1

for answer in answers:
    print(answer)


Measured memory_bytes: 3572
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>

#define MOD 1e9+7;
#define INF 1e17+9;
#define PI acos(-1);

using namespace std;

int main(){
	long long n,k;
	cin >> n >> k;
	vector<long long> h(n,0);
	for(long long i=0;i<n;i++){
		cin >> h[i];
	}
	sort(h.begin(),h.end());
	long long cost=1e9+7;
	for(int i=0;i<=n-k;i++){
		cost=min(cost,h[i+k-1]-h[i]);
	}
	cout << cost << endl; 
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <set>
#include <algorithm>
using namespace std;

const int nlimit = 12;
int n, k;
string cards[nlimit];

int solve();
int main(){
  while(cin >> n >> k, n!=0 && k!=0){
    for(int i=0; i<n; i++) cin >> cards[i];
    cout << solve() << endl;
  }

  return 0;
}

int solve(){
  set<string> s;

  sort(cards, cards+n);
  do{
    string tmp = "";
    for(int i=0; i<k; i++){
      tmp += cards[i];
    }
    s.insert(tmp);
  }while(next_permutation(cards, cards+n));

  return s.size();
}



Measured memory_bytes: 3332
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n, k;
  cin >> n >> k;
  vector<vector<int>> mapping(2*k, vector<int>(2*k, 0));
  rep(i, n){
    int x, y;
    cin >> x >> y;
    char c;
    cin >> c;
    if(c == 'B') x += k;
    x %= 2*k;
    y %= 2*k;
    mapping.at(y).at(x)++;
  }
  // rep(i, 2*k){
  //   rep(j, 2*k) cerr << mapping.at(i).at(j) << " ";
  //   cerr << endl;
  // }
  vector<vector<int>> sums(2*2*k+1, vector<int>(2*2*k+1, 0));
  rep(i, 2*2*k){
    rep(j, 2*2*k){
      sums.at(i+1).at(j+1) = sums.at(i).at(j+1);
      sums.at(i+1).at(j+1) += sums.at(i+1).at(j);
      sums.at(i+1).at(j+1) -= sums.at(i).at(j);
      sums.at(i+1).at(j+1) += mapping.at(i%(2*k)).at(j%(2*k));
    }
  }
  // rep(i, 2*2*k+1){
  //   rep(j, 2*2*k+1){
  //     cerr << sums.at(i).at(j) << " ";
  //   }
  //   cerr << endl;
  // }
  int ans = 0;
  rep(i, 2*k){
    rep(j, 2*k){
      int add = sums.at(i+k).at(j+k) - sums.at(i).at(j+k) - sums.at(i+k).at(j) + sums.at(i).at(j);
      int ad2 = sums.at(i+2*k).at(j+2*k) - sums.at(i+k).at(j+2*k) - sums.at(i+2*k).at(j+k) + sums.at(i+k).at(j+k);
      // cerr << i << " " << j << " " << add << " " << ad2 << endl;
      add += ad2;
      ans = max(ans, add);
      
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 81648
#!/usr/bin/python3

sl = []
nl = []

n = int(input())

for i in range(n):
    s,t= input().split()
    sl.append(s)
    nl.append(int(t))

index = sl.index(input())

cnt = 0

for i in nl[index+1:]:
    cnt += i

print(cnt)

Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <string>
#include <typeinfo>
#include <climits>
#include <algorithm>
#include <cctype>
#include <stdio.h>
#include <cstdlib>
using namespace std;

int main(){
    char s[4];
    cin >> s;
    
    cout << 700+100*count(s,s+4,'o');
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
while(true)
{
int w,h;
scanf("%d %d", &h, &w);
if(0==h&&0==w)
break;

bool isStartSharp = true;
for(int i = 0; i < h; ++i)
{
bool isSharp = isStartSharp;
for(int j = 0; j  <w; ++j)
{
if(isSharp) printf("#");
else printf(".");
isSharp = !isSharp;
}
printf("\n");
isStartSharp = !isStartSharp;
}
printf("\n");
}
return 0;
}

Measured memory_bytes: 1004
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		int l = saori.saori_hayami();
		int[] a = new int[n];
		for(int i = 0;i < n;i++){
			a[i] = l + i;
		}
		int ans = 0;
		Arrays.sort(a);
		if(a[0] <= 0 && a[n-1] >= 0){
			for(int i = 0;i < n;i++){
				ans += a[i];
			}
		} else if(a[0] > 0){
			for(int i = 1;i < n;i++){
				ans += a[i];
			}
		} else {
			for(int i = 0;i < n-1;i++){
				ans += a[i];
			}
		}
		System.out.println(ans);


		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 21332
#include <stdio.h>

void flip(int *a, int *b)
{
    int c;
    if(*a > *b) {
        c = *a;
        *a = *b;
        *b = c;
    }
}

int main(void)
{
    int a, b, c;

    scanf("%d %d %d", &a, &b, &c);
    flip(&a,&b);    flip(&b,&c);    flip(&a,&b);
    printf("%d %d %d\n", a, b, c);

    return 0;
}

Measured memory_bytes: 596
#include <stdio.h>
#include <string.h>
 
int main(){
    int m, h;
    char cards[256], temp[256], result[256];
    int i, j=0, len;
 
    while(1){
        scanf("%s", cards);
        len=strlen(cards);
        if(strcmp(cards, "-")==0&&len==1)break;
        scanf("%d", &m);
        for(;m>0;m--){
            scanf("%d", &h);
            strcpy(temp, cards);
            for(i=0;i<h;i++){
                cards[len-h+i]=temp[i];
            }
            for(i=0;i<len-h;i++){
                cards[i]=temp[i+h];
            }
        }
        for(i=0;i<len;i++){
            result[j++]=cards[i];
        }
        result[j++]='\n';
    }
    result[j]='\0';
    printf("%s", result);
 
    return 0;
}

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

class Problem {
private:
  map<string, vector<string> > m;
  set<string> num, vis;

public:
  Problem() {
    int n; cin >> n;
    if(n == 0) exit(0);
    string first;
    for(int i = 0; i < n; ++i) {
      string s; cin >> s;
      replace(s.begin(), s.end(), ':', ' ');
      replace(s.begin(), s.end(), ',', ' ');
      replace(s.begin(), s.end(), '.', ' ');
      stringstream ss(s);
      string group;
      ss >> group;
      if(first.empty()) first = group;
      string name;
      while(ss >> name) {
        m[group].push_back(name);
      }
    }
    cout << rec(first) << endl;
  }

  int rec(const string &s) {
    vis.insert(s);
    if(!m.count(s)) return 1;
    int res = 0;
    for(int i = 0; i < m[s].size(); ++i) {
      if(vis.count(m[s][i])) continue;
      res += rec(m[s][i]);
    }
    return res;
  }
};

int main() {
  while(1) Problem p;
  return 0;
}

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;
const int MOD = 2019;

int main(){
  int L, R;
  cin >> L >> R;
  vector<bool> flag(MOD, false);
  if(R - L >= MOD) {
    REP(i, MOD) flag[i] = true;
  }else{
    L %= MOD;
    R %= MOD;

    REP(i, MOD) {
      if(L <= R) {
        if(L <= i && i <= R) flag[i] = true;
      }else{
        if(i <= R || L <= i) flag[i] = true;
      }
    }
  }

  int ret = MOD;
  REP(i, MOD)for(int j = i + 1; j < MOD; ++j) {
    if(!flag[i] || !flag[j]) continue;
    ret = min(ret, i * j % MOD);
  }

  cout << ret << endl;
  return 0;
}



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

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

using namespace std;

int main(){
	string s; cin>>s;
	int n=s.length();

	int i;
	for(i=(n+1)/2; i<n && s[i]==s[n-i-1] && s[i]==s[n/2]; i++);
	cout<<i<<endl;

	return 0;
}


Measured memory_bytes: 512
import sys
stdin = sys.stdin
def li(): return map(int, stdin.readline().split())

N, M = tuple(li())
common = set(range(1,M+1))
for _ in range(N):
    answer = tuple(li())
    favs = set(answer[1:])
    common = common.intersection(favs)
print(len(common))



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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

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

ll fact(ll n) {
    if (n < 0) {
        return -1;
    } else if (n == 0 || n == 1) {
        return 1;
    } else {
        return n * fact(n - 1);
    }
}

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N;
    cin >> N;

    vector<Pll> p;
    rep (i, N) {
        ll x, y;
        cin >> x >> y;
        p.push_back(make_pair(x, y));
    }

    sort(p.begin(), p.end());

    double sum = 0;
    do {
        rep (i, N-1) {
            sum += sqrt((p[i].first-p[i+1].first)*(p[i].first-p[i+1].first) + (p[i].second-p[i+1].second)*(p[i].second-p[i+1].second));
        }
    } while (next_permutation(p.begin(), p.end()));

    double n = fact(N);
    cout << setprecision(12) << sum/n << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = System.Console.ReadLine().Trim().Split(' ');
            int iA = int.Parse(sS[0]);
            int iB = int.Parse(sS[1]);
            int iC = int.Parse(sS[2]);
            int iD = int.Parse(sS[3]);

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            string sOut = "Yes";
            while (true)
            {
                iC -= iB;
                if (iC <= 0) { break; }
                iA -= iD;
                if (iA <= 0) { sOut = "No"; break; }
            }

            // 出力
            System.Console.WriteLine("{0}", sOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


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

using namespace std;

int mod(int64_t number)
{
	constexpr int MOD{1'000'000'007};
	number %= MOD;
	if(number < 0)
	{
		number += MOD;
	}
	return number;
}

int bin_exp(int x, int y)
{
	int res{1};
	x = mod(x);
	while(y)
	{
		if(y & 1)
		{
			res = mod(1LL * res * x);
		}
		x = mod(1LL * x * x);
		y >>= 1;
	}
	return res;
}

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

	int N, K;
	cin >> N >> K;
	vector<int> dp(K + 1);
	for(int k = K; k >= 1; --k)
	{
		dp[k] = bin_exp(K / k, N);
	}
	for(int k = K - 1; k >= 1; --k)
	{
		int sub{};
		for(int j = k + k; j <= K; j += k)
		{
			sub = mod(sub + dp[j]);
		}
		dp[k] = mod(dp[k] - sub);
	}
  	int res{};
	for(int k = 1; k <= K; ++k)
	{
		res = mod(res + mod(1LL * dp[k] * k));
	}
  
	cout << res << "\n";
}

Measured memory_bytes: 3708
import math
def make_divisors(n):
    D=[]
    for i in range(1, int(n**0.5)+1):
        if n%i==0:
            D.append(i)
            if i!=n//i:
                D.append(n//i)
    D=reversed(sorted(D))
    return D

n=int(input())
Ans=[n]
T=make_divisors(n-1) #nスタートのもの
for t in T:
    if t!=1:
        Ans.append(t)

S=make_divisors(n) #nの約数
for s in S:
    now=n
    if s!=n and s!=1:
        while now%s==0:
            now=now//s
        if now%s==1:
            Ans.append(s)
        
Ans.sort()
ans=0
cnt=0
for a in Ans:
    if cnt!=a:
        cnt=a
        ans+=1
print(ans)

Measured memory_bytes: 39920
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int primax = 1000000;
		boolean[] pri = new boolean[primax+10000];
		for(int i=2;i<=primax;i++) pri[i] = true;
		for(int i=2;i<=primax+1;i++){
			for(int j=i+i;j<=primax;j+=i){
					pri[j]=false;
			}
		}
		
		while(true){
			int n = sc.nextInt();
			int x = sc.nextInt();
			if(n==0 && x==0) break;
			
			int[] a = new int[n];
			boolean[] f = new boolean[x+1];
			f[0] = true;
			for(int i=0;i<n;i++){
				a[i] = sc.nextInt();
				for(int j=a[i];j<=x;j+=a[i]){
					f[j] = true;
				}
			}
			
			int max = 0;
			for(int i=1;i<=x;i++){
				if(f[i]==false){
					for(int j=0;j<n;j++){
						if(i-a[j]>=0 && f[i-a[j]]==true){
							f[i] = true;
							break;
						}
					}
				}
				if(f[i]==true && pri[i]==true) max = i;
			}
			
			if(max==0) System.out.println("NA");
			else System.out.println(max);
		}	
	}	
}

Measured memory_bytes: 59520
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
 
#define MOD 1000000007

int d[300];

int main(){
  int n,m;
  cin>>n>>m;
  clr(d,0);
  rep(i,0,m){
    int a,l;
    cin>>a>>l;
    rep(i,0,l){
      d[(a+i)%n]=1;
    }
  }
  int flag = 1;
  rep(i,0,n){
    if(d[i]==0){
      flag = 0;
    }
  }
  if(flag == 1){
    cout << n << " 1" << endl;
    return 0;
  }
  rep(i,0,n){
    if(d[i]==0)break;
    d[i+n]=d[i];
  }
  map<int,int> ma;
  rep(i,1,2*n){
    rep(j,i,2*n){
      if(d[i-1]==0&&d[i]==1&&d[j]==1&&d[j+1]==0){
        flag = 1;
        rep(k,i,j+1){
          if(d[k]==0)flag=0;
        }
        if(flag == 1){
          ma[j-i+1]++;
        }
      }
    }
  }
  map<int,int>::reverse_iterator itr = ma.rbegin();
  while(itr!=ma.rend()){
    cout << (*itr).fi << " " << (*itr).se << endl;
    itr++;
  }
  return 0;
}


Measured memory_bytes: 1200
M=10**9+7;F=lambda X:pow(X,M-2,M);H,W,A,B=map(int,input().split());Z=C=1
for I in range(H-1):Z=C=C*(W+H-B-2-I)*F(I+1)%M
for I in range(1,H-A):C=C*(B-1+I)*(H-I)*F(I*(W+H-B-1-I))%M;Z+=C
print(Z%M)


Measured memory_bytes: 3064