akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,N) for(int i = 0; i < N; i++)

int N;
vector<vector<int>> f;
vector<vector<int>> p;
const ll inf = 1 << 30;


int main() {
    cin >> N;
    f.resize(N); p.resize(N);
    rep(i,N) f[i].resize(10), p[i].resize(11);
    rep(i,N)rep(j,10) scanf("%d", &f[i][j]);
    rep(i,N)rep(j,11) scanf("%d", &p[i][j]);

    ll ans = -inf;
    for (int bits = 1; bits < (1<<10); bits++) {
        vector<ll> count(N);
        rep(i,10) {
            if ((bits>>i)&1){
                rep(j,N) {
                    if(f[j][i]) {
                        count[j]++;
                    }
                }
            }
        }
        ll sum = 0;
        rep(i,N) sum += p[i][count[i]];
        ans = max(ans,sum);
    }

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


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int[] v = new int[n];
		int[] c = new int[n];
		for (int i = 0; i < v.length; i++) {
			v[i] = Integer.parseInt(sc.next());
		}
		for (int i = 0; i < c.length; i++) {
			c[i] = Integer.parseInt(sc.next());
		}
		int ans = 0;
		for (int i = 0; i < (1 << n); i++) {
			int sum = 0;
			for (int j = 0; j < n; j++) {
				if ((i & (1 << j)) != 0) {
					sum += v[j] - c[j];
				}
			}
			ans = Math.max(ans, sum);
		}
		System.out.println(ans);
		sc.close();
	}
}

Measured memory_bytes: 21460
#include <iostream>

using namespace std;

// プロトタイプ宣言
int gcd(int i, int j);

int main()
{
	
	int i,j;
	while(cin >> i >> j){
		int tmp;
		if(i<j){
			tmp = i;
			i = j;
			j = tmp;
		}
		int ret_gcd, ret_lcm;
		ret_gcd = gcd(i,j);
		ret_lcm = (i/ret_gcd)*j;
		
		cout << ret_gcd << ' ' << ret_lcm <<endl;
		
	}
	return 0;
}

int gcd(int i, int j)
{
	
	if(j > 0){
		return gcd(j, i%j);
	}else{
		return i;
	}
	
}

Measured memory_bytes: 1160
loop do
  m, f, r = gets.split.map(&:to_i)
  break if m == -1 && f == -1 && r == -1
  if m == -1 || f == -1
    puts 'F'
  else
    case m + f
    when 80..100
      puts 'A'
    when 65..79
      puts 'B'
    when 50..64
      puts 'C'
    when 30..49
      if 50 <= r
        puts 'C'
      else
        puts 'D'
      end
    when 0..29
      puts 'F'
    end
  end
end

Measured memory_bytes: 6112
import java.util.*;

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

		int K = sc.nextInt();
		int S = sc.next().length();
		
		long rev25 = rev(25);
		long pow25k = pow(25, K);
		long combsk_s = comb(S+K, S);
		long ans = 0;
		for(int i=0; i<=K; i++) {
			ans = (ans + combsk_s*pow25k)%MOD;
			
			pow25k = (pow25k*rev25)%MOD;
			combsk_s = (combsk_s * (K-i))%MOD;
			combsk_s = (combsk_s * rev(S+1+i))%MOD;
		}
//		System.out.println((comb(S+K, S)*pow(25, K))%MOD);
		System.out.println(ans);

		sc.close();
	}
	
	static long comb(long a, long b) {
		long ans = 1;
		for(int i=0; i<b; i++)
			ans = (ans * (a-i))%MOD;
		for(int i=0; i<b; i++)
			ans = (ans * rev(b-i))%MOD;

		return ans;
	}
	
	static long rev(long a) {
		return pow(a, MOD-2);
	}
	
	static long pow(long a, long b) {
		long ans = 1;
		while(b>0) {
			if((b&1)!=0)
				ans = (ans * a)%MOD;
			a = (a * a)%MOD;
			b>>=1;
		}
		
		return ans;
	}
}


Measured memory_bytes: 37652
import java.util.Scanner;

class Main {
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();
        if (a < b && b < c) {
            System.out.println("Yes");
        } else {
            System.out.println("No");   
        }
    }
}


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

int main()
{
    string a, b;
    cin >> a >> b;
    int num = stoi(a+b);
    for (int i=1;i<=1000;i++)
    {
        if(i*i == num)
        {
            cout << "Yes" << endl;
            return 0;    
        }
    }
    cout << "No" << 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();
		int K = sc.nextInt();
		int[] a = new int[N];
		for(int i=0; i<N; i++)
			a[i] = sc.nextInt();
		Arrays.sort(a);
		
		int min = -1;
		int max = N;
		while(min+1 < max) {
			int mid = (min+max)/2;
			boolean[] visited = new boolean[K];
			visited[0] = true;
			for(int i=0; i<N; i++) {
				if(i==mid)
					continue;
				for(int j=K-1; j>=0; j--)
					if(visited[j] && j+a[i]<K)
						visited[j+a[i]] = true;
			}
			boolean ok = false;
			for(int i=K-1; i+a[mid]>=K && i>=0; i--)
				if(visited[i]) {
					ok = true;
					break;
				}
			if(ok) {
				max = mid;
			} else {
				min = mid;
			}
		}
		
		System.out.println(max);
		
		sc.close();
	}
}


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

typedef long long ll;
#define rep(i, n) for(int i = 0; i < n; i++)

const int lim = 1000000007;

