akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include<algorithm>
#include <stdio.h>
#include <bitset>
#include<math.h>
#include<list>
#include<map>
using namespace std;
typedef long long ll;

int main() {
	int a, b, ans;
	cin >> a >> b;
	if (a < 10 && b < 10) {
		ans = a * b;
	}
	else {
		ans = -1;

	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Set;
import java.util.stream.Collectors;


public class Main {
	
	public static void main(String[] args) {
		Scanner s =new Scanner(System.in);
		
		int i;
		i=s.nextInt();
		s.nextLine();
		int[][] dp= new int[2][i];
				int[][] mat= new int[2][i];

		for(int n=0;n<2;n++){
			for(int j=0;j<i;j++){
				mat[n][j]=s.nextInt();
			}
			s.nextLine();
			
		}
		int i1=0;
		for(int j=0;j<i;j++){
			i1+=mat[0][j];
				dp[0][j]=i1;
			}
		i1=0;
		for(int j=0;j<i;j++){
			i1+=mat[1][i-j-1];
				dp[1][i-j-1]=i1;
			}
		int mx=0;
		for(int j=0;j<i;j++){
			if(dp[0][j]+dp[1][j]>mx)mx=dp[0][j]+dp[1][j];
			}
		System.out.println(mx);

	}
	
}

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

public class AtCoderC
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());

        int max = 0;
        Dictionary<string, int> dic = new Dictionary<string, int>();
        for (int i = 0; i < n; i++)
        {
            string s = Console.ReadLine();
            if (dic.ContainsKey(s))
            {
                int current = dic[s];
                dic[s] = current + 1;
                if (max < current + 1)
                {
                    max = current + 1;
                }

            }
            else
            {
                if (max < 1)
                {
                    max = 1;
                }
                dic.Add(s, 1);
            }
        }

        List<string> answers = new List<string>();
        foreach (var item in dic)
        {
            if (item.Value == max)
            {
                answers.Add(item.Key);
            }
        }

        // answers.Sort();
        var array = answers.ToArray();
        Array.Sort(array, Cmp);

        foreach (var answer in array)
        {
            Console.WriteLine(answer);
        }
    }

    private static int Cmp(string a, string b)
    {
        for (var i = 0; i < Math.Min(a.Length, b.Length); i++)
            if (a[i] < b[i]) return -1;
            else if (a[i] > b[i]) return 1;
        if (a.Length == b.Length) return 0;
        if (a.Length > b.Length) return 1;
        else return -1;
    }
}

Measured memory_bytes: 42332
#include <iostream>

using namespace std;

void rwFile() {
    freopen("INP.inp", "r", stdin);
    freopen("OUT.out", "w", stdout);
}

const long long oo = 1e18;

void solve() {
    int n; cin >> n;
    int k; cin >> k;
    int arr[n];
    for (int i = 0; i < n; i++) cin >> arr[i];
    long long res[n];
    res[0] = 0;
    for (int i = 1; i < n; i++) res[i] = oo;
    for (int i = 1; i < n; i++) {
        for (int j = 1; j <= k; j++) {
            if (i - j >= 0) {
                res[i]= min(res[i], abs(arr[i] - arr[i - j]) + res[i - j]);
            }
        }
    }
    cout << res[n - 1];
}

int main()
{
    //rwFile();
    solve();
}


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

int main(){
    char c;

    cin >> c;

    if(c=='A')cout << 'T' <<endl;
  	if(c=='T')cout << 'A' <<endl;
  	if(c=='G')cout << 'C' <<endl;
  	if(c=='C')cout << 'G' <<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 REP(i,n) for(int i=1;i<=n;i++)
typedef long long ll;
const int INF = 1<<21;

//m[i][j]はM_{i}M_{i+1}...M_{j}を計算するための最小の掛け算の回数とする。
int m[110][110];

int main(){
	int n;
	cin >> n;
	vector<int> p(n+1);
	rep(i,n){
		int a,b;
		cin >> a >> b;
		p[i] = a;
		if(i==n-1){
			p[i+1] = b;
		}
		p[i] = a;
	}
	
	rep(i,n){
		rep(j,n){
			if(i==j) continue;
			m[i][j] = INF;
		}
	}
	
	//lは対象となる行列の数
	for (int l = 2; l <= n ; ++l) {
		for (int i = 0; i <= n - l ; ++i) {
			int j = i + l - 1;
			for (int k = i; k <= j - 1; ++k) {
				m[i][j] = min(m[i][j], m[i][k] + m[k+1][j] + p[i]*p[k+1]*p[j+1]);
			}
		}
	}
	
	cout << m[0][n-1] << endl;
    return 0;
}




Measured memory_bytes: 3140
n= int(input())
k=((8*n+1)**0.5-1)/2
if k.is_integer():
    print('Yes')
    ik=int(k)
    print(ik+1)
    prel,newl=[],[]
    nexv,last=0,0
    for i in range(ik+1):
        if i==0:
            print(ik,*[t+1 for t in range(ik)])
            nexv=1
        else:
            last+=ik-i+1
            newl=[b+last+1 for b in range(ik-i)]
            for b in range(len(prel)):prel[b]+=1
            print(ik,*(prel+[nexv]+newl))
            prel.append(nexv)
            if newl:nexv=newl[0]
else:print('No')

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

int main(){
  int n;
  cin >> n;
  string s[n];
  rep(i,n)cin >> s[i];

  int ac=0,wa=0,tle=0,re=0;

  rep(i,n){
    if(s[i]=="AC")ac++;
    else if(s[i]=="WA")wa++;
    else if(s[i]=="TLE")tle++;
    else re++;
  }
  
  cout << "AC x " << ac  << endl;
  cout << "WA x " << wa  << endl;
  cout << "TLE x " << tle  << endl;
  cout << "RE x " << re  << endl;
}

Measured memory_bytes: 6748
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)
//std::sort(v.begin(), v.end(), std::greater<Type>());

