akhauriyash/Code-Regression huggingface dataset:
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	if n == 1 {
		fmt.Println("Hello World")
	} else {
		fmt.Println(nextInt() + nextInt())
	}
}


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

int main(){
	string ss;
	int num=0;
	while(cin>>ss){
		int cnt=0;
		for(int i=0,j=ss.size()-1;i<ss.size()/2;i++,j--){
			if(ss[i]==ss[j])cnt++;
		}
		if(cnt==ss.size()/2)num++;
	}
	cout<<num<<endl;
	return 0;
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
typedef long long i64;
using std::cout;
using std::endl;
using std::cin;

int main() {
	int n; cin >> n; int ox, oy, oh;
	std::vector<int> x(n), y(n), h(n);
	for(int i = 0; i < n; i++) {
		cin >> x[i] >> y[i] >> h[i];
		
		if(h[i]) {
			ox = x[i];
			oy = y[i];
			oh = h[i];
		}
	}
	
	for(int i = 0; i < 101; i++) {
		for(int j = 0; j < 101; j++) {
			int H = std::abs(i - ox) + std::abs(j - oy) + oh;
			
			bool f = true;
			for(int k = 0; k < n; k++) {
				f &= h[k] == std::max(0, H - std::abs(i - x[k]) - std::abs(j - y[k]));
			}
			
			if(f) {
				cout << i << " " << j << " " << H << endl;
				return 0;
			}
		}
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
 
using namespace std;
 
int main(){
  int a, b, c;
  cin>> a >> b >> c;
  
  if (a==b){
    if (c!=a){
      cout<<"Yes";
    }
    else{
      cout <<"No";
    }
  }
    else if(b==c){
      if(a!=b){
        cout<<"Yes";
      }
      else{
        cout<<"No";
      }
    }
      else if(c==a){
        if(b!=a){
          cout<<"Yes";
        }
        else{
          cout<<"No";
        }
      }
        else{
          cout<<"No";
        }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rp(i,n) for (int i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define all_acc(x) (x).begin(), (x).end(), 0LL
#define int long long
#define absSort(v) sort(a.begin(), a.end(), [](int i, int j) -> bool { return abs(i) < abs(j); });
using namespace std;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
using ll = long long;
double pi=3.14159265359;

//出力するよ
void output_tate(vector<int> s){
    int n = s.size();
    for (int i = 0; i < n; i++){
        //if (i != 0)
        //    cout << " ";
        cout << s[i]<<endl;
    }
    //cout << endl;
}

void output_yoko(vector<int> s){
    int n = s.size();
    for (int i = 0; i < n; i++){
        if (i != 0)
            cout << " ";
        cout << s[i];//<<endl;
    }
    cout << endl;
}

int MOD = pow(10, 9) + 7;

int kaijou(int n){
    if(n==0) return 1;
    else{
        return ((n%MOD)*(kaijou(n-1)%MOD))%MOD;
    }
}

bool ispow(int n){
    int rn=sqrt(n);
    if(rn*rn==n) return true;
    else return false;
}

map<int,int> soinsu;

void soinsuu(int n){
    vector<pair<int,int>> ret;
    for(int i=2;i*i<=n;i++){
        if(n%i !=0) continue;
        int ex=0;
        while(n%i ==0){
            ex++;
            n /= i; //n変更することで、それ以降の約数で割り切れることはない
        }
        ret.push_back(make_pair(i,ex));
    }
    //nが素数だった場合
    if(n!=1) ret.push_back(make_pair(n,1));

    for(auto p:ret){
        int i=p.first;
        int num=p.second;
        soinsu[i]+=num;
    }
}


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

    int ans=1;

    for(int i=1;i<=n;i++){
        soinsuu(i);
    }

    //cout<<soinsu.size()<<endl;

    for(auto p:soinsu){
        int i=p.first,num=p.second;
        //cout<<i<<" "<<num<<endl;
        ans=(ans*(num+1)%MOD)%MOD;
    }

    cout<<ans<<endl;
}


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

using namespace std;

struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}init;

typedef long long LL;

template<typename T>void chmin(T &a,T b){a=min(a,b);}
template<typename T>void chmax(T &a,T b){a=max(a,b);}
template<typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}

int main(){
    int N;cin>>N;
    int A,B;cin>>A>>B;
    int a=0,b=0;
    string s;cin>>s;
    for(int i=0;i<N;i++){
        if(s[i]=='a'){
            if(a+b<A+B){
                a++;
                cout<<"Yes"<<endl;
            }
            else cout<<"No"<<endl;
        }
        else if(s[i]=='b'){
            if(a+b<A+B&&b<B){
                b++;
                cout<<"Yes"<<endl;
            }
            else cout<<"No"<<endl;

        }
        else cout<<"No"<<endl;

    }
        
    return 0;
}


Measured memory_bytes: 976
#include<iostream>
#include<cstring>
#include<string>
#include<set>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
	map<string,int> m;
int main()
{
	int N;
	cin>>N;
	map<string,int>::iterator it;
//	memset(num,0,sizeof(num));
	for(int i=0;i<N;i++)
	{
	    string s;
     	cin>>s;
	    it=m.find(s);
		if(it!=m.end()) it->second++;
		else
		m.insert(pair<string,int>(s,1));
	}
	int tmax=-1;
	for(it=m.begin();it!=m.end();it++)
	{
		if(it->second>tmax) tmax=it->second;
	}
	for(it=m.begin();it!=m.end();it++)
	{
		if(it->second==tmax) cout<<it->first<<endl;
	}
	
}

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

typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<LD, LD> PDD;

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define dbl(k, x) fixed << setprecision(k) << (x)

template <typename _T>
inline void _DBG(const char *s, _T x) {
  cerr << s << " = " << x << "\n";
}
template <typename _T, typename... args>
void _DBG(const char *s, _T x, args... a) {
  while (*s != ',') cerr << *s++;
  cerr << " = " << x << ',';
  _DBG(s + 1, a...);
}

#define _upgrade                \
  ios_base::sync_with_stdio(0); \
  cin.tie(0);                   \
  cout.tie(0);
#define DBG(...) _DBG(#__VA_ARGS__, __VA_ARGS__)

// ********************** CODE ********************** //

const LL mod = 1e9 + 7;

int main() {
  _upgrade;
  LL n, k;
  cin >> n >> k;

  vector<LL> prefix_sum(n + 2);
  for (LL i = 1; i < n + 2; i++) {
    prefix_sum[i] = prefix_sum[i - 1] + i - 1;
  }

  LL res = 0;
  for (int i = k; i < n + 2; i++) {
    LL maxx = prefix_sum[n + 1] - prefix_sum[n + 1 - i];
    LL minn = prefix_sum[i];

    res += (maxx - minn + 1);
    res %= mod;
  }

  cout << res << "\n";
  return 0;
}

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

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  
  int P1 = A * N;
  int P2 = B;
  if (P1 > P2) {
    cout << P2 << endl;
  }
  else {
    cout << P1 << endl;
  }
}

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

void sorter ( int* data, int elements )
{
    int i, j, cmp, key;
    for ( i = 0; i < elements; i++ )
    {
        key = data[i];
        for ( j = i; j > 0; j-- )
        {
            cmp = data[j - 1];
            if ( key < cmp )
            {
                break;
            }
            else
            {
                data[j] = cmp;
            }
        }
        data[j] = key;
    }
}

int main ( void )
{
    int input[5];
    if ( scanf( "%d %d %d %d %d", &input[0], &input[1], &input[2], &input[3], &input[4] ) != EOF )
    {
        sorter( input, 5 );
    }
    else
    {
        fputs( "Syntax Error", stderr );
        exit( EXIT_FAILURE );
    }

    printf( "%d %d %d %d %d\n", input[0], input[1], input[2], input[3], input[4] );

    return 0;
}

Measured memory_bytes: 596
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K,N;
		K = sc.nextInt();
		N = sc.nextInt();
		int a[] = new int[N];
		for (int i = 0;i<N;i++) {
			a[i] = sc.nextInt();
		}
		int sa=0;
		for (int i=1;i<N;i++) {
			if (a[i]-a[i-1]>sa) {
				sa= a[i]-a[i-1];
			}
		}
		if (a[N-1]-a[0]<K-sa) {
			System.out.println(a[N-1]-a[0]);
		} else {
			System.out.println(K-sa);
		}
	}
}

