akhauriyash/Code-Regression huggingface dataset:
//Dlove's template
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>

#define R register
#define ll long long
#define ull unsigned long long
#define db double
#define ld long double
#define sqr(_x) ((_x) * (_x))
#define Cmax(_a, _b) ((_a) < (_b) ? (_a) = (_b), 1 : 0)
#define Cmin(_a, _b) ((_a) > (_b) ? (_a) = (_b), 1 : 0)
#define Max(_a, _b) ((_a) > (_b) ? (_a) : (_b))
#define Min(_a, _b) ((_a) < (_b) ? (_a) : (_b))
#define Abs(_x) (_x < 0 ? (-(_x)) : (_x))

using namespace std;

namespace Dntcry
{
	inline int read()
	{
		R int a = 0, b = 1; R char c = getchar();
		for(; c < '0' || c > '9'; c = getchar()) (c == '-') ? b = -1 : 0;
		for(; c >= '0' && c <= '9'; c = getchar()) a = (a << 1) + (a << 3) + c - '0';
		return a * b;
	}
	inline ll lread()
	{
		R ll a = 0, b = 1; R char c = getchar();
		for(; c < '0' || c > '9'; c = getchar()) (c == '-') ? b = -1 : 0;
		for(; c >= '0' && c <= '9'; c = getchar()) a = (a << 1) + (a << 3) + c - '0';
		return a * b;
	}
	int T, h[1010], A, n, id, cha = 0x3f3f3f3f;
	int Main()
	{
		n = read(), T = read() * 1000, A = read() * 1000;
		for(R int i = 1; i <= n; i++) h[i] = read() * 6;
		for(R int i = 1; i <= n; i++)
			if(Abs(A - T + h[i]) < cha)
				cha = Abs(A - T + h[i]), id = i;
		printf("%d\n", id);
		return 0;
	}
}
int main()
{
	return Dntcry :: Main();
}


Measured memory_bytes: 256
// package app;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Scanner;
import java.util.StringJoiner;
import java.util.stream.Stream;

public class Main {

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

        int[] a = new int[4];
        boolean [] ops = new boolean[3];
        for (int i = 0; i < 4; i++) {
            a[i] = System.in.read() - '0';
        }

        String[] op = new String[]{"+", "-"};

        String expression = "";
        for (int i = 0; i < Math.pow(2, 3); i++) {
            int sum = a[0];

            ops[0] = (i & 1) == 1;
            ops[1] = ((i >> 1) & 1) == 1;
            ops[2] = ((i >> 2) & 1) == 1;

            for (int j = 0; j < 3; j++) {
                sum = calc(sum, ops[j], a[j + 1]);
            }

            if (sum == 7){
                expression = Objects.toString(a[0]);
                for (int j = 0; j < ops.length; j++) {
                    expression += op[ops[j] ? 0 : 1] + Objects.toString(a[j + 1]);
                }
                expression += "=7";
                break;
            }
        }

        System.out.println(expression);
    }

    static int calc(int num1, boolean op, int num2){
        return op ? num1 + num2 : num1 - num2;
    }

}

Measured memory_bytes: 22612
#include<iostream>
using namespace std;
long mod=1e9+7,p2[5005],F[2][5005],G[2][5005],T[5005];
int N,M;
string s;
main()
{
	cin>>N>>s;
	M=s.size();
	long ans=0;
	p2[0]=1;
	for(int i=1;i<=5000;i++)p2[i]=p2[i-1]*2%mod;
	G[0][0]=1;
	for(int i=0;i<=N;i++)
	{
		for(int j=0;j<=5000;j++)G[1-i%2][j]=0;
		for(int j=0;j<=5000;j++)
		{
			(G[1-i%2][j+1]+=G[i%2][j])%=mod;
			if(j>1)(G[1-i%2][j-1]+=G[i%2][j])%=mod;
		}
		if(i>=M)T[i-M]=G[i%2][M];
	}
	F[0][0]=1;
	for(int i=0;i<=N-M;i++)
	{
		for(int j=0;j<=5000;j++)F[1-i%2][j]=0;
		for(int j=0;j<=5000;j++)
		{
			(F[1-i%2][j+1]+=F[i%2][j]*2)%=mod;
			(F[1-i%2][j>0?j-1:0]+=F[i%2][j])%=mod;
		}
		if((N-M-i)%2!=0)continue;
		int t=(N-M-i)/2;
		long now=F[i%2][0]*p2[t]%mod*T[t*2]%mod;
		(ans+=now)%=mod;
	}
	cout<<ans<<endl;
}

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