ll w,h,x,y;

int main(){
  cin >> w >> h >> x >> y;
  cout<< double(w)*h/2 <<" ";
  if(x*2==w && y*2==h) cout<< 1 <<endl;
  else cout<< 0 <<endl;
}


Measured memory_bytes: 256
macro_rules !input {(source =$s :expr ,$($r :tt ) *) =>{let mut iter =$s .split_whitespace () ;let mut next =||{iter .next () .unwrap () } ;input_inner !{next ,$($r ) *} } ;($($r :tt ) *) =>{let stdin =std ::io ::stdin () ;let mut bytes =std ::io ::Read ::bytes (std ::io ::BufReader ::new (stdin .lock () ) ) ;let mut next =move ||->String {bytes .by_ref () .map (|r |r .unwrap () as char ) .skip_while (|c |c .is_whitespace () ) .take_while (|c |!c .is_whitespace () ) .collect () } ;input_inner !{next ,$($r ) *} } ;}
macro_rules !input_inner {($next :expr ) =>{} ;($next :expr ,) =>{} ;($next :expr ,$var :ident :$t :tt $($r :tt ) *) =>{let $var =read_value !($next ,$t ) ;input_inner !{$next $($r ) *} } ;}
macro_rules !read_value {($next :expr ,($($t :tt ) ,*) ) =>{($(read_value !($next ,$t ) ) ,*) } ;($next :expr ,[$t :tt ;$len :expr ] ) =>{(0 ..$len ) .map (|_ |read_value !($next ,$t ) ) .collect ::<Vec <_ >>() } ;($next :expr ,chars ) =>{read_value !($next ,String ) .chars () .collect ::<Vec <char >>() } ;($next :expr ,usize1 ) =>{read_value !($next ,usize ) -1 } ;($next :expr ,$t :ty ) =>{$next () .parse ::<$t >() .expect ("Parse error" ) } ;}

fn main() {
   input! {
      n: usize,
      a: [i64; n]
   }
   let mut s = a[0];
   let mut ans = 0;
   if a[0] == 0 {
      s = 1;
      ans += 1;
   }
   for i in 1..n {
      if (s + a[i]) * s >= 0 {
         if s > 0 {
            ans += s + a[i] + 1;
            s = -1;
         } else {
            ans += 1 - (s + a[i]);
            s = 1;
         }
      } else {
         s += a[i];
      }
   }

   let mut ans1;
   if a[0] == 0 {
      s = -1;
      ans1 = 1;
   } else if a[0] > 0 {
      s = -1;
      ans1 = a[0] + 1;
   } else {
      s = 1;
      ans1 = 1 - a[0];
   }
   for i in 1..n {
      if (s + a[i]) * s >= 0 {
         if s > 0 {
            ans1 += s + a[i] + 1;
            s = -1;
         } else {
            ans1 += 1 - (s + a[i]);
            s = 1;
         }
      } else {
         s += a[i];
      }
   }
   println!("{}", std::cmp::min(ans, ans1));
}


Measured memory_bytes: 4476
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

int x_pos[16010][16010] = {0};
int y_pos[16010][16010] = {0};
int x_dir[8000] = {};
int y_dir[8000] = {};

int main()
{
    string s;
    int x, y;
    cin >> s;
    scanf("%d %d", &x, &y);
    int direction = 0;
    int x_res;
    int y_res;
    int x_idx = 0;
    int y_idx = 0;
    int val = 0;
    int count = 0;
    int x_sum = 0;
    int y_sum = 0;
    int first_count = 0;

    for(int i=0; i<s.size(); i++){
        if(s[i] == 'F'){
            first_count ++;
        }
        else{
            break;
        }
    }

    for(int i=first_count; i<=s.size(); i++){
        if(s[i] == 'F'){
            if(val == 0){
                direction = direction ^ (count % 2);
                count = 0;
            }
            val++;
        }
        else{
            if(val != 0){
                if(direction == 0){
                    x_dir[x_idx] = val;
                    x_sum -= val;
                    x_idx++;
                }
                else{
                    y_dir[y_idx] = val;
                    y_sum -= val;
                    y_idx++;
                }
                val = 0;
            }
            count++;
        }
    }

    x_res = x - x_sum - first_count;
    y_res = y - y_sum;

    if(x_res < 0 || y_res < 0){
        printf("No\n");
    }
    else{
        x_pos[0][0] = 1;
        y_pos[0][0] = 1;

        for(int i=0; i<x_idx; ++i){
            for(int j=0; j<=x_res; ++j){
                x_pos[i+1][j] |= x_pos[i][j];
                if(j>=x_dir[i]*2){
                    x_pos[i+1][j] |= x_pos[i][j - x_dir[i]*2];
                }
            }
        }

        for(int i=0; i<y_idx; ++i){
            for(int j=0; j<=y_res; ++j){
                y_pos[i+1][j] |= y_pos[i][j];
                if(j>=y_dir[i]*2){
                    y_pos[i+1][j] |= y_pos[i][j - y_dir[i]*2];
                }
            }
        }

        if(x_pos[x_idx][x_res] == 1 && y_pos[y_idx][y_res] == 1){
            printf("Yes\n");
        }
        else{
            printf("No\n");
        }
    }

    return 0;
}


Measured memory_bytes: 252288
d,n = map(int,input().split())
if d == 0:
    if n != 100:
        print(n)
    else:
        print(n+1)
elif d == 1:
    if n != 100:
        print(n*100)
    else:
        print('10100')
else:
    if n != 100:
        print(n*10000)
    else:
        print('1010000')

Measured memory_bytes: 3060
#include <iostream>
#include <vector>

using namespace std;

