akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////

int main(){fastio
    ll n,k;cin>>n>>k;
    ll a[n];rep(i,0,n-1)cin>>a[i];
    ll sum[1<<n];memset(sum,0,sizeof(sum));
    rep(i,0,(1<<n)-1){
        rep(j,0,n-1){
            if((i>>j)&1)sum[i]+=a[j];
        }
    }
    bool f[1<<n];memset(f,false,sizeof(f));
    rep(i,0,(1<<n)-1){
        if(sum[i]==k)f[i]=true;
    }
    rep(i,0,(1<<n)-1){
        if(f[i]){
            rep(j,0,n-1){
                f[i|(1<<j)]=true;
            }
        }
    }
    ll ans=0;
    /*
    rep(i,0,(1<<n)-1){
        rep(j,0,n-1){
            if((i>>j)&1)cout<<1;
            else cout<<0;
        }cout<<":"<<f[i]<<endl;
    }*/
    rep(i,0,(1<<n)-1){
        if(!f[i]){
            ll c=0;
            rep(j,0,n-1){
                if((i>>j)&1)c++;
            }
            Max(ans,c);
        }
    }
    cout<<n-ans<<endl;
    
    return 0;
}



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

int dp[100010][3];
vector<int> v[100010];
int s, t;
int n, m;

int main()
{
    cin >> n >> m;
    REP(i, m)
    {
        int x, y;
        cin >> x >> y;
        v[x].push_back(y);
    }
    cin >> s >> t;
    queue<P> que;
    que.push(P(s, 1));
    dp[s][0] = 1;
    while (!que.empty())
    {
        P p = que.front();
        que.pop();
        if (p.first == t && (p.second + 2) % 3 == 0)
        {
            cout << (p.second + 1) / 3 << endl;
            return 0;
        }
        int step = (p.second + 3) % 3;
        for (auto i : v[p.first])
        {
            if (dp[i][step])
            {
                continue;
            }
            else
            {
                dp[i][step] = p.second + 1;
                que.push(P(i, p.second + 1));
            }
        }
    }
    cout << -1 << endl;
}

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

int main() {
  string s;
  cin >> s;
  
  int st = 0, ed = s.size() - 1;
  while (s[st] != 'A') {
    st++;
  }
  while (s[ed] != 'Z') {
    ed--;
  }
  
  cout << ed - st + 1<< endl;
}


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

int main(){
    long int N,C;
    //max1 = 0,max2=0,max3=0,max4=0,res1=0,res2=0,res3=0,res4=0;
    long int maxr=-1,maxl=-1;
    cin >> N >> C;
    unsigned long int x[N+2],v[N],sumr[N+1],suml[N+1];
    long int maxl1[N+1],maxr1[N+1];
    //3=N 20=C
    x[0]=0;
    x[N+1]=C;
    for (long int i =0; i < N; i++){
        cin >>x[i+1]>>v[i];
    } 
    //sum of right rotation
    sumr[0] = 0;
    for(long int i = 1;i<=N;i++){
        sumr[i]=sumr[i-1]+v[i-1];
    }
    
    //sum of left rotation
    suml[0] = 0;
     for(long int i = 1;i<=N;i++){
        suml[i]=suml[i-1]+v[N-i];
    }   
    
    maxl1[0]=0;
    for(long int J = 1;J<=N;J++){
       //
        long int maxl0 = suml[J] - C + x[N+1-J]; 
        maxl1[J] = max(maxl1[J-1],maxl0);
    }
    

    for(long int I= 0;I<=N;I++){
        //J=0
        long int res=sumr[I]+suml[0];
        res -= x[I];
        if(maxr<res) maxr =res;
        res = sumr[I]-x[I]*2;
        res += maxl1[N-I];
        if(maxr<res)             maxr =res;
//        cout << "maxr: "<< res <<endl;
        
    }
    
    maxr1[0]=0;
    for(long int I = 1;I<=N;I++){
       //
        long int maxr0 = sumr[I] - x[I]; 
        maxr1[I] = max(maxr1[I-1],maxr0);
    }
    

    for(long int J = 0;J<=N;J++){
        //I=0
        long int res=suml[J]+sumr[0];
        res -= C - x[N+1-J];
        if(maxl<res) maxl = res;
        res = suml[J]-2*C+2*x[N+1-J];
        res += maxr1[N-J];
        if(maxl<res) maxl =res;
//        cout << "maxl: " << res << endl;
    }
 
    cout << max(maxr,maxl) << endl;
}


