akhauriyash/Code-Regression huggingface dataset:
import java.io.PrintWriter
import java.util.*
import java.math.*

val pw = PrintWriter(System.out)

fun main(args: Array<String>) {
    val s = read().replace(",", " ")
    println(s)
    pw.flush()
}

fun inputList() = 
    readLine()!!.split(" ").map(String::toInt)

fun sum_digits(num_: Long): Long {
    var num = num_
    var rtn: Long = 0
    while(num != 0.toLong()) {
        val tmp = num % 10
        rtn += tmp
        num /= 10
    }
    return rtn
}

/****** Decrared Functions ******/

// IO
fun read() = readLine()!!
fun readInt() = read().toInt()
fun readLong() = read().toLong()
fun readDouble() = read().toDouble()
fun readListOfString() = read().split(" ")
fun readListOfInt() = readListOfString().map { it.toInt() }
fun readListOfLong() = readListOfString().map { it.toLong() }
fun readListOfDouble() = readListOfString().map { it.toDouble() }


fun println(value : Any) {
    pw.println(value)
}

fun gcd(a: Long, b: Long): Long = 
    if(b != 0L) a else gcd(b, a % b)

fun lcm(a: Long, b: Long) = 
    if(b==0L) a else gcd(b, a % b)


Measured memory_bytes: 36152
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <stack>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;
typedef long long int ll;