int
main()
{
    int n;
    uint64_t ans = 1;
    uint64_t j,k;
    vector<uint64_t> a;
    cin >> n;

    for(int i=0;i<n;i++){
        uint64_t x;
        cin >> x;
        if(x==0){
            cout << "0" << endl;
            return 0;
        }
        a.push_back(x);
    }

    for(auto i : a){
        if(i > 1000000000000000000ULL) {
            cout << "-1" << endl;
            return 0;
        }
        if(ans > 1000000000000000000ULL) {
            cout << "-1" << endl;
            return 0;
        }

        j = ans;
        ans = j * i;
        k = ans / i;
        if(j != k){
            cout << "-1" << endl;
            return 0;
        }

        if(ans > 1000000000000000000ULL) {
            cout << "-1" << endl;
            return 0;
        }
    }

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


Measured memory_bytes: 4272
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc =new Scanner(System.in);
		int[] A=new int [52];
	   	for(int i=0;i<52;i++){
	   		A[i]=0;
	   	}
	   	int n= sc.nextInt();
    	int[] B=new int[n];
    	for(int i=0;i<n;i++){
    		String a=sc.next();
	    	int b=sc.nextInt();
	   		if(a.equals("S")){
	   			B[i]=b;
	   		}else if(a.equals("H")){
	   			B[i]=13+b;
    		}else if(a.equals("C")){
    			B[i]=26+b;
	    	}else if(a.equals("D")){
	    		B[i]=39+b;
	   		}
	   		for(int j=1;j<53;j++){
	   			if(j==B[i]){
	   				A[j-1]=1;
	   			}
	   		}
	   	}
    	for(int i=0;i<52;i++){
    		if(A[i]==0){
    			if(i+1<14){
    				System.out.println("S "+(i+1));
    			}else if(i+1<27){
    				System.out.println("H "+(i-12));
    			}else if(i+1<40){
    				System.out.println("C "+(i-25));
    			}else if(i+1<53){
    				System.out.println("D "+(i-38));
    			}
    		}
    	}
	}
}

Measured memory_bytes: 26196
import itertools

# ((a ? b) ? (c ? d))
# (((a ? b) ? c) ? d)
# ((a ? (b ? c)) ? d)
p = ['(({}{}{}){}({}{}{}))', '((({}{}{}){}{}){}{})', '(({}{}({}{}{})){}{})']
o = ['+', '-', '*']

def f(a, b, c, d):
    for i,j,k,l in itertools.permutations([a,b,c,d]):
        for o1,o2,o3 in itertools.product(o, repeat=3):
            for pp in p:
                r = pp.format(i, o1, j, o2, k, o3, l)
                if eval(r) == 10:
                    return r
    return 0

while True:
    a,b,c,d = map(int, raw_input().split())
    if a==b==c==d==0:
        break
    print f(a, b, c, d)

Measured memory_bytes: 4396
#include <iostream>
#include <queue>
#define N 200
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
void bfs(int,int);
int dy[6]={-1,-1,0,1,1,0};
int dx[6]={-1,0,1,1,0,-1};
int t;
int data[N][N];
int main(){
  int n,x,y,sx,sy;
  while(1){
    cin >> t >> n;
    if(t==0&&n==0) break;
    for(int i=0;i<N;i++)
      for(int j=0;j<N;j++) data[i][j]=0;
    while(n--){
      cin >> x >> y;
      data[y+100][x+100]=-1;
    }
    cin >> sx >> sy;
    data[sy+100][sx+100]=1;
    bfs(sy+100,sx+100);
    int cnt=0;
    for(int i=0;i<N;i++){
      for(int j=0;j<N;j++){
    if(data[i][j]==1) cnt++;
      }
    }
    cout << cnt << endl;
  }
  return 0;
}
void bfs(int y,int x){
  queue<P1> Q;
  Q.push(P1(0,P(y,x)));
  while(Q.empty()!=1){
    P1 v=Q.front();
    Q.pop();
    int d=v.first,y1=v.second.first,x1=v.second.second;
    for(int i=0;i<6;i++){
      if(0<=y1+dy[i]&&y1+dy[i]<N&&0<=x1+dx[i]&&x1+dx[i]<N&&data[y1+dy[i]][x1+dx[i]]==0){
    data[y1+dy[i]][x1+dx[i]]=1;
    if(d<=t-2) Q.push(P1(d+1,P(y1+dy[i],x1+dx[i])));
      }
    }
  }
}

Measured memory_bytes: 1376
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define mp make_pair
#define fi first
#define se second
#define pb push_back

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int a, b;

    cin >> a >> b;

    if (b % a == 0)
        cout << a + b << endl;
    else
        cout << b - a << endl;

    return 0;
}

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

int main()
{
    int a, b;
    double c, s, l, h;
    scanf("%d%d%lf", &a, &b, &c);
    c=c*M_PI/180;
    s=0.5*a*b*sin(c);
    l=a+b+sqrt(a*a+b*b-2*a*b*cos(c));
    h=2*s/a;
    printf("%f\n%f\n%f\n\n", s, l, h);
    return 0;
}

Measured memory_bytes: 648
<?php

$X = fgets(STDIN);

for ($i = -200; $i <= 200; $i++) {
    for ($j = -200; $j <= 200; $j++) {
        if (pow($i, 5) - pow($j, 5) == $X) {
            break 2;
        }
    }
}

echo $i . ' ' . $j . PHP_EOL;


Measured memory_bytes: 16192
//
//  agc028a.cpp
//  
//
//  Created by Yoshida Satoshi on 2018/10/23.
//

#include <stdio.h>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>

#define MAX 100005

