akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem C


# See:
# https://note.nkmk.me/python-gcd-lcm/
# https://docs.python.jp/3/library/functools.html
# https://docs.python.jp/3/library/fractions.html
def lcm_for_list(numbers):
    from functools import reduce
    return reduce(lcm, numbers, 1)


def lcm(x, y):
    from fractions import gcd  # for Ver.3.4 or lower.
    return (x * y) // gcd(x, y)


if __name__ == '__main__':
    n = int(input())
    t = [int(input()) for _ in range(n)]
    print(lcm_for_list(t))


Measured memory_bytes: 5120
#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>

#pragma region 定義
#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define f_cin(X) scanf("%f",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)

#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)
#define  ll_cout(X) printf("%lld\n",X)

typedef long long  ll;
#define rept(x, s, n) for (int x = s; x < n; x++)

#define Yes_RTN s_cout("Yes");return 0
#define No_RTN  s_cout("No");return 0
#define YES_RTN s_cout("YES");return 0
#define NO_RTN  s_cout("NO");return 0


int i_cins(int n, int* A);
int l_cins2(int n, long* A, long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);

int s_asorts(const void* a, const void* b);

//昇順
int s_asorts(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int s_asort(const void* a, const void* b) {
	return(*(int*)a - *(int*)b);
}
int l_cins2(int n, long* a, long* b) {
	int i;
	rept(i, 0, n) {
		l_cin2(*(a + i), *(b + i));
	}
	return 0;
}
int i_cins(int n, int* a) {
	int i;
	for (i = 0; i < n; i++) {
		i_cin(*(a + i));
	}

	return 0;
}
int _gcd(int a, int b) {
	int r, tmp;
	if (a < b) { tmp = a; a = b; b = tmp; }
	r = a % b;
	while (r) {
		if (!r) break;
		a = b; b = r;
		r = a % b;
	}
	return(b);
}

long _max(long a, long b) {
	return a > b ? a : b;
}
long _min(long a, long b) {
	return a < b ? a : b;
}
int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}

#pragma endregion



int main(void) {
	int W,a,b,tmp;

	i_cin3(W,a,b);

	if (b < a)  _swp(&a, &b); 
	tmp = b - W - a;
	i_cout(tmp<=0?0:tmp);
	
	return 0;
}



Measured memory_bytes: 128
#include<bits/stdc++.h>
#define speed_up ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long
#define ara(A,N) sort(A,A+N)
#define rev(A,N) sort(A,A+N,greater<long long>())
using namespace std;
ll f(ll a, ll b)
{
    string s;
    int n, num;
    num = max(a, b);
    s = to_string(num);
    n = s.size();
    return n;
}
int main()
{
    ll n;
    cin>>n;
    ll a, b, ans = 1 , d = INT_MAX, root;
    root = sqrt(n);
    for(ll i = root; i>=1; i--)
    {
        if(n%i == 0)
        {
            a = i;
            b = n/i;
            ans = f(a, b);
            d = min(d, ans);
        }
    }
    cout<<d;
    return 0;
}



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


int dp__[100];

//最大公約数
ll gcd(ll x, ll y){
  if(x % y == 0) return y;
  return gcd(y, x % y);
}
//最小公倍数
ll lcm(ll x, ll y){
  return x * y / gcd(x, y);
}
//フィボナッチ数列
//配列dpを-1で初期化する
int fib(int n){
  if(n == 0 || n == 1) return dp__[n] = 1;
  if(dp__[n] != -1) return dp__[n];
  return dp__[n] = fib(n - 1) + fib(n - 2);
}
//階乗計算(factorial)
int fact(int n){
  if(n = 1) return 1;
  return n * fact(n - 1);
}
//累乗計算(Exponentiation)
//x**y
ll expo(int x, int y){
  ll ans = 1;
  rep(i, y){
    ans *= x;
  }
  return ans;
}
//桁数
int keta(ll x){
  if(x == 0) return 1;
  int res = 0;
  while(x){
    x /= 10;
    res++;
  }
  return res;
}


int main(){
  string s;
  cin >> s ;

  rep(i, s.length()) cout << 'x';
}




Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split()))

ans = 0
for i in range(n - 2):
    for j in range(i, n - 1):
        if l[i] == l[j]:
            continue
        for k in range(j, n):
            if l[i] == l[k] or l[j] == l[k]:
                continue
            a, b, c = sorted([l[i], l[j], l[k]])
            if c - a < b:
                ans += 1
print(ans)

Measured memory_bytes: 74084
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[][] arrN = new int[n][2];
		for (int i = 0; i < n; i++) {
			arrN[i][0] = sc.nextInt();
			arrN[i][1] = sc.nextInt();
		}
		int[][] arrM = new int[m][2];
		for (int i = 0; i < m; i++) {
			arrM[i][0] = sc.nextInt();
			arrM[i][1] = sc.nextInt();
		}
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < n; i++) {
			int min = Integer.MAX_VALUE;
			int point = 0;
			for (int j = 0; j < m; j++) {
				int d = Math.abs(arrN[i][0] - arrM[j][0]) + Math.abs(arrN[i][1] - arrM[j][1]);
				if (min > d) {
					min = d;
					point = j + 1;
				}
			}
			sb.append(point).append("\n");
		}
		System.out.println(sb);
	}
}


Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
const int MOD=1e9+7;
const int INF=1e15;