int main(){
    int N, H;
    cin >> N >> H;
    vector<int> a(N), b(N);
    rep(i, N) cin >> a[i] >> b[i];

    //aの中で最大のダメージを格納
    int mx_a = 0;
    rep(i, N) mx_a = max(mx_a, a[i]);

    //bの中でmx_aよりも大きなダメージを与えられるものの数と、その合計を格納
    int cnt = 0;
    ll sum = 0;
    sort(b.begin(), b.end(), greater<int>());
    rep(i, N){
        if(b[i] > mx_a){
            cnt++;
            sum += b[i];
        }
        if(sum >= H){
            cout << cnt << endl;
            return 0;
        }
    }

    //刀を振ることで与えなければならないダメージを計算
    int d = H - sum;
    //d以上となるための、mx_aのダメージが与えられる刀を振る回数を求める
    int c = (d + mx_a -1) / mx_a;
    int ans = c + cnt;
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N, A, B;
    cin >> N >> A >> B;

    if ((B-A)%2) {
        cout << "Borys" << endl;
    } else {
        cout << "Alice" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String args[]) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		long x=sc.nextLong();
		long length[]=new long[n+1];
		long count=0;
		long pati[]=new long[n+1];
		//String s[]=new String[n+1];
		//s[0]="P";
		length[0]=1L;
		pati[0]=0L;
		for(int i=1;i<=n;++i) {
			//s[i]="B"+s[i-1]+"P"+s[i-1]+"B";
			length[i]=3+length[i-1]*2;
			pati[i]=1+2*pati[i-1];
		}
		
		//char c[]=s[n].toCharArray();
		int index=n;
		while(index>=0){
			if(x==1) {
				if(index==0)++count;
				break;
			}
			else if(x<=length[index]/2) {
				--index;
				--x;
			}
			else if(x==length[index]/2+1) {
				count=count+pati[index]+1;
				break;
			}
			else if(x==length[index]) {
				count = count+2*pati[index]+1;
				break;
			}
			else if(x>length[index]/2+1) {
				count =count+pati[index]+1;
				x=x-length[index]/2-1;
				--index;

			}

		}
		System.out.println(count);
	}
}


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

int main() {
  long long n, a, b, ans;
  cin >> n >> a >> b;
  if(a == 0) {
    ans = 0;
  } else {
    ans = (n / (a+b)) * a;
    long long tmp;
    tmp = n % (a+b);
    if(tmp <= a) {
      ans += tmp;
    } else {
      ans += a;
    }
  }

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


Measured memory_bytes: 256
//
// Created on 2019-02-09.
//
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
template<class T> bool INRANGE(T x,T a,T b) { return a<=x&&x<=b; }

#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

#define PB push_back
#define INF 1e9
#define MOD 1e9+7
#define EPS 1e-9

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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


    int n, t;
    cin >> n;

    int ans = 0;
    vi before;
    bool isOk = true;
    REP(i, n){
        isOk = true;
        cin >> t;
        for (int h: before){
            if (h > t) isOk = false;
        }
        if (isOk) ans++;
        before.emplace_back(t);
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
import numpy as np

n=int(input())

a=np.zeros([n,2])

for i in range(n):
    d1,d2=map(int,input().split())
    a[i][0]=d1
    a[i][1]=d2

#print(a)

ans=0
for j in range(n-2):
    #print(a[j][0])
    #print(a[j][1])
    if a[j][0]==a[j][1] :
        a1=0
       # print(a1)
        if a[j+1][0]==a[j+1][1]:
            a2=0
           # print(a2)
            if a[j+2][0]==a[j+2][1] :
                a3=0
                #print(a3)
                if a1==0 and a2==0 and a3==0 :
                    ans=ans+1
                   # print(ans)
    a1=0
    a2=0
    a3=0


if ans>0 :
    print("Yes")
if ans==0 :
    print("No")

Measured memory_bytes: 26992
#include <stdio.h>

int main(void){
    int a, b;
    scanf("%d %d", &a, &b);
    if(a < 3 || a > 20 || b < 3 || b > 20){
        return -1;
    }
    if(a == b){
        printf("%d\n", a+b);
    }else{
        int x = a > b ? a+(a-1) : b+(b-1);
        printf("%d\n", x);
    }
    
    return 0;
}

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


int main(){
    int A, B, ret=-1, i;
    double Ap, Bp, Ap_1, Bp_1;
    cin >> A >> B;
    Ap = 12.5 * A;
    Ap_1 = 12.5 * (A + 1);
    Bp = 10 * B;
    Bp_1 = 10 * (B+1);

/*
    for(i=(int)Ap;i<Ap_1;i++)
    {
        if( ((int)Bp <= i) && (i < (int)Bp_1))
        {
            ret = 0;
            break;
        }
    }
*/
rep(i,10000){
    Ap = i * 0.08;
    Bp = i * 0.1;
    if( (int)(i * 0.08) == A && (int)(i * 0.1) == B )
    {
        ret = 0;
        break;
    }
}


    if(ret == 0)
    {
        cout << i << endl;
    }
    else
    {
        cout << -1 << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    int p[N];
    int ans = 0;
    int max_p = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> p[i];
        ans += p[i];
        max_p = max(max_p, p[i]);
    }
    cout << ans - max_p / 2 << endl;
}

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

int main(){
  int A, B, C;
  cin >> A >> B >> C;
  int ans =0;
  if(A+B>=C){
    cout << B+C << endl;
    return 0;
  }
  cout << A+2*B+1 << endl;
  return 0;
}

Measured memory_bytes: 256
N,X = map(int,input().split())
x = sorted(list(map(int,input().split())))
diff = [abs(X-i) for i in x]
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)
if N == 1:
    print(diff[0])
else:
    gcda = gcd(diff[0],diff[1])
    for i in range(2,N):
        gcda = gcd(gcda,diff[i])
    print(gcda)

Measured memory_bytes: 14252
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

         int a, b;
         while (true) {
         	a = sc.nextInt();
         	b = sc.nextInt();
         	if (a == 0 && b == 0) {
         		break;
         	}
             if (a < b) {
                 System.out.printf("%d %d%n",a,b);
             } else {
                 System.out.printf("%d %d%n",b,a);
             
             }
        }
    }
}