Measured memory_bytes: 4992
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int h = in.nextInt();
        int w = in.nextInt();
        int m = in.nextInt();
        int[] row = new int[h];
        int[] col = new int[w];
        ArrayList<Pair> list = new ArrayList<>(m);
        HashMap<Integer, Integer> map = new HashMap<>();
        for(int i=0; i<m; i++) {
            int x = in.nextInt() - 1;
            int y = in.nextInt() - 1;
            list.add(new Pair(x, y));
            row[x]++;
            col[y]++;
            map.put(convert(x, y, w), 1);
        }
        int max = 0, colIndex = 0, rowIndex = 0, colMax = 0, rowMax = 0;
        for(int i=0; i<h; i++) {
            if(row[i] > rowMax) {
                rowIndex = i;
                rowMax = row[i];
            }
        }
        for(int i=0; i<w; i++) {
            if(col[i] > colMax) {
                colMax = col[i];
                colIndex = i;
            }
        }
        for(int i=0; i<w; i++) {
            if(map.containsKey(convert(rowIndex, i, w)))
                max = Math.max(max, row[rowIndex] + col[i] - 1);
            else
                max = Math.max(max, row[rowIndex] + col[i]);
        }
        for(int i=0; i<h; i++) {
            if(map.containsKey(convert(i, colIndex, w)))
                max = Math.max(max, row[i] + col[colIndex] - 1);
            else
                max = Math.max(max, row[i] + col[colIndex]);
        }
        System.out.println(max);
        in.close();
    }

    static int convert(int i, int j, int w) {
        return i*w + j;
    }

    static class Pair {
        Integer i, j;

        Pair(int i, int j) {
            this.i = i;
            this.j = j;
        }

        Pair() {}

        public int hashCode() {
            return 31 * i.hashCode() + j.hashCode();
        }
    }
}


Measured memory_bytes: 90028
#include <bits/stdc++.h>
#define db(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl
#define ll long long
#define ld long double
#define pll pair<ll, ll>
#define MOD 1000000007
using namespace std;
const long long INF = 3*1e18;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    string S;
    cin >> S;
    int countA = 0, countB = 0;
    for(int i = 0; i < S.size(); i++)
        if(S[i] == 'A') countA++;
        else countB++;
    if(countA == 3 || countB == 3) cout << "No\n";
    else cout << "Yes\n";
}

Measured memory_bytes: 256
n=int(input())
a=[[int(i) for i in input().split()] for m in range(n)]
import itertools
import math
p=list(itertools.permutations(range(n),n))
total=0
for i in p:
    tmp=0
    for j in range(n-1):
        x=(a[i[j]][0]-a[i[j+1]][0])**2+(a[i[j]][1]-a[i[j+1]][1])**2
        x=x**0.5
        tmp+=x
    total+=tmp
print(total/math.factorial(n))

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

const int MOD = 1e9+7;

int mod_pow(int x, int pow) {
	if(pow == 0) return 1;
    int a = mod_pow(x, pow / 2);
    a = a * a % MOD;
    if(pow % 2 == 1) a *= x;
    return a % MOD;
}

int calc_div(int a, int b) {
	return a * mod_pow(b, MOD - 2) % MOD;
}

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

	int n, a, b;
	cin >> n >> a >> b;
	int com_all = mod_pow(2, n) - 1;

	int com_a = 1, com_b = 1;
	ll all = mod_pow(2, n) - 1;

    for (int i = 1; i <= a; i++) {
        com_a *= (n + 1) - i, com_a %= MOD;
        com_a = calc_div(com_a, i), com_a %= MOD;
    }
    for (int i = 1; i <= b; i++) {
        com_b *= (n + 1) - i, com_b %= MOD;
        com_b = calc_div(com_b, i), com_b %= MOD;
    }

	int res = all - (com_a + com_b);
	cout << (res + MOD * 10) % MOD << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <numeric> // accumulate(begin,end,初期値)
#include <string>

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<x<<endl
#define rep(i,n) for(ll i = 0;i < n;++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0)

const ll INF = 1e9+7;

// 各桁の和
template<typename T>T digit(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;}
template<typename T>T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}
ll bikkuri(ll n){
  if(n == 2)return 1;
  ll tmp = 3;
  for(ll i = 4;i <= n;++i){
  	tmp *= i;
  }
  return tmp;
}
int main(){
  int n;cin>>n;
  vector<string> s(n);
  map<string,ll> m;
  rep(i,n){
    cin>>s[i];
    sort(all(s[i]));
  }
  sort(all(s));
  for(auto S:s){
    m[S]++;
  }
  ll ans = 0;
  for(auto x:m){
    ll tmp = x.se;
    ans+=tmp*(tmp-1)/2;
  }
  print(ans);
  return 0;
}


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

//#define Fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
typedef vector<int>Vl;
typedef pair<int,int>PII;
typedef vector<PII>Vll;
typedef vector<pair<int,pair<int,int> > >Vlll;
typedef priority_queue<int>PQL;
typedef map<int,int>MP;
#define S second
#define F first
#define mp make_pair
#define ms(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define sl(n) scanf("%lld",&n)
#define pl(n) printf("%lld",n)
const int mod=1e9+7;
const int sze=1e5+2;
signed main(){
 int n,m;
 sl(n);sl(m);
 bool visited[n+1];
 map<int,int>mp;
 ms(visited,false);
 int correct=0;
 for(int i=1;i<=m;i++){
	 int pi;
	 string str;
	 cin>>pi>>str;
	 if(str=="WA" && !visited[pi])mp[pi]++;
	 else if(!visited[pi] && str=="AC") {
		 visited[pi]=true;
		 correct++;
	 }
 }
 int inco=0;
 for(auto it:mp){
	 if(visited[it.F])inco+=it.S;
	 
 }
 cout<<correct<<" "<<inco<<endl;
}


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