signed main(){
    int N;cin>>N;
    map<string,int>memo;
    REP(i,N){
        string d;cin>>d;
        memo[d]++;
    }
    int ans=0;
    for(auto it=memo.begin();it!=memo.end();it++){
        ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 19260
#if defined(DAIJOBU)
#include "/home/ichigo/includes.hpp"
#include "PP.hpp"
#define deb(x...) cerr << "[" << #x << "] = " << x << "\n";
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long lint;
typedef vector<lint> vlint;
typedef vector<vlint> vvlint;
typedef pair<lint, lint> plint;
typedef double ld;

template<class T> bool chmin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool chmax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main() {
    ios::sync_with_stdio(false);
	cin.tie(0);
  	
	int a, b;
	cin >> a >> b;
	cout << max({a + b, a - b, a * b}) << '\n';
    return 0;
}



Measured memory_bytes: 256
n,a,b = map(int,input().split())
s = list(input())
count = 0
countb = 0
for i in range(n):
    if s[i] == "a":
        if count < a + b:
            print("Yes")
            count = count + 1
        else:
            print("No")
    elif s[i] == "b":
        if count < a + b and countb < b:
            print("Yes")
            count = count + 1
            countb = countb + 1
        else:
            print("No")
    else:
        print("No")

Measured memory_bytes: 4704
#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 vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef vector<pll> vll;
typedef vector<vl> vvl;

#define fori(i, n) for (int i = 0; i < n; i++)
#define ford(i, n) for (int i = n - 1; i >= 0; i--)
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define repd(i, a, b) for (int i = a; i >= b; i--)
#define trav(x, a) for (auto &x : a)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define endl '\n'
#define sz(a) (int)(a).size()
#define fi first
#define se second

clock_t time_p = clock();
void time_taken()
{
    time_p = clock() - time_p;
    cerr << "Time Taken : " << (float)(time_p) / CLOCKS_PER_SEC << "\n";
}

const ll mod = 1e9 + 7;
const ll INF = 1e18;

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

    int n;
    cin >> n;
    int ans;
    if (n < 600)
    {
        ans = 8;
    }
    else if(n<800){
        ans = 7;
    }
    else if(n<1000){
        ans = 6;
    }
    else if(n<1200){
        ans = 5;
    }
    else if(n<1400){
        ans = 4;
    }
    else if(n<1600){
        ans = 3;
    }
    else if(n<1800){
        ans = 2;
    }
    else
        ans = 1;
    cout << ans << endl;

    time_taken();
    return 0;
}

Measured memory_bytes: 3800
#include<stdio.h>
 int main()
{
    int x,a,b,d1,d2;

    scanf("%d%d%d",&x,&a,&b);

    d1=x-a;
    if(d1<0) d1=d1*(-1);

    d2=x-b;
    if(d2<0) d2=d2*(-1);

    if(d1<d2) printf("A");
    else printf("B");

}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(){
    int n,x,cnt;
    int iniI,iniJ,inik;
    while(cin>>n>>x,n!=0||x!=0){
        cnt=0;
        iniI=1; 
        for(int i=iniI;i<=n;i++){
            iniI=i+1;
            iniJ=i+1; 
            for(int j=iniJ;j<=n;j++){
                iniJ=j+1;
                inik=j+1;
                for(int k=inik;k<=n;k++){
                    inik=k+1;
                    if((i+j+k)==x){
                        cnt++;
                        //cout<<"○"<<i<<"+"<<j<<"+"<<k<<"=="<<x<<endl;
                    }
                    /*else{
                        cout<<"×"<<i<<"+"<<j<<"+"<<k<<"!="<<x<<endl;
                    }*/
                }
            }
        }
        cout<<cnt<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define rFORq(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int x; SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long x; SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
////////////////////////////////////////////////////////////////////
int main(){ 
    ll X,Y;
    SCLLD2(X,Y);
    if (abs(X-Y) > 1){
        printf("Alice\n");
    }else{
        printf("Brown\n");
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
//#define ll __int128
#define ll long long
#define int long long
//#define int __int128
#define LEFT(a) ((a)<<1)
#define RIGHT(a) (LEFT(a) + 1)
#define MID(a,b) ((a+b)>>1)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define y1 y122

/*
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")

#pragma GCC target("avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")

#pragma comment(linker, "/STACK: 20000000005")
*/

using namespace std;

const int N = 200005;

int n;
int a[N], l[N], r[N];
int A[N];
int sum;

main()
{
    ios_base::sync_with_stdio(0);
    cin >> n;
    for (int i = 0; i <= n; i++){
        cin >> a[i];
    }
    if (n == 0){
        if (a[0] != 1)
            cout << -1 << endl;
        else
            cout << 1 << endl;
        return 0;
    }
    if (a[0]){
        cout << -1 << endl;
        return 0;
    }
    A[n] = 0;
    for (int i = n-1; i >= 0; i--)
        A[i] = A[i+1] + a[i+1];
    l[0] = r[0] = 1;
    for (int i = 1; i <= n; i++){
        l[i] = max (0ll, l[i-1] - a[i]);
        r[i] = r[i-1] * 2 - a[i];
        if (r[i] > A[i])
            r[i] = A[i];
        if (l[i] > r[i]){
            cout << -1 << endl;
            return 0;
        }
        if (r[i] <= 0 && i < n){
            cout << -1 << endl;
            return 0;
        }
        if (i == n){
            if (l[i]){
                cout << -1 << endl;
                return 0;
            }
            l[i] = r[i] = 0;
        }
    }
    for (int i = n-1; i >= 0; i--){
        r[i] = min (r[i], r[i+1] + a[i+1]);
        l[i] = max (l[i], l[i+1] + a[i+1] + 1 >> 1);
        if (l[i] > r[i]){
            cout << -1 << endl;
            return 0;
        }
        if (r[i] <= 0 && i < n){
            cout << -1 << endl;
            return 0;
        }
    }
    int ans = 0;
    for (int i = 0; i <= n; i++){
        ans += r[i] + a[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 6784
/**
       **********    ************
	  Author : Avi J Patel
	  University : DA-IICT
       **********    ************
**/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define pf push_front
#define mp make_pair 
#define mt make_tuple
#define ff first
#define ss second
#define si size()
#define MOD 1000000007
#define Mod 998244353
#define N 200001
#define large 10000000000000001
#define For(i,m,n) for(long long i=m;i<n;i++)
#define st(x) sort(x.begin(),x.end())
#define re(x,i) reverse(x.begin()+i,x.end())
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    if(a.second < b.second) return true; 
    else if(a.ss==b.ss) return a.ff<b.ff;
	else return false;
}
bool sortbyboth(const pair<int,int> &a, const pair<int,int> &b)
{
	if(a.first<b.first) return true;
	else if(a.first==b.first) return a.second<b.second;
	else return false;
} 
ull powr(ull x1, ull n1) {
    if(x1==0)
    {
        return 0;
    }
    ull result=1;
    while(n1>0)
    {
        if(n1&1)
        {
            result=(result*x1);
        }
        n1=n1>>1;
        x1=(x1*x1);
    }
    return result;
}
int fact(int n) 
{ 
    // single line to find factorial 
    return (n==1 || n==0) ? 1: n * fact(n - 1);  
}
ll bioCo(ll n, ll k)  
{  
    ll res = 1;  
    if ( k > n - k )  
        k = n - k;  
    for (ll i = 0; i < k; ++i)  
    {  
        res *= (n - i);  
        res /= (i + 1);
		
    }  
  
    return res;  
}   
int main()
{
	FAST
	string s;
	cin>>s;
	int cnt=0;
	for(int i=0;i<s.size()/2;i++)
	{
		if(s[i]!=s[s.size()-i-1])
		{
			cnt++;
		}
	}
	cout<<cnt;
	return 0;
}















Measured memory_bytes: 256
import java.util.*;
class Main{
  public static void main(String args[]){
    int coinVal=0;
    int coinVal2=0;
    int total=0;
    int toyPrice=0;
    Scanner scanner = new Scanner(System.in);
    coinVal = scanner.nextInt();
    coinVal2 = scanner.nextInt();
    toyPrice = scanner.nextInt();
    total = coinVal+coinVal2;
    if(total >= toyPrice){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 21844
n=int(input())
x=list(map(int,input().split()))

# 2重ループにすると楽に書けるが計算量が10^10になり厳しいので、
# min_i[i] = (x[0]～x[i]の中での最小値) という配列をつくった

min_i = [x[0]]
for i in range(1,n):
    min_i.append(min(min_i[i-1],x[i]))

count=0
for i in range(1,n):
    if min_i[i-1] < x[i]:
        count=count+1

print(n-count)


Measured memory_bytes: 24744
import java.io.*;
import java.util.*;

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

		int k = in.nextInt();
		String s = in.next();

		if (s.length() <= k)
			System.out.println(s);
		else
			System.out.println(s.substring(0,k) + "...");
	}
}



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

bool good(int n){
  int cnt=0;
  while(n){
    cnt++;
    n /= 10;
  }

  if(cnt % 2 == 0)
    return false;
  else
    return true;
}

int main(){
  ios::sync_with_stdio(false);
  int n;

  cin >> n;
  int res = 0;
  for(int i=1; i<=n; i++){
    if(good(i))
      res++;
  }

  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;
struct node{
	int key;
	node *parent,*left,*right;
};
node *NIL,*root;

void inorder(struct	node *u){
	if(u==NIL)return;
	inorder(u->left);
	printf(" %d",u->key);
	inorder(u->right);
}
void preorder(struct node *u){
	if(u==NIL)return;
	printf(" %d",u->key);
	preorder(u->left);
	preorder(u->right);
}
void pr(){
	inorder(root);
	printf("\n");
	preorder(root);
	printf("\n");
}
void insert(int key){
	node *y = NIL;
	node *x = root;
	node *z;
	z = (node *)malloc(sizeof(node));
	z->key = key;
	z->left = NIL;
	z->right = NIL;
	
	while(x!=NIL){//when x==NIL break
		y = x;
		if(z->key < x->key)x = x->left;
		else x = x->right;
	}
	z->parent = y;
	if(y == NIL)root = z;//z became root,insert root
	else if(z->key < y->key)y->left = z;
	else y->right = z;
}
node * find(node *u,int k){
	while((u != NIL) && (k != u->key)){	
	//when you exchange the position of '(u != NIL)' with '(k != u->key)',the program will run failed
	//you must make sure that u!=NIl firstly,otherwise k will compare with NIL->key(which is not defined)
		if(k < u->key)u = u->left;
		else u = u->right;
	}
	return u;
}
int main()
{
	int n,k;
	scanf("%d",&n);
	char s[20];
	for(int i=0;i<n;++i){
		scanf("%s",s);
		if(s[0]=='i'){
			scanf("%d",&k);
			insert(k);
		}else if(s[0]=='f'){
			scanf("%d",&k);
			node *t = find(root,k);
			if(t != NIL )printf("yes\n");
			else printf("no\n");
		}
		else pr();
	}
	return 0;
}

Measured memory_bytes: 21908
#include<iostream>

#include<stdio.h>
#include <stdlib.h>
#include<string>
#include<queue>
#include<algorithm>
#include<math.h>

using namespace std;
//using ll = long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
const long long INF = 1LL << 60;

int main(){
    string s;
    cin >> s;
    int answer = s.size();
    for (int i = 0; i < 26; ++i) {
        char c = 'a' + i;
        int max = 0, tmp = 0;
        for (int j = 0; j < s.size(); ++j) {
            if(s[j] != c){
                tmp++;
            }else{
                if(tmp > max) max = tmp;
                tmp = 0;
            }
        }
        if(tmp > max) max = tmp;
        if(max < answer) answer = max;
    }
    printf("%d\n", answer);
    return 0;
}

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

int main(){
  int a,b;
  cin >> a >> b;
  if(a == b){
    cout << "Draw" << endl;
  }else{
    if(a == 1 || a > b && b!=1) {
      cout << "Alice" << endl;
    }else
      cout << "Bob" << endl;
  }
  return 0;
  
}


Measured memory_bytes: 256
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N = int(input())
S = list(input())

ans = 0
for i in range(1, N - 1):
    l, r = set(S[0: i]), set(S[i:])
    ans = max(ans, len(l & r))

print(ans)

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;

void solve()
{
    int N, A, B; cin >> N >> A >> B;
    cout << min(A*N, B) << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

Measured memory_bytes: 256
def framod(n, mod, a=1):
    for i in range(1,n+1):
        a=a * i % mod
    return a

def power(n, r, mod):
    if r == 0: return 1
    if r%2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * power(n, r-1, mod) % mod

def comb(n, k, mod):
    a=framod(n, mod)
    b=framod(k, mod)
    c=framod(n-k, mod)
    return (a * power(b, mod-2, mod) * power(c, mod-2, mod)) % mod

x, y = map(int, input().split())
if  x/y > 2 or y/x > 2:
    print(0)
else:
    if (2*x-y)%3 != 0 or (2*y - x)%3 != 0:
        print(0)
    else:
        a = (2*x-y) / 3
        b = (2*y-x) / 3
        a, b = int(a), int(b)
        mod = 10**9 + 7
        print(comb(a+b, a, mod))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000009
const long long INF = 1LL<<60;

int main() {
    string s,t;
    cin>>s>>t;

    int n=s.size();
    int m=t.size();

    if(n<m){
        cout<<"UNRESTORABLE"<<endl;
        return 0;
    }

    string ans=s;
    for(int i=n-m;i>=0;i--){
        bool ok=true;
        for(int j=0;j<m;j++){
            if(s[i+j]=='?') continue;
            if(s[i+j]!=t[j]) ok=false;
        }
        if(ok){
            rep(j,m) ans[i+j]=t[j];
            rep(i,n){
                if(ans[i]=='?') ans[i]='a';
            }
            cout<<ans<<endl;
            return 0;
        }
    }

    cout<<"UNRESTORABLE"<<endl;

}

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

int main()
{
	int a, b, x, m;

	cin >> a >> b >> x;

	if (a > 2 * b)
		m = (x + 499) / 500 * b;
	else if (a < b || ((x - 1) % 1000) >= 500)
		m = (x + 999) / 1000 * a;
	else
		m = x / 1000 * a + b;

	cout << m << endl;

	return 0;
}


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

#define TRUE        1
#define FALSE       0

#define KIND_MAX    4


void init();
void insert(char *str);
int find(char *str);

typedef struct _dic{
    char exist;
    struct _dic *next[KIND_MAX];
} DIC;

DIC dic;

int main(){
    char cmd[7];
    char str[13];
    int n;
    int i;

    init();

    scanf("%d",&n);

    for(i=0;i<n;i++){
        scanf("%s %s",cmd,str);
        if(cmd[0]=='i'){
            /* cmd is "insert" */
            insert(str);
        }else{
            /* cmd is "find" */
            printf(find(str)?"yes\n":"no\n");
        }
    }

    return 0;
}

void init(){
    int i;
    for(i=0;i<KIND_MAX;i++)dic.next[i] = NULL;
    dic.exist = FALSE;
}

void insert(char *str){
    DIC *pdic;
    DIC *nextdic;
    int nextid;
    int i;

    pdic = &dic;

    while(*str!='\0'){
        switch(*str){
            case 'A': nextid = 0; break;
            case 'C': nextid = 1; break;
            case 'G': nextid = 2; break;
            case 'T': nextid = 3; break;
        }

        nextdic = pdic->next[nextid];

        if( nextdic == NULL ){
            nextdic = (DIC*)malloc(sizeof(DIC));
            for(i=0;i<KIND_MAX;i++)nextdic->next[i] = NULL;
            nextdic->exist = FALSE;

            pdic->next[nextid] = nextdic;
        }

        pdic = nextdic;
        str++;
    }

    pdic->exist = TRUE;
}

int find(char *str){
    DIC *pdic;
    int nextid;

    pdic = &dic;

    while(*str!='\0'){
        switch(*str){
            case 'A': nextid = 0; break;
            case 'C': nextid = 1; break;
            case 'G': nextid = 2; break;
            case 'T': nextid = 3; break;
        }

        pdic = pdic->next[nextid];
        if(pdic==NULL)break;
        str++;
    }

    return (*str=='\0')&&(pdic->exist);
}




Measured memory_bytes: 18100
// 2020-08-23 18:07:45
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

void answer() {
  string s;
  cin >> s;
  int n = s.size();
  int ans = 0;
  rep(i, n) {
    int d = 0;
    if(i % 2 == 0) { // g
      if(s[i] == 'g') d = 0;
      else d = -1;
    }
    else { // p
      if(s[i] == 'g') d = 1;
      else d = 0;
    }
    ans += d;
  }
  cout << ans << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

char X[4] = {'S','S','W','W'};
char Y[4] = {'S','W','S','W'};

int main(){
    ll N;
    cin >> N;
    string s;
    cin >> s;
    string ss = s+s+s;
    vector<char> v(N+1);
    rep(k,4){
        bool flag = true;
        v[0] = X[k];
        v[1] = Y[k];
        rep(i,N-2){
            if((v[i+1] == 'S' && ss[N+i+1] == 'o') || (v[i+1] == 'W' && ss[N+i+1] == 'x') ){
                v[i+2] = v[i];
            }else{
                v[i+2] = ((v[i]=='S')?'W':'S');
            }
        }
        rep(i,N){
            if((ss[N+i+1] == 'o' && v[(i+1)%N] == 'S') || (v[(i+1)%N] == 'W' && ss[N+i+1] == 'x')){
                if(v[i] == v[(i+2)%N])continue;
                flag = false;
                break;
            }else{
                if(v[i] != v[(i+2)%N])continue;
                flag = false;
                break;
            }
        }
        if(flag){
            rep(j,N){
                cout << v[j];
            }
            cout << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 4048
#include <iostream>
#include <cmath>
#include <map>
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)

using namespace std;

class Point{
public:
  double x, y;
  Point(double x = 0, double y = 0): x(x), y(y){}
  Point operator + (Point p){ return Point(x + p.x, y + p.y); }
  Point operator - (Point p){ return Point(x - p.x, y - p.y); }
  Point operator * ( double a ){ return Point(a*x, a*y); }
  double abs(){ return sqrt(norm()); }
  double norm(){ return x*x + y*y; }
  bool operator < ( const Point &p) const {
    return x != p.x ? x < p.x : y < p.y;
  }
  bool operator == (const Point &p) const {
    return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
  }
};
typedef Point Vector;

struct Segment{
  Point p1, p2;
};
typedef Segment Line;

class Circle{
public:
  Point p;
  int r;
};

int n;
Circle c[100];

double dot(Vector a, Vector b){
  return a.x*b.x + a.y*b.y;
}

double cross(Vector a, Vector b){
  return a.x*b.y - a.y*b.x;
}

double getDistanceLP(Line s, Point p){
  return abs(cross(s.p2 - s.p1, p - s.p1) / (s.p2 - s.p1).abs());
}

bool is_cross(Circle c, Line l){
  double dist1 = (c.p - l.p1).abs();
  double dist2 = (c.p - l.p2).abs();
  bool f1 = false, f2 = false;
  if(dist1 < (double) c.r || abs(dist1 - c.r) < EPS) f1 = true;
  if(dist2 < (double) c.r || abs(dist2 - c.r) < EPS) f2 = true;
  if(f1 && f2) return false;
  else if(f1 || f2) return true;
  Point p1, p2, p3, p4;
  p1 = l.p1 - l.p2;
  p2 = l.p2 - l.p1;
  p3 = c.p - l.p2;
  p4 = c.p - l.p1;
  //cout << dot(p1, p3) << ' ' << dot(p2, p4);
  if(dot(p1, p3) >= 0 && dot(p2, p4) >= 0){
    //cout << '!';
    double d = getDistanceLP(l, c.p);
    //cout << "(" << d << ", " << c.r << ")";
    if(d < c.r || abs(d - c.r) < EPS) return true;
  }
  return false;
}

string solve(Line l){
  for(int i=0;i<n;i++){
    //cout << i <<  ' ';
    if(is_cross(c[i], l)){
      return "Safe";
    }
    //cout << endl;
  }
  return "Danger";
}

main(){
  int m;
  while(cin >> n){
    if(n == 0) break;
    for(int i=0;i<n;i++){
      cin >> c[i].p.x >> c[i].p.y >> c[i].r;
    }
    cin >> m;
    for(int i=0;i<m;i++){
      Line input;
      cin >> input.p1.x >> input.p1.y >> input.p2.x >> input.p2.y;
      cout << solve(input) << endl;
    }
  }
  return 0;
}

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

int N, W;
int w[110], v[110];

int main() {
    cin >> N >> W;
    for (int i = 0; i < N; i++) cin >> w[i] >> v[i];

    int sum_v = 0;
    for (int i = 0; i < N; i++) {
        sum_v += v[i];
    }

    ll dp[sum_v + 1];
    for (int i = 0; i <= sum_v; i++) {
        dp[i] = (ll)1.0e18;
    }

    dp[0] = 0;

    for (int i = 0; i < N; i++) {
        for (int j = sum_v; j >= v[i]; j--) {
            dp[j] = min(dp[j], dp[j-v[i]] + w[i]);
        }
    }

    int ans = 0;
    for (int i = 0; i <= sum_v; i++) {
        if (dp[i] <= W) {
            ans = max(ans, i);
        }
    }

    cout << ans << endl;

    return 0;
}


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

int main() {
    int S; cin >> S;
    int h, m, s;
    h = S / 3600;
    S -= 3600 * h;
    m = S / 60;
    S -= 60 * m;
    s = S;
    cout << h << ":" << m << ":" << s << endl;

    return 0;
}


Measured memory_bytes: 3100
#include <iostream>
using namespace std;
int main(){
    int h,w; cin >> h >> w;
    char a[h+1][w+1];
    
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> a[i][j];
        }
    }
    
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (a[i][j] == '#') break;
            if (j == w - 1) {
                for (int k = i; k < h - 1; k++) {
                    for (int l = 0; l < w; l++) {
                        a[k][l] = a[k+1][l];
                    }
                }
                h--;
                i--;
            }
        }
    }

    for (int i = 0; i < w; i++) {
        for (int j = 0; j < h; j++) {
            if (a[j][i] == '#') break;
            if (j == h - 1) {
                for (int k = i; k < w - 1; k++) {
                    for (int l = 0; l < h; l++) {
                        a[l][k] = a[l][k+1];
                    }
                }
                w--;
                i--;
            }
        }
    }

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cout << a[i][j];
            if (j == w - 1) cout << endl;
        }
    }
}

Measured memory_bytes: 256
import numpy as np

c = [list(map(int, input().split())) for i in range(3)]

A = np.array([
    [1, 0, 0, 1, 0, 0],
    [1, 0, 0, 0, 1, 0],
    [1, 0, 0, 0, 0, 1],
    [0, 1, 0, 1, 0, 0],
    [0, 1, 0, 0, 1, 0],
    [0, 1, 0, 0, 0, 1],
    [0, 0, 1, 1, 0, 0],
    [0, 0, 1, 0, 1, 0],
    [0, 0, 1, 0, 0, 1]])

B = np.array([
    [1, 0, 0, 1, 0, 0, c[0][0]],
    [1, 0, 0, 0, 1, 0, c[0][1]],
    [1, 0, 0, 0, 0, 1, c[0][2]],
    [0, 1, 0, 1, 0, 0, c[1][0]],
    [0, 1, 0, 0, 1, 0, c[1][1]],
    [0, 1, 0, 0, 0, 1, c[1][2]],
    [0, 0, 1, 1, 0, 0, c[2][0]],
    [0, 0, 1, 0, 1, 0, c[2][1]],
    [0, 0, 1, 0, 0, 1, c[2][2]]])

rankA = np.linalg.matrix_rank(A)
rankB = np.linalg.matrix_rank(B)

if rankA == rankB:
    print("Yes")
else:
    print("No")

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

using namespace std;

#define ll long long
#define mx 0
#define mn 1e9
#define v(dt) vector<dt>
#define pr(x, y) pair<x,y>
#define loop(x, s, n) for(int x = s; x < n; ++x)
#define in_arr(n) loop(i,0,n){cin>>a[i];}
#define out_arr(n) loop(i,0,n){cout<<a[i];}

const int N = 1e5 + 7;

inline void boost() {
    cin.tie(0), cout.tie(0), cin.sync_with_stdio(0), cout.sync_with_stdio(0);
}

int main() {
    boost();
    ll n;
    cin>>n;
    map <string,ll> mp;
    vector<string> a(n);
    for (int i=0;i<n;i++)
    {
        cin>>a[i];
        sort(a[i].begin(),a[i].end());
        ++mp[a[i]];
    }
    ll cnt = 0;
    for (auto i:mp)
    {
        if (i.second>1) cnt+=(i.second*(i.second-1)/2);
    }
    cout<<cnt;

}

Measured memory_bytes: 16640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.IO;
using System.Text;
using System.Diagnostics;

class Program
{
    static void Main()
    {
        int[] nk = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        int[] a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        Dictionary<long, long> dict = new Dictionary<long, long>();
        long ans = 0;

        for (long i = 0; i < nk[0]; i++)
        {
            if (dict.ContainsKey(a[i]))
            {
                dict[a[i]]++;
            }
            else
            {
                dict[a[i]] = 1;
            }
        }

        int types = dict.Count();
        foreach (var item in dict.OrderBy(x => x.Value))
        {
            if(types > nk[1])
            {
                ans += item.Value;
                types--;
            }
            else
            {
                break;
            }
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 45380
fun main(args: Array<String>) {
    val (N, M) = readInputLine().split(" ").map { it.toInt() }
    val bridges = mutableListOf<Pair<Int, Int>>()

    for (i in 1..M) {
        val (a, b) = readInputLine().split(" ").map { it.toInt() }
        bridges.add(Pair(a, b))
    }
    
    bridges.sortBy { it.second }
    bridges.sortBy { it.first }
    
    val ansList = mutableListOf<Pair<Int, Int>>()
    ansList.add(bridges.first())
    
    for ((a, b) in bridges.drop(1)) {
        if (ansList.last().first == a) {
            // 始点が同じ場合は終点がより始点に近い方のみを残す
            continue
        }
        if (b <= ansList.last().second) {
            // 包含関係にある場合は始点がより終点に近い方のみを残す
            ansList.removeAt(ansList.lastIndex)
            ansList.add(Pair(a, b))
            continue
        }
        
        if (ansList.last().let { it.first < a && it.second < b && a < it.second }) {
            // 始点が異なり、終点も異なるが、ベクトルが交わる場合はより内側の始点、終点を残す
            val b = ansList.last().second
            ansList.removeAt(ansList.lastIndex)
            ansList.add(Pair(a, b))
            continue
        }
        
        // 上記以外はそのまま候補に足す
        ansList.add(Pair(a, b))
    }
    
    println(ansList.size)
}

fun readInputLine(): String {
    return readLine()!!
}


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

int main(){
	int n;
	scanf("%d", &n);
	char city[n+1][11];
	int point[n+1];
	for(int i=1; i<=n; i++){
		scanf("%s", &city[i]);
		scanf("%d", &point[i]);
	}
	int number[n+1];
	for(int i=1; i<=n; i++){
		number[i] = i;
	}
	
	char swap_city[11];
	int swap_point, swap_number;
	for(int i=n; i>=2; i--){
		for(int j=1; j<i; j++){
			if(strcmp(city[j], city[j+1]) > 0){
				strcpy(swap_city, city[j]); strcpy(city[j], city[j+1]); strcpy(city[j+1], swap_city);
				swap_point=point[j]; point[j]=point[j+1]; point[j+1]=swap_point;
				swap_number=number[j]; number[j]=number[j+1]; number[j+1]=swap_number;
			}
			else if(strcmp(city[j], city[j+1]) == 0){
				if(point[j] < point[j+1]){
					swap_point=point[j]; point[j]=point[j+1]; point[j+1]=swap_point;
					swap_number=number[j]; number[j]=number[j+1]; number[j+1]=swap_number;
				}
			}
		}
	}
	
	for(int i=1; i<=n; i++){
		printf("%d\n", number[i]);
	}
	
	return 0;
}

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

using namespace std;

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

  int N;
  cin >> N;
  vector<int> A(N - 1);
  vector<int> sum(N);

  for (int i = 0; i < N - 1; i++) {
    cin >> A.at(i);
  }
  for (int i = 0; i < N - 1; i++) {
    sum.at(A.at(i) - 1)++;
  }

  for (int i = 0; i < N; i++) {
    cout << sum.at(i) << endl;
  }
}


Measured memory_bytes: 4768
#include <iostream>
#include <utility>
#include <algorithm>
#include <functional>
using namespace std;

int n, m;
long x[3][1000];
long a[1000];
long sub(int s) {
  for (int i = 0; i < n; ++i) {
    long val = 0;
    for (int k = 0; k < 3; ++k) {
      val += s & (1 << k) ? x[k][i] : -x[k][i];
    }
    a[i] = val;
  }
  sort(a, a + n, greater<long>());
  
  long sum = 0;
  for (int i = 0; i < m; ++i) {
    sum += a[i];
  }
  return sum;
}

int main() {
  cin >> n >> m;
  for (int i = 0; i < n; ++i) cin >> x[0][i] >> x[1][i] >> x[2][i];
  
  long mx = 0;
  for (int s = 0; s < (1 << 3); ++s) {
    mx = max(mx, sub(s));
  }
  cout << mx << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        sc.nextLine();
        StringBuilder s = new StringBuilder(sc.nextLine());
        StringBuilder t = new StringBuilder(sc.nextLine());
        int ovCount = 0;
        for (int i = 0; i < N; ++i) {
            if (s.substring(i).equals(t.substring(0, N - i))) {
                ovCount = N - i;
                break;
            }
        }
        System.out.println((s.length() + t.length() - ovCount));
    }
}

Measured memory_bytes: 9684
#include<bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i = 0;i < (n);i++)
using namespace std;
const int INF = 1e9;

int n;
int main(){
  cin>>n;
  if(n<=999)cout<<"ABC"<<endl;
  else cout<<"ABD"<<endl;
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int num[200005];
int main()
{
    int x,y;
    cin>>x>>y;
    if(y==2)
    {
        int a,b;
        cin>>a>>b;
        cout<<min(b-a,x+a-b)<<endl;
    }
    else
    {
        cin>>num[0]>>num[1];
        int maxn=num[1]-num[0];
        for(int i=2;i<y;i++)
        {
            cin>>num[i];
            maxn=max(maxn,num[i]-num[i-1]);
        }
        maxn=max(x+num[0]-num[y-1],maxn);
        cout<<x-maxn<<endl;
    }
    return 0;
}

Measured memory_bytes: 1024
from copy import copy, deepcopy
from collections import Counter
from math import sqrt, floor, factorial, log
from itertools import permutations, combinations, combinations_with_replacement
from operator import mul
from functools import reduce
import bisect

MOD = 10**9 + 7
INF = float('inf')

N, K = list(map(int, input().split()))
A = list(map(int, input().split()))

#A = [0 for i in range(N)]
B = [0 for i in range(N)]

# print(A)
for _ in range(K):
    B = [0 for i in range(N)]
    for i in range(N):
        B[max(i-A[i], 0)] += 1
        idx = min(i+A[i]+1, N)
        if idx != N:
            B[idx] -= 1
    # print(B)
    for i in range(N-1):
        B[i+1] += B[i]
    # print(B)
    A = B.copy()
    if _ > 10 * int(log(N)):
        break

L = " ".join([str(x) for x in A])
print(L)


Measured memory_bytes: 190332
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.Set;

public class Main {
	Scanner sc = new Scanner(System.in);
	
	public static void main(String[] args) {
		Main m = new Main();
		m.run();
	}
	
	void run() {
		
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		List<Set<Integer>>g = new ArrayList<Set<Integer>>();
		
		for(int i = 0 ;i < n+1 ; i ++) {
			g.add(new HashSet<Integer>());
		}
		for(int i = 0 ; i < m; i++) {
			int a = sc.nextInt() ;
			int b = sc.nextInt() ;
			g.get(a).add(b);
			g.get(b).add(a);
		}
		
		if(!removeCircuit(g)) {
			System.out.println("No");
			return ;
		}
		if(!removeCircuit(g)) {
			System.out.println("No");
			return ;
		}
		if(!removeCircuit(g)) {
			System.out.println("No");
			return ;
		}
		
		while(true) {
			boolean f = true;
			for(int i = 0 ;i < n+1 ; i++) {
				if(g.get(i).size() != 0) {
					f = false;
					if(!removeCircuit2(g)) {
						System.out.println("No");
						return ;
					}
					break;
				}
			}
			if(f) break;
		}
		System.out.println("Yes");
	}
	
	boolean removeCircuit(List<Set<Integer>> g) {
		
		int start = -1;
		int goal = -1;
		
		for(int i = 0; i < g.size(); i++) {
			start = i;
			for(int j : g.get(i)) {
				goal = j;
			}
			if(goal != -1) {
				break;
			}
		}
		if(goal == -1) {
			return false;
		}
		
		g.get(start).remove(goal);
		g.get(goal).remove(start);
		

		Set<Integer> visited = new HashSet<Integer>();

		PriorityQueue<int[]> queue = new PriorityQueue<int[]>((a1,a2)->Integer.compare(a1[1],a2[1]));
		queue.add(new int[]{start,0,-1});
		
		int prev[] = new int[g.size()];

		while(true) {
			if(queue.isEmpty()) {
				return false;
			}
			int[] now = queue.poll();

			if(visited.contains(now[0])) {
				continue;
			}
			visited.add(now[0]);
			prev[now[0]] = now[2];

			if(now[0] == goal) {
				break;
			}
			
			for(int j: g.get(now[0])) {
				if(!visited.contains(j)) {
					queue.add(new int[] {j,now[1]+1, now[0]});
				}
			}
		}
		
		int now = goal;
		for(;now != start;) {
			int p = prev[now];
			g.get(now).remove(p);
			g.get(p).remove(now);

			now = p;
		}
		
		return true;
	}

	
	boolean removeCircuit2(List<Set<Integer>> g) {
		
		int start = -1;
		int goal = -1;
		
		for(int i = 0; i < g.size(); i++) {
			start = i;
			for(int j : g.get(i)) {
				goal = j;
			}
			if(goal != -1) {
				break;
			}
		}
		if(goal == -1) {
			return false;
		}
		
		g.get(start).remove(goal);
		g.get(goal).remove(start);
		
		int now = start;

		while(now != goal) {
			int next = -1;

			for(int j: g.get(now)) {
				next = j;
				break;
			}
			
			if(next == -1) {
				return false;
			}
			
			g.get(now).remove(next);
			g.get(next).remove(now);

			now = next;
		}
		
		return true;
	}

}


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

int main(){
  int l, A, B, a, b;

  while(cin >> l >> A >> B >> a >> b){
    int usedA = (A - 1) / a + 1;
    int usedB = (B - 1) / b + 1;

    cout << l - max(usedA, usedB) << endl;
  }
}

Measured memory_bytes: 1164
# C - Many Medians
import copy
N = int(input())
X = list(map(int, input().split()))
X2 = []

X2 = copy.copy(X)
X2.sort(reverse=True)
Xm_1 = X2[N//2]
Xm_2 = X2[(N//2)-1]

for i in range(N):
    if X[i] <= Xm_1:
        print(Xm_2)
    else:
        print(Xm_1)


Measured memory_bytes: 27156
a,b,c = map(int,input().split())

x = max(a,b,c)
z = min(a,b,c)
y = a + b + c - x - z

cnt = 0

if z % 2 == y % 2:
    cnt += (y - z) / 2
    cnt += (x - y)
elif z % 2 != y % 2 and z % 2 == x % 2:
    cnt += (x - z) / 2
    if y % 2 == x % 2:
        cnt += (x - y)
    else:
        cnt += ((x + 1)- y) / 2
        cnt += 1
elif z % 2 != y % 2 and z % 2 != x % 2:
    cnt += (x - y) / 2
    cnt += ((x + 1)- z) / 2
    cnt += 1

print(int(cnt))

Measured memory_bytes: 9108
# coding: utf-8
# 日本語を入力できるようにするために上記一文が必要


x = input()
str_list = "a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z".split(',')

if x in str_list:
        print("a")
else:
        print("A")

Measured memory_bytes: 9024
import heapq

N,M=map(int,input().split())
A=list(map(int,input().split()))
A=list(map(lambda x: x*(-1), A))
A.sort()

for _ in range(M):
  n=heapq.heappop(A)
  n=-(-n//2)
  heapq.heappush(A,n)
print(-sum(A))

Measured memory_bytes: 14180
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (1E9+7)
#define PI 3.1415926535897932384

std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}

int main() {
	char a, b, c;
	vi d;
	cin >> a >> b >> c;
	d.push_back(a - 'a');
	d.push_back(b - 'a');
	d.push_back(c - 'a');
	sort(all(d));
	if (d[0] == 0 && d[1] == 1 && d[2] == 2)cout << "Yes" << endl;
	else cout <<"No" <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=2005,mod=1e9+7;
int f[N][N],fac[N*N],ifac[N*N];
int Pow(int x,int k){
	int ret=1;
	while(k){
		if(k&1)ret=1ll*ret*x%mod;
		k>>=1;x=1ll*x*x%mod;
	}
	return ret;
}
int C(int n,int m){
	if(n<m)return 0;
	return 1ll*fac[n]*ifac[m]%mod*ifac[n-m]%mod;
}
int main(){
	fac[0]=1;
	for(int i=1;i<=4000000;i++)fac[i]=1ll*fac[i-1]*i%mod;
	ifac[4000000]=Pow(fac[4000000],mod-2);
	for(int i=3999999;~i;i--)ifac[i]=1ll*ifac[i+1]*(i+1)%mod;
	int n,m;scanf("%d%d",&n,&m);
	if(m==1)cout<<1<<"\n",exit(0);
	f[0][0]=1;
	for(int i=0;i<=n;i++){
		for(int j=0;j<=i;j++){
			if(j<i)f[i][j+1]=(f[i][j+1]+f[i][j])%mod;
			f[i+1][j]=(f[i+1][j]+1ll*C(i*(m-1)+j+m-2,m-2)*f[i][j])%mod;
		}
	}
	cout<<1ll*f[n][n]*fac[n]%mod<<"\n";
}

Measured memory_bytes: 47360
#include "bits/stdc++.h"

using namespace std;

const double EPS = 1e-2;

struct pt {
  long long x, y;
  double ang;
  pt(int _x = 0, int _y = 0) : x(_x), y(_y) {
    ang = atan2(y, x);
  }
};

bool cmp(const pt& a, const pt& b) {
  if(a.ang == b.ang)
    return abs(a.x) + abs(a.y) < abs(b.x) + abs(b.y);
  return a.ang < b.ang;
}

long long score(long long a, long long b) {
  return a*a + b*b;
}

bool valid(double x) {
  return x < M_PI;
}

double angle(double a, double b) {
  return b-a;
}

int main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  vector <pt> X;
  for(int i=0; i<n; i++)
  {
    int x, y;
    cin >> x >> y;
    X.push_back(pt(x,y));
  }
  sort(X.begin(), X.end(), cmp);
  int l = 0;
  long long res = 0, tttx = 0, ttty = 0;
  for(int p=0; p<2*n; p++) {
    while(l - p < n and
          valid(((l/n == p/n) ? 0 : +2*M_PI) + angle(X[p%n].ang, X[l%n].ang))) {
      tttx += X[l%n].x;
      ttty += X[l%n].y;
      res = max(res,score(tttx, ttty));
      l++;
    }
    tttx -= X[p%n].x;
    ttty -= X[p%n].y;
    res = max(res, score(tttx, ttty));
  }
  cout << fixed << setprecision(20) << sqrt(1.0*res) << "\n";
}


Measured memory_bytes: 512
from collections import deque

H, W, K = map(int, input().split())

mp = [input() for _ in range(H)]

rlt = 1010

h = deque([[1]])

while h:
  t = h.pop()
  if len(t) == H:
    t.append(1)
    tmp = sum(t) - 2
    bs = tmp
    lst = [0]*H
    j = -1
    for i in range(len(t)-1):
      if t[i] == 1:
        j += 1
      lst[i] = j 
    cnt = [0]*(lst[-1]+1)
    for j in range(W):
      tcnt = [0]*(lst[-1]+1)
      f = 0
      for i in range(H):
        tcnt[lst[i]] += int(mp[i][j])
      for k in range(lst[-1]+1):
        if tcnt[k] > K:
          f = 2
          break
        cnt[k] += tcnt[k]
        if cnt[k] > K:
          f = 1
          break
      if f == 2:
        break
      if f == 1:
        tmp += 1
        for k in range(lst[-1]+1):
          cnt[k] = tcnt[k]
    if f < 2:
      rlt = min(rlt, tmp)
    
  else:
    for i in range(2):
      h.append(t+[i])

print(rlt)

Measured memory_bytes: 74712