using namespace std;
int main(){
    long long n,m;
    char s[MAX];
    char t[MAX];
    
    cin>>n>>m;
    
    cin>>s>>t;
    
    long long gcd=1;
    
    for(long long i=1;i*i<=n;i++){
        if(n%i==0){
            if(m%i==0){
                gcd=max(gcd,i);
            }
            long long j=n/i;
            if(m%j==0){
                gcd=max(gcd,j);
            }
        }
    }
    
    long long dn=n/gcd;
    long long dm=m/gcd;
    long long ans=n*dm;
    
    for(long long i=0;i<gcd;i++){
        if(s[dn*i]!=t[dm*i]){
            ans=-1;
            break;
        }
    }

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


Measured memory_bytes: 384
using System;

class ABC_132_C
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());

        string[] input = Console.ReadLine().Split(' ');
        int[] d = new int[N];
        for (int i = 0; i < N; i++)
        {
            d[i] = int.Parse(input[i]);
        }

        Array.Sort(d);

        int min = d[(N/2)-1];
        int max = d[N/2];

        Console.WriteLine(max-min);
    }
}

Measured memory_bytes: 18912
'use strict'

function Main(input) {
  const S = input.split("")
  const remaining = 15 - S.length

  let win = S.filter(x => x === "o").length
  
  if (win + remaining >= 8) {
    console.log("YES")
  } else {
    console.log("NO")
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim())


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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    ll n, c;
    cin >> n >> c;
    vector<ll> x(n), v(n), dpr(n, 0), dpl(n, 0);
    rep(i, n) cin >> x[i] >> v[i];
    dpr[0] = v[0] - x[0];
    for (int i=1; i<n; ++i) dpr[i] = dpr[i-1]+v[i]-(x[i]-x[i-1]);
    for (int i=1; i<n; ++i) dpr[i] = max(dpr[i], dpr[i-1]);
    dpl[n-1] = v[n-1] - (c - x[n-1]);
    for (int i=n-2; i>=0; --i) dpl[i] = dpl[i+1]+v[i]-(x[i+1]-x[i]);
    for (int i=n-2; i>=0; --i) dpl[i] = max(dpl[i], dpl[i+1]);
    ll ans = max(0LL, dpr[0]);
    for (int i=0; i<n; ++i) {
        ll tmp = dpr[i];
        if (i+1<n and dpl[i+1]-x[i] > 0) tmp += dpl[i+1] - x[i];
        ans = max(ans, tmp);
    }
    for (int i=n-1; i>=0; --i) {
        ll tmp = dpl[i];
        if (i>=1 and dpr[i-1]-(c-x[i]) > 0) tmp += dpr[i-1] - (c - x[i]);
        ans = max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3328
from collections import*
n,k,l=map(int,input().split());d=[-1]*n;t=[-1]*n
def f(l,x):
  if l[x]<0:return x
  else:l[x]=f(l,l[x]);return l[x]
def u(l,x,y):
  if f(l,x)!=f(l,y):l[f(l,y)]=f(l,x)
for _ in range(k):a,b=map(int,input().split());u(d,a-1,b-1)
for _ in range(l):a,b=map(int,input().split());u(t,a-1,b-1)
p=[(f(d,i),f(t,i))for i in range(n)];c=Counter(p);print(*[c[p[i]]for i in range(n)])

Measured memory_bytes: 44388
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int n,m;
    while(cin>>n>>m,n||m){
        int d[1000],sum=0;
        for(int i=0;i<n;i++)cin>>d[i];
        sort(d,d+n,greater<int>());
        for(int i=0;i<n;i++){
            if((i+1)%m!=0)sum+=d[i];
        }
        cout<<sum<<endl;

    }
}

Measured memory_bytes: 1180
import math
 
def f(a, b):
    return a**4 + a**3 * b + a**2 * b**2 + a * b**3 + b**4

def ihate(x):
    sq = int(math.sqrt(x)) + 1
    facts = []
    for i in range(1, sq):
        if x % i == 0:
            facts.append(i)
 
    for fa in facts:
        d = x // fa
        for a, b in zip(range(-fa, 2000), range(0, 2000+fa)):
            if f(a, b) == d:
                return f'{a} {b}' if a > b else f'{b} {a}'
x = int(input())
print(ihate(x))

Measured memory_bytes: 9196
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <stdio.h>

using namespace std;

#define fo(i,n) for(int i=0; i<(int)n; i++)
#define rep(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
#define mp(a,b) make_pair(a,b)
#define pb(x) push_back(x)
#define pii pair<int,int>

int n;
map<string,set<string> > group;
vector<string> v;
map<string,bool> done;

set<string> solve(string m) {
	set<string> tmp = group[m];
	if (done[m]) return tmp;
	rep(it,group[m]) {
		if (group.find(*it)!=group.end()) {
			set<string> tmp2 = solve(*it);
			rep(it2,tmp2) tmp.insert(*it2);
			tmp.erase(*it);
		}
	}
	done[m] = 1;
	group[m] = tmp;
	return tmp;
}

int main() {

    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);

	while (scanf("%d",&n) && n!=0) {
		group.clear();
		v.clear();
		done.clear();
		for (int i=0; i<n; i++) {
			string s;
			cin>>s;
			for (int j=0; j<s.length(); j++) if (s[j]==':') {
				s[j] = ' ';
				break;
			}
			stringstream ss(s);
			string name;
			ss>>name;
			set<string> vs;
			ss>>s;
			for (int j=0; j<s.length(); j++) {
				if (s[j]=='.' || s[j]==',') s[j]=' ';
			}
			stringstream ss2(s);
			while (ss2>>s) {
				vs.insert(s);
			}
			group[name] = vs;
			v.push_back(name);
			done[name] = 0;
		}
		
		for (int i=0; i<n; i++) {
			group[v[i]] = solve(v[i]);
		}

		int ans = group[v[0]].size();
		
		cout<<ans<<endl;
		
	}

    return 0;

}

Measured memory_bytes: 1592
def gcd(a, b):
    '''ユークリッド互除法を使った最大公約数の求め方'''
    while b != 0:
        a, b = b, a % b
    return(a)


def lcm(a, b):
    '''最小公倍数の求め方'''
    return a * b // gcd(a, b)


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

lcmCD = lcm(C, D)