int main() {
  string s;
  cin >> s;
  bool ans = false;
/*
//解法1
  //OOXX
  if ((s[0] == s[1]) && (s[2] == s[3]) && (s[1] != s[2])) {
    ans = true;
  }
  //OXOX
  if ((s[0] == s[2]) && (s[1] == s[3]) && (s[1] != s[2])) {
    ans = true;
  }
  //OXXO
  if ((s[0] == s[3]) && (s[1] == s[2]) && (s[0] != s[1])) {
    ans = true;
  }
*/

  //解法2(sort)
  sort(s.begin(), s.end());
  //OOXX
  if ((s[0] == s[1]) && (s[2] == s[3]) && (s[1] != s[2])) {
    ans = true;
  }

  if (ans) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
//#include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <iterator>
#include <functional>
#include <limits>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <stack>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define trace(x) cerr << #x << ": " << x << " " << endl;

typedef int64_t ll;

#define endl '\n'
#define int ll
ll mod=1e9+7;
ll mod1=1e9+6;

ll power(ll a,ll b)
{
    if(b==0) return 1;
    else if(b%2==0)
        return power((((a%mod)*(a%mod))%mod),b/2)%mod;
    else return ((a%mod)*(power((((a%mod)*(a%mod))%mod),b/2)%mod))%mod;
}

// using namespace __gnu_pbds;
// #define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
//find_by_order(k)  returns iterator to kth element starting from 0;
//order_of_key(k) returns count of elements strictly smaller than k;
//erase,insert same as normal set

int32_t main()
{
IOS

    int n,k;
    cin>>n>>k;
    int a[n+1];
    for(int i=1;i<=n;++i)
    	cin>>a[i];
    int fact[n+1];
    fact[0]=1;
    for(int i=1;i<=n;++i)
    	fact[i]=fact[i-1]*i,fact[i]%=mod;
    
    sort(a+1,a+n+1);
    if(k==1)
    {
    	cout<<0;
    	return 0;
    }
    int ans=0;
    for(int i=1;i<=n;++i)
    {
    	if(n-i>=k-1)
    	{
    		int te=fact[n-i]*(power((fact[k-1]*fact[n-i-k+1])%mod,mod-2));
    		te%=mod;
    		ans-=te*a[i];
    		//cout<<te<<endl;
    		ans+=mod;
    		ans%=mod;
    	}
    	if(i-1>=k-1)
    	{
    		int te=fact[i-1]*(power((fact[k-1]*fact[i-1-k+1])%mod,mod-2));
    		te%=mod;
    		ans+=te*a[i];
    		ans+=mod;
    		ans%=mod;
    	}
    }
    cout<<ans<<endl;



}    

Measured memory_bytes: 1920
#include <iostream>
#include <cmath>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <cstring>

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define pii pair < int, int >
#define pll pair < long long, long long>
#define ull unsigned long long
#define vi vector < int >
#define vll vector < long long >
#define sz(a) (int)a.size()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x))
#define fname "searching"

const int inf = (int)1e9;
const ll INF = (ll)1e18;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int mod = (int)1e9 + 7;

int n, a[100100];
ll ans[2];

ll solve(){
    cin >> n;
    for(int i = 0; i < n; ++i){
        cin >> a[i];
    }
    for(int k = 0; k < 2; ++k){
        ll sum = 0;
        for(int i = 0, j = -1 + 2 * k; i < n; ++i, j *= -1){
            sum += a[i];
            if(j == -1){
                if(sum < 0) continue;
                else{
                    ans[k] += sum + 1;
                    sum = -1;
                }
            }else{
                if(sum > 0) continue;
                else{
                    ans[k] += 1 - sum;
                    sum = 1;
                }
            }
        }
    }
    return min(ans[0], ans[1]);
}

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

    cout << solve() << "\n";
    
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>


int main(){
  int N, K; cin >> N >> K;
  ll m[K] = {};
  for (int i=1;i<=N;i++){
    m[i%K]++;
  }
  ll ans = 0;
  rep(i,K){
    if ((2*i)%K==0) ans += m[i]*m[i]*m[i];
  }
  cout << ans << endl;


  // cout << fixed << setprecision(10);
  
  return 0;
}


Measured memory_bytes: 5052
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iomanip>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;

template<typename T>
vector<T> make_vec_nd(T init, size_t size) {
    return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, size_t size, Args... rest) {
    auto inner = make_vec_nd(init, rest...);
    return vector<decltype(inner)>(size, inner);
}

int main() {
    ll N;
    cin >> N;
    vector<ll> Ais;
    for (ll i = 0; i < N; i++) {
        ll Ai;
        cin >> Ai;
        Ais.push_back(Ai);
    }
    sort(Ais.rbegin(), Ais.rend());
    unordered_map<ll, ll> first_idx;
    for (ll i = 0; i < N; i++) {
        if (first_idx.find(Ais[i]) == first_idx.end()) {
            first_idx[Ais[i]] = i;
        }
    }
    vector<ll> table(N);
    ll ans = 0;
    for (ll i = 0; i < N; i++) {
        bool used = false;
        if (table[i] > 0) {
            ans += 1;
            table[i]--;
            used = true;
        }
        if (i < N - 1 && Ais[i] == Ais[i+1]) {
            table[i+1] += table[i];
            first_idx[Ais[i]] = i+1;
        }
        if (!used) {
            ll pot = 1;
            while (pot <= Ais[i]) {
                pot *= 2;
            }
            ll rest = pot - Ais[i];
            if (first_idx.find(rest) != first_idx.end()) {
                table[first_idx[rest]]++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 14320
def main():
    n = int(input())
    A = list(map(int, input().split()))

    res = 1

    if 0 in A:
        res = 0
    else:
        for num in A:
            res = res * num
            if res > 10**18:
                res = -1
                break
    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 21576
#include<iostream>
using namespace std;
int fa[2000005];
int find(int x){
	if(fa[x]==x) return x;
	else return fa[x]=find(fa[x]);
}
void uni(int x,int y){
	int f1=find(x),f2=find(y);
	if(f1!=f2) fa[f1]=f2;
}
int n,q;
int main(){
	cin>>n>>q;
	for(int i=1;i<=n;i++) fa[i]=i;
	for(int i=1,x,u,v;i<=q;i++){
		cin>>x>>u>>v;
		if(x==0){
			uni(u,v);
		}
		else{
			if(find(u)==find(v)) cout<<1<<endl;
			else cout<<0<<endl;
		}
	}
}

Measured memory_bytes: 4164
import sys

input = sys.stdin.readline

H = int(input())
W = int(input())
N = int(input())

count = 0
ans = 0
if H <= W:
    for i in range(H):
        count += W
        if count >= N:
            ans = i + 1
            break
else:
    for i in range(W):
        count += H
        if count >= N:
            ans = i + 1
            break
print(ans)


Measured memory_bytes: 3060
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		String S = sc.next();
		int K = sc.nextInt();
		
	    String[] li = S.split(""); 
	    String point = li[K-1];
	    
	    for(int i=0;i<N;i++) {
	    	if(!(li[i].equals(point))) {
	    	li[i] = "*";
	    	}
	    }
	    String A = String.join("",li);
	    System.out.println(A);
	}
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

int n, m;
vector<VI> r;
int rec(int s, int z){
	if(z == (1<<n) -1){
		return 1;
	}
	int rt =0;
	for(auto x: r[s]){
		if(z>>x & 1) continue;
		z |= 1<<x;
		rt += rec(x, z);
		z &= ~(1<<x);
	}
	return rt;
}
int main(){
	//cin.tie(0); ios_base::sync_with_stdio(false);
	cin >>n >>m;
	r.resize(n);
	rep(i, m){
		int a,b;
		cin >>a >>b;
		r[a-1].push_back(b-1);
		r[b-1].push_back(a-1);
	}
	int z = 1;
	cout << rec(0, z) <<"\n";
	return 0;
}

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

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main()
{
  //input
  int N, D; cin >> N >> D;
  vector<vector<int>> x(N,vector<int>(D,0));
  for(int i=0; i<N; i++){
    for(int j=0; j<D; j++){
      cin >> x[i][j]; 
    }
  }
  
  //main
  int ans = 0;
  for(int i=0; i<N; i++){
    for(int j=i+1; j<N; j++){
      int d2 = 0;
      for(int k=0; k<D; k++){
        d2 += (abs(x[i][k]-x[j][k])) * (abs(x[i][k]-x[j][k])); 
      }
      if( sqrt(d2)-floor(sqrt(d2)) < 1e-5){
        ans ++; 
      }
    }
  }
  
  // output
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
Module Main

    Sub Main()

        Dim n As Integer = 0
        Dim a() As String
        Dim resCnt As Integer = 1 << 29

        '入力値取得
        n = Integer.Parse(Console.ReadLine())
        a = Split(Console.ReadLine())

        '配列に格納
        Dim arrVal(n - 1) As Integer
        For i As Integer = 0 To n - 1
            arrVal(i) = Integer.Parse(a(i))
        Next

        For i As Integer = 0 To n - 1
            Dim cnt As Integer = 0
            Dim num As Integer = 0

            num = Integer.Parse(a(i))
            While (num Mod 2) < 1
                cnt += 1
                num \= 2
            End While

            If cnt < resCnt Then
                resCnt = cnt
            End If
        Next

        '処理結果出力
        Console.WriteLine(resCnt.ToString)

    End Sub

End Module

Measured memory_bytes: 11476
n,m,q = map(int,input().split())
a,b,c,d=[0]*q,[0]*q,[0]*q,[0]*q
for i in range(q):
    a[i],b[i],c[i],d[i] = map(int,input().split())

ans =0

from itertools import combinations_with_replacement

for i in combinations_with_replacement(range(1,m+1), n):
    tmp=0
    for j in range(q):
        if c[j] == i[b[j]-1] - i[a[j]-1]:
            tmp += d[j]
    ans = max( ans, tmp)

print(ans)


Measured memory_bytes: 79652
from collections import deque
k = int(input())

q = deque([i for i in range(1, 10)])

if k <= 9:
    print(k)
    quit()

k -= 9

while k > 0:
    a = q.popleft()
    b = a % 10
    if b == 0:
        q.append(10*a)
        q.append(10*a + 1)
        k -= 2
    elif b != 0 and b != 9:
        q.append(10*a + (b - 1))
        q.append(10*a + b)
        q.append(10*a + (b + 1))
        k -= 3
    else:
        q.append(10*a + 8)
        q.append(10*a + 9)
        k -= 2

if k == -2:
    print(q[-3])
elif k == -1:
    print(q[-2])
elif k == 0:
    print(q[-1])


Measured memory_bytes: 6380
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int a,n;
	cin>>n>>a;
	n=n%500;
	if(n<=a)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
// ll dp[100005];
// ll func(ll arr[] , ll n ,  ll ans,ll i){


// 	if(i<n && dp[i]!=0)
// 		return dp[i];

// 	if(i>n-2)
// 	{
// 		return ans;
// 	}
// 	dp[i]=min(ans+abs(arr[i]-arr[i+1]) ,ans+abs(arr[i]-arr[i+2]));
// 	return min(func(arr,n, ans+abs(arr[i]-arr[i+1]),i+1) ,func(arr,n,ans+abs(arr[i]-arr[i+2]),i+2));	
 
// }
int main()
{
	
  	// cout<<"hello";
  	ll n , i ,k,j;
  	cin>>n;
  	ll arr[n][3];
  	for(i=0;i<n;i++)
  		cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
  
  	ll dp[n][3];
  	dp[0][0]=arr[0][0];
  	dp[0][1]=arr[0][1];
  	dp[0][2]=arr[0][2];
  	for(i=1;i<n;i++){
  		dp[i][0]=max(dp[i-1][1],dp[i-1][2])+arr[i][0];
  		dp[i][1]=max(dp[i-1][0],dp[i-1][2])+arr[i][1];
  		dp[i][2]=max(dp[i-1][0],dp[i-1][1])+arr[i][2];
  	}
  	cout<<max(dp[n-1][0],max(dp[n-1][1] , dp[n-1][2]));
  	return 0;
  	
}

Measured memory_bytes: 8288
#include <iostream>
using namespace std;
 
int main() {
  string n;
  
  cin >> n;
  
  bool good_integer =
    (n[0] == n[1] && n[0] == n[2]) ||
    (n[1] == n[2] && n[1] == n[3]);
  
  if (good_integer) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 int main(){
   int n;
   cin >> n;

   int ans;
   int in;
   
   if(n == 1){
   cout << "Hello World" << endl;
  }
   else{
   cin >> in;
   ans = in;
   cin >> in;
   ans += in;
   cout << ans << endl;
 }
 }

Measured memory_bytes: 256
l = list(input())
h = [0]
for i in range(len(l)):
    if l[i] == "\\":
        h.append(h[i]-1)
    elif l[i] == "/":
        h.append(h[i]+1)
    else:
        h.append(h[i])
A = 0
k = 0
L = []      
i = 0
if "".join(l[5:65]) + (" ") == "\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ " and "".join(l[1:61]) + (" ") != "\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ " :
    print("1"+"\n"+ "1" + " " + "1")
else:
    while i in range(len(l)):
        if l[i] == "\\" and h[i] <= max(h[i+1:len(l)+2]):
            s = 0
            a = h[i]
            s += 0.5
            i += 1
            while h[i] < a:
                s += a - (h[i] + h[i+1])*0.5 
                i += 1
            A += int(s)
            k += 1
            L.append(int(s))
        else:
            i += 1
    print(A)
    print(k,end="")
    if len(L) >0:
        print(" ",end="")
        print(" ".join(map(str, L)))
    else:
        print("")

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

const bool DEBUG = true;

const int MAX_N = 1005;
const int MAX_V = MAX_N * (MAX_N - 1) / 2;
vector<int> to[MAX_V];
int id[MAX_N][MAX_N];

int to_match_id(int i, int j) {
  if (i > j) swap(i, j);
  return id[i][j];
}

bool visited[MAX_V];
bool calculated[MAX_V];
int dp[MAX_V];  // vからスタートしたときの最長経路を保存しておくテーブル
int dfs(int v) {
  if (visited[v]) {
    if (!calculated[v]) return -1;
    return dp[v];
  }
  visited[v] = true;
  dp[v] = 1;
  // メモ化再帰
  for (auto &&u : to[v]) {
    int res = dfs(u);
    if (res == -1) return -1;
    dp[v] = max(dp[v], res + 1);
  }

  calculated[v] = true;
  return dp[v];
}

int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  vector<vector<int>> a(n, vector<int>(n - 1));
  for (size_t i = 0; i < n; i++) {
    for (size_t j = 0; j < n - 1; j++) {
      cin >> a[i][j];
      a[i][j]--;
    }
  }
  int V = 0;
  for (size_t i = 0; i < n; i++)
    for (size_t j = 0; j < n; j++) {
      if (i < j) id[i][j] = V++;
    }

  for (size_t i = 0; i < n; i++) {
    // a[i][j] にmatch_idが入るようにする
    for (size_t j = 0; j < n - 1; j++) a[i][j] = to_match_id(i, a[i][j]);
    // 次の試合から前の試合へエッジを張る
    for (size_t j = 0; j < n - 2; j++) to[a[i][j + 1]].push_back(a[i][j]);
  }

  // DFSを行う
  int day = 0;
  for (size_t i = 0; i < V; i++) {
    int res = dfs(i);
    if (res == -1) {
      cout << "-1" << endl;
      return 0;
    }
    day = max(day, res);
  }

  cout << day << endl;
  return 0;
}


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

typedef long long int ll;

int main(){
	vector <ll> v;
	
	ll n,k;
	scanf("%lld %lld",&n,&k);
	
	for(ll i = 0; i < n; i++){
		ll temp;
		scanf("%lld",&temp);
		v.push_back(temp);
	}
	
	sort(v.begin(),v.end());
	
	ll ans = 0;
	for(ll i = 0; i < k; i++){
		ans += v[i];
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 3788
s=input()

gu=0
pa=0
win=0

for t in s:
  if t=='g':
    if gu>pa:
      pa+=1
      win+=1
    else:
      gu+=1
  else:
    if gu>pa:
      pa+=1
    else:
      win-=1
      gu+=1
print(win)
      
    

Measured memory_bytes: 3316
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
using namespace std;
#include <vector>
#define rep(i,n) for (int i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

/*
#include <math.h>
int standerd = int(pow(10.0,9.0)) + 7;
*/
string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll N;
ll K;
ll MAX=110000;
ll sum=0;


ll getPowerN(ll value){
    ll ans = 1;
    ll cnt = N;
    while(cnt>0){
        if(cnt%2==1){
            ans = ans * value % MOD;
        }
        value = value * value % MOD;
        cnt = cnt/2;
    }
    return ans;
}

int main(){


    ll cnt[MAX]={};
    ll ans[MAX]={};
    cin >> N;
    cin >> K;

    ll baisu;
    for( ll index = K ; index >1 ; index-- ){
        baisu = K / index;
        ans[index] = getPowerN(baisu);
        for( int aft_index = 2 ; aft_index <=baisu ; aft_index++ ){
            ans[index]-=ans[index*aft_index];
        }
    }

    sum = getPowerN(K) % MOD;
    for( ll index = 2 ; index <= K ; index++ ){
        sum += (index - 1 ) * ans[index];
        sum %= MOD;
    }
    cout << sum << endl;
}

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

int main(){
  string s;
  cin >> s;
  int n;
  n = s.size()/2;
  int ans=0;
  for(int i=0;i<n;i++){
    if(s.at(i)!=s.at(s.size()-1-i))ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import math
n = sorted(list(map(int,input().split())))
if n[1] - n[0] >= 2:
    ans = 0
elif n[1] - n[0] == 0:
    ans = math.factorial(n[1]) **2 * 2
else:
    ans = n[1] * math.factorial(n[0])**2
print(ans % (10**9 + 7) )

Measured memory_bytes: 4748
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
#include<chrono>
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define PRINT(x) std::cout << x << std::endl
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
#define veccat(v1, v2) std::copy((v2).begin(),(v2).end(),std::back_inserter(v1)/*v1の後ろにv2を入れる*/)
#define intmax (std::numeric_limits<int64_t>::max() / 4)
using namespace std;
const double EPS = 1e-9;
const double PI = acos(-1.0);
const double MOD = 1e9+7;

using ll = long long;



int main(void){
  int t;
  cin >> t;
  ll a[t], b[t], c[t], d[t];
  rep(i, t) cin >> a[i] >> b[i] >> c[i] >> d[i];

  rep(j, t){
    int f=0;
    ll limit = 0L;
    ll store = a[j];
    ll diff = d[j] - b[j];
    if(diff < 0) {PRINT("No"); continue;}
    if(a[j] - b[j] < 0) {PRINT("No"); continue;}
    if(c[j] >= b[j]) {PRINT("Yes"); continue;}
    ll g = __gcd(b[j],d[j]);
    ll m = b[j] - g + (a[j] % g);
    if (m > c[j]){
      cout << "No" << endl;
    } else {
      cout << "Yes" << endl;
    }    
    /*
    rep(i, 50000){   
      //if(store / b[j] <= 0) {PRINT("No"); f=1; break;}
      store = store % b[j];
      //if(store < 0) {PRINT("No"); f=1; break;}
      if(store <= c[j]) store = store + d[j]; 
      //在庫がb未満
      if(store < b[j]) {PRINT("No"); f=1; break;}         
    }
    if(!f) PRINT("Yes");
    */
  }


  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define _rep(i,m,n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

/*int H,W;
vector<vector<int>> field;

void dfs(int h, int w){
   field[h][w] = 0;
   
   for(int dh = -1; dh <= 1; dh++){
      for(int dw = -1; dw <= 1; dw++){
         int nh = h + dh;
         int nw = w + dw;
      
         if(nh < 0 || nh >= H || nw < 0 || nw >= W)continue;
         if(field[nh][nw] == 0)continue;

         dfs(nh, nw);
      }
   }
}*/

int main(){
   int n; cin >> n;
   vector<int> s(n);
   int sum = 0;
   rep(i,n){
      cin >> s[i];
      sum += s[i];
   }
   sort(s.begin(), s.end());
   if(sum % 10 != 0){
      cout << sum << endl;
      return 0;
   }else{
      int i = 0;
      while(true){
         if(i == n - 1)break;
         sum -= s[i];
         if(sum % 10 != 0){
            cout << sum << endl;
            return 0;
         }else{
            sum += s[i];
            i++;
         }
      }
   }
   cout << 0 << endl;
   return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define rrep(i,n) for(int (i)=1;i<=(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define MOD 1000000007
#define INF 1e18
#define fcout cout << fixed << setprecision(15)
#define int long long
#define endl "\n"
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};

class UnionFind {
public:
	vector <ll> par; // 各元の親を表す配列
	vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

	// Constructor
	UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool unite(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;
		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}

	bool same(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}

	ll getsize(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}
};

signed main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	
	int n, m;
	cin >> n >> m;
	UnionFind ut(n + m);
	rep(i, n) {
		int k;
		cin >> k;
		rep(j, k) {
			int l;
			cin >> l;
			ut.unite(--l, m + i);
		}
	}
	int rt = ut.root(m);
	rep(i, n) {
		if(rt != ut.root(m + i)) {
			puts("NO");
			return 0;
		}
	}
	puts("YES");
	return 0;
}

Measured memory_bytes: 3328
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

void read();
template<typename First, typename... Rest> void read(First& first, Rest&... rest);
void write();
template<typename First, typename... Rest> void write(First first, Rest... rest);
template<typename T> void write_vec(vector<T>& v, char divider);

int main(){
    int N, K;
    read(N, K);
    vector<int> A(N);
    for(int i = 0; i < N; i++){
        read(A[i]);
    }
    N -= K;
    int ans = 1;
    if(N > 0) {
        ans += N / (K - 1);
        if(N % (K - 1)) ans++;
    }
    write(ans);
    return 0;
}

//配列以外の入力を受け取る
void read(){

}
template<typename First, typename... Rest>
void read(First& first, Rest&... rest){
    cin >> first;
    read(rest...);
}
//
//配列以外を出力する
void write(){

}
template<typename First, typename... Rest>
void write(First first, Rest... rest){
    cout << first << " ";
    write(rest...);
}
//
//配列を区切って出力する
template<typename T>
void write_vec(vector<T>& v, char divider){
    for(size_t i = 0; i < v.size(); i++){
        cout << v[i] << divider;
    }
}
//

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

int main() {
  int N = 0;
  cin >> N;

  vector<uint64_t> L(N+1);
  
  L.at(0) = 2;
  L.at(1) = 1;

  for (int i = 2; i < L.size(); i++) {
    L.at(i) = L.at(i-1) + L.at(i-2);
  }
  
  cout << L.at(L.size()-1) << endl;
}


Measured memory_bytes: 3600
v[20];char t[9],s[9],c;main(a,L,i,j,k){for(;scanf("%d%d",&a,&L),L;)for(v[0]=a,k=1;;v[k++]=a){for(sprintf(t,"%0*d",L,a),s[L]=i=0;i<L;s[i]=t[L-i-1],i++)for(j=1;j<L-i;j++)if(t[j]<t[j-1])c=t[j],t[j]=t[j-1],t[j-1]=c;for(a=atoi(s)-atoi(t),i=0;i<k;i++)if(v[i]==a)break;if(i<k){printf("%d %d %d\n",i,a,k-i);break;}}exit(0);}

Measured memory_bytes: 624
#include <bits/stdc++.h> 
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
#define vbi vector<bool> 
#define mod 1000000007
#define INF 1000000000
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define sd second
#define ft first
#define ms(x,v) memset(x,v,sizeof x)
#define endl '\n'
#define cnl cout<<endl;
#define frr(i,b) for(ll i=0; i<b;i++)
#define fb(i,b) for(ll i=b-1; i>=0; i--)
#define pi  3.141592653589793238
ll i,j,k;
long long dp[100+5][100000+6];
void solve(){
       ll n; cin>>n; 
       ll w; cin>>w;
       ll z=0;
        vector<long long > we(105),val(105);
        ll sum=0;
        for(i=0;i<n;i++) {
            cin>>we[i];
            cin>>val[i];
            sum=sum+val[i];
        }
        //cout<<sum<<endl;
        for(j=1;j<=sum;j++) dp[0][j]=1000000000;
            ll ans=0;
       for(i=1;i<=n;i++){
        for(j=1;j<=sum;j++){
          dp[i][j]=dp[i-1][j];
          if((j-val[i-1])>=0) dp[i][j]=min(dp[i][j],dp[i-1][j-val[i-1]]+we[i-1]);
          if(dp[i][j]<=w)  ans=max(ans,j);
        } 
       }
       cout<<ans;
      }
 signed main(){
    
    solve();
    return 0;
  }

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

int main() {
  
  int N;
  cin >> N;
  
  if ( N%1000 == 0 ) {
    cout << "Yes" << endl; 
  }
  
  else if ( N%1111 == 0 ) {
    cout << "Yes" << endl;
  }
  
  else if ( N%1000%111 == 0 ) {
    cout << "Yes" << endl;
  }
  
  else if ( N/10%111 == 0 ) {
    cout << "Yes" << endl; 
  }
  
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define deb(x) cout<<#x<<"="<<x<<endl;
#define endl '\n'
#define M 1000000007
#define int long long
#define max_n 1000000

using namespace std;

void solve()
{
	ll n,m;
	cin>>n>>m;
	cout<<n*(n-1)/2+m*(m-1)/2<<endl;
}

int32_t main() 
{
	IOS	
	ll T=1;
	// cin>>T;
	for(ll i=1;i<=T;++i)
	{		
		// cout<<"Case #"<<i<<": ";
    	solve();
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>
#include <iterator>
#include <functional>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s,t;
  cin>>s>>t;
  int ans=0;
  REP(i,3){
    if(s[i]==t[i])ans++;
  }
  cout<<ans<<endl;
}


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

int main(){
  int N , M ; cin >> N >> M ; 
  vector<int> A(N) , B(N) ; 
  
  for(int i = 0 ; i< N ; i++){
    cin >> A.at(i) >> B.at(i) ; 
  }
  vector<pair<int , int >> AB(N) ; 
  for(int i = 0 ; i < N ; i++){
    AB.at(i) = make_pair(A.at(i) , B.at(i)) ; 
  }
  sort(AB.begin() , AB.end()) ; 
  
  long long ans = 0 ; 
  for(int i = 0 ; i < N ; i++){
    long long num_buy = min(M , AB.at(i).second) ; 
    ans += num_buy * AB.at(i).first ;
    M -= num_buy ; 
  }
  
  cout << ans << endl ; 
}

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

int main() {
    int n;
    cin >> n;
    cout << n / 3 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int a,b;
  if(scanf("%d",&a)==1 && scanf("%d",&b)==1){}
  int sum = a + b;
  int sub = a - b;
  int qua = a * b;
  if(sum >= sub && sum >= qua){
    printf("%d",sum);
  }else if(sub >= qua){
    printf("%d",sub);
  }else{
    printf("%d",qua);
  }
  return 0;
}
     

Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

#define INF 1000000007 //1000000000000000003
#define MOD 1000000007

#define ll long long

//printf("%.10f", );
//cout << fixed << setprecision(10) << heikin << endl;

using namespace std;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct { int to; long long dist; };

vector<edge>tree[100010];
vector<P> connect[100005];
long long cost[100005];

int dist[100][100];

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

int main() {

	int N, M;
	cin >> N >> M;

	for (int i = 0; i<N; i++) {
		for (int j = 0; j<N; j++) {
			if (i == j) dist[i][j] = 0;
			else dist[i][j] = INF;
		}
	}
	vector<int>a(M);
	vector<int>b(M);
	vector<int>c(M);
	for (int i = 0; i < M; ++i) {
		cin >> a[i] >> b[i] >> c[i];
		--a[i]; --b[i];
		dist[a[i]][b[i]] = c[i];
		dist[b[i]][a[i]] = c[i];
	}

	for (int k = 0; k < N; ++k) {
		for (int i = 0; i < N;++i) {
			for (int j = 0; j < N;++j) {
				dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
			}
		}
	}

	int ans = 0;
	for (int i = 0; i < M;++i) {
		if (dist[a[i]][b[i]] < c[i])ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 4992
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 998244353
inline void add(int &x, int v) { x += v; if (x>=MOD)x-=MOD; }

int N;
string S;
int dp[4003][4003];
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> S;
  N = S.length();
  dp[0][0] = 1;

  int pre = 0;
  rep(i, 2*N) {
    if (i < N) pre += (int)(S[i]-'0');
    rep(j, 2*N+1) {
      rep(k, 2) {
        int state = j+k;
        if (state > 2*N) continue;
        if (i < N && !(pre-(i+1) <= state && state <= pre)) continue;
        add(dp[i+1][state], dp[i][j]);
      }
    }
  }
  cout << dp[2*N][pre] << "\n";
  return 0;
}


Measured memory_bytes: 61312
import itertools
import numpy as np
N, M = map(int, raw_input().split())
G = [map(int, raw_input().split()) for i in range(M)]
ans = 0
for x in itertools.permutations(range(1,N+1)):
    if x[0] != 1:
        continue
    ok = True
    for i in range(N-1):
        a, b = x[i:i+2]
        if (not [a, b] in G) and (not [b, a] in G):
            ok = False
            break
    if ok:
        ans += 1
print ans

Measured memory_bytes: 16008
n, m = gets.split.map(&:to_i)
points = gets.split.map(&:to_i)
difs = []
if m==1 or m<=n
    p 0
else
    points.sort.each_cons(2){|i, j| difs.push((i-j).abs)}
    p difs.sort.slice(0, m-n).inject(:+)
end

Measured memory_bytes: 11248
#ifdef _WIN32
#define DEBUG	1
#endif

#define _CRT_SECURE_NO_WARNINGS
#define MATH_PI 3.14159265358979323846264338327950288419716939
#include <iostream>
#include <string.h>
#include <fstream>
using namespace std;

#ifdef DEBUG
#include "include.h"
#else
inline void wait(){}
inline void dout(const char *arg, ...){}
#endif

template<typename T>inline void swap(T a, T b){T t = a; a = b; b = t;}

#define CLIP(ptr, min, max) {if((min)<=(max)){if(ptr<(min)){ptr=(min);}if(ptr>(max)){ptr=(max);}}}
#define max(a, b) a > b ? a : b;
#define min(a, b) a > b ? b : a;
#define Sin(deg) sin((deg)*MATH_PI/180)
#define Cos(deg) cos((deg)*MATH_PI/180)
#define Tan(deg) tan((deg)*MATH_PI/180)
#define Rad(deg) ((deg)*MATH_PI/180)
#define ff(param, num) for(int param=0 ; param<num ; ++param)
#define fi(num) for(int i=0 ; i<num ; ++i)
#define fj(num) for(int j=0 ; j<num ; ++j)
#define fk(num) for(int k=0 ; k<num ; ++k)
#define fl(num) for(int l=0 ; l<num ; ++l)
#define ffr(param, num) for(int param=num-1 ; param>=0 ; --param)
#define fir(num) for(int i=num-1 ; i>=0 ; --i)
#define fjr(num) for(int j=num-1 ; j>=0 ; --j)
#define fkr(num) for(int k=num-1 ; k>=0 ; --k)
#define flr(num) for(int l=num-1 ; l>=0 ; --l)
#define gi(p) Scanf("%d", p)
#define gi2(p1, p2) Scanf2("%d %d", p1, p2)
#define gi3(p1, p2, p3) Scanf3("%d %d %d", p1, p2, p3)
#define gi4(p1, p2, p3, p4) Scanf4("%d %d %d %d", p1, p2, p3, p4)
#define gll(p) Scanf("%lld", p)
#define gll2(p1, p2) Scanf2("%lld %lld", p1, p2)
#define gll3(p1, p2, p3) Scanf3("%lld %lld %lld", p1, p2, p3)
#define gll4(p1, p2, p3, p4) Scanf4("%lld %lld %lld %lld", p1, p2, p3, p4)
#define gf(p) Scanf("%f", p)
#define gf2(p1, p2) Scanf2("%f %f", p1, p2)
#define gf3(p1, p2, p3) Scanf3("%f %f %f", p1, p2, p3)
#define gf4(p1, p2, p3, p4) Scanf4("%f %f %f %f", p1, p2, p3, p4)
#ifdef DEBUG
#define gc(buf) fscanf(local_in.fp, "%s", buf)
#define Scanf(expr, p) fscanf(local_in.fp, expr, &p)
#define Scanf2(expr, p1, p2) fscanf(local_in.fp, expr, &p1, &p2)
#define Scanf3(expr, p1, p2, p3) fscanf(local_in.fp, expr, &p1, &p2, &p3)
#define Scanf4(expr, p1, p2, p3, p4) fscanf(local_in.fp, expr, &p1, &p2, &p3, &p4)
#else
#define gc(buf) Scanf("%s", buf)
#define Scanf(expr, p) scanf(expr, &p)
#define Scanf2(expr, p1, p2) scanf(expr, &p1, &p2)
#define Scanf3(expr, p1, p2, p3) scanf(expr, &p1, &p2, &p3)
#define Scanf4(expr, p1, p2, p3, p4) scanf(expr, &p1, &p2, &p3, &p4)
#endif
#define ans(p) cout << p << endl;
signed main() {

	int ii, jj, kk, ll;
	int N;
	int ret = 0;
	int flag = 0;
	char cbuf[8192];

	gc(cbuf);
	int count = 0, count_max = 0;

	int length = strlen(cbuf);
	fi(length){
		if(cbuf[i] == 'A' || cbuf[i] == 'T' || cbuf[i] == 'G' || cbuf[i] == 'C'){
			count++;
		}else{
			count_max = max(count, count_max);
			count = 0;
		}
	}
	count_max = max(count, count_max);

	ans(count_max);

	wait();

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<queue>
#include<cmath>
#include<map>
#include<vector>
#include<iomanip>
using namespace std;
typedef long long ll;
ll inf = 100000000;
ll v[205];
ll x[20000005];
ll a[10000005];
ll dp[20005][10005];
int dx[4] = { 1,-1,0,0 };
int dy[4] = { 0,0,1,-1 };
typedef pair<ll, ll> P;
double q[200005];
ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}
string s[2000005];
P p[2000005];
int main() {
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		for (int j = 0; j < s.size() - i; j++) {
			string a = s;
			a.erase(i, j);

			if (a == "keyence") {
				cout << "YES" << endl;
				return 0;
			}
		}
	}
	cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 16640
<?php /*atcoder.php*/

$at = new Atcoder();
$at->main();
unset($at);

class Atcoder{
	private function arrayIn(){
		$buf = explode(" ", fgets(STDIN));
		return $this->killNewLine($buf);
	}
	private function killNewLine($buf = null){
		$buf = str_replace("\r\n", "", $buf);
		$buf = str_replace("\n", "", $buf);
		$buf = str_replace("\r", "", $buf);
		return $buf;
	}
	
	private function surveying($x1 = 0, $y1 = 0, $x2 = 0, $y2 = 0){
		$buf_x = ($x1 - $x2);
		$buf_y = ($y1 - $y2);
		$buf_ans = ($buf_x * $buf_x) + ($buf_y * $buf_y);
		return sqrt($buf_ans);
	}
	
	private function slope($x1 = 0, $y1 = 0, $x2 = 0, $y2 = 0){
		$buf_x = ($x1 - $x2);
		$buf_y = ($y1 - $y2);
		if(0 == $buf_x){
			$buf_ans = 0;
		}else{
			$buf_ans = $buf_y / $buf_x;
		}
		return $buf_ans;
	}
	
	public function main(){
		$s = $this->arrayIn();
		$ans = "";

		$x3 = 0;
		$y3 = 0;
		$x4 = 0;
		$y4 = 0;
		
		$bufx = ($s[0] - $s[2]) * -1 ;
		$bufy = ($s[1] - $s[3]) * -1 ;

		$x3 = $s[2] - $bufy;
		$y3 = $s[3] + $bufx;

		$x4 = $x3 - $bufx;
		$y4 = $y3 - $bufy;

		$ans = $x3 . " " . $y3 . " " . $x4 . " " . $y4;

		echo $ans . "\n";

	}
}
?>

Measured memory_bytes: 4728
from collections import deque

h, w = [int(i) for i in input().split()]
a = [list(input()) for _ in range(h)]

b = [[-1 for _ in range(w)] for _ in range(h)]

q = deque()

for i in range(h):
    for j in range(w):
        if(a[i][j] == "#"):
            b[i][j] = 0
            q.append(i)
            q.append(j)
kotae = 0
while(len(q)):
    x = int(q.popleft())
    y = int(q.popleft())
    dx = [0, 0, -1, 1]
    dy = [-1, 1, 0, 0]

    for i in range(4):
        if(0 <= x + dx[i] and x + dx[i] < h and 0 <= y + dy[i] and y + dy[i] < w):
            if(b[x+dx[i]][y+dy[i]] == -1):
                q.append(x + dx[i])
                q.append(y + dy[i])
                b[x+dx[i]][y+dy[i]] = b[x][y] + 1
                kotae = max(kotae, b[x+dx[i]][y+dy[i]])
print(kotae)






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

int main() {
  string s,t;
  cin>>s>>t;
  int al,i,yj=0,count=0,c;
  for(al='a';al<='z';al++){
    for(i=0;s[i]!='\0';i++){
      if(al==s[i]&&count==0){count++;c=t[i];}
      else if(al==s[i]&&count==1&&c!=t[i])yj=810;
      }
    count=0;
  }
  for(al='a';al<='z';al++){
    for(i=0;t[i]!='\0';i++){
      if(al==t[i]&&count==0){count++;c=s[i];}
      else if(al==t[i]&&count==1&&c!=s[i])yj=810;
      }
    count=0;
  }
  
  yj!=810?cout<<"Yes":cout<<"No";
  return 0;
}

Measured memory_bytes: 776
#include<stdio.h>

int main(void){
    int a;
    int b;
    int c;
    int y=0;
    scanf("%d %d %d",&a,&b,&c);
    for(int i=a;i<=b;i++){
        if(c%i==0){
            y++;
        }
    }
    printf("%d\n",y);
    return 0;
}


Measured memory_bytes: 2100
n=int(input())
X = list(map(int,input().split()))
h = True
count = 0
while h:
  for i in range(n):
    if X[i] %2 == 0 :
      X[i] = X[i]/2
    else:
      h = False
      break
  count+=1
  
print(count-1)


Measured memory_bytes: 2940
import javax.print.DocFlavor;
import java.awt.*;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;
import java.util.List;

public class Main {

    static String br = System.getProperty("line.separator");
    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int N = nextInt();
        Map<String, Integer> map = new TreeMap<>();

        int max = 0;
        for(int i=0; i<N; i++){
            String S = next();
            if(map.containsKey(S)){
                map.put(S, map.get(S)+1);
            }else{
                map.put(S, 1);
            }
            max = Math.max(max, map.get(S));
        }

        for(String key : map.keySet()){
            if(map.get(key) == max){
                println(key);
            }
        }
    }

    static int nextInt() {
        return Integer.parseInt(next());
    }

    static Long nextLong() {
        return Long.parseLong(next());
    }

    static String next() {
        return sc.next();
    }

    static String nextLine(){
        return sc.nextLine();
    }

    static void println(Object o) {
        out.println(o);
        out.flush();
    }

    static void print(Object o) {
        PrintWriter out = new PrintWriter(System.out);
        out.print(o);
        out.flush();
    }
}


Measured memory_bytes: 77968
import math

N, D = map(int, input().split())
X = [list(map(int, input().split())) for i in range(N)]

ans = 0
tmp = 0
s = 1.5
for i in range(N):
    for k in range(N):
        if i == k:
            continue
        else:
            for j in range(D):
                tmp += (X[i][j] - X[k][j]) ** 2
                s = math.sqrt(tmp)
        if s % 1 == 0:
            ans += 1
        s = 0
        tmp = 0
print(ans//2)


Measured memory_bytes: 3064
//       BAAP IZ HERE           //
#include<bits/stdc++.h>
using namespace std;
#define gcd __gcd
#define lli long long int
#define jmd ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)

int main()
{
    jmd; lli a[5]; lli pos=0;
    for(int i=0;i<5;i++)
    {
        cin>>a[i];
        if(a[i]==0)
            pos = i+1;
    }
    cout<<pos;
}

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

using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	vector<bool> broken(n + 1, false);
	for (int i = 0; i < m; i++) {
		int index;
		cin >> index;
		broken[index] = true;
	}
	vector<long long int> dp(n + 1, 0);
	dp[0] = 1;
	for (int i = 1; i < n + 1; i++) {
		if (broken[i]) {
			continue;
		}
		dp[i] = dp[i - 1];
		if (i > 1) {
			dp[i] = (dp[i] + dp[i - 2]) % 1000000007;
		}
	}
	cout << dp[n] << endl;
}

Measured memory_bytes: 1024