Measured memory_bytes: 85184
package main

import "fmt"

func main() {
  var S, T string
  fmt.Scan(&S, &T)
  
  for i := range S {
    if S[i:]+S[:i] == T {
      fmt.Println("Yes")
      break
    }
    if i == len(S)-1 {
      fmt.Println("No")
    }
  }
}

Measured memory_bytes: 512
input = gets.to_i
digit = input % 10

if (digit == 2 || digit == 4 || digit == 5 || digit == 7 || digit == 9)
  puts 'hon'
elsif (digit == 0 || digit == 1 || digit == 6 || digit == 8)
  puts 'pon'
else
  puts 'bon'
end


Measured memory_bytes: 14320
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():

    n,k=map(int,input().split())
    A=list(map(int,input().split()))

    from functools import reduce
    from fractions import gcd
    G=reduce(gcd,A)

    if k%G==0 and k<=max(A):
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')

resolve()


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

using namespace std;

int main()
{
    string ch;

    cin>>ch;

    if(ch[0]=='R'){
        if(ch[1]=='R'){
            if(ch[2]=='R'){
                cout<<"3"<<endl;
            }
            else{
                cout<<"2"<<endl;
            }
        }
        else{
            cout<<"1"<<endl;
        }
    }
    else if(ch[1]=='R'){
        if(ch[2]=='R'){
            cout<<"2"<<endl;
        }
        else{
            cout<<"1"<<endl;
        }
    }
    else if(ch[2]=='R'){
        cout<<"1"<<endl;
    }
    else{
        cout<<"0"<<endl;
    }

    return 0;
}