divB = (B // C) + (B // D) - (B // lcmCD)
divA_1 = ((A - 1) // C) + ((A - 1) // D) - ((A - 1) // lcmCD)
print((B - A) - (divB - divA_1) + 1)

Measured memory_bytes: 3064
import numpy

n,m = map(int,input().split())
a = numpy.zeros([n,n], dtype=int)
b = numpy.zeros([m,m], dtype=int)
for i in range(n):
    s = input()
    for j in range(n):
        if s[j] == "#":
            a[i,j] = 1
for i in range(m):
    s = input()
    for j in range(m):
        if s[j] == "#":
            b[i,j] = 1

for i in range(n-m+1):
    for j in range(n-m+1):
        if numpy.all(a[i:i+m, j:j+m] == b):
            print("Yes")
            exit()
print("No")

Measured memory_bytes: 27228
#include<stdio.h>
#include<string.h>

int main(void) {
   char s[11], t[12];
   int i;
   int cnt = 0;
   scanf("%s",s);
   scanf("%s",t);
   int s_len = strlen(s);
   int t_len = strlen(t);

   if(1 <= s_len && s_len <= 10 && t_len == s_len + 1) {
      for(i = 0; s[i] != '\0'; i++) {
         if(s[i] == t[i]) {
            cnt++;
         }
      }
      if(cnt == s_len && t[t_len-1] >= 'a' && t[t_len - 1] <= 'z') {
         printf("Yes");
      } else {
         printf("No");
      }
   }
   return 0;
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;



int main() {
    string s;
    cin >> s;
    cout << s.substr(0, 3) << endl;

    return 0;
}

Measured memory_bytes: 3640
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);

		int n = scanner.nextInt();
		int[] as = new int[n];
		int[] bs = new int[n];
		int[] cs = new int[n - 1];
		for (int i = 0; i < n; i++) {
			as[i] = scanner.nextInt();
		}
		for (int i = 0; i < n; i++) {
			bs[i] = scanner.nextInt();
		}
		for (int i = 0; i < n - 1; i++) {
			cs[i] = scanner.nextInt();
		}

		int sum = 0;
		int preA = 0;
		boolean flag = false;
		for (int a : as) {
			sum += bs[a - 1];
			if (flag && preA + 1 == a) {
				sum += cs[preA - 1];
			} else {
				flag = true;
			}
			preA = a;
		}
		System.out.println(sum);

	}
}


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

int main(){
	int h, w;
	cin >> h >> w;
	string s[50];
	rep(i, h) cin >> s[i];
	int dx[8] = {1, 1, 1, 0, 0, -1, -1, -1};
	int dy[8] = {0, 1, -1, 1, -1, -1, 1, 0};

	rep(i, h){
		rep(j, w){
			if(s[i][j] == '#') continue;

			int num = 0;
			rep(d, 8){
				int ni = i + dy[d];
				int nj = j + dx[d];

				if(ni < 0 || h <= ni) continue;
				if(nj < 0 || w <= nj) continue;
				if(s[ni][nj] == '#') num++;
			}
			s[i][j] = char(num + '0');
		}
	}
	rep(i, h) cout << s[i] << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
typedef long long ll;
const int Max = 1e6 + 5;
const int Mod = 1e9 + 7;
int lst[Max];
int ls[Max];

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

int main()
{
	int n;
	cin >> n;
	ll res=1;
	for (int i = 1;i <= n;i++)
	{
		ll t;
		scanf("%lld", &t);
		res /= gcd(t, res);
		res *= t;
	}
	cout << res;

}

Measured memory_bytes: 3196
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,x,y;
	scanf("%d%d%d%d%d",&a,&b,&c,&x,&y);
	int ans=0;
	if (c*2<a+b){
		int t=min(x,y);
		ans+=t*c*2;
		x-=t;
		y-=t;
	}
	if (x) ans+=x*min(a,c*2);
	if (y) ans+=y*min(b,c*2);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long x = sc.nextLong();
		long count = b/x - a/x;
		if(a%x == 0)count++;
		System.out.println(count);
	}
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<int>;

int main(){
    int N, M;
    cin >> N >> M;
    Graph G[N];
    for (int i = 0; i < M; i++)
    {
        int s, t;
        cin >> s >> t;
        G[s-1].push_back(t-1);
        G[t-1].push_back(s-1);
    }
    vector<int> dist(N, -1);
    int key[N];

    queue<int> que;

    dist[0] = 0;
    que.push(0);

    while(!que.empty()){
        int v = que.front();
        que.pop();

        for (int nv : G[v])
        {
            if (dist[nv] != -1) continue;
            
            dist[nv] = dist[v] + 1;
            que.push(nv);
            key[nv] = v;
        }
        
    }
    if (find(dist.begin(), dist.end(), -1) != dist.end()){
		cout << "No" << "\n";
    }else{
		cout << "Yes" << "\n";
        for (int v = 1; v < N; ++v) cout << key[v] + 1<< "\n";
    }
    return 0;
}

Measured memory_bytes: 10668
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
    return (ull)rng() % B;
}

char c[55][55];
char s[55][55];

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int q; cin >> q;
	while(q--){
		int h,w; cin >> h >> w;
		vector<char> v;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				cin >> c[i][j];
				if(c[i][j]!='.')v.push_back(c[i][j]);
			}
		}
		sort(v.begin(), v.end());
		v.erase(unique(v.begin(), v.end()),v.end());
		int k=v.size();
		map<char,int> l,r,u,d;
		for(int i=0;i<k;i++){
			l[v[i]]=1e9;
			u[v[i]]=1e9;
		}
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				for(int p=0;p<k;p++){
					if(c[i][j]==v[p]){
						l[v[p]]=min(l[v[p]],j);
						r[v[p]]=max(r[v[p]],j);
						u[v[p]]=min(u[v[p]],i);
						d[v[p]]=max(d[v[p]],i);
					}
				}
			}
		}
		bool ok=0;
		do{
			if(ok)break;
			for(int i=0;i<h;i++){
				for(int j=0;j<w;j++){
					s[i][j]='.';
				}
			}
			for(int p=0;p<k;p++){
				for(int i=u[v[p]];i<=d[v[p]];i++){
					for(int j=l[v[p]];j<=r[v[p]];j++){
						s[i][j]=v[p];
					}
				}
			}
			bool check=1;
			for(int i=0;i<h;i++){
				for(int j=0;j<w;j++){
					if(c[i][j]!=s[i][j])check=0;
				}
			}
			if(check)ok=1;
		}while(next_permutation(v.begin(), v.end()));
		if(ok)printf("SAFE\n");
		else printf("SUSPICIOUS\n");
	}
}