int main(){
	int x;
	cin>>x;
	if(x >= 30){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}


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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 1
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

signed main(){

	lli n,z,w;
	cin>>n>>z>>w;

	vector<lli> a(n);
	REP(i,0,n)cin>>a[i];
 
	if(n==1){
		cout<<abs(a[0]-w)<<endl;
		return 0;
	}
 
	cout<<max(abs(a[n-1]-w),abs(a[n-1]-a[n-2]))<<endl;

	return 0;
}

Measured memory_bytes: 256
/*#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include<bits/stdc++.h>
#define ll long long
#define N 5005
#define inf 1000000005
#define mod 1000000007
#define put putchar('\n')
#define F(i,a,b) for (int i=(a);i<=(b);i++)
#define D(i,a,b) for (int i=(a);i>=(b);i--)
#define go(i,t) for (int i=head[t];i;i=Next[i])
#define sqr(x) ((x)*(x))
#define re register
#define mp make_pair
#define fi first
#define se second
#define int ll
using namespace std;
inline int read(){char c=getchar();int tot=1;while ((c<'0'|| c>'9')&&c!='-') c=getchar();if (c=='-'){tot=-1;c=getchar();}
int sum=0;while (c>='0'&&c<='9'){sum=sum*10+c-'0';c=getchar();}return sum*tot;}
inline void wr(int x){if (x<0) {putchar('-');wr(-x);return;}if(x>=10)wr(x/10);putchar(x%10+'0');}
inline void wrn(int x){wr(x);put;}inline void wri(int x){wr(x);putchar(' ');}
inline void wrn(int x,int y){wri(x);wrn(y);}inline void wrn(int a,int b,int c){wri(a);wrn(b,c);}
int n,m,dp[N][N],g[N],f[N],sum[N],fa[N],x,y;
int nedge,Next[N*2],head[N],to[N*2];
#define V to[i]
void add(int a,int b){
	Next[++nedge]=head[a];head[a]=nedge;to[nedge]=b;
}
inline void tadd(int &x,int k){
	x+=k;x-=(x>=mod)?mod:0;x+=(x<0)?mod:0;
}
void dfs(int x){
	sum[x]=1;dp[x][1]=1;
	go(i,x){
		if (V==fa[x]) continue;
		fa[V]=x;dfs(V);
		F(j,0,sum[x]) g[j]=dp[x][j],dp[x][j]=0;
		F(j,0,sum[x]){
			F(k,0,sum[V]){
				tadd(dp[x][j+k],1LL*g[j]*dp[V][k]%mod);
			}
		}
		sum[x]+=sum[V];
	}
	for(int i=0;i<=sum[x];i+=2) tadd(dp[x][0],1LL*-dp[x][i]*f[i]%mod);
}
signed main(){
	n=read();
	F(I,1,n-1){
		x=read();y=read();add(x,y);add(y,x);
	}
	f[0]=1;
	F(i,1,n/2){
		f[i*2]=1LL*f[i*2-2]*(i*2-1)%mod;
	}
	dfs(1);
	wrn(mod-dp[1][0]);
	return 0;
}

Measured memory_bytes: 194176
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	m := nextInt()
	var ary = make([]int, n+1)
	for i := 0; i < m; i++ {
		broken := nextInt()
		ary[broken] = -1
	}

	ary[0] = 1
	if ary[1] == -1 {
		ary[1] = 0
	} else {
		ary[1] = 1
	}

	for i := 2; i < n+1; i++ {
		if ary[i] == -1 {
			ary[i] = 0
			continue
		}
		ary[i] = (ary[i-1] + ary[i-2]) % 1000000007
	}
	fmt.Println(ary[n] % 1000000007)
}


Measured memory_bytes: 1920
import sys

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

if A % 2 == 1 or B % 2 == 1 or C % 2 == 1:
    print (0)
    sys.exit()


for i in range(100000):

    na = A
    nb = B
    nc = C

    A = (nb+nc) // 2
    B = (na+nc) // 2
    C = (na+nb) // 2

    if A % 2 == 1 or B % 2 == 1 or C % 2 == 1:
        print (i+1)
        sys.exit()

print (-1)


Measured memory_bytes: 38640
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;

int main(void){
 int a,b,k;
 cin>>a>>b>>k;
 int t=a+k-1;
 int s=a;
 while(s<=min(b,t)){
     cout<<s<<endl;
     s++;
 }
 s=b-k+1;
 if(s<=t){
     s=t+1;
 }
 while(s<=b){
     cout<<s<<endl;
     s++;
 }
 return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <limits.h>

using namespace std;

typedef long long LL;

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define dumpMap(m) { for (auto it: m) cout << it.first << "=>" << it.second << ' '; }

const int MOD = 1000000007;

bool know[12][12];


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

    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    LL ans = 1e18;
    rep(x, 1 << n) {
        if (__builtin_popcount(x) < k) continue;
        LL tmp = 0;
        int hi = 0;
        rep(i, n) {
            if (x & (1 << i)) {
                //! building i must be visible
                if (a[i] <= hi) {
                    ++hi;
                    tmp += hi - a[i];
                }
            }
            hi = max(hi, a[i]);
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<62;

int main() {
  ll l;
  cin >> l;
  vec a(l);
  for(ll i=0;i<l;i++) {
    cin >> a[i];
  }
  ll sum=0;
  for(ll i=0;i<l;i++) {
    sum+=a[i];
  }
  ll ans=sum;
  vec dp(4);
  for(ll i=0;i<l;i++) {
    dp[3]=min({dp[0],dp[1],dp[2],dp[3]})+(a[i]==0?2:a[i]%2);
    dp[2]=min({dp[0],dp[1],dp[2]})+(a[i]+1)%2;
    dp[1]=min(dp[0],dp[1])+(a[i]==0?2:a[i]%2);
    dp[0]+=a[i];
    ans=min(ans,min({dp[0],dp[1],dp[2],dp[3]})+sum-dp[0]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
int main()
{
  
    ll n,q,k,i,j=0,s=0,s2=0;
    cin>>n>>k;
    ///ll a[100005], b[n];
    priority_queue<ll>p;
    //map<ll,ll>m;

    //memset(b,0,sizeof(b));
    for(i=0;i<n;i++)
    {
      cin>>s;
      p.push(s);
    }
    s=0;
for(i=1;i<=k;i++)
{
  ll temp=p.top();
  p.pop();
  p.push(temp/2);
}
for(i=0;i<n;i++)
{
     ll temp=p.top();s+=temp;p.pop();
}
cout<<s<<endl;
    

  return 0;
} 

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

using namespace std;

int main()
{
    int A, B, C, D, E, a = 0;
    cin >> A >> B >> C >> D >> E;
    vector<int> v = {A, B, C, D, E};
    vector<int> b;

    do
    {
        int Sum = v[0];

        for (int i = 0; i < v.size(); i++)
        {

            if (i == 0 && Sum % 10 != 0)
            {
                a = (v[i] / 10 + 1) * 10 - v[i];
                Sum += a;
                continue;
            }

            if (i == 0 && Sum % 10 == 0)
            {
                continue;
            }

            if (Sum % 10 == 0)
            {
                Sum += v[i];
                continue;
            }

            if (Sum % 10 != 0 && i != 0)
            {
                a = (v[i - 1] / 10 + 1) * 10 - v[i - 1];
                Sum += a + v[i];

                continue;
            }
        }
        b.push_back(Sum);

    } while (next_permutation(v.begin(), v.end()));

    auto iter = min_element(b.begin(), b.end());

    cout << *iter << endl;
}

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

int main() {
  int n;
  cin >> n;
  int l[n];
  for ( int i = 0; i < n; i++ ) { cin >> l[i]; }
  sort(l, l+n);
  int ans = 0;
  for ( int i = n-1; i > 1; i-- ) {
    for ( int j = 0; j < i; j++ ) {
      for ( int k = j+1; k < i; k++ ) {
        if ( l[i] < l[j]+l[k] ) {
          ans += i-k;
          break;
        }
      }
    }
  }

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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <cstdlib>
#include <deque>

using namespace std;
const long long P = 1000000007;

int main() {
  int n;
  cin >> n;
  int a[n];
  for(int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int count = 0;
  int tmp = 0;
  for(int i = 0; i < n; i++) {
    if(a[i] == tmp) {
      count++;
      tmp = 0;
    }else {
      tmp = a[i];
    }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#define max 101
#define f(ii, ss, nn) for(ii = ss;i < nn;i++)

struct trip{
	int p;int s;
};

int Sort(struct trip a[max], int left, int mid, int right){
	struct trip l[max/2+2], r[max/2+2];
	int ln = 0, rn = 0;
	for(int i = left;i < mid;i++)l[i-left] = a[i];
	for(int i = mid;i < right;i++)r[i-mid] = a[i];
	for(int i = left;i < right;i++){
		if((l[ln].p >= r[rn].p && ln < mid - left) || rn >= right - mid)a[i] = l[ln++];
		else a[i] = r[rn++];
	}
	return 0;
}

int MergeSort(struct trip a[max], int left, int right){
	if(left + 1 >= right)return 0;
	int mid = (left + right) / 2;
	MergeSort(a, left, mid);
	MergeSort(a, mid, right);
	Sort(a, left, mid, right);
	return 0;
}

int main(){
	int n, m, a[1001][max];
	struct trip b[max];
	
	while(scanf("%d %d", &n, &m) && n != 0 && m != 0){
		for(int i = 0;i < m;i++)b[i].p = 0, b[i].s = i + 1;
		for(int i = 0;i < n;i++)
			for(int j = 0;j < m;j++)scanf("%d", &a[i][j]);
		for(int i = 0;i < m;i++)
			for(int j = 0;j < n;j++)b[i].p += a[j][i];
		MergeSort(b, 0, m);
		for(int i = 0;i < m - 1;i++)printf("%d ", b[i].s);
		printf("%d\n", b[m - 1].s);
	}
	return 0;
}

Measured memory_bytes: 3036
#include <iostream>
#include <string>
#include <map>

using namespace std;
 
int main()
{
    string D;
    cin >> D;

    map<string, string> chrismas = {
        {"22", "Christmas Eve Eve Eve"},
        {"23", "Christmas Eve Eve"},
        {"24", "Christmas Eve"},
        {"25", "Christmas"},
    };

    cout << chrismas[D] << endl;

    return 0;
}


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

int main(){
  ll n;
  cin >> n;
  map<ll,ll> s;
  map<ll,ll> t;
  vector<ll> m;
  for(ll i=1;i<=n;++i){
    ll a;
    cin >> a;
    s[i+a]++;
    //mapはオブジェクトからKeyを取り出せないので、Keyを記憶しておく
    if( s[i+a] == 1 ) m.push_back(i+a);
    t[i-a]++;
  }
  ll ans = 0;
  for(ll i=0;i<m.size();++i){
    ans += s[m.at(i)]*t[m.at(i)];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 38844
#include<bits/stdc++.h>
#include<string>
#define rep(i,n) for(int i = 0; i <(n); i++)
using namespace std;
 
int main(){
  int N,M;
  cin >> N  >> M;
  bool p_log[N];
  int wrong_num[N];

  rep (i,N) p_log[i] = true;
  rep (i,N) wrong_num[i] = 0;
  int temp_p = 0;
  int cac = 0;
  int cwa = 0;
  
  rep(i,M){
    int P = 0;
    string  S;
    cin >> P >> S;
    P = P - 1;
    if ( S == "AC"  && p_log[P]){
      ++cac;
      p_log[P] = false;
      cwa = cwa + wrong_num[P];
    }
    else if ( S == "WA" && p_log[P]){
      wrong_num[P] = wrong_num[P] + 1;
    } 
  }
  
  cout << cac << " "<< cwa <<endl;
  return 0; 
}

Measured memory_bytes: 768
from collections import Counter

N, M = map(int, input().split())
A_list = []
for _ in range(N):
    a = list(map(int, input().split()))
    A_list.append(a)

ans = N
for _ in range(M-1):
    most_like_list = []
    for i in range(N):
        most_like_list.append(A_list[i][0])
    most_like, ans_new = Counter(most_like_list).most_common()[0]
    ans = min(ans, ans_new)
    for i in range(N):
        A_list[i].remove(most_like)

print(ans)


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

def num2alpha(num):
    if num <= 26:
        return chr(64+num)
    elif num % 26 == 0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num // 26) + chr(64 + num % 26)
        
def base_10_to_n(X, n):
    if (int(X/n)):
        return base_10_to_n(int(X/n), n)+str(X % n)
    return str(X % n)
def main():
    n = int(input())
    alpha = num2alpha(n)
    print(alpha.lower())

if __name__ == "__main__":
    main()


Measured memory_bytes: 9120
#include <stdio.h>

int main(void)
{
    int i,N,rate,max=0,min=0,sum=0;
    int cr[9]={};
    
    scanf("%d",&N);
    for(i=0;i<N;i++){
        scanf("%d",&rate);
        if(3200>rate)cr[rate/400]=1;
        else if(3200<=rate)cr[8]++;
    }
    for(i=0;i<8;i++)sum+=cr[i];
    max=sum+cr[8];
    if(sum==0&&cr[8]>0)min=1;
    else min=sum;
    printf("%d %d\n",min, max);
    
    return 0;
}

Measured memory_bytes: 128
while(1):
    a = list(map(int,input().split()))
    if a[0]==0:
        break
    else:
        for i in range(a[0]):
            if i %2==0:
                for i in range(a[1]):
                    if i %2 ==0:
                        print("#",end="")
                    else:
                        print(".",end="")
            else:
                for j in range(a[1]):
                    if j %2== 0 :
                        print(".",end="")
                    else:
                        print("#",end="")
            print("")
        print("")


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


def solve(A: int, B: int, C: int):
    answer = 0
    max_abc= max(A,B,C)

    answer += (max_abc-A)//2
    A = max_abc-int((max_abc-A)%2 != 0)
    answer += (max_abc-B)//2
    B = max_abc-int((max_abc-B)%2 != 0)
    answer += (max_abc-C)//2
    C = max_abc-int((max_abc-C)%2 != 0)

    if A == B == C:
        print(answer)
        return 

    if [A,B,C].count(max_abc) == 2:
        answer += 2
    else:
        answer += 1

    print(answer)

    
    return


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
    C = int(next(tokens))  # type: int
    solve(A, B, C)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3192
#include<stdio.h>

int main(void)
{
	int i,n,a1=0,a2,b,c,sum=0;
	int bonus[21]={0};
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%d",&a2);
		if(a2==a1+1)
			bonus[a1]=1;
		a1=a2;
	}
	for(i=0;i<n;i++){
		scanf("%d",&b);
		sum+=b;
	}
	for(i=1;i<=n-1;i++){
		scanf("%d",&c);
		if(bonus[i]==1)
			sum+=c;
	}
	printf("%d",sum);

	return 0;
}

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

#define ull unsigned long long
#define endl '\n'
#define ll long long
const int N = 2e5 + 5;
ll a[N];
int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        //freopen("VLJUM.INP", "r", stdin);
        //freopen("VLJUM.OUT", "w", stdout);
        ll n;
        cin >> n;
        for (int i = 1; i <= 2 * n; i++) cin >> a[i];
        sort(a + 1, a + 2 * n + 1);
        ll ans = 0;
        for (int i = 1; i <= n; i++){
                ans = ans + min(a[(i - 1) * 2 + 1], a[(i - 1) * 2 + 2]);
        }
        cout << ans;
}



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

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

void solve(long long N, std::vector<pair<ll, ll>> v) {
  ll currSum = 0;
  for (auto &item : v) {
      currSum += item.second;
      if (currSum > item.first) {
	  cout << NO << endl;
	  return;
      }
  }
  cout << YES << endl;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
  long long N;
  scanf("%lld", &N);
  std::vector<pair<ll, ll>> v(N);
  for (int i = 0; i < N; i++) {
    ll first, second;
    cin >> first >> second;
    v[i] = {second, first};
  }
  sort(v.begin(), v.end());
  solve(N, std::move(v));
  return 0;
}


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

int main() {
string A;
cin >> A;
if(A == "111"){
cout << 3 <<endl;
}
else if(A == "110"||A == "101"||A == "011"){
    cout << 2 <<endl;
}
else if(A == "100"||A == "010"||A == "001"){
    cout << 1 <<endl;
}
else if(A == "000"){
    cout << 0 <<endl;
}
}

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

int N;

int main() {
  cin >> N;
  vector<int> P(N), Q(N);
  rep(i, N) cin >> P[i];
  rep(i, N) cin >> Q[i];

  vector<int> a(N);
  rep(i, N) a[i] = i + 1;

  int p, q;
  int i = 0;
  do {
    bool same = true;
    rep(i, N) same &= P[i] == a[i];
    if (same) p = i;

    same = true;
    rep(i, N) same &= Q[i] == a[i];
    if (same) q = i;

    ++i;
  } while (next_permutation(all(a)));

  cout << abs(p - q) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
//increase stack size
#pragma comment(linker, "/STACK:16777216")

ll mxm() {return LLONG_MIN;}
template<typename... Args>
ll mxm(ll a, Args... args) { return max(a,mxm(args...)); }

ll mnm() {return LLONG_MAX;}
template<typename... Args>
ll mnm(ll a, Args... args) { return min(a,mnm(args...)); }

template<class T> ostream& operator<<(ostream& os,vector<T> V){
	os<<"[ ";for(auto v:V)os<<v<<" ";return os<<"]";
}
template<class L,class R> ostream& operator<<(ostream& os,pair<L,R> P){
	return os<<"("<<P.first<<","<<P.second<<")";
}

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__,__VA_ARGS__)
template<typename Arg1>
void __f(const char* name,Arg1&& arg1){
	cout<<name<<" : "<<arg1<<endl;
}
template <typename Arg1,typename... Args>
void __f(const char* names,Arg1&& arg1,Args&&... args){
	const char* comma=strchr(names+1,',');cout.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1,args...);
}
#else
#define trace(...) 1
#endif

#define ld long double
#define pll pair<ll,ll>
#define ii pair<int,int>
#define vll vector<ll>
#define vii vector<ii>
#define vi vector<int>
#define vpll vector<pll>
#define vld vector<ld>
#define vvld vector<vld>
#define vvi vector<vi>
#define vvll vector<vll>
#define vvpll vector<vpll>
#define vvii vector<vii>
#define I insert
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define all(x)	x.begin(),x.end()

const int mod=1e9+7;
// 128 bit: __int128
inline int add(int a,int b){a+=b;if(a>=mod)a-=mod;return a;}
inline int sub(int a,int b){a-=b;if(a<0)a+=mod;return a;}
inline int mul(int a,int b){return (a*1ll*b)%mod;}
inline int power(int a,int b){int rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
inline int inv(int a){return power(a,mod-2);}

struct compare{
	bool operator() (const int &a,const int &b) const{
		return a>b;
	}
};

vector<pair<ii, ii> > queries;

int ans = 0;

void rec(vi v, int n, int m){
	if(v.size() == n){
		int what = 0;
		for(auto j : queries){
			int a = j.F.F - 1, b = j.F.S - 1;
			if(v[b] - v[a] == j.S.F)
				what += j.S.S;
		}
		ans = max(ans, what);
		return;
	}
	if(v.size() == 0){
		for(int j = 1; j <= m; j++){
			v.pb(j);
			rec(v, n, m);
			v.pop_back();
		}
	}
	else{
		for(int j = v.back(); j <= m; j++){
			v.pb(j);
			rec(v, n, m);
			v.pop_back();
		}
	}
}

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout<<setprecision(25);
	int n, m, q;
	cin >> n >> m >> q;
	queries.resize(q);
	for(int i = 0; i < q; i++)
		cin >> queries[i].F.F >> queries[i].F.S >> queries[i].S.F >> queries[i].S.S;
	vi v;
	rec(v, n, m);
	cout << ans << endl;
}

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

string to_bit(ll n){
    int c[50] {0};
    int i = 0;
    while(n){
        c[i] = n % 2;
        n /= 2;
        i++;
    }
    string s = "";
    for(int i = 49; i >= 0; i--){
        s.push_back('0' + c[i]);
    }
    return s;
}

ll pow(int n){
    ll r = 1;
    for(int i = 0; i < n; i++){
        r *= 2;
    }
    return r;
}

int main(){
    int n;
    ll k;
    cin >> n >> k;
    string kbit = to_bit(k);
    ll a[100001];
    string bits[100001];
    for(int i = 0; i < n; i++){
        cin >> a[i];
        bits[i] = to_bit(a[i]);
    }
    ll ans = 0;
    string ansbit = "00000000000000000000000000000000000000000000000000";
    for(int l = 0; l < 50; l++){
        int b0 = 0;
        int b1 = 0;
        for(int i = 0; i < n; i++){
            if(bits[i][l] == '0'){
                b0++;
            }
            else{
                b1++;
            }
        }
        string ansbit1 = ansbit;
        ansbit1[l] = '1';
        if(b0 >= b1 && kbit >= ansbit1){
            ans += pow(49 - l) * b0;
            ansbit = ansbit1;
        }
        else{
            ans += pow(49 - l) * b1;
        }
    }
    cout << ans << endl;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

ll n;
ll a[55],b[55],c[55],d[55];
vector<ll> xs,ys;
bool w[500][500];
bool vis[500][500];
ll dd[]={-1,0,1,0,-1};

int main(){
  while(1){
    cin>>n;
    if(n==0)break;
    rep(i,n){
      cin>>a[i]>>d[i]>>c[i]>>b[i];
      a[i]*=2; d[i]*=2; c[i]*=2; b[i]*=2;
    }

    xs.clear();
    ys.clear();
    rep(i,n){
      xs.push_back(a[i]+1);
      xs.push_back(a[i]);
      xs.push_back(a[i]-1);
      xs.push_back(c[i]+1);
      xs.push_back(c[i]);
      xs.push_back(c[i]-1);
    }
    rep(i,n){
      ys.push_back(b[i]+1);
      ys.push_back(b[i]);
      ys.push_back(b[i]-1);
      ys.push_back(d[i]+1);
      ys.push_back(d[i]);
      ys.push_back(d[i]-1);
    }
    sort(all(xs));
    uni(xs);
    sort(all(ys));
    uni(ys);
    memset(w,0,sizeof(w));
    rep(i,n){
      a[i]=lower_bound(all(xs),a[i])-xs.begin();
      c[i]=lower_bound(all(xs),c[i])-xs.begin();
      b[i]=lower_bound(all(ys),b[i])-ys.begin();
      d[i]=lower_bound(all(ys),d[i])-ys.begin();
      repl(y,b[i],d[i]+1){
        w[y][a[i]]=true;
        w[y][c[i]]=true;      
      }
      repl(x,a[i],c[i]+1){
        w[b[i]][x]=true;
        w[d[i]][x]=true;      
      }
    }
    ll res=0;
    memset(vis,0,sizeof(vis));
    rep(i,500)rep(j,500){
      if(vis[i][j]||w[i][j])continue;
      res++;
      queue<P> que;
      que.push(P(i,j));
      while(que.size()){
        P p=que.front(); que.pop();
        ll ci=p.fi,cj=p.se;
        rep(d,4){
          ll ni=ci+dd[d],nj=cj+dd[d+1];
          if(ni>=0&&ni<500&&nj>=0&&nj<500&&!vis[ni][nj]&&!w[ni][nj]){
            vis[ni][nj]=true;
            que.push(P(ni,nj));
          }
        }
      }
    }
    cout<<res<<endl;
  }
  return 0;
}



Measured memory_bytes: 3680
#include<iostream>
#include<queue>
using namespace std;
int head1=1,tail1=0,head2=1,tail2=0;
bool vis[300000];
int q1[300000],q2[300000],a[300000];
int cnt=0,jian=0;
int main(){
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	cin>>a[i];
	for(int i=1;i<=n;i++)
	{
		if(a[i]>a[i-1]) cnt++;
		else cnt=1;
		if(cnt==k)
		{
			vis[i]=1;
			cnt--;jian++;
		}
	}
	for(int i=1;i<=k;i++)
	{
		if(i==1) q1[++tail1]=a[i],q2[++tail2]=a[i];
		else{
			while(q1[tail1]<a[i]&&head1<=tail1) tail1--;
			q1[++tail1]=a[i];
			while(q2[tail2]>a[i]&&head2<=tail2) tail2--;
			q2[++tail2]=a[i];
		}
	}
	int ans=n-k+1;
	for(int i=k+1;i<=n;i++)
	{
		if(a[i-k]==q2[head2]&&a[i]>q1[head1]) 
		{
			ans--;
			if(vis[i]) ans++;
		}
		if(q1[head1]==a[i-k]) head1++;
		if(q2[head2]==a[i-k]) head2++;
		while(q1[tail1]<a[i]&&head1<=tail1) tail1--;
			q1[++tail1]=a[i];
		while(q2[tail2]>a[i]&&head2<=tail2) tail2--;
			q2[++tail2]=a[i];
			
	}
	if(jian)
	ans=ans-jian+1;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
using i64=long long;
int read(){int x;scanf("%d",&x);return x;}
int A[11],n,m,q,a[51],b[51],c[51],d[51],ans;
void check(){
    int sum=0;
    for(int i=1;i<=q;++i) if(A[b[i]]==A[a[i]]+c[i]) sum+=d[i];
    ans=max(ans,sum);
}
void dfs(int now,int low)
{
    if(now==n+1) return check(); 
    for(int i=low;i<=m;++i) A[now]=i,dfs(now+1,i),A[now]=0;
}
int main()
{
    cin>>n>>m>>q;
    for(int i=1;i<=q;++i) cin>>a[i]>>b[i]>>c[i]>>d[i];
    dfs(1,1);
    cout<<ans;
}


Measured memory_bytes: 3632
from collections import Counter

n=int(input())
s=[input() for i in range(n)]

c = Counter(s)
c2 = c.most_common()
m = c2[0][1]#最大値
ans = [i[0] for i in c2 if i[1] == m]#回数が最大となるもの
ans.sort()
print(*ans)

Measured memory_bytes: 120784
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,a,b) for(int i=a;i<=b;i++)
inline ll r() {
	ll x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9')c=getchar();
	if(c=='-')f=-1,c=getchar();
	while(isdigit(c))x=x*10+c-'0',c=getchar();
	return x*f;
}
#define d r()

int main(){
	ll n=d;
	cout<<(1000-n%1000)%1000;
	return 0;
}


Measured memory_bytes: 3624
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long ll;
 
int main() {
	int n, o, t, h;
	cin >> n;
	o = n % 10;
	t = (n % 100 - o) / 10;
	h = n / 100;
	if (o == 7 || t == 7 || h == 7) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3632
import math

N, a, b = map(int, input().split())
product_list = sorted(map(int, input().split()), reverse = True)

def nCm(n, m):
    return math.factorial(n) / (math.factorial(m) * (math.factorial(n - m)))

# average_list
average_list = []
average_idx = []
for i in range(a, b+1):
    average = sum(product_list[:i]) / i
    average_list.append(average)
    average_idx.append(i)

max_average = max(average_list)
max_average_idx = [average_idx[i] for i in range(len(average_list)) if average_list[i] == max_average]

pattern_num = int(0)

for i in max_average_idx:
    choice_num = product_list[:i].count(product_list[i-1])
    all_num = product_list.count(product_list[i-1])

    pattern_num += int(nCm(all_num, choice_num))

print(float(max_average), pattern_num)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define print(s) cout << s << endl
typedef long long ll;
using namespace std;

int main() {
    int a, b; cin >> a >> b;
    cout << (a%b > 0 ? 1 : 0) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
		int c = 0;
		int d = 0;
		int aa = a;
		while(aa>0) {
			aa--;
			c += b*Math.pow(10,aa);
			
		}
		while(b>0) {
			b--;
			d += a*Math.pow(10,b);
		}
		System.out.println(Math.max(c, d));
	}
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=mod*mod*3LL;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

struct UnionFind {
    vector<int> par;
    UnionFind(int n) :par(n, -1) { }
    void init(int n) { par.assign(n, -1); }
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    bool connect(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    int size(int x) {
        return -par[root(x)];
    }
};
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    cin >> n >> m;
    UnionFind uf(n);
    vector<vector<ll> > v(n);
    ll a,b;
    for(int i=0;i<m;i++){
    	cin >> a >> b;
    	a--;b--;
    	v[a].pb(b);
    	v[b].pb(a);
    }
    vector<int> used(n,0);
    auto dfs = [&](auto&& dfs,int now) -> void{
    	used[now] = true;
    	ll niko = v[now][0];
    	for(auto& to:v[now]){
    		uf.connect(niko,to);
    		if(!used[to]) dfs(dfs,to);
    	}
    	return;
    };
    dfs(dfs,0);
    if(uf.size(0) == n){
    	cout << n*(n-1)/2 - m << endl;
    }else{
    	ll niko = uf.root(0);
    	ll maki;
    	for(int i=1;i<n;i++){
    		if(uf.root(i)!=niko){
    			maki = uf.root(i);
    			break;
    		}
    	}
    	niko=uf.size(niko);
    	maki=uf.size(maki);
    	cout << niko * maki - m << endl;
    }
    return 0;
}


Measured memory_bytes: 8064
def gcd(a,b)
	a,b = b,a if b>a
	a%b == 0 ? b : gcd(b,a%b)
end

def lcm(a,b)
	a*b/gcd(a,b)
end

while line = gets
	break if line == "\n"
	a,b = line.split
	puts "#{gcd(a.to_i,b.to_i)} #{lcm(a.to_i,b.to_i)}"
end

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

int main(){
    int n, m, p, c;
    while(cin >> n >> m){
        if(n * m == 0) break;
        vector<int> mou(n);
        for(int i = 0;i<n;i++) mou[i] = n-i;
        for(int i = 0;i<m;i++){
            vector<int> tmp(n);
            cin >> p >> c;
            for(int j = 0;j<c;j++){
                tmp[j] = mou[p+j-1];
            }
            for(int j = 0;j<p-1;j++){
                tmp[c+j] = mou[j];
            }
            for(int j = 0;j<p+c-1;j++){
                mou[j] = tmp[j];
            }
            // for(int j = 0;j<n;j++) cout << tmp[j];
            // cout << " ";
            // for(int j = 0;j<n;j++){cout << mou[j];}
            // cout << endl;
        }
        cout << mou[0] << endl;
    }
    return 0;
}


Measured memory_bytes: 3092
using System;

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

		int count = 0;
		for (int i = 0; i < n; i++)
		{
			int a = int.Parse(Console.ReadLine());

			if (IsPrime(a))
			{
				count ++;
			}
		}

		Console.WriteLine(count);
	}

	static bool IsPrime(int n)
	{
		int p = (int)Math.Sqrt(n);

		for (int i = 2; i <= p; i += (i ==2) ? 1 : 2)
		{
			if (n % i == 0)
			{
				return false;
			}
		}
		return true;
	}
}



Measured memory_bytes: 15880
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <climits>
#include <memory>
#include <sstream>
#include <iomanip>

using namespace std;

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

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

	cout << min(c, b/a) << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define MAX 500000
#define SENTINEL 2000000000

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

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

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

int main(){
    int A[MAX],n,i;
    cnt=0;
    
    cin>>n;
    for(i=0;i<n;i++) cin>>A[i];
    
    mergeSort(A,n,0,n);
    
    for(i=0;i<n;i++){
        if(i) cout<<" ";
        cout<<A[i];
    }
    cout<<endl;
    
    cout<<cnt<<endl;
    
    return 0;
}



Measured memory_bytes: 6888
def main():
    S = str(input())

    for i in range(len(S)):
        if (i+1) % 2 == 0:
            if S[i] == "R" :
                print('No')
                return
        else:
            if S[i] == "L":
                print("No")
                return
    print("Yes")

if __name__ == "__main__":
    main()

Measured memory_bytes: 2940
#include <algorithm>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

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

const int INF = 0x3f3f3f3f, MOD = 1000000007;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*-----------------------------------------*/
// n = 今見ているビットの数
vector<int> solve(int n, int a, int b) {
  if (n == 1) return {a, b};

  // ・最上位ビットが同じ
  // a = 0aaaaa, b = 0bbbbb とする
  // solve(n - 1, a, b)       において 0xxxxx の形でとりうる値を全列挙
  // solve(n - 1, 1aaaaa, 1yyyyy)          1xxxxx
  // 条件を満たすようにこの二者をつなげるには
  // (0aaaaa -> 1aaaaa) は条件を満たすので
  // (1yyyyy -> 前者の要素の二番目) が条件を満たすようにすればよい
  if ((a >> (n - 1) & 1) == (b >> (n - 1) & 1)) {
    vector<int> res1 = solve(n - 1, a, b);
    vector<int> res2 = solve(n - 1, a ^ (1 << (n - 1)), res1[1] ^ (1 << (n - 1)));
    vector<int> res{res1.front()};
    copy(ALL(res2), back_inserter(res));
    copy(res1.begin() + 1, res1.end(), back_inserter(res));
    return res;
  }

  // ・最上位ビットが異なる
  // a = 0aaaaa, b = 1bbbbb とする
  // solve(n - 1, a, a ^ 1) において 0xxxxx の形でとりうる値を全列挙
  // a ^ 1 = 0aaaa1 とすると
  // solve(n - 1, 1aaaa1, b)         1xxxxx
  // (0aaaa1 -> 1aaaa1) は条件を満たす
  else {
    vector<int> res = solve(n - 1, a, a ^ 1), res2 = solve(n - 1, a ^ 1 ^ (1 << (n - 1)), b);
    copy(ALL(res2), back_inserter(res));
    return res;
  }
  // 0xxxxx, 1xxxxx
  // それぞれの形でとりうる数を条件を満たす形で全列挙できる
}

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

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

  // 0 <= i <= 2^n-1 を満たす整数は 2^n 個ある
  // 条件を満たす順列の隣接する要素において立っているビットの数の差は1
  // よって, P_0 と P_2^n-1 では立っているビットの数の偶奇が異なる
  if (abs(__builtin_popcount(a) - __builtin_popcount(b)) % 2 == 0) {
    cout << "NO\n";
    return 0;
  }

  vector<int> ans = solve(n, a, b);
  cout << "YES\n";
  REP(i, 1 << n) cout << ans[i] << (i == (1 << n) - 1 ? '\n' : ' ');
  return 0;
}