int Q = 0;
int N = 0;
struct Pos
{
	int in;
	int out;
}POS;

struct Proc
{
	char name[11];
	int time;
}PQ[100000+1];

int enQueue(Proc p)
{
	int temp = POS.in + 1;
	if (temp > N)
	{
		temp = 0;
	}
	if (POS.out == temp)
	{
		//printf("Err: Queue Over Run\n");
		return -1;
	}
	POS.in = temp;
	PQ[POS.in]= p;
	return 0;
}

int deQueue(Proc *p)
{
	if (POS.out == POS.in)
	{
		//printf("Err: Queue is Empty.\n");
		return -1;	// empty
	}
	POS.out++;
	if (POS.out > N)
	{
		POS.out = 0;
	}
	*p = PQ[POS.out];
	return 0;
}

void initializeQueue()
{
	POS.in = 0;
	POS.out = 0;
}

int main()
{
	initializeQueue();

	cin >> N >> Q;
	for (int i = 0; i < N; i++)
	{
		Proc inputP;
		cin >> inputP.name >> inputP.time;
		if (enQueue(inputP) < 0)
		{
			return -1;
		}
	}

	int time = 0;
	Proc p;
	while (deQueue(&p) == 0)
	{
		if (p.time <= Q)
		{
			time = time + p.time;
			cout << p.name << " " << time << endl;
		}
		else
		{
			time = time + Q;
			p.time = p.time - Q;
			enQueue(p);
		}
	}

	return 0;
}

Measured memory_bytes: 3812
def main():
    k, n = map(int, input().split())
    a = list(map(int, input().split()))
    cost = 10**10
    for i in range(n-1):
        cost = min(cost, k - abs(a[i]-a[i+1]))
    print(min(cost, k-abs(a[0]+k-a[n-1])))

if __name__ == "__main__":
    main()

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

using namespace std;
using ll = long long;
using ii = pair<int, int>;

const int MAX { 200010 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

struct Restaurant {
    string city;
    int score, id;
};

vector<int> solve(int N, vector<Restaurant>& xs)
{
    sort(xs.begin(), xs.end(), [](const Restaurant& a, const Restaurant& b) {
        if (a.city == b.city)
            return a.score > b.score;

        return a.city < b.city;
    });

    vector<int> ans(N);

    for (int i = 0; i < N; ++i)
        ans[i] = xs[i].id;

    return ans;
}

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

    int N;
    cin >> N;

    vector<Restaurant> xs(N);

    for (int i = 0; i < N; ++i)
    {
        cin >> xs[i].city >> xs[i].score;
        xs[i].id = i + 1;
    }

    auto ans = solve(N, xs);

    for (auto x : ans)
        cout << x << '\n';

    return 0;
}


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

int main()
{
    int a,b,c,x,ans;
    cin >> a >> b >> c >> x;
    
    for(int i = 0; i <= a; i++)
    {
        
        for(int j = 0; j <= b; j++)
        {
            
            for(int k = 0; k <= c; k++)
            {
                if(500*i+100*j+50*k == x)ans++;
            }
            
        }
        
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import sys

l = raw_input().split()
N = int(l[0])
M = int(l[1])

AB = [[0 for i in range(2)] for j in range(N)]

for n in range(N):
    l = raw_input().split()
    AB[n][0] = int(l[0])
    AB[n][1] = int(l[1])

ab = sorted(AB, key=lambda a: a[0])
#print(ab)

sum = 0
drinks = 0
for n in range(N):
    a = ab[n]
    if drinks + a[1] < M:
        sum += a[0] * a[1]
        drinks += a[1]
    else:
        num = M - drinks
        sum += a[0] * num
        drinks += num
        break

print(sum)


Measured memory_bytes: 27124
exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']

require 'prime'

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

def big(a,b) return (a>b)? a:b end

def small(a,b) return (a<b)? a:b end

m1,d1 = inp
m2,d2 = inp
puts (m1 == m2)? 0 : 1



Measured memory_bytes: 4920
<?php
// BFSで解いてみる（多点スタートな最短経路問題）
list($h, $w) = ints();
$q = new SplQueue(); // キューを用意
$dist = array_fill(0, $h, array_fill(0, $w, -1)); // 距離を格納する配列（-1の場合はその頂点が未発見）
for ($i = 0; $i < $h; ++$i) {
    list($s[$i]) = strs();
    for ($j = 0; $j < $w; ++$j) {
        if ($s[$i][$j] === '#') {
            // 多点をスタートとして扱う
            $dist[$i][$j] = 0;
            $q->enqueue([$i, $j]);
        }
    }
}
$dy = [1, 0, -1, 0];
$dx = [0, 1, 0, -1];
// BFS
while (!$q->isEmpty()) {
    list($y, $x) = $q->dequeue();
    for ($dir = 0; $dir < 4; ++$dir) {
        $ny = $y + $dy[$dir];
        $nx = $x + $dx[$dir];
        if ($ny > $h - 1 || $ny < 0 || $nx > $w - 1 || $nx < 0) continue; // 範囲外
        if ($dist[$ny][$nx] !== -1) continue; // 発見済み
        $dist[$ny][$nx] = $dist[$y][$x] + 1;
        $q->enqueue([$ny, $nx]);
    }
}
$max = 0;
for ($i = 0; $i < $h; ++$i) $max = max($max, max($dist[$i]));
echo $max;
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}
function strs()
{
    return explode(' ', trim(fgets(STDIN)));
}


Measured memory_bytes: 456328
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


int main(){
    
    int a,b;
    cin >> a >> b;
    ll ans = 0;
    if(a > b){
	ans += a;
	a--;
    }else{
	ans += b;
	b--;
    }
    if(a > b){
	ans += a;
	a--;
    }else{
	ans += b;
	b--;
    }
    P(ans);
    
	   
    return  0;
}


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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;

template <typename T>
istream& operator>> (istream &f, vector<T> &a){
    for(auto &el : a){ f >> el; }
    return f;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector<string> a(n);
    cin >> a;
    sort(a.begin(), a.end());
    for(auto &el : a){
        cout << el;
    }
}

Measured memory_bytes: 256
import bisect
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

waa=[0 for i in range(n+1)]
wab=[0 for i in range(m+1)]
for i in range(1,n+1):
  waa[i]=waa[i-1]+a[i-1]
for i in range(1,m+1):
  wab[i]=wab[i-1]+b[i-1]

ans=0
for i in range(n+1):
  idx=0
  if waa[i]>k:
    break
  idx=bisect.bisect_right(wab,k-waa[i])
  ans=max(ans,i+idx-1)
print(ans)

Measured memory_bytes: 132676
import sys, math
from functools import lru_cache
from collections import deque
sys.setrecursionlimit(500000)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]