Measured memory_bytes: 3196
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for (int i = 0; i < (n); ++i)
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; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin >> n;
    vector<int> a(n),b(n);
    rep(i,n){
        cin >> a[i];
        a[i]--;
    }
    vector<bool> c(n);
    rep(i,n){
        cin >> b[i];
        b[i]--;
        c[b[i]]=true;
    }
    bool f=true;
    int u,v;
    rep(i,n){
        if(!c[a[i]]){
            f=false;
            u=a[i];
        }
        else{
            v=a[i];
        }
    }
    if(f){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
        rep(i,n){
            cout << a[i]+1;
            if(i!=n-1){
                cout << " ";
            }
        }
        cout << endl;
        rep(i,n){
            if(a[i]==u){
                cout << v+1;
            }
            else{
                cout << a[i]+1;
            }
            if(i!=n-1){
                cout << " ";
            }
        }
        cout << endl;
    }
}


Measured memory_bytes: 3840
h,w=map(int,input().split())
l=[[0]*w]*h
m=[""]*h
for k in range(h):
  m[k]=input()
l[0][0]=1
for k in range(h):
  for j in range(w):
    if m[k][j]=="#":
      l[k][j]=0
    else:
      if k==0:
        if j!=0:
          l[k][j]=l[0][j-1]
      elif j==0:
        if k!=0:
          l[k][j]=l[k-1][j]
      else:
        l[k][j]=l[k-1][j]+l[k][j-1]
print(l[h-1][w-1]%1000000007)


Measured memory_bytes: 4340
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>

using namespace std;
#define REP(m,n) for(int i=m;i<n;++i)
#define REP(j,m,n) for(int j=m;j<n;++j)
#define INF 10000000000000000
#define MOD 1000000007
#define ll long long
#define mp make_pair

vector<int>a, b, c;
vector<int>bb;

int main() {
	long long n, ans=0;
	cin >> n;
	REP(i, 0, n) {
		long long tmp;
		cin >> tmp;
		a.push_back(tmp);
	}
	sort(a.begin(), a.end());
	reverse(a.begin(), a.end());
	REP(i, 0, n) {
		long long tmp;
		cin >> tmp;
		b.push_back(tmp);
	}
	sort(b.begin(), b.end());
	reverse(b.begin(), b.end());
	long long check = 0, add = 0;
	REP(i, 0, n) {
		while (a[check] >= b[i]) {
			check++;
			if (check == n) {
				break;
			}
		}
		bb.push_back(n - check);
		add += n - check;
	}
	REP(i, 0, n) {
		long long tmp;
		cin >> tmp;
		c.push_back(tmp);
	}
	sort(c.begin(), c.end());
	reverse(c.begin(), c.end());
	check = 0;
	REP(i, 0, n) {
		while (b[check] >= c[i]) {
			add -= bb[check];
			check++;
			if (check == n) {
				break;
			}			
		}
		ans += add;
	}
	cout <<ans<<endl;
	return 0;
}

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

// macros
#define overload_rep(va_0, va_1, va_2, name, ...) name
#define rep_0(i, n) for(int i = 0; i < (n); ++i)
#define rep_1(i, x, y) for(int i = (x); i <= (y); ++i)
#define rep(...) overload_rep(__VA_ARGS__, rep_1, rep_0)(__VA_ARGS__)
#define all(a) a.begin(), a.end()
#ifndef STOP_DEBUG
#define debug(...)\
    do { cerr << boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_cerr(__VA_ARGS__); cerr << noboolalpha; } while (0)
#else
#define debug(...)
#endif

// functions
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
void debug_cerr(){ cerr << '\n'; }
template<class Head, class... Tail>
void debug_cerr(Head head, Tail... tail){
    cerr << ' ' << head;
    debug_cerr(tail...);
}

// cin/cout setup
struct IoSetup{
    IoSetup(){
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} iosetup;

// libraries

// declarations
int H, W, K;
char grid[300][300];
int ans[300][300];

// solve
int main(){

    cin >> H >> W >> K;
    rep(i, H)rep(j, W)cin >> grid[i][j];

    int l = 0, now = 1, fir = H;
    rep(i, H){
        bool exi = false;
        rep(j, W){
            if(grid[i][j] == '#'){
                exi = true;
                rep(k, l, j)ans[i][k] = now;
                now++;
                l = j + 1;
            }
        }
        if(exi){
            rep(k, l, W - 1)ans[i][k] = now - 1;
            chmin(fir, i);
        } else if(now > 1){
            rep(j, W)ans[i][j] = ans[i - 1][j];
        }
        l = 0;
    }

    for(int i = fir - 1; i >= 0; --i){
        rep(j, W)ans[i][j] = ans[i + 1][j];
    }

    rep(i, H){
        rep(j, W - 1)cout << ans[i][j] << ' ';
        cout << ans[i][W - 1] << '\n';
    }

}


Measured memory_bytes: 1280
#include<iostream>
#include<vector>
int main()
{
  using namespace std;
  int n;
  double res;
  cin>>n;
  vector<int> vec(n);
  for(int i=0;i<n;i++)
    cin>>vec[i];
  for(int i=0;i<n;i++)
    res+=1.0/vec[i];
  cout<<1/res<<endl;
  return 0;
}

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

using namespace std;

class Process {
public:
    string mName;
    int mTime;