Measured memory_bytes: 1896
#include<bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

#define FOR(i,a,b) for (int i = a; i < b; ++i)
#define FORR(i,a,b) for (int i = b - 1; i >= a; --i)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) FORR(i,0,n)

template<class T>
inline void read(T& x) {
  T s = 0, base = 1;
  char c;
  while (!isdigit(c=getchar())) if (c == '-') base = -base;
  while (isdigit(c)) {
    s = s * 10 + (c^48);
    c = getchar();
  }
  x = base * s;
}

int D, G;
int p[10], c[10];

int main() {
  read(D);
  read(G);
  G /= 100;

  REP(i,D) {
    read(p[i]);
    read(c[i]);
    c[i] /= 100;
  }

  int ans = numeric_limits<int>::max();
  for (int i = 0; i < (1 << D); ++i) {
    // i: 使いきったか否かを表すビット
    int sum = 0;
    int cnt = 0;

    for (int j = 0; j < D; ++j) {
      if ((i >> j) & 1) {
        sum += p[j] * (j + 1) + c[j];
        cnt += p[j];
      }
    }

    for (int j = D - 1; j >= 0; --j) {
      if ((i >> j) & 1) continue;
      if (sum >= G) break;
      int buf = min((G - sum) / (j + 1), p[j]);
      cnt += buf;
      sum += (j + 1) * buf;
    }

    if (G <= sum) ans = min(ans, cnt);
  }

  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
#
# abc091 b
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """3
apple
orange
apple
1
grape"""
        output = """2"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """3
apple
orange
apple
5
apple
apple
apple
apple
apple"""
        output = """1"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """1
voldemort
10
voldemort
voldemort
voldemort
voldemort
voldemort
voldemort
voldemort
voldemort
voldemort
voldemort"""
        output = """0"""
        self.assertIO(input, output)

    def test_入力例_4(self):
        input = """6
red
red
blue
yellow
yellow
red
5
red
red
yellow
green
blue"""
        output = """1"""
        self.assertIO(input, output)


def resolve():
    N = int(input())
    s = []
    for _ in range(N):
        s.append(input())
    M = int(input())
    t = []
    for _ in range(M):
        t.append(input())
    ans = 0
    for i in range(N):
        ans = max(s.count(s[i]) - t.count(s[i]), ans)
    print(ans)


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 16232
import java.util.*;
 
//update 2020/1/1 23:01
 
public class Main{
 
  static Scanner sc = new Scanner(System.in);
  static StringBuilder sb = new StringBuilder();
 
  public static void main(String[] args) {
 
	int[] aaa = new int[3];
    
    aaa[0] = nextInt();
    aaa[1] = nextInt();
    aaa[2] = nextInt();
 
    System.out.println(aaa[2]+" "+aaa[0]+" "+aaa[1]);
    
  }
  /*
    static String toSmall(String s){
      char c = s.charAt(0);
      //if(Character.isUpperCase(c)){
      if(c<=90){
        c += 32;
      }
      return String.valueOf(c);
    }
    static String toBig(String s){
      char c = s.charAt(0);
      //if(Character.isLowerCase(c)){
      if(c>=97){
        c -= 32;
      }
      return String.valueOf(c);
    }
  */
 
  static String toSmall(String s){
    return s.toLowerCase();
  }
 
  static String toBig(String s){
    return s.toUpperCase();
  }
 
  static String next(){
    return sc.next();
  }
 
  static int nextInt(){
    return Integer.parseInt(sc.next());
  }
 
  static long nextLong(){
    return Long.parseLong(sc.next());
  }
 
  static double nextDouble(){
    return Double.parseDouble(sc.next());
  }
 
  static String[] splitString(String s){
    return s.split("");
  }
 
  static char[] splitChar(String s){
    return s.toCharArray();
  }
 
  static int charToInt(char a){
    return a - 48;
  }
 
////////////////////////////////////////////
  public static int max(int[] a){
    int lng = a.length;
    int max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
  public static long max(long[] a){
    int lng = a.length;
    long max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
////////////////////////////////////////////
 
////////////////////////////////////////////
  public static int min(int[] a){
    int lng = a.length;
    int min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
  public static long min(long[] a){
    int lng = a.length;
    long min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
////////////////////////////////////////////
 
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> P;

vector<P> prime_factorize(int N){
	vector<P> ans;
	for(int a = 2; a*a <= N; a++){
		if(N%a == 0){
			int ex = 0;
			while(N%a == 0){
				ex++;
				N /= a;
			}
			ans.push_back(P(a, ex));
		}
	}
	if(N != 1) ans.push_back(P(N, 1));
	return ans;
}

signed main(){
    int N; cin >> N;
    vector<int> vec(98);
    for(int i = 1; i <= N; i++){
        vector<P> vec1 = prime_factorize(i);
        for(int j = 0; j < vec1.size(); j++) vec[vec1[j].first] += vec1[j].second;
    }
    int c2 = 0, c4 = 0, c14 = 0, c24 = 0, c74 = 0;
    for(int i = 0; i < vec.size(); i++){
        if(vec[i] >= 2) c2++;
        if(vec[i] >= 4) c4++;
        if(vec[i] >= 14) c14++;
        if(vec[i] >= 24) c24++;
        if(vec[i] >= 74) c74++;
    } 
    int ans = (c4 - 1) * c14 + (c2 - 1) * c24 + c74 + (c2 - 2) * c4 * (c4 - 1) / 2;
    cout << ans << endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(10)<<fixed;
  int n;
  double x[10], y[10];
  cin>>n;
  REP(i, n){
    cin>>x[i]>>y[i];
  }
  vi v(n);
  iota(ALL(v), 0);
  double ans=0;
  int cnt=0;
  do{
    REP(i, n-1){
      ans+=sqrt((x[v[i]]-x[v[i+1]])*(x[v[i]]-x[v[i+1]])+(y[v[i]]-y[v[i+1]])*(y[v[i]]-y[v[i+1]]));
    }
    ++cnt;
  }while(next_permutation(ALL(v)));
  cout<<ans/cnt<<'\n';
  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue> //C++
#include <string> //C++
#include <iostream> //C++
#include <vector> //C++
#include <algorithm> //C++
#include<map> //C++
using namespace std; //C++
#define rep(i, a, n) for (i = (a); i < (n); i++)
#define  max(x,y) ((x)>(y)?(x):(y))
#define  min(x,y) ((x)>(y)?(y):(x))

//C++で提出



// string s="AAA";    s.size() =3    (sのサイズ) ...1
// vector <int> a;    配列a(サイズは0) ...2
// a.push_back(10);   配列のサイズが一つ増えて一番後ろに10を代入 ...2
// A.pop_back();   最後の要素が消去される
// sort(A.begin(),A.end());   配列Aの最初の要素から最後の要素(/.)より前までを小さい順に並び替えてa[0]から代入していく...3
// reverse(A.begin(),A.end());   配列Aの最初の要素から最後の要素(/.)までを逆の順にしてa[0]から代入していく
// s.substr(3,2)   配列s[3]から2個の文字を抜き出した文字列 (s[3]とs[4]) ...4
// strcmp(s1,s2)  文字列が等しければ0を出力　s1>s2なら1 s1<s2なら-1を出力　C言語用なので配列は、s1[100]にする...5





int main()
{
	int x, a, b,c;
	cin >> a >> b >>c>> x;
	int count = 0;
	int ans;
	int i, j,z;

	

	for (i = 0; i <= c; i++) {
		
		for (j = 0; j <= b ; j++) {
			
			for (z = 0; z <= a; z++) {
				if (50 * i + 100 * j +500*z== x) {
					count++;
				}
			}
		}
	}

	cout << count;

	return 0;
}
	




Measured memory_bytes: 256
def lack(S,A):
    for i in range(1,14):
        if not A[i]:
            print(S,i)

N = int(input())
S = [0]*15
H = [0]*15
C = [0]*15
D = [0]*15

for i in range(N):
    c,n = input().split()
    n = int(n)
    if c == "S":
        S[n] = 1
    elif c == "H":
        H[n] = 1
    elif c == "C":
        C[n] = 1
    elif c == "D":
        D[n] = 1

lack("S",S)
lack("H",H)
lack("C",C)
lack("D",D)



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

int main() {
string s;
cin >> s;
for(int i = s.size()-1; i >= 2; i--){
  string t = s.substr(0,i);
  if(t.size()%2 == 0){
    string x = t.substr(0,t.size()/2);
    string y = t.substr(t.size()/2,t.size()/2);
    if(x == y){
      cout << t.size() << endl;
      return 0;
    }
  }
}
}


Measured memory_bytes: 3628
n, k = map(int, input().split())
sunuke = [False for i in range(n)]
for i in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    for j in a:
        sunuke[j-1] = True
ans = 0
for i in sunuke:
    if i == False:
        ans += 1
print(ans)


Measured memory_bytes: 9184
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

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

  int n;
  cin >> n;
  int a[n];
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }

  int count = 0;
  while(true){
    bool odd = true;
    for(int i = 0; i < n; i++){
      if(a[i] % 2 != 0){
        odd = false;  break;
      }
      a[i] /= 2;
    }
    if(!odd) break;
    ++count;
  }

  cout << count << endl;

  return 0;
}


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

const long long d = 1e9+7;

int main() {
        long long n;
        cin >> n;
        long long rem = 1;
        for (long long i=1; i<=n; ++i) {
                rem = rem*i%d;
        }
        cout << rem << endl;
        return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		int toi = Integer.parseInt(scanner.nextLine());
		int atemp = toi;
		int btemp = toi;
		int flag = 0;

		if(toi > 3) {
			if(toi % 4 == 0  || toi % 7 == 0) {
				System.out.println("Yes");
				flag = 1;
			}else{
				while(btemp > 3 && atemp > 3) {
					atemp -= 4;
					btemp -= 7;
					if(atemp % 7 == 0) {
						System.out.println("Yes");
						flag = 1;
						break;
					}
					if(btemp % 4 == 0) {
						System.out.println("Yes");
						flag = 1;
						break;
					}
				}
			}

			if(flag == 0) {
				System.out.println("No");

			}

		}else{
			System.out.println("No");
		}

	}
}

Measured memory_bytes: 22996
N = int(input())
e = [[] for _ in range(N)]
for _ in range(N-1):
  u,v,w = map(int, input().split())
  u -= 1
  v -= 1
  e[u].append((v,w))
  e[v].append((u,w))

res = [-1]*N
res[0] = 0
q = [0]
while len(q):
  v = q.pop()
  for u,w in e[v]:
    if res[u]>=0:
      continue
    res[u] = res[v]+w
    q.append(u)

for r in res:
  print(r%2)

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

int totalDigits(int n) {
  int result = 0;
  while(n!=0) {
    result += n % 10;
    n /= 10;
  }

  return result;
}
int main() {
  int n;
  cin >> n;
  int min = INT_MAX;
  for(int i=1;i<=n/2;i++) {
    if(totalDigits(i) + totalDigits(n-i) < min) {
      min = totalDigits(i) + totalDigits(n-i);
    }
  }

  cout << min << endl;
}

Measured memory_bytes: 256