def main():
    S = input()
    for i in range(1, 6):
        if S == 'hi'*i:
            print('Yes')
            return
    print('No')


if __name__ == '__main__':
    main()

Measured memory_bytes: 67356
#define INF 10000000000
#define MOD 1000000007

#if 1   // use_templates

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <algorithm>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, up) for (ll i = 0; i < up; ++i)
#define repp(i, up) for (ll i = 0; i <= up; ++i)
#define rrep(i, lo, up) for (ll i = lo; i < up; ++i)
#define rrepp(i, lo, up) for (ll i = lo; i <= up; ++i)
#define eep(i, lo, up) for ((i) = (lo); (i) < (up); ++(i))
#define eepp(i, lo, up) for ((i) = (lo); (i) <= (up); ++(i))


ll gcd(ll a, ll b);

ll gcd(ll a, ll b)
{
    if (a < b) {
        return gcd(b, a);
    }
    ll r;
    while (r = a % b) {
        a = b;
        b = r;
    }
    return b;
}

#endif  // end of use_templates


int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n + 1, 1);
    vector<ll> b(n + 1);
    repp(i, n) {
        b[i] = i;
    }
    for (ll i = 2; i * i <= n; ++i) {
        if (a[i] > 1) {
            continue;
        }
        for (ll j = i; j <= n; j += i) {
            ll cnt = 0;
            while (b[j] % i == 0) {
                b[j] /= i;
                ++cnt;
            }
            a[j] *= cnt + 1;
        }
    }
    ll result = a[1];
    rrepp(i, 2, n) {
        if (a[i] <= 1) {
            result += i * 2;
        } else if (b[i] == 1) {
            result += i * a[i];
        } else {
            result += i * a[i] * 2;
        }
    }
    cout << result << endl;
    return 0;
}


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

int L[500001], R[500001];
int cnt = 0;

void merge(int *A, int left, int mid, int right){
    int i;
    int n = mid - left + 1;
    int n2 = right - mid;
    for(i=0;i<n;i++) L[i] = A[left+i];
    for(i=0;i<n2;i++) R[i] = A[mid+i+1];
    L[n] = R[n2] = INT_MAX;
    int r=0, l=0;
    for(i=left;i<=right;i++){
        cnt++;
        if(L[l] <= R[r]){
            A[i] = L[l++];
        }else{
            A[i] = R[r++];
        }
    }
}

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