    Process() {
        mName = "";
        mTime = 0;
    }
    Process(string name, int time) {
        mName = name;
        mTime = time;
    }
};

int doProcess(deque<Process>& qProcess, int Q, int totalTime) {
    int nFinishT = totalTime;
    Process front = qProcess.front();
    if (front.mTime <= Q) {
        nFinishT += front.mTime;
        //int nRemain = Q - front.mTime;
        qProcess.pop_front();
        cout << front.mName << ' ' << nFinishT << endl;
        //doProcess(qProcess, nRemain, nFinishT);
    }
    else {
        front.mTime -= Q;
        qProcess.pop_front();
        qProcess.push_back(front);
        nFinishT += Q;
    }
    return nFinishT;
}

int main()
{
    int N{ 0 }, Q{ 0 };
    cin >> N >> Q;
    
    deque<Process> qProcess;

    for (int i = 0; i < N; i++) {
        string name;
        int time{ 0 };
        cin >> name >> time;

        qProcess.push_back(Process(name,time));
    }

    int totalTime = 0;
    while (!qProcess.empty()) {
        totalTime = doProcess(qProcess, Q, totalTime);
    }
}


Measured memory_bytes: 6248
import java.util.Scanner;

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

		int n = sc.nextInt();

		int sum = 0;
		int maxL = 0;
		for (int i = 0; i < n; i++) {
			int l = sc.nextInt();
			sum += l;
			if (l > maxL) {
				maxL = l;
			}
		}

		System.out.println((sum - maxL) > maxL ? "Yes" : "No");

		sc.close();
	}
}


Measured memory_bytes: 21204
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>

using namespace std;

typedef long long ll;
typedef long double ld;

#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep1(i,n) for(int i=1; i<=(int)(n); i++)
#define all(c) c.begin(),c.end()
#define psb push_back
#define ppb pop_back

const int I_INF = 1001001001;
const ll LL_INF = 1001001001001001001;
const ld EPS = 0.001;

int main() {
    int N, Q;
    cin >> N;

    map<ll,ll> a;
    rep (i, N) {
        ll n = 0;
        cin >> n;
        a[n]++;
    }

    cin >> Q;

    ll sum = 0;
    for (const auto [k,v] : a) sum += k*v;

    vl ans;
    rep (i, Q) {
        ll b, c;
        cin >> b >> c;

        if (!a.count(b)) {
            ans.psb(sum);
            continue;
        }

        ll v = a[b];
        sum -= b*v;
        a.erase(b);
        a[c] += v;
        sum += c*v;

        ans.psb(sum);
    }

    for (const auto n : ans) cout << n << endl;
}


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

int main(){
    ll n,a,b;
    cin >> n >> a >> b;
    ll p = (a+b);
    ll s = n/p;
    ll ans = s*a;
    ans += min(a,n%p);
    cout << ans << endl;
}

Measured memory_bytes: 256
N=int(input())
SP=[]
for i in range(N):
  s,p=map(str,input().split())
  SP.append([i+1,s,int(p)])
SP.sort(key=lambda x:x[2],reverse=True)
SP.sort(key=lambda x:x[1])
for i in range(N):
  print(SP[i][0])

Measured memory_bytes: 3064
import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
dp = [[float("inf")] * N for _ in range(N)]
k = [[-1] * N for _ in range(N)]
cs = [0] * (N + 1)
for i in range(N):
  cs[i + 1] = cs[i] + a[i]
  k[i][i] = i
  dp[i][i] = 0
#print(k, cs)
def mongedp():
  global dp
  global k
  for d in range(1, N):
    for i in range(N):
      if i + d >= N: continue
      j = i + d
      for t in range(k[i][j - 1], min(k[i + 1][j] + 1, j)):
        temp = dp[i][t] + dp[t + 1][j] + cs[j + 1] - cs[i]
        if temp < dp[i][j]:
          dp[i][j] = temp
          k[i][j] = t
mongedp()
print(dp[0][-1])

Measured memory_bytes: 47580
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = GetLongNum();
            var L = GetLongNumArray().ToList();
            var count = 0;

            while (L.Count > 2)
            {
                var max = L.Max();
                L.Remove(max);
                for (int i = 0; i < L.Count - 1; i++)
                {
                    for (int j = 0; j < L.Count - (i + 1); j++)
                    {
                        if (L[i] + L[i + j + 1] > max
                            && L[i] != L[i + j + 1]
                            && L[i] != max
                            && L[i + j + 1] != max)
                        {
                            count++;
                        }
                    }
                }
            }

            Console.WriteLine(count);
        }

        private static long[] GetLongNumArray()
        {
            var input = Console.ReadLine().Split(' ');
            return input.Select(x => long.Parse(x)).ToArray();
        }

        private static long GetLongNum()
        {
            return long.Parse(Console.ReadLine());
        }

        private static string[] GetStringArray()
        {
            return Console.ReadLine().Split(' ');
        }

        private static string GetString()
        {
            return Console.ReadLine();
        }
    }
}


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

int main(){
  int a[5];

  for( int i=0;i<5;i++ )
    cin >> a[i];

  sort( a, a+5 );

  cout << a[4];
  for( int i=3;i>=0;--i )
    cout << " " << a[i];
  cout << endl;

  return 0;
}

Measured memory_bytes: 0
N, K = map(int, input().split())

def func(n):
    r = n
    for i in range(2, n + 1):
        if i ** 2 > n:
            break

        if n % i == 0:
            r -= r // i
            while n % i == 0:
                n //= i
        
    if n > 1:
        r -= r // n
    return r