Measured memory_bytes: 3576
#define _DEBUG
//ヘッダー
#include<bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;

//型定義
typedef long long ll;

//定数
const ll INF=1e+18;
const int MOD=998244353;

//デバッグ
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug1(x1) cout<<#x1<<": "<<x1<<endl
#define debug2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug5,debug4,debug3,debug2,debug1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

//省略
using vi  = vector<int>;
using vii = vector<vector<int>>;
using vl  = vector<ll>;
using vll = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;


int main(){
    int K;
    cin>>K;
    REP(i,K){
        cout<<"ACL";
    }
    cout<<endl;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int a, b; cin >> a >> b;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (((a)%mod) * ((b)%mod)) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;++i)
#define drep(i,n,m) for(int i = n;i >= m;--i)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;
const int mod = 1e9+7;
// int sum = accumulate(a, a+n, 0LL);
// int mx = max_element(a, a+n);
// int mn = min_element(a, a+n);
// int cnt = count(a, a+n, k);

int N,D;

int X[20][20];

int flag=0;

signed main()
{

    cin >> N >> D;

    rep(i,N)
    {
        rep(j,D)cin >> X[i][j];
    }

    int ans=0;
        
    for(int i=0;i<N-1;i++)
    {
        for(int j=i+1;j<N;j++)
        {
            int cnt=0;
            for(int k=0;k<D;k++)
            {

                cnt+=pow(abs(X[i][k]-X[j][k]),2);

            }
            for(int l=0;l<=16000;l++)
            {
                if(cnt==l*l)
                {
                    ans++;
                    
                    break;
                }
            }
        }
        
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        HashMap<String,Integer> Blue = new HashMap<>();
        HashMap<String,Integer> Red = new HashMap<>();


        for(int i=0;i<N;i++){
            String cur = sc.next();
            if(Blue.containsKey(cur)){
                Blue.put(cur,Blue.get(cur)+1);
            }
            else Blue.put(cur,1);
        }
        int M = sc.nextInt();
        for(int i=0;i<M;i++){
            String cur = sc.next();
            if(Red.containsKey(cur)){
                Red.put(cur,Red.get(cur)+1);
            }
            else Red.put(cur,1);
        }
        int ans = 0;
        for(String w:Blue.keySet()){
            int pos = Blue.get(w);
            int neg = Red.getOrDefault(w,0);
            ans = Math.max(ans,pos-neg);
        }


        
        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define lp(i,a,n) for(int i=a;i<=n;++i)
#define lpd(i,a,n) for(int i=a;i>=n;--i)
#define mem(a,b) memset(a,b,sizeof a)
#define all(v) v.begin(),v.end()
#define println(a) cout <<(a) <<endl
#define sz(x) ((int)(x).size())
#define readi(x) scanf("%d",&x)
#define read2i(x,y) scanf("%d%d",&x,&y)
#define read3i(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define mod 1000000007
#define eps 1e-9
#define infi 1000000000
#define infll 1000000000000000000ll
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef set<int> si;
typedef map<int,int> mii;

const int N = 1502;
int n,a[N];

int main(){
    readi(n);
    lp(i,1,n) readi(a[i]);
    int sum = accumulate(a+1, a+1+n, 0);
    double av = 1.0 * sum / n;
    double mn = infll;
    lp(i,1,n) mn = min(mn, fabs(av - a[i]));
    lp(i,1,n) if(mn == fabs(av - a[i])) return cout <<i-1, 0;
    assert(false);
}

/*
uniform_int_distribution<type>(l, r)(rng)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
*/


Measured memory_bytes: 256
n = int(input())
xy=[[] for _ in range(n)]
for i in range(n):
    a=int(input())
    for j in range(a):
        xy[i].append(list(map(int,input().split())))
len_xy=len(xy)
ans=0
for i in range(2**n):
    num=str(bin(i))[2:]
    num=list(num.zfill(n))
    flag=True
    for j in range(n):
        if num[j]=='1':
            for x,y in xy[j]:
                if num[x-1]!=str(y):
                    flag=False
    if flag:
        ans=max(ans,num.count('1'))
print(ans)


Measured memory_bytes: 3064
n = int(input())
a_list = list(map(int, input().split()))
cnt = 0
even = True

while(even):
    for i in range(n):
        if a_list[i] % 2 != 0:
            even = False
            break
        else:
          a_list[i] /= 2
    cnt += 1

print(cnt - 1)


Measured memory_bytes: 2940
#pragma region header
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
#pragma endregion
int main() {
    int n;cin >> n;
    vvi a(2, vi(n));
    int sum = 0;
    rep(i, 2) {
        rep(j, n) {
            cin >> a[i][j];
            if(i==1) sum += a[i][j];
        }
    }
    int up = a[0][0];
    int down = sum;
    int ma = -1;
    rep(i, n) {
        chmax(ma,up+down);
        up+=a[0][i+1];down -= a[1][i];
    }
    cout << ma << endl;
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;

int main() {
    int h,w;
    cin>>h>>w;;
    char s[51][51];
    for(int i=0;i<w;i++){
        for(int j=0;j<h;j++){
            cin>>s[i][j];
        }
    }
    int c=1;
    for(int i=0;i<w;i++){
        for(int j=0;j<h;j++){
            if(s[i][j]=='#'&&
               s[i-1][j]=='.'&&
               s[i+1][j]=='.'&&
               s[i][j-1]=='.'&&
               s[i][j+1]=='.'
               )
                c*=0;
        }
    }
    if(c==0){
    cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <math.h>
using namespace std;

int main()
{
	int n, k;
	string s;
	cin >> n >> k >> s;
	s[k - 1] += 'a' - 'A';
	cout << s << endl;

	return 0;
}


Measured memory_bytes: 256
import math

A,B,H,M=map(float,input().split())

pi2 = 2 * math.pi
theta = abs((pi2 * ((H/12)+(M/(60*12)))) - (pi2 * (M/60)))
if(theta >= math.pi):
  theta = pi2 - theta
c = math.sqrt((A ** 2) + (B ** 2) - (2 * A * B * math.cos(theta)))
print(c)


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

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

typedef tree<
ll,
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
// ordered_set X;
// *X.find_by_order(i) = ith largest element (counting from zero)
// X.order_of_key(k) = number of items in X < k (strict lt)

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

    int N;
    cin >> N;
    
    ll K;
    cin >> K;

    if (N%2 == 0) {
        int k = N/2;
        if ((2*N - K) < 3*k) {
            cout << -1 << endl;
            return 0;
        }

        for (int i=0;i<k;i++) {
            cout << (K+i) << " " << (K + 3*k + i) << " " << (K + 2*N + 2*i) << endl;
        }

        for (int i=0;i<k-1;i++) {
            cout << (K+k+i) << " " << (K + 2*k + 1 + i) << " " << (K + 2*N + 2*i + 1) << endl;
        }

        cout << (K + 2*k - 1) << " " << (K + 2*k) << " " << (K + 3*N - 1) << endl;
    } else {
        int k = N/2;
        if ((2*N - K) < 3*k + 1) {
            cout << -1 << endl;
            return 0;
        }

        for (int i=0;i<=k;i++) {
            cout << (K+i) << " " << (K + 3*k + 1 + i) << " " << (K + 2*N + 2*i) << endl;
        }
        for (int i=1;i<=k;i++) {
            cout << (K+k+i) << " " << (K+2*k+i) << " " << (K + 2*N + 2*i - 1) << endl;
        }
    }

    return 0;
}

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

typedef struct{
 char E;
 int n;
} card;

void isStable(card in[],card out[],int n){
  int i,j,a,f,p,flag=0;
  for(i=0;i<n;i++){
    f=0;
    for(j=0;j<n;j++){
      if(in[i].n==out[j].n){
        f=1;
        p=0;
        if(in[i].E!=out[j].E){
          for(a=i-1;a>=0;a--)
            if(in[a].E==out[j].E && in[a].n==out[j].n)p=1;
          if(p==0)
            flag=1;
        }
      }
      if(f==1)break;
    }
    if(flag==1) {
      printf("Not stable\n");
      return;    
    }
  }
  printf("Stable\n");
  return;
}
  
int partition(card *A,int p,int r){
  int i,j;
  card x,a;
  x=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j].n<=x.n){
      i++;
      a=A[i];
      A[i]=A[j];
      A[j]=a;
    }
  }
  a=A[i+1];
  A[i+1]=A[r];
  A[r]=a;
  return i+1;
}
void quicksort(card *A,int p,int r){
  int q;
  if(p<r){
    q=partition(A,p,r);
    quicksort(A,p,q-1);
    quicksort(A,q+1,r);
  }
}
int main(){
  int i;
  card in[100000];
  card out[100000];
  int N;
  int a;
  char b;
  char d;
  

  scanf("%d",&N);
	
  scanf("%c",&d);
  for(i=0;i<N;i++){
    scanf("%c",&b);
    scanf("%d",&a);
    scanf("%c",&d);
    in[i].n=a;
    out[i].n=a;
    in[i].E=b;
    out[i].E=b;
  }
  quicksort(out,0,N-1);
  isStable(in,out,N);
  for(i=0;i<N;i++){
      printf("%c %d\n",out[i].E,out[i].n);
  }
  return 0;
}



Measured memory_bytes: 3368
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
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(){
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    if(n%2 == 1) {
        cout << 0 << endl;
        return 0;
    }
    ll ans = 0;
    ll k = 10;
    while(k<=n) {
        ans+=n/k;
        k*=5;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3652
word_list = list(input().lower())
alphabet_uniq = list(set(word_list))
alphabet_uniq.sort()

alphabet_uniq.append('END')
if len(alphabet_uniq) != 27:
    for i in range(0, len(alphabet_uniq)):
        if chr(i + 97) != alphabet_uniq[i]:
            print(chr(i + 97))
            break
else:
    print(None)


Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using PL = pair<ll, ll>;
// Welcome to my source code!

const int MAX_NQ = 200000;

int n, q;
vector<int> g[MAX_NQ];
P px[MAX_NQ];
ll ver[MAX_NQ];

void dfs(int v, int prev, ll add) {
    int idx = lower_bound(px, px + q, P(v, 0)) - px;
    for (int i = idx; i < q; i++) {
        if (px[i].first == v) add += px[i].second;
        else break;
    }
    ver[v] += add;
    for (auto u : g[v]) {
        if (u == prev) continue;
        dfs(u, v, add);
    }
    return;
}

int main() {
    cin >> n >> q;
    for (int i = 1, a, b; i <= n - 1; i++) {
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    for (int i = 0, p, x; i < q; i++) {
        cin >> p >> x;
        px[i] = P(p - 1, x);
    }
    sort(px, px + q);
    dfs(0, -1, 0LL);
    for (int i = 0; i < n; i++) {
        if (i > 0) cout << ' ';
        cout << ver[i];
    }
    cout << endl;
}

Measured memory_bytes: 25856
#include <iostream>
#include <algorithm>
#include <math.h>

using namespace std;
// 最大公約数を求める関数
long lcm(long x, long y)
{
    long r;

    if(x == 0 || y == 0)  // 引数チェック
    {
        fprintf(stderr, "引数エラーです。\n");
        return 0;
    }

    // ユーグリッドの互除法
    while((r = x % y) != 0) // yで割り切れるまでループ
    {
        x = y;
        y = r;
    }
  if(y<0){
    y = -y;
  }
    return y;
}

// 最大公約数を求める関数


int main()
{
    int n;
    cin >> n;
    long x;
    cin >> x;
    long a, c;
    cin >> a;
    c = a-x;
    if(c<0){
        c = (-1)*c;
    }
    for(int i = 1; i<n;i++){
        cin >> a;
        c = lcm(a-x,c);
      
    }
    cout << c;
    
    
    return 0;
}

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

int n,m,q;
vector<int> a, b, c, d;
int ans;

void dfs(vector<int> A){
    if(A.size() == n+1){
        int now=0;
        rep(i,q){
            if(A[b[i]] - A[a[i]] == c[i]) now += d[i];
        }
        ans = max(ans,now);
        return;
    }

    A.push_back(A.back());
    while(A.back() <= m){
        dfs(A);
        A.back()++;
    }
}

int main(){
    
    cin>>n>>m>>q;
    a = b = c = d =vector<int>(q);
    for(int i=0;i<q;i++){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    dfs(vector<int>(1,1));
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
//#include<boost/multiprecision/cpp_int.hpp>
//using boost::multiprecision::cpp_int;

#define int long long
#define cint cpp_int
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) (((a)+(b)-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/2
#define PI acos(-1.0)

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;
typedef priority_queue<int> PQi;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vout(Vs &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vvout(VVi &v){for(int i=0;i<(v).size();i++) vout(v[i]);}
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 mypow(int x, int n, int m){if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}
int digit(int k,int i){string s = to_string(k);return s[s.size()-i]-'0';}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());} //vectorの同じ要素消す
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
int leng(int n){string s=to_string(n); return s.size();} //intの桁数
int digitsum(int n){int ret=0; while(n>0){ret+=n%10;n/=10;}return ret;} //桁和
int lesscount(int x,Vi &a){return lower_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx未満の数の個数
int orlesscount(int x,Vi &a){return upper_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx以下の数の個数
int morecount(int x,Vi &a){return a.size()-orlesscount(x,a);} //vector aにおけるxより大きい数の個数
int ormorecount(int x,Vi &a){return a.size()-lesscount(x,a);} //vector aにおけるx以上の数の個数
int count(int x,Vi &a) {return upper_bound(ALL(a),x)-lower_bound(ALL(a),x);} //vector aにおけるxの個数
Vi accum(Vi &v){Vi ret((v).size()+1);REP(i,0,(v).size()) ret[i+1]=ret[i]+v[i];return ret;}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);
    int x;
    cin>>x;
    REP(i,0,100000){
        if(i*(i+1)/2 >= x) {cout<<i<<endl; return 0;}
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <bitset>
#include <cmath>
#include <stack>
#include <iomanip>
#include <map>
#include <math.h>
#include <string.h>
using namespace std;

vector <string> S;
int main()
{
    int N;
    int L;
    cin >> N >> L;
    S.resize(N);
    for(int i = 0; i < N; i++) cin >> S[i];
    for(int i = 0; i < N; i++)
    {
        for(int j = i + 1; j < N; j++)
        {
            if (S[i].compare(S[j]) > 0)
            {
                string tmp;
                tmp = S[i];
                S[i] = S[j];
                S[j] = tmp;
            }
        }
    }
    for(int i = 0; i < N; i++)
    {
        cout << S[i];
    }
    cout << endl;
}

Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    for (int i=0; i<s.length(); i++)
    {
        if (s[i]=='C')
        {
            for (int j=i+1; j<s.length(); j++)
            {
                if (s[j]=='F')
                {
                    cout<<"Yes";
                    return 0;
                }
            }
        }
    }
    cout<<"No";
    return 0;
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

#define MAX_N 20
i64 N;
i64 V[MAX_N];
i64 C[MAX_N];

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

    REP(i, N) cin >> V[i];
    REP(i, N) cin >> C[i];

    i64 s = 0;
    REP(i, N) {
        s += max(V[i] - C[i], (i64)0);
    }
    cout << s << endl;

    return 0;
}

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

int N;

int main(){
	cin >> N;

	int log = floor(log10((float)N));
	log = (log%2==0) ? log : log-1;
	int cand = min((int)pow(10, log+1)-1, N);

	//cerr << "log: " << log << endl;

	int count = 0;
	while(true){
		//cerr << "cand: " << cand << endl;
		if(cand != 0 && cand != 100 && cand != 10000 && cand != 1000000){
			//cerr << "passA" << endl;
			cand--;
			count++;
		}
		else if(log-2 >= 0){
			//cerr << "passB" << endl;
			count++;
			log -= 2;
			cand = (int)pow(10, log+1)-1;
		}
		else{
			//cerr << "passC" << endl;
			break;
		}
	}

	cout << count << endl;
}


Measured memory_bytes: 512
x,y,a,b,c = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))

p.sort()
q.sort()
r.sort()

ans = 0

cnt = 0

while x+y-cnt > 0:
    if x > 0:
        p1 = p[-1]
    else:
        p1 = 0
    if y > 0:
        p2 = q[-1]
    else:
        p2 = 0
    if cnt < c:
        p3 = r[-1]
    else:
        p3 = 0
    eat = max(p1,p2,p3)
    ans += eat
    if x > 0 and p[-1] == eat:
        x -= 1
        p.pop()
    elif y > 0 and q[-1] == eat:
        y -= 1
        q.pop()
    else:
        cnt += 1
        r.pop()
print(ans)


Measured memory_bytes: 23328
N=int(input())
s=[]
for i in range(N):
    s.append(input())
a=s.count('AC')
b=s.count('WA')
c=s.count('TLE')
d=s.count('RE')
print('AC x ' +str(a))
print('WA x ' +str(b))
print('TLE x ' +str(c))
print('RE x ' +str(d))

Measured memory_bytes: 16180
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
#ifdef LOCAL
#define debug(x) cerr << #x << ": " << x << endl
#else
#define debug(x)
#endif
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

int H, A;
signed main(){
	cin >> H >> A;
	cout << (H+A-1)/A << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int first     =     sc.nextInt();
		int second    =     sc.nextInt();
		int third     =     sc.nextInt();
		
		int bunsetu5 = 0;
		int bunsetu7 = 0;
		
		if ( first == 5 ) {
			bunsetu5++;
		} else if (first == 7 ) {
			bunsetu7++;
		}
		if ( second == 5 ) {
			bunsetu5++;
		} else if (second == 7 ) {
			bunsetu7++;
		}
		if ( third == 5 ) {
			bunsetu5++;
		} else if (third == 7 ) {
			bunsetu7++;
		}
		
		if ( bunsetu5 == 2 && bunsetu7 == 1 ) {
			System.out.println("YES");
		}
		else {
			System.out.println("NO");
		}
	}
}


Measured memory_bytes: 9680
while True:
    H, W = map(int, input().split())
    if H == 0 and W == 0:
        break
    for i in range(H):
        if i % 2:
            print('.#' * (W // 2), end='')
            if W % 2:
                print('.')
            else:
                print()
        else:
            print('#.' * (W // 2), end='')
            if W % 2:
                print('#')
            else:
                print()
    print()



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

int main() {
  int N;
  std::cin >> N;
  std::vector<int64_t> sum(N);
  int64_t ss = 0;
  for (int i = 0; i < N; ++i) {
    int temp;
    std::cin >> temp;
    ss = temp + ss;
    sum[i] = ss;
  }

  int64_t absmin = 1 << 31 - 1;
  auto last = sum[N - 1];
  for (int i = 0; i < N - 1; ++i) {
    int64_t l = sum[i];
    int64_t r = last - sum[i];
    auto abs = std::abs(l - r);
    if (abs < absmin) absmin = abs;
  }

  std::cout << absmin << std::endl;
}


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

bool triangle(int x, int y, int z){
    int maxl = max(x, max(y, z));
    if(x == y) return 0;
    if(x == z) return 0;
    if(z == y) return 0;
    if(maxl == x) return y + z > x;
    if(maxl == y) return x + z > y;
    if(maxl == z) return y + x > z;
    return -1;
}

int main(){
    
    int n,ans = 0;
    cin >> n;
    vector<int> l(n);
    for(int i = 0;i < n;i++) cin >> l[i];
    
    //3本選ぶ
    for(int i = 0;i < n - 2;i++){
        for(int j = i + 1;j < n - 1;j++){
            for(int k = j + 1;k < n;k++ ){
                //三角形を満たすかどうか調べる
                if(triangle(l[i], l[j], l[k])){ 
                    ans++;
                }
            }
        }
    }

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

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

int main(){
   int S, W;
   cin >> S >> W;
   if(S > W) cout << "safe" << endl;
   else cout << "unsafe" << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#define LL long long
using namespace std;

int main()
{
    LL n,ans=1;
    LL t;
    cin>>n;
    while(n--)
    {
        cin>>t;
        if(ans!=-1&&ans!=0)
        {
            if(ans*t<ans||ans*t>(LL)1000000000000000000)
                ans=-1;
            else if(t==0)
            {
                ans=0;
            }
            else {ans*=t;}
        }
        else if(t==0)
            ans=0;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

const int MOD = 1000000007;

int main(){
    int n; cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];

    sort(a.rbegin(), a.rend());
    int ans1 = a[0];

    int median1, median2;
    median1 = median2 = a[0]/2;
    if (a[0]% 2 == 1) median2 += 1;

    int min_diff = 1000000000;
    int ans2 = 0;
    for (int i = 1; i < n; i++){
        int diff = min(abs(median1-a[i]), abs(median2-a[i]));
        if (min_diff > diff){
            min_diff = diff;
            ans2 = a[i];
        }
    }

    cout << ans1 << " " << ans2 << endl;
}


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

using namespace std;

#define MAXN 100005
vector<int> h;
int memo[MAXN];
int K;
int cost(int curr) {
	if(memo[curr] != -1)
		return memo[curr];
	if(curr == h.size()-1)
		return 0;
	set<int> costs;
	for(int i = 1; i <= K; i++) {
		if(curr + i < h.size())
			costs.insert(cost(curr + i) + abs(h[curr] - h[curr+i]));
	}

	memo[curr] = *(costs.begin());
	return memo[curr];
}
int main() {
    int N;
	cin>>N>>K;
	int temp;
	for(int i = 0; i < N; i++) {
		cin>>temp;
		h.push_back(temp);
	}
	memset(memo,-1,sizeof memo);
	cout<<cost(0);
}

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

from collections import defaultdict
d = defaultdict(list)
B = []
for _ in range(m):
    a1, a2 = list(map(int, input().split()))
    B.append([a1, a2])
    d[a1].append(a2)
    d[a2].append(a1)
    
def dfs(a, conn):
    memo[a] = 1
    for c in conn:
        if memo[c] == 0:
            dfs(c, d[c])
            
cnt = 0
for b in B:
    a1, a2 = b
    memo = [0]*(n+1)
    conn = set(d[a1]) - set([a2])
    dfs(a1, conn)
    if memo.count(1) != n:
        cnt += 1
print(cnt)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
// types
typedef long long ll; 
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
// IO
#define fo(i, n) for (int i = 0; i < n; i++)
#define fo1(i, n) for (int i = 1; i <= n; i++)
#define sc(n) scanf("%d", &n) 
#define sca(a, n) fo(i, n) sc(a[i])
#define pd(a) printf("%d ", a)
#define pld(a) printf("%d\n", a)
#define pda(a, n) fo(i, n) pd(a[i])
#define pl printf("\n")
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b) 
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
// math
const ll mod = 1e9+7;
template<typename T> T gcf(T a, T b) {return (b == 0) ? a : gcf(b, a%b);} 
template<typename T> T lcm(T a, T b) {return (a*b)/gcf(a, b);}
template<typename T> T sumTo(T x) {return x * (x+1) / 2;}
template<typename T> T sumSquaresTo(T x) {return x * (x+1) * (2*x+1) / 6;}
template<typename T> T ceilDiv(T n, T d) {return (n+d-1)/d;}

void solve() {
    int n; sc(n);
    n %= 10;
    if (n == 3) cout << "bon";
    else if (n == 0 || n == 1 || n == 6 || n == 8) cout << "pon";
    else cout << "hon";
}

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

Measured memory_bytes: 3752
#include <iostream>
#include <functional>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>

namespace TokorotenLab
{
    /*
    Arguments:
        Search range: [begin, end)
        Target function: f(x)
    Requirement:
        f(x) => { false, ..., false, true, ..., true }
    Judge:
        true_bound == begin => All f(x) are true
        true_bound == end => All f(x) are false
    */
    std::pair<long long, long long> binary_search(long long begin, long long end, std::function<bool(long long)> f)
    {
        long long false_bound = begin - 1LL; // ( ..., false_bound] => false
        long long true_bound = end; // [true_bound, ... ) => true
        long long x;

        while(true_bound - false_bound > 1LL)
        {
            x = false_bound + (true_bound - false_bound) / 2LL;
            if(f(x))
            {
                true_bound = x;
            }
            else
            {
                false_bound = x;
            }
        }

        return std::make_pair(false_bound, true_bound);
    }
}

using namespace std;

#define int long long

signed main()
{
    int r, d, x;

    cin >> r >> d >> x;

    for(int i = 0; i < 10; ++i) {
        x = r * x - d;
        cout << x << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
int main() {
  int N;
  cin >> N;
  vector<int> ans(N);
  vector<int> A(N-1);
  rep(i,N-1){
    cin >> A.at(i);
    ans.at(A.at(i)-1) ++; 
  }
  rep(i,N){
    cout << ans.at(i) << endl;
  }
  return 0;
}


Measured memory_bytes: 4768
#include <iostream>
using namespace std;
int N, M, Q, p, r, a, prv[200007], nxt[200007];
int main() {
	cin >> N >> M >> Q;
	for (int i = 0; i < N; i++) prv[i] = (i + N - 1) % N, nxt[i] = (i + 1) % N;
	for (int i = 0; i < M; i++) {
		cin >> a;
		for (int j = 0; j < a; j++) p = a % 2 ? prv[p] : nxt[p];
		nxt[prv[p]] = nxt[p], prv[nxt[p]] = prv[p];
		r = nxt[p], prv[p] = nxt[p] = -1, p = r;
	}
	for (int i = 0; i < Q; i++) cin >> a, cout << (prv[a] != -1 ? 1 : 0) << endl;
	return 0;
}

Measured memory_bytes: 4644
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
    // cout << fixed << setprecision(10) << flush;

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

    vector<int> dis_from_one(n, -1);
    dis_from_one[0] = 0;
    int d = 1;
    int i = a[0];
    while(dis_from_one[i] == -1){
        dis_from_one[i] = d;
        if(k == d){
            cout << i+1 << endl;
            return 0;
        }
        d++;
        i = a[i];
    }


    int rem = (k-dis_from_one[i]) % (d - dis_from_one[i]);
    for(int ii=0; ii<rem; ii++){
        i = a[i];
    }
    cout << i+1 << endl;

    return 0;
}

Measured memory_bytes: 6372
#include<iostream>
#include<stdio.h>

using namespace std;
int main(){
    double a, b;
    cin >>a >>b;
    int d = a/b;
    int r = (int)a%(int)b;
    double f = a/b;
    printf("%d %d %f", d, r, f);
    return 0;
}


Measured memory_bytes: 3192
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
#include <bitset>

////多倍長整数, cpp_intで宣言
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;

//#pragma gcc target ("avx2")
//#pragma gcc optimization ("Ofast")
//#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printLdb(a) printf("%.50Lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2LL) //等差数列の和、初項,末項,項数
#define pb push_back
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0L)*2.0L*PI)
#define rad_to_deg(rad) (((rad)/2.0L/PI)*360.0L)
#define Please return
#define AC 0
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */
#define inf numeric_limits<double>::infinity();
#define linf numeric_limits<long double>::infinity()

using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1e9 + 7;
constexpr long double eps = 1e-6;
const long double PI = acosl(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1 && c != ' ') {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	rep(i, 5) {
		int a;
		scanf("%d", &a);
		if (not a) printf("%d\n", i + 1);
	}

	Please AC;
}

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

int LCSLength(char*,char*);

int main(){
  int n,i;
  char X[1000],Y[1000];

  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf("%s",X);
    scanf("%s",Y);
    printf("%d\n",LCSLength(X,Y));
  }

  return 0;
}

int LCSLength(char *X,char *Y){
  int i,j,c[1001][1001];
  int m,n;

  m = strlen(X);
  n = strlen(Y);
  
  for(i=1;i<=m;i++){
    c[i][0] = 0;
  }
  for(j=0;j<=n;j++){
    c[0][j] = 0;
  }
  
  for(i=1;i<=m;i++){
    for(j=1;j<=n;j++){
      if(X[i-1]==Y[j-1]) c[i][j]=c[i-1][j-1]+1;
      else if(c[i-1][j]>=c[i][j-1]) c[i][j] = c[i-1][j];
      else c[i][j] = c[i][j-1];
    }
  }

  return c[m][n];
}

Measured memory_bytes: 4524