int main(){
    int n;
    cin >> n;
    int A[n];
    rep(i,n){
        cin >> A[i];
    }
    mergeSort(A,0,n-1);
    rep(i,n){
        cout << A[i];
        i==n-1 ? cout << endl : cout << " ";
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 6948
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
  int n,k,r,s,p,i,j,res=0;
  string t;
  bool f;
  cin >> n >> k >> r >> s >> p;
  cin >> t;
  for(i=0;i<k;i++){
    f=1;
    for(j=0;j*k+i<n;j++){
      if(!f&&t[j*k+i]==t[(j-1)*k+i]){
        f=1;
        continue;
      }
      f=0;
      if(t[j*k+i]=='r')
        res+=p;
      else if(t[j*k+i]=='s')
        res+=r;
      else
        res+=s;
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 512
//ALDS1_4D
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

bool IsAllocate(vector<int> packet, int allocate, int max_track) {
 int sum = 0;
 int num_track = 0;

 for (int i = 0; i < packet.size(); ) {
  if (sum + packet.at(i) <= allocate) {
   sum += packet.at(i);
   ++i;
  } else {
   ++num_track;
   if (num_track == max_track) {
    return false;
   }
   sum = 0;
  }
 }
 return true;
}

int main() {
 int num_packet, num_track;
 cin >> num_packet >> num_track;

 int max_weight = 0, sum_weight = 0;
 vector<int> packet(num_packet);
 for (int i = 0; i < num_packet; ++i) {
  cin >> packet.at(i);
  sum_weight += packet.at(i);
  max_weight = max(max_weight, packet.at(i));	
 }

 int low = max_weight;
 int high = sum_weight;

 while (low < high) {
  int alloc = (low + high) / 2;
  if (IsAllocate(packet, alloc, num_track)) {
   high = alloc;
  } else {
   low = alloc + 1;
  }

 }
 cout << low << '\n';

 return 0;
}

Measured memory_bytes: 1800
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9+ 7;
const int INF = numeric_limits<int>::max() - 1e8;
const ll INFLL = numeric_limits<ll>::max() - 1e17;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    cin >> A;
    int ans = 0;
    function<void(int, int)> dfs = [&](int idx, int before) {
        before %= 2;
        if (idx == N) {
            if (before == 0) ans++;
            return;
        }
        for (int i = -1; i <= 1; i++) dfs(idx + 1, before * (A[idx] + i));
    };
    for (int i = -1; i <= 1; i++) dfs(1, (A[0] + i) % 2);
    cout << ans << endl;
}

Measured memory_bytes: 256
ary = []
ARGF.each do |line|
  m, f, r = line.split.map(&:to_i)
  break if (m + f + r) == -3
  sum = m+f
  if (m < 0 || f < 0) || sum < 30
    ary << "F"
  elsif sum >= 80
    ary << "A"
  elsif sum >= 65 && sum < 80
    ary << "B"
  elsif sum >= 50 && sum < 65
    ary << "C"
  elsif r >= 50
    ary << "C"
  else
    ary << "D"
  end
end

puts ary

Measured memory_bytes: 6104
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define P pair<ll, ll>

/* ---------- Constants  */
const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const double PI = acos(-1);
// const double EPS = 1e-10;
// mt19937 mert(LL(time(0)));

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */

int const MAX_V = 100000;

int V, E;

vector<int> G[MAX_V];
int colors[MAX_V];

bool dfs(int v, int c) {
    colors[v] = c;

    for (int i = 0; i < G[v].size(); i++) {
        if (colors[G[v][i]] == c) return false;
        if (colors[G[v][i]] == 0 && !dfs(G[v][i], -c)) return false;
    }

    return true;
}


int main() {
    cin >> V >> E;

    for (int i = 0; i < E; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;

        G[a].push_back(b);
        G[b].push_back(a);
    }

    fill(colors, colors + V, 0);

    bool is_bin = dfs(0, 1);

    if (is_bin) {
        int minus_num = 0;
        int one_num = 0;
        for (int i = 0; i < V; i++) {
            if (colors[i] == 1) one_num++;
            if (colors[i] == -1) minus_num++;
        }

        ll ret = (ll)minus_num * (ll)one_num;
        cout << ret - (ll)E << endl;
    } else {
        cout << (ll)V * (ll)(V - 1) / 2LL - (ll)E << endl;
    }

    return 0;
}

Measured memory_bytes: 6528
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Security.Cryptography.X509Certificates;
using System.Text.RegularExpressions;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var r = int.Parse(Console.ReadLine());
            var l = Console.ReadLine().Split(' ');
            if (l.Any(x => x == "Y"))
            {
                Console.WriteLine("Four");
            }
            else
            {
                Console.WriteLine("Three");

            }
        }
    }
}

Measured memory_bytes: 13268
#include <iostream>

using namespace std;