Measured memory_bytes: 39864
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {

        static void Main(string[] args)
        {
            var r = ReadIntArray();
            var H = r[0];
            var W = r[1];
            List<string> row = new List<string>();
            row.Add(string.Concat(Enumerable.Repeat("#", W + 2).ToArray()));
            for (int i = 0; i < H; i++)
            {
                var line = Read();
                row.Add("#" + line + "#");
            }
            row.Add(string.Concat(Enumerable.Repeat("#", W + 2).ToArray()));
            foreach (var item in row)
            {
                Console.WriteLine(item);
            }
        }
        private static readonly Func<string> Read = () => Console.ReadLine();
        private static readonly Func<string[]> ReadStringArray = () => Console.ReadLine().Split();
        private static readonly Func<int> ReadInt = () => int.Parse(Console.ReadLine());
        private static readonly Func<long> ReadLong = () => long.Parse(Console.ReadLine());
        private static readonly Func<int[]> ReadIntArray = () => Console.ReadLine().Split().Select(int.Parse).ToArray();
        private static readonly Func<long[]> ReadLongArray = () => Console.ReadLine().Split().Select(long.Parse).ToArray();
        private static readonly Action<string> Cw = str => Console.WriteLine(str);
    }
}

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

int main() {
	string S;
	cin >> S;
	cout << ((S=="ABC") ? "ARC" : "ABC") << endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,val;
    
    cin>>n;
    vector<int>vect(n);
    vector<int>dp(n,INT_MAX);
    for(int i=0;i<n;i++)
    {
        cin>>val;
        vect[i]=val;
    }
    
    dp[0]=0;
    for(int i=0;i<n;i++)
    {
        if(i+1<n)
        {
            dp[i+1]=min(dp[i+1],dp[i]+abs(vect[i]-vect[i+1]));


        }
        if(i+2<n)
        {
            dp[i+2]=min(dp[i+2],dp[i]+abs(vect[i]-vect[i+2]));
        }
   
    }

    cout<<dp[n-1];

    return 0;
}

Measured memory_bytes: 1024
N, Q = [int(i) for i in input().split()]
S = input()

cumsum = [0]
for i in range(1, N):
    if (S[i-1], S[i]) == ("A", "C"):
        cumsum.append(cumsum[i-1]+1)
    else:
        cumsum.append(cumsum[i-1])

for i in range(Q):
    l, r = [int(i)-1 for i in input().split()]
    print(cumsum[r]-cumsum[l])


Measured memory_bytes: 6176
if __name__ == "__main__":
    N=int(input())
    work=[]

    for i in range(N):
        W=list(map(int,input().split()))
        work.append(W)
    
    work.sort(key=lambda x:x[1])
    result=0
    flg=0

    for i in range(N):
        result+=work[i][0]
        if result>work[i][1]:
            flg=1
            break
    
    if flg==1:
        print('No')
    else:
        print('Yes')

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

using namespace std;

#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define _repis(i,a,b,s) for(int i=a, i##_len(b); i<i##_len; i+=s)
#define REP(...) _overload3(__VA_ARGS__,_repis,_repi,_rep,)(__VA_ARGS__)

#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REPARR(i, v) for(int i = 0;i < v.size();++i)

#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl
#define POSS(n) cout<<((n)?"POSSIBLE":"IMPOSSIBLE")<<endl