MOD = 10 ** 9 + 7
ans = 0
for i in range(1, K + 1):
    ans += func(i) * pow(K // i, N, MOD)
print(ans % MOD)


Measured memory_bytes: 74240
#include<bits/stdc++.h>
#define I int
#define S(a) scanf("%d",&a)
#define S2(a,b) scanf("%d%d",&a,&b)
#define P(a) printf("%d\n",a)
#define PL(a) printf("%lld\n",a)
#define PT(t) printf("Case %d: ",t)
#define PB(a) push_back(a)
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define ll long long 
using namespace std;
#define mx 500004
#define md 1000000007ll
typedef pair<int, int >P;
typedef vector<ll>V;

////////define value/////
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}

ll fac[mx + 2];
ll hmw(int n, int k){
    if(n > k)return 0;
    return (fac[k] * mdINV(fac[k-n], md))%md;
}
vector<int>v[mx + 2];

ll  bfs(int u, int p, int k){
    ll ch = v[u].size() - (p!=0);
    int k1 = k - 1 - (p != 0);
  //  cout<<u<<" "<<ch<<" "<<k1<<endl;
    ll res = hmw(ch, k1);
  //  cout<<u<<" "<<res<<endl;
    for(int i = 0; i < v[u].size(); i++){
        int x = v[u][i];
        if( x == p)continue;
        res = (res * bfs(x, u, k) ) % md;
    }
    return res % md;
}
int main(){
    fac[0] = 1;
    for(int i = 1; i <= mx; i++){
        fac[i] = (i * fac[i-1]) % md;
    }
    int n,k;
    cin>>n>>k;
    for(int i = 1; i < n; i++){
        int x,y;
        cin>>x>>y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    cout<<(bfs(1, 0, k) * (ll)k) % md<<endl;
    return 0;
}

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

const string YES = "Yes";
const string NO = "No";

int main() {
    int N,K,Q;
    cin >> N >> K >> Q;

    int points[N] = {0};

    for(int i = 0 ; i < Q ; i++) {
        int A;
        cin >> A;

        points[A -1]++;
    }
    
    for (int l = 0; l < N; l++) {
        if (1 <= K - Q + points[l]) {
            cout << YES << endl;
        } else {
            cout << NO << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 1024
<?php
  $n = trim(fgets(STDIN));
  $v = explode(" ",trim(fgets(STDIN)));
  $c = explode(" ",trim(fgets(STDIN)));
  $total = 0;
  for($i=0; $i<$n; $i++){
      // x-yの差が0だったら
    $m = $v[$i] - $c[$i];
    if($m >= 0){
      $total += $m;
    }
  }
  echo $total."\n";

Measured memory_bytes: 4604
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def main():
    n=int(input())
    par=[-1]*n
    dep=[-1]*n
    typ=["internal node"]*n
    chi=[[] for _ in range(n)]
    for _ in range(n):
        u,deg,*child=map(int,input().split())
        if deg==0:typ[u]="leaf"
        chi[u]=child
        for cu in child:
            par[cu]=u
    root=par.index(-1)
    typ[root]="root"
    d=0
    now=[root]
    while now:
        nxt=[]
        for u in now:
            dep[u]=d
            nxt+=chi[u]
        now=nxt
        d+=1
    #print(par)
    #print(dep)
    #print(typ)
    #print(chi)
    for u in range(n):
        print("node {}: parent = {}, depth = {}, {}, {}".format(u,par[u],dep[u],typ[u],chi[u]))

main()



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

int main() {
    string s, t;
    cin >> s >> t;
    int n = s.size();
    map<char, char> st, ts;
    rep(i,n) {
       if (st.count(s.at(i))) {
           if (st.at(s.at(i)) != t.at(i)) {
               cout << "No" << endl;
               return 0;
           }
       }
       else {
           st[s.at(i)] = t.at(i);
       }
       if (ts.count(t.at(i))) {
           if (ts.at(t.at(i)) != s.at(i)) {
               cout << "No" << endl;
               return 0;
           }
       }
       else {
           ts[t.at(i)] = s.at(i);
       }
    }
    cout << "Yes" << endl;
    return 0;
}

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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;

const ll mod = 1000000007;
const double pi = 3.1415926535897932384626;

ll powmod(ll a, ll b) {ll res = 1; ll rem = a % mod; for (; b; b >>= 1) {if (b & 1) res = (res * rem) % mod; rem = (rem * rem) % mod;} return res;}

int main()
{
    //freopen("in", "r", stdin);
    //freopen("out", "w", stdout);
    
    int a = 0;
    int b = 0;
    int c = 0;
    int d = 0;
    scanf("%d %d %d %d", &a, &b, &c, &d);

    int e = max(a, c);
    int f = min(b, d);

    int g = f - e;

    if (g < 0) g = 0;
    printf("%d\n", g);

    return 0;
}

    


Measured memory_bytes: 256
import sys
import collections

def input():
    return sys.stdin.readline()[:-1]

def main():
    n = int(input())
    x = [list(map(int, input().split())) for _ in range(n)]

    if n == 1:
        print(1)
    else:
        dist = [(x[j][0] - x[i][0], x[j][1] - x[i][1]) for j in range(n) for i in range(n)]
        c = collections.Counter(dist)
        ans = c.most_common()
        print(n - ans[1][1])

if __name__ == '__main__':
    main()


Measured memory_bytes: 40688
#include <bits/stdc++.h>
#define ll long long int

#define mx 100007
using namespace std;

int main()
{
    ll t,n,item,temp,a,b,c,x,y,z,sum,flag,k;
    string s,s1,s2;
    vector<ll>v;
    vector<string>vs;
    map<ll,ll>mp;
    map<ll,ll>check;

    ll arr[mx];
   vector<pair<ll,ll> >vp;
   cin>>n;
   if(n<30)
    cout<<"No"<<endl;
   else
    cout<<"Yes"<<endl;

    return 0;
}


Measured memory_bytes: 3612