int main(){
	int n;
	cin >> n;
	int a,b;
	while(n){
	a = b = 0;
	for(int i = 0; i < n; i++){
		int x,y;
		cin >> x >> y;
		if(x < y) b+=x+y;
		else if(y<x) a+=x+y;
		else{
			a += x;
			b += y;
		}
	}
	cout << a << " " << b << endl;
	cin >> n;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007
#define INF 1000000000000
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

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

int64_t N, M; cin >> N >> M;

if (N == 1) 
    if (M == 1)  cout << "1\n";
    else cout << M -2 << endl;
else  
    if (M == 1) cout << N - 2 << endl;
    else cout << (N - 2) * (M - 2) << endl;

}
// 書いて考える
// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る．境界に注意．求めたい量の変域．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり



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

#define MEM(a, b) memset(a, b, sizeof a);
#define REP(i, k) for(int i = (0); i < (k); i++ )

#define ALL(cont) cont.begin(), cont.end()
#define RALL(cont) cont.begin(), cont.end()
#define FOREACH(it, l) for(auto it=l.begin(); it != l.end(); it++)
#define mp make_pair
#define pb push_back
#define debug puts("FANGO")
#define INF (int)MAX_INT
#define EPS (int)1e-9
#define PI acos(-1)
#define MOD 1000000007

typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<piii> viii;
typedef long long int32;
typedef unsigned long long uint32;
typedef long long int int64;
typedef unsigned long long int uint64;

template <class T>
T sqr(T val) {
  return val * val;
}

void solve(__attribute__((unused)) int tc = 0) {
  //cout << "Test case " << tc << " : " << "\n";
  int a, b;
  cin >> a >> b;
  int maxi = 0;
  maxi += max(a, b);
  if (a > b) a--;
  else b--;
  maxi += max(a, b);
  cout << maxi << "\n";
  return;
}

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

  /*int TC;
  cin >> TC;
  REP(tc, TC) {
    solve(tc);
  }*/
  solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for (ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
bool chmin(ll& a, ll b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
bool chmax(ll& a, ll b) {
    if (b > a) {
        a = b;
        return 1;
    }
    return 0;
}
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;

int main() {
    cin >> h >> w;
    vl A;
    ll dp[h][w];
    rep(i, h) {
        rep(j, w) {
            dp[i][j] = INF;
            if (i == 0 ||	j == 0) dp[i][j] = 1;
            cin >> x;
            if (i > 0)chmin(dp[i][j],dp[i-1][j]+1);
            if (j > 0)chmin(dp[i][j],dp[i][j-1]+1);
            if (i > 0&&j>0)chmin(dp[i][j],dp[i-1][j-1]+1);
            if (x == 1) dp[i][j] = 0;
            ans = max(ans, dp[i][j]);
        }
    }

    cout << ans*ans << endl;
}



Measured memory_bytes: 18388
#include<set>
#include<map>
//#include<cmath>
#include<queue>
#include<bitset>
#include<string>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>

#define For(i,x,y) for (int i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define lf else if

#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> Vi;

int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}

const int N=2e6+19;
const int p=1e9+7;

int Pow(int a,int b){
	int res=1;
	for (;b;b>>=1,a=1ll*a*a%p) if (b&1) res=1ll*res*a%p;
	return res;
}

int fac[N],inv[N];
int x1,x2,x3,x4,x5,x6;
int y1,y2,y3,y4,y5,y6;
int ans,tmp;

int C(int n,int m){
	return 1ll*fac[n]*inv[m]%p*inv[n-m]%p;
}
int F(int a,int b,int c,int d){
	assert(a<=c&&b<=d);
	return C(c-a+d-b,c-a);
}
void Work(int a,int b,int c,int d,int f){
	tmp=0;
	For(i,y3,y4+1){
		tmp=(tmp-1ll*(x3+i)*F(x3,i,c,d)%p*F(a,b,x3-1,i))%p;
		tmp=(tmp+1ll*(x4+i+1)*F(a,b,x4,i)%p*F(x4+1,i,c,d))%p;
	}
	For(i,x3,x4+1){
		tmp=(tmp-1ll*(y3+i)*F(i,y3,c,d)%p*F(a,b,i,y3-1))%p;
		tmp=(tmp+1ll*(y4+i+1)*F(a,b,i,y4)%p*F(i,y4+1,c,d))%p;
	}
	tmp=(tmp+p)%p;
	if (f==1) ans=(ans+tmp)%p;else ans=(ans-tmp+p)%p;
}

int main(){
	fac[0]=1;
	For(i,1,N) fac[i]=1ll*fac[i-1]*i%p;
	inv[N-1]=Pow(fac[N-1],p-2);
	for (int i=N-1;i;i--) inv[i-1]=1ll*inv[i]*i%p;
	x1=IN(),x2=IN(),x3=IN(),x4=IN(),x5=IN(),x6=IN();
	y1=IN(),y2=IN(),y3=IN(),y4=IN(),y5=IN(),y6=IN();
	
	Work(x1-1,y1-1,x6+1,y6+1,1);
	Work(x1-1,y2,x6+1,y6+1,-1);
	Work(x2,y1-1,x6+1,y6+1,-1);
	Work(x2,y2,x6+1,y6+1,1);
	
	Work(x1-1,y1-1,x5,y6+1,-1);
	Work(x1-1,y2,x5,y6+1,1);
	Work(x2,y1-1,x5,y6+1,1);
	Work(x2,y2,x5,y6+1,-1);
	
	Work(x1-1,y1-1,x6+1,y5,-1);
	Work(x1-1,y2,x6+1,y5,1);
	Work(x2,y1-1,x6+1,y5,1);
	Work(x2,y2,x6+1,y5,-1);
	
	Work(x1-1,y1-1,x5,y5,1);
	Work(x1-1,y2,x5,y5,-1);
	Work(x2,y1-1,x5,y5,-1);
	Work(x2,y2,x5,y5,1);
	printf("%d\n",ans);
}

Measured memory_bytes: 16000
# include <bits/stdc++.h>
# define sz(x) (int)((x).size())
# define f first 
# define s second
# define pb push_back
# define ub upper_bound
# define lb lower_bound
# define all(x) x.begin(), x.end()
# define pqueue priority_queue
# define Speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
# define rep(i,n) for(int i=0;i<n;++i)
# define forn(i,n) for(int i=1;i<=n;++i)

using namespace std;

template<class T> void umin(T &a,T b){a=min(a,b);}
template<class T> void umax(T &a,T b){a=max(a,b);}

typedef long long ll;
typedef pair<int,int> pii;

const int inf=1e9,mod=1e9+7,N=2e5+5;

int pref[2][N];

void solve(){
	int n;
	cin>>n;
	int a[2][n+1];
	rep(i,2){
		forn(j,n){
			cin>>a[i][j];
			if(j==1){
				pref[i][j]=a[i][j];
			}
			else pref[i][j]=pref[i][j-1]+a[i][j];
		}
	}
	int ans=0;
	forn(i,n){
		umax(ans,pref[0][i]+pref[1][n-1]-pref[1][i-1]+a[1][n]);
	}
	cout<<ans;
	
}
int main(){
 	Speed();
	int T=1; 
	//cin>>T;	
	while(T--)solve();
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
const int N = 2e6 + 5;
int p[N], a[N], b[N];
struct node {
  int l, r, mid, mn;
} s[N << 2];
void build(int di, int l, int r) {
  s[di].l = l, s[di].r = r, s[di].mid = l + r >> 1, s[di].mn = 1e9;
  if (l == r) return;
  build(di << 1, l, s[di].mid), build(di << 1 | 1, s[di].mid + 1, r);
}
void ins(int di, int x, int v) {
  if (s[di].l == s[di].r) {
    s[di].mn = v;
    return;
  }
  if (x <= s[di].mid)
    ins(di << 1, x, v);
  else
    ins(di << 1 | 1, x, v);
  s[di].mn = min(s[di << 1].mn, s[di << 1 | 1].mn);
}
int qry(int di, int l, int r) {
  if (l <= s[di].l && s[di].r <= r)
    return s[di].mn;
  else if (r <= s[di].mid)
    return qry(di << 1, l, r);
  else if (l > s[di].mid)
    return qry(di << 1 | 1, l, r);
  return min(qry(di << 1, l, r), qry(di << 1 | 1, l, r));
}
struct edge {
  int to, nxt;
} e[N << 1];
int head[N], tot = 1;
void adde(int x, int y) {
  e[tot] = (edge){y, head[x]};
  head[x] = tot++;
}
priority_queue<int> q;
int n, rd[N];
void topo() {
  for (int i = 1; i <= n; i++)
    for (int j = head[i]; j; j = e[j].nxt) rd[e[j].to]++;
  for (int i = 1; i <= n; i++)
    if (!rd[i]) q.push(i);
  int tt = 0;
  while (!q.empty()) {
    int u = q.top();
    q.pop(), b[++tt] = u;
    for (int i = head[u]; i; i = e[i].nxt)
      if (!(--rd[e[i].to])) q.push(e[i].to);
  }
}
int main() {
  int k;
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x), a[x] = i;
  }
  for (int i = 1; i <= n / 2; i++) swap(a[i], a[n - i + 1]);
  build(1, 1, n);
  for (int i = n; i >= 1; i--) {
    int x = qry(1, max(1, a[i] - k + 1), a[i]);
    if (x >= 1 && x <= n) adde(a[i], a[x]);
    x = qry(1, a[i], min(n, a[i] + k - 1));
    if (x >= 1 && x <= n) adde(a[i], a[x]);
    ins(1, a[i], i);
  }
  topo();
  for (int i = 1; i <= n / 2; i++) swap(b[i], b[n - i + 1]);
  for (int i = 1; i <= n; i++) p[b[i]] = i;
  for (int i = 1; i <= n; i++) printf("%d\n", p[i]);
}


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

int main(void)
{
  int n;
  int cnt = 0;
  int i;
  char s[11], input[11], copy[21];
  
  scanf("%s%d", s, &n);
  for (i = 0; i < n; i++){
    scanf("%s", input);
    sprintf(copy, "%s%s", input, input);
    if (strstr(copy, s) != NULL){
      cnt++;
    }
  }
  
  printf("%d\n", cnt);
  
  return (0);
}

Measured memory_bytes: 616
#include<stdio.h>
int main()
{
	int a,b,c,d;
	while(scanf("%d %d %d %d",&a,&b,&c,&d)!=EOF)
	{
		if(a*b<=c*d)
			printf("%d\n", c*d);
		else if(a*b>c*d)
			printf("%d\n", a*b);
	}
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>

using namespace std;

int main(){
  while(true){
    int N,K;
    string ans = "Yes";
    cin >> N >> K;
    int S[K];
    if( N == 0 && K == 0 ) break;
    for(int i = 0; i < K; ++i){
      cin >> S[i];
    }
    for(int i = 0; i < N; ++i){
      for(int j = 0; j < K; ++j){
	int B; cin >> B; S[j] -= B;
      }
    }
    for(int i = 0; i < K; ++i){
      if( S[i] < 0 ){
	ans = "No";
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 908
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
#include <queue>
using namespace std;
#define DEB(variable) cout << #variable << '=' << variable << endl

#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

using llint = long long int;

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr long long int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    llint x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<llint> va(a), vb(b), vc(c);
    priority_queue<llint> aq, bq, cq;
    REP(i,a){
        cin >> va[i];
        aq.push(va[i]);
    }
    REP(i,b){
        cin >> vb[i];
        bq.push(vb[i]);
    }
    REP(i,c){
        cin >> vc[i];
        cq.push(vc[i]);
    }
    sort(va.begin(), va.end(), greater<llint>());
    sort(vb.begin(), vb.end(), greater<llint>());
    sort(vc.begin(), vc.end(), greater<llint>());
    llint atea = 0, ateb = 0, atec = 0, result = 0;

    while(atea+ateb+atec!=x+y){
        if(atea>=x){
            if(bq.top()>=cq.top()){
                result += bq.top();
                ateb++;
                bq.pop();
            }else{
                result += cq.top();
                atec++;
                cq.pop();
            }
        }else if(ateb>=y){
            if(aq.top()>=cq.top()){
                result += aq.top();
                atea++;
                aq.pop();
            }else{
                result += cq.top();
                atec++;
                cq.pop();
            }
        }else{
            if(cq.top()>bq.top()&&cq.top()>aq.top()&&!cq.empty()){
                result += cq.top();
                atec++;
                cq.pop();
            }else if(aq.top()>=bq.top()){
                result += aq.top();
                atea++;
                aq.pop();
            }else if(bq.top()>aq.top()){
                result += bq.top();
                ateb++;
                bq.pop();
            }
        }
    }
    cout<<result<<endl;
    return 0;
}


Measured memory_bytes: 5748
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

struct state{
	string s;
	int p,id;
};

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<state> g(n);
	rep(i,n){
		cin>>g[i].s>>g[i].p;
		g[i].id=i;
	}
	sort(begin(g),end(g),[](const state &a,const state &b){
		if(a.s!=b.s) return a.s<b.s;
		else return a.p>b.p;
	});
	rep(i,n){
		cout<<g[i].id+1<<endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;



int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

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

	cout << min(n*a, b) << "\n";
	
	
	return 0;
}

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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define pll pair<ll, ll>
#define vll vector<ll>

using namespace std;

const ll MOD = 1000000007;
const ll INF = (1LL << 60);

int main() {
  // std::cout << std::fixed << std::setprecision(10);
  ll N;
  scanf("%lld", &N);

  ll n = N % 10;

  if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9) {
    cout << "hon" << endl;
  }
  if (n == 0 || n == 1 || n == 6 || n == 8) {
    cout << "pon" << endl;
  }
  if (n == 3) {
    cout << "bon" << endl;
  }
}


Measured memory_bytes: 3764
#include<bits/stdc++.h>
using namespace std;
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
typedef long long ll;
struct dish{
  ll A,B;
  bool operator<(const dish &o) const {return A+B < o.A+o.B;}
  bool operator>(const dish &o) const {return A+B > o.A+o.B;}
};
int main(){
  ll N,i,ans = 0;scanf("%lld",&N);
  dish D[N];
  for(i=0;i<N;i++) scanf("%lld%lld",&D[i].A,&D[i].B);
  sort(D,D+N,greater<dish>());
  for(i=0;i<N;i++){
    if(i&1) ans -= D[i].B;
    else ans += D[i].A;
  }
  printf("%lld\n",ans);
}

Measured memory_bytes: 5400
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
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;}
const int P = 1000000007;
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z main.cpp
//.\a.exe

int main(void){ios::sync_with_stdio(false);cin.tie(0);
////////////////////////////////////////////////////////
int n,k,q;
cin >> n >> k >> q;
int a[q],b[n];
for(int i=0;i<n;i++){
   b[i]=0;
}
for(int i=0;i<q;i++){
   cin >> a[i];
}

for(int i=0;i<q;i++){
   b[a[i]-1]++;
}

for(int i=0;i<n;i++){
   b[i]=b[i]-q+k;
}
for(int i=0;i<n;i++){
   if(b[i]>0){
      cout << "Yes" << endl;
   }
   else{
      cout << "No" << endl;
   }
}
////////////////////////////////////////////////////////
return 0;}

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

using namespace std;

int main()
{
  int a,b;
  cin>>a>>b;
    int i;
  for( i=1; i <1500;i++)
  {
      int k = floor(i * 0.08);
      int j = floor(i*0.1);

      if(k == a && j == b)
      {
          
          break;
      }
      
  }
  if(i == 1500)
  {
      cout<<"-1";
  }
  else{
      cout<<i;
  }

  
}

Measured memory_bytes: 256