int main(){
    string s;
    cin>>s;
    REP(i,s.size()-1){
        if(s.substr(i, 2)=="AC"){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount _builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace __gnu_pbds;
using namespace std;
//typedef
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
//constants
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
//
#define forn(i, n)for(ll i=0;i<n;i++)
// gcd of a and b
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
// distance between (a,b) and (c,d)
long double dis(long long a,long long b,long long c,long long d){return sqrt( ((a)-(c))*((a)-(c))+((b)-(d))*((b)-(d)) );}
// simple prime check
bool isprime(long long a){
if(a==2)return 1;
if(!(a&1))return 0;
for(ll i=3;i*i<=a;i+=2){
	if(a%i==0)return 0;
}
return 1;
}
// fast expo
long long mpow(long long base,long long exponent,long long modulus){
if(modulus==1)return 0;
long long result = 1;
base=base%modulus;
while(exponent){
		if(exponent%2 == 1)
			result=(result*base)%modulus;
		exponent=exponent>>1;
		base=(base*base)%modulus;
	}
return result;
}
// modular inverse
ll minv(ll a,ll mod){
	ll _gcd=gcd(a,mod);
	assert(_gcd==1);
	return mpow(a,mod-2,mod);
}

/*
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/

/*
ll dx[]={1,0,-1,0,1,1,-1,-1};
ll dy[]={0,-1,0,1,1,-1,-1,1};
*/

/*
void sieve(int N){
	for(int i=0;i<=N;i++){
		spf[i]=i;
	}
	for(int i=2;i*i<=N;i++){
		if(spf[i]==i){
			for(int j=i*i;j<=N;j+=i){
				spf[j]=min(spf[j],i);
			}
		}
	}
	return;
}
*/

/*
void nCr(ll n,ll k){
	ll i,j;
	for(i=0;i<=n;i++){
		for(j=0;j<=min(i,k);j++){

			if(j==0 or j==i)C[i][j]=1LL;
			else  C[i][j]=(C[i-1][j-1]+C[i-1][j])%MOD;

		}
	}
	return;
}
*/
/*
ll ncr(ll N,ll K){
	if(N<K)return 0;
	if(K==0)return 1;
	if(N==0)return 0;

	ll den=1;
	for(ll i=1;i<=K;i++)den*=i;
	ll num=1;
	while(K--){
		num*=N;
		if(num%den==0){
			num/=den;
			den=1;
		}
		N--;
	}

	return num;
}
*/
ll n,m;
multiset<ll>ss;
map<ll,ll>ma;
int main(){FAST;
cin>>n>>m;

for(ll i=0;i<n;i++){
	ll x;cin>>x;
	ss.insert(x);
}

for(ll i=0;i<m;i++){
	ll x,y;cin>>x>>y;
	ma[y]+=x;
}

for(auto it = ma.rbegin();it!=ma.rend();++it){
	pll p = *it;
	ll val = p.first;
	ll ct = p.second;
	while(*ss.begin()<val and ct){
		ss.insert(val);
		ss.erase(ss.begin());
		ct--;
	}
}
ll ans = 0;
for(auto it:ss)ans+=it;
cout<<ans;
return 0;
}




Measured memory_bytes: 11264
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#include <set>
#include <stack>
#include <cctype>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)

#define AAA (1000000007) 


using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pairII;


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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
ll powD(ll a, ll b) {
	ll ans = 1;
	a %= AAA;
	for (int i = 0; i < b; i++)
	{
		ans *= a;
		ans %= AAA;
	}
	return ans;
}


int main() {
	int i, j, k;

	int N, M, K;

	string S;

	cin >> S;

	int ans = 0;
	rep(i, 0, S.size() - 1) {
		if (S[i] != S[i + 1])
			ans++;


	}
	cout << ans;

	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
const double EPS = 1e-8;
const double INF = 1e12;
#define EQ(n,m) (abs((n)-(m)) < EPS)

struct Point{
    double x,y,z;
    Point(double x, double y, double z):x(x), y(y), z(z){}
    Point(){}
    Point &operator +=(const Point &a){ x+=a.x; y+=a.y; z+=a.z; return *this; }
    Point &operator -=(const Point &a){ x-=a.x; y-=a.y; z-=a.z; return *this; }
    Point &operator *=(const double &a){ x*=a; y*=a; z*=a; return *this; }
    Point operator +(const Point &a) const{ return Point(x+a.x, y+a.y, z+a.z); }
    Point operator -(const Point &a) const{ return Point(x-a.x, y-a.y, z-a.z); }
    Point operator *(const double &a) const{ return Point(a*x, a*y, a*z); }
    Point operator -() { return Point(-x, -y, -z); }
};
 
double dot(const Point &a, const Point &b){
    return a.x*b.x +a.y*b.y +a.z*b.z;
}
Point cross(const Point &a, const Point &b){
    return Point(a.y*b.z -a.z*b.y, a.z*b.x -a.x*b.z, a.x*b.y -a.y*b.x);
}
double abs(const Point &a){
    return sqrt(dot(a, a));
}
Point unit(const Point &a){
    return a *(1/abs(a));
}
bool operator ==(const Point &a, const Point &b){
    return abs(a-b) < EPS;
}

Point projectionLP3(Point p, Point q, Point c){
    double t = dot(unit(q-p), c-p);
    return p +unit(q-p) *t;
}
double distancePlP(Point a, Point b, Point c, Point p){
    Point normal = unit(cross(b-a, c-a));
    return abs(dot(normal, p-a));
}

int main(){
    Point p[2][3], v[2];
    for(int i=0; i<2; i++){
        for(int j=0; j<3; j++){
            cin >> p[i][j].x >> p[i][j].y >> p[i][j].z;
        }
        v[i] = cross(p[i][1], p[i][2]);
        p[i][1] += p[i][0];
        p[i][2] += p[i][0];

    }
    if(abs(cross(v[0], v[1])) < EPS){
        cout << "NO" << endl;
        return 0;
    }

    Point commondir = unit(cross(v[0], v[1]));
    double angle = acos(dot(v[0], v[1]));
    double d = distancePlP(p[1][0], p[1][1], p[1][2], p[0][0]) /sin(angle);
    Point tocp = unit(cross(v[0], commondir));
    Point cp;
    if(distancePlP(p[1][0], p[1][1], p[1][2], p[0][0] +tocp*d) < EPS){
        cp = p[0][0] +tocp*d;
    }else{
        cp = p[0][0] -tocp*d;
    }

    Point pro = projectionLP3(cp, cp +commondir, p[0][0]);
    double dsq = dot(pro -p[0][0], pro -p[0][0]);
    double dist = sqrt(1 -dsq);
    if((abs(pro +commondir*dist -p[1][0]) +EPS < 1) !=
        (abs(pro -commondir*dist -p[1][0]) +EPS < 1)){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 3516
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,A,B,i;
  A=0;
  B=0;
  i=0;
  cin >> N;
  vector<int>vec(N);
  for(i=0; i<N; i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  for (i=0; i<N; i++){
    if(i==0){
      A+=vec.at(0);
    }
    else if(i%2==1){
      B+=vec.at(i);
    }
    else{
      A+=vec.at(i);
    }
  }
  cout << A-B << endl;
}

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

#define debug(...) fprintf(stderr, __VA_ARGS__)

#ifndef AT_HOME
#define getchar() IO::myGetchar()
#define putchar(x) IO::myPutchar(x)
#endif

namespace IO {
	static const int IN_BUF = 1 << 23, OUT_BUF = 1 << 23;

	inline char myGetchar() {
		static char buf[IN_BUF], *ps = buf, *pt = buf;
		if (ps == pt) {
			ps = buf, pt = buf + fread(buf, 1, IN_BUF, stdin);
		}
		return ps == pt ? EOF : *ps++;
	}

	template<typename T>
	inline bool read(T &x) {
		bool op = 0;
		char ch = getchar();
		x = 0;
		for (; !isdigit(ch) && ch != EOF; ch = getchar()) {
			op ^= (ch == '-');
		}
		if (ch == EOF) {
			return false;
		}
		for (; isdigit(ch); ch = getchar()) {
			x = x * 10 + (ch ^ '0');
		}
		if (op) {
			x = -x;
		}
		return true;
	}

	inline int readStr(char *s) {
		int n = 0;
		char ch = getchar();
		for (; isspace(ch) && ch != EOF; ch = getchar())
			;
		for (; !isspace(ch) && ch != EOF; ch = getchar()) {
			s[n++] = ch;
		}
		s[n] = '\0';
		return n;
	}

	inline void myPutchar(char x) {
		static char pbuf[OUT_BUF], *pp = pbuf;
		struct _flusher {
			~_flusher() {
				fwrite(pbuf, 1, pp - pbuf, stdout);
			}
		};
		static _flusher outputFlusher;
		if (pp == pbuf + OUT_BUF) {
			fwrite(pbuf, 1, OUT_BUF, stdout);
			pp = pbuf;
		}
		*pp++ = x;
	}

	template<typename T>
	inline void print_(T x) {
		if (x == 0) {
			putchar('0');
			return;
		}
		static int num[40];
		if (x < 0) {
			putchar('-');
			x = -x;
		}
		for (*num = 0; x; x /= 10) {
			num[++*num] = x % 10;
		}
		while (*num){
			putchar(num[*num] ^ '0');
			--*num;
		}
	}

	template<typename T>
	inline void print(T x, char ch = '\n') {
		print_(x);
		putchar(ch);
	}

	inline void printStr_(const char *s, int n = -1) {
		if (n == -1) {
			n = strlen(s);
		}
		for (int i = 0; i < n; ++i) {
			putchar(s[i]);
		}
	}

	inline void printStr(const char *s, int n = -1, char ch = '\n') {
		printStr_(s, n);
		putchar(ch);
	}
}
using namespace IO;

long long n, ans;

void check(long long m) {
	if (m > 0 && (n / m) * (m + 1) == n) {
		ans += m;
	}
}

int main() {
	read(n);
	for (int i = 1; 1ll * i * i <= n; ++i) {
		if (n % i == 0) {
			check(i - 1);
			if (1ll * i * i < n) {
				check(n / i - 1);
			}
		}
	}
	print(ans);
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, s, n) for (int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int a;
  cin >> a;
  cout << a + a * a + a * a * a << endl;
  return 0;
}

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

int main() {
  int N;
  string S, T;
  cin >> N >> S >> T;

  string res(N * 2, 'a');
  rep(i, N) {
    res[i * 2] = S[i];
    res[i * 2 + 1] = T[i];
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int t, p, r;
    while (cin >> t >> p >> r && t){
        vector<pair<P, int> > a(t);
        REP(i,t) a[i].second = i+1;
        int w[50][10] = {};
        while (r--){
            int x, y, z;
            string s;
            cin >> x >> y >> z >> s;
            x--;
            y--;
            if (s == "WRONG"){
                w[x][y]++;
            }else{
                a[x].first.first--;
                a[x].first.second += z + 1200 * w[x][y];
            }
        }
        sort(a.begin(), a.end());
        REP(i,t){
            printf("%d %d %d\n", a[i].second, -a[i].first.first, a[i].first.second);
        }
    }
    return 0;
}

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

int main() {
    int64_t n;
    cin >> n;
    vector<int64_t> a(n), b(n);
    for (auto& e : a) cin >> e;
    for (auto& e : b) cin >> e;

    int ans = 0;
    for (int64_t i = 0; i < 29; i++) {
        vector<int> mb(n);
        transform(begin(b), end(b), begin(mb), [&](auto e) { return e % (1l << (i + 1)); });
        sort(begin(mb), end(mb));

        int64_t cnt = 0;
        for (auto& e : a) {
            int64_t ma = e % (1l << (i + 1));
            auto flitr = lower_bound(begin(mb), end(mb), (1l << i) - ma);
            auto fritr = lower_bound(begin(mb), end(mb), 2l * (1l << i) - ma);
            auto slitr = lower_bound(begin(mb), end(mb), 3l * (1l << i) - ma);
            auto sritr = lower_bound(begin(mb), end(mb), 4l * (1l << i) - ma);
            cnt += ((fritr - flitr) + (sritr - slitr));
        }

        ans += (cnt % 2) << i;
    }

    cout << ans << endl;
}


Measured memory_bytes: 4208
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = Integer.parseInt(sc.next());
		int A = Integer.parseInt(sc.next());
		int B = Integer.parseInt(sc.next());
		boolean flag = false;
		for (int i = A; i <= B; i++) {
			if (i % K == 0) {
				flag = true;
				break;
			}
		}
		if (flag) {
			System.out.println("OK");
		} else {
			System.out.println("NG");
		}
	}
}


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

int main (){
	int n;cin>>n;
	int n1=n/1000*10+n/100%10;
	int n2=n/10%10*10+n%10;
	if (n1>=1&&n1<=12){
		if (n2>=1&&n2<=12) cout<<"AMBIGUOUS"<<endl;
		else cout<<"MMYY"<<endl;
	}else{
		if (n2>=1&&n2<=12) cout<<"YYMM"<<endl;
		else cout<<"NA"<<endl;
	}
	return 0;
}

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

long sumdig(long A)
{
    long sum=0,rem;

    while(A>0)
    {
        rem=A%10;
        A=A/10;
        sum+=rem;
    }

    return sum;
}

int main()
{
    long N,A,B,ans=INT_MAX;
    cin>>N;
    A=1;
    B=N-A;

    while(B>= N/2)
    {
      ans= min(ans,sumdig(A) + sumdig(B));

      A=A+1;
      B=B-1;
    }

    cout<<ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll l,r,ans=2019;
int main(){
    cin>>l>>r;
    for(int i=l;i<=min(l+2019,r);i++){
        for(int j=i+1;j<=min(l+2019,r);j++)
            ans=min(ans,1ll*i%2019*j%2019);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
// https://beta.atcoder.jp/contests/abc107

#define SUBMIT
#define DEBUG

#include <utility>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <sstream>
#include <map>

using namespace std;
using ui64 = unsigned long long;
using i64 = long long;

int main() {
#ifdef SUBMIT
    auto& stream = cin;
#else
    string program_input_str = R"(1 2 3 4
6 7 8 0
5 10 11 12
9 13 14 15
)";
    stringstream stream(program_input_str);
#endif
    int N, i;
    stream >> N >> i;

    cout << (N - i + 1) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long 
using namespace std;
const int maxn=110000;
int n,m;
int len=0;
vector<int> v[maxn];
struct node
{
  int x;
  int dist;
  int id;
}a[maxn];
int col[maxn][15];
int t;
inline void init()
{
  scanf("%d%d",&n,&m);
  for(int i=1;i<=m;i++)
  {
    int x,y;
    scanf("%d%d",&x,&y);
    v[x].push_back(y);
    v[y].push_back(x);
  }
  for(int i=1;i<=n;i++)
    v[i].push_back(i);
  scanf("%d",&t);
  for(int i=1;i<=t;i++)
    scanf("%d%d%d",&a[i].x,&a[i].dist,&a[i].id);
}
inline void dfs(int x,int dist,int id)
{
  if(dist==-1)
    return;
  if(col[x][dist])
    return;
  col[x][dist]=id;
  for(int i=0;i<v[x].size();i++)
  {
    int y=v[x][i];
    dfs(y,dist-1,id);
  }
}
inline void work_()
{
  for(int i=t;i>=1;i--)
    dfs(a[i].x,a[i].dist,a[i].id);
  for(int i=1;i<=n;i++)
    printf("%d\n",col[i][0]);
}
int main()
{
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	init();
	work_();
	//cout<<log(w)<<endl;
	return 0;
}


Measured memory_bytes: 14456
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
 
 
bool check(string a){
        for(int i=0; i<a.length()/2; i++){
                if(a[i] == a[a.length() - i - 1]){
                        continue;
                }else{
                        return false;
                }
 
        }
        return true;
 
}
 
 
 
int main(){
         ios::sync_with_stdio(false);    
        cin.tie(0);
        string s;
        cin>>s;
        int l = s.length();
        // cout<<l;
        if(check(s) && check(s.substr(0,(l-1)/2)) && check(s.substr((l+3)/2-1,(l-1)/2))){
                
                cout<<"Yes";
        }else{
                // cout<<check(s) <<check(s.substr(0,(l-1)/2-1))<< check(s.substr((l+3)/2-1,l-1));
                cout<<"No";
        }
 
 
 
 
        
        
 
 
 
       
                                
        
 
 
        return 0;
 
}

Measured memory_bytes: 256
x,y,z=map(int,input().split())
if x<y:
    if y>z:
        if z>x:
            print("Yes")
        else:
            print("No")
    else:
        print("No")
elif x>y:
    if y<z:
        if x>z:
            print("Yes")
        else:
            print("No")
    else:
        print("No")
else:
    print("No")


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <cmath>

using namespace std;

int smaller(int x, int y){
	if(x < y){
		return x;
	}
	return y;
}

int main(){
	int N, A, B;
	cin >> N >> A >> B;
	cout << smaller(A*N, B) << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  char c; cin >> c;
  if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')
    cout << "vowel" << endl;
  else
    cout << "consonant" << endl;
  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
 
#include <bits/stdc++.h> 
 
#define len(x) (int)((x).size())
#define endl '\n'
#define x first
#define y second
#define int long long
#define double long double
#define all(a) (a).begin(), (a).end()
 
#ifdef LOCAL
	#define dbg(x) cout << #x << " = " << x << endl;
#else 
	#define dbg(x)
#endif 
 
using namespace std;
 
void solve(); signed main() {
#ifdef LOCAL
    freopen("file1.txt", "r", stdin);                                       
    freopen("file2.txt", "w", stderr);
#endif
    srand(time(0));
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(10);
    solve();  	
}
 
const int MAXN = 2e5 + 10, INF = 1e18, MOD = 1e9 + 7;

void solve() {
    string s;
    cin >> s;
    int n = len(s);
    vector<int> a;
    for (int i = 0; i < n; ++i) {
        if (s[i] == '?') {
            a.push_back(-1);
        }
        else {
            a.push_back(s[i] - '0');
        }
    }

    vector<vector<int>> dp(n, vector<int>(13));
    if (a[0] == -1) {
        for (int r = 0; r < 10; ++r) {
            dp[0][r] = 1;
        }
    }
    else {
        dp[0][a[0]] = 1;
    }

    for (int i = 1; i < n; ++i) {
        if (a[i] == -1) {
            for (int num = 0; num < 10; ++num) {
                for (int r = 0; r < 13; ++r) {
                    for (int pr = 0; pr < 13; ++pr) {
                        if ((pr * 10 % 13 + num) % 13 == r) {
                            dp[i][r] += dp[i - 1][pr];
                            dp[i][r] %= MOD;
                        }
                    }
                }
            }
        }
        else {
            int num = a[i];
            for (int r = 0; r < 13; ++r) {
                for (int pr = 0; pr < 13; ++pr) {
                    if ((pr * 10 % 13 + num) % 13 == r) {
                        dp[i][r] += dp[i - 1][pr];
                        dp[i][r] %= MOD;
                    }
                }
            }
        }
    }

    cout << dp[n - 1][5] << endl;
}   

Measured memory_bytes: 14404
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>
#include <utility>
#include <sstream>
#include <numeric>
#include <iterator>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef pair<int, int> P;

int main(int argc, const char * argv[]) {
  ll x;
  cin >> x;
  ll tmp = 100;
  ll count = 0;
  while(tmp < x){
    tmp += tmp*0.01;
    count++;
  }
  cout << count << endl;
  return 0;
}


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

int main(){
  int N, x = 0, ans = 0;
  string S;
  cin >> N >> S;
  for(int i = 0; i < N; i++){
    if(S.at(i) == 'I') x++;
    else x--;
    ans = max(ans, x);
  }
  cout << ans << endl;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a;
    for(int i=0; i<n; i++){
        int aa;
        cin >> aa;
        a.push_back(aa);
    }

    int q;
    cin >> q;
    for(int i=0; i<q; i++){
        int b, e, k;
        cin >> b >> e >> k;
        cout << count(a.begin()+b, a.begin()+e, k) << endl;
    }
    return 0;
}


Measured memory_bytes: 3160
//
#include <vector>
#include <set>
#include <map>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
//
using ll = long long;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
#define outD(fpv) cout << setprecision(20) << fpv << endl;
inline void yes(bool cond) { cond ? puts("YES") : puts("NO"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
template<typename Type> inline void unique(Type& arr) { sort(arr); arr.erase(unique(arr.begin(), arr.end()), arr.end()); }
constexpr double BIGP = 1000000007L;
constexpr double INF_I = std::numeric_limits<ll>::max();
constexpr double INF_F = std::numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    ll A, B, C;
    cin >> A >> B >> C;
    cout << max(C - (A - B), 0LL);
    //
    return 0;
}

Measured memory_bytes: 3660
#include<stdio.h>
 
 int main(){
int a,c,d;
char b,op;
while(1){
scanf("%d %c %d",&a,&op,&c);
if ( op== '+' ){
d=a+c;
} else if ( op == '-' ){
d=a-c;
} else if ( op == '*' ){
d=a*c;
} else if ( op == '/' ){
d=a/c;
} else {
break;
}

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

Measured memory_bytes: 600
#include <stdio.h>
#include <algorithm>
int s[10][10],v,e,t1,t2;
using namespace std;
main()
{
    scanf("%d %d",&v,&e);
    for(int i=0;i<e;i++)
    {
        scanf("%d %d",&t1,&t2);
        s[t1][t2]=1;
        s[t2][t1]=1;
    }
    int arr[v];
    for (int i=0;i<v;i++)
    {
        arr[i]=i+1;
    }
    bool p=true;
    int cnt=0;
    do
    {
        p=true;
        if(arr[0]!=1) break;
        for (int i=0;i<v-1;i++)
        {
            if(s[arr[i]][arr[i+1]]==1);
            else
            {
                p=false;
                break;
            }
        }
        if(p==true) cnt++;
    }while (next_permutation(arr,arr+v));
    printf("%d\n",cnt);
}


Measured memory_bytes: 128
S = input()

def is_rotate(s: str) -> bool:
    is_r = True
    for i in range(len(s)//2):
        if s[i] != s[len(s)-1-i]:
            is_r = False
    #print(s, is_r)
    return is_r

N = len(S)
ans = 'No'
if is_rotate(S) and is_rotate(S[:(N-1)//2]) and is_rotate(S[(N+3)//2 - 1:]):
    ans = 'Yes'

print(ans)


Measured memory_bytes: 38256
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        long n = sc.nextLong();
        long sqrt = (long) Math.sqrt(n);
        for(long i = sqrt; i > 0; i--){
            if(n % i == 0) {
                System.out.println(n/i + i - 2);
                return;
            }
        }
    }
}

Measured memory_bytes: 23764
#include <stdio.h>

int is_winner(int turn, int *having_amount, int mayors) {
    int zero_condition = 1;
    int i;
    for (i = 0; i < mayors; i++) {
        if (i != turn) {
            zero_condition = zero_condition & (having_amount[i] == 0);
        }
    }
    return zero_condition;
}

int main(void) {
    int mayors;
    int pebbles_in_bowl;
    int i;

    while (1) {
        scanf("%d %d", &mayors, &pebbles_in_bowl);
        if (mayors == 0 && pebbles_in_bowl == 0)
            break;
        else {
            int turn = 0;
            int having_amount[mayors];

            // initialize
            for (i = 0; i < mayors; i++) {
                having_amount[i] = 0;
            }

            while (1) {
                if (pebbles_in_bowl == 0) {
                    pebbles_in_bowl += having_amount[turn];
                    having_amount[turn] = 0;
                }
                else if (pebbles_in_bowl == 1) {
                    if (is_winner(turn, having_amount, mayors)) {
                        printf("%d\n", turn);
                        break;
                    } else {
                        having_amount[turn]++;
                        pebbles_in_bowl--;
                    }
                } else {
                    having_amount[turn]++;
                    pebbles_in_bowl--;
                }

                // go to the next turn
                if (turn == mayors-1) {
                    turn = 0;
                } else {
                    turn++;
                }
            }
        }
    }

    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
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; }


int main() {
    ll n, k, a;
    cin >> n >> k;
    vector<ll> num;
    map<ll, ll> d;
    rep1(i, k){
        cin >> a;
        d[a]++;
    }
    for (ll i=n; i<n*10+1; i++){
        ll num = i;
        bool judge = true;
        while (num>0){
            ll res = num % 10;
            if (d[res]>0) judge = false; 
            num /= 10;
        }
        if (judge){
            cout << i << endl;
            return 0;
        }
    }
    //priantf("%.12f", ans);
}

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

int main(){
  int n;
  cin >> n;
  int a[n];
  for(int i=0;i<n;i++)
    cin >> a[i];
  int ans=1, flag=0;
  for(int i=1;i<n;i++){
    for(int j=0;j<i;j++){
      	if(a[j]<=a[i]){
          flag=1;
        }
      else{
      flag=0;
      break;
      }
    }
    if(flag)
      	ans++;
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> dp(n),v;
    for( int i = 0; i < n; i++)
    {
        int b;
        cin >> b;
        v.push_back(b);
    }
    dp[0]=0;
    dp[1]=abs(v[0]-v[1]);
    for( int i = 2; i < n; i++)
    {
        int val;
        dp[i]=min(dp[i-1]+abs(v[i-1]-v[i]),dp[i-2]+abs(v[i-2]-v[i]));
    }
    cout << dp[n-1];
}



Measured memory_bytes: 1276
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define maxn 303
#define maxm 303
#define pb push_back
#define MOD 1000000007
using namespace std;
long long dp[maxn][maxn][maxn];
typedef pair<int,int> ii;
vector<ii> cond[maxm];
main(){
	int N,M,a,b,c;
	cin >> N >> M;
	For(i,1,M){
		cin >> a >> b >> c;
		cond[b].pb(ii(a,c));
	}
//	cout << "--";
	long long ans = 0;
	dp[0][0][0] = 1;
	For(i,0,N){
		For(j,0,N){
			For(k,0,N){
				int r = max(i,max(j,k));
				For(t,1,cond[r].size()){
					int l = cond[r][t-1].first;
					int v = cond[r][t-1].second;
					int numColor = (i>=l)+(j>=l)+(k>=l);	
					if(numColor != v){
						dp[i][j][k] = 0;
						break;
					}
				}			
				if(dp[i][j][k] == 0)	continue;
				if(r==N) {
					ans = (ans+ dp[i][j][k])%MOD;
					continue;
				}
				(dp[r+1][j][k] += dp[i][j][k]) %= MOD;
				(dp[i][r+1][k] += dp[i][j][k]) %= MOD;
				(dp[i][j][r+1] += dp[i][j][k]) %= MOD;
			}
		}
	}
	cout << ans;
}

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pll> pip;
const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS  = 1e-9;

int main() {
	string s; cin >> s;
	
	int c = count(ALL(s), 'p');
	int n = s.size() / 2;
	
	cout << -c + n << endl;
	
	return 0;
}


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

using namespace std;

typedef int64_t i64;

int main() {
  i64 N, M;
  cin >> N >> M;
  vector<i64> H(N);
  for (i64 i = 0; i < N; i++) {
    cin >> H[i];
  }
  vector<i64> Good(N, 1);
  for (i64 i = 0; i < M; i++) {
    i64 a, b;
    cin >> a >> b;
    if (H[a-1] > H[b-1]) {
      Good[b-1] = 0;
    } else if(H[a-1] < H[b-1]) {
      Good[a-1] = 0;
    } else {
      Good[b-1] = Good[a-1] = 0;
    }
  }
  i64 r;
  r = accumulate(Good.begin(), Good.end(), 0);
  cout << r << endl;
}


Measured memory_bytes: 4828
N, M=map(int, input().split())

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
      
    def main(self):
      return max([len(self.members(r)) for r in self.roots()])
uf = UnionFind(N)

for _ in range(M):
  A, B  = map(int, input().split())
  uf.union(A-1,B-1)
  
print(-min(uf.parents))


Measured memory_bytes: 14528
from itertools import permutations
N = int(input())
ps = list(map(int, input().split()))
qs = list(map(int, input().split()))

xs = [i+1 for i in range(N)]
perms = permutations(xs,N)
cntp = cntq = 0
for i,(perm) in enumerate(perms):
    
    if list(perm) == ps: cntp = i
    if list(perm) == qs: cntq = i
print(abs(cntp-cntq))

Measured memory_bytes: 3188
n = int(input())
S = [input() for i in range(n)]

ans = 0
a_cnt = 0
b_cnt = 0
ba_cnt = 0
for i in range(n):
    ans+=S[i].count('AB')
    if S[i][0]=='B' and S[i][-1]=='A':
        ba_cnt+=1
    elif S[i][-1]=='A':
        a_cnt+=1
    elif S[i][0]=='B':
        b_cnt+=1

print(ans+min(a_cnt,b_cnt)+ba_cnt-1*(ba_cnt>0 and a_cnt==b_cnt==0))

Measured memory_bytes: 3700
package main

import (
  "strings"
  "fmt"
)

func main() {
  var s string
  fmt.Scanf("%s", &s)
  
  ans := "Yes"
  if !strings.Contains(s, "a") {
    ans = "No"
  }
  if !strings.Contains(s, "b") {
    ans = "No"
  }
  if !strings.Contains(s, "c") {
    ans = "No"
  }
  fmt.Printf("%s\n", ans)
}

Measured memory_bytes: 1836
import java.util.Scanner;

public class Main{

    public static void main(String[] args) {
        
        Scanner scan = new Scanner(System.in);
        char[] c1 = scan.nextLine().toCharArray();
        char[] c2 = scan.nextLine().toCharArray();
        char[] c3 = scan.nextLine().toCharArray();

        System.out.println(String.valueOf(c1[0]) + String.valueOf(c2[1]) + String.valueOf(c3[2]));
        
        scan.close();
    
    }

}

Measured memory_bytes: 23764