akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define pb push_back

using namespace std;

const int e = 2e5 + 69;

int main()
{
    int n, k;
    multiset<ll>s;
    cin >> n >> k;
    for(int i=1; i<=n; i++){
        ll x;
        cin >> x;
        s.insert(x);
    }
    ll ans = 0;
    for(auto j : s){
        ans += j;
        k --;
        if(k == 0){
            break;
        }
    }
    cout << ans;
}


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

int main() {
  string s;
  cin >> s;
  int n = s.size();
  if(s[n - 1] == 's')
    cout << s << "es";
  else
    cout << s << 's';
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;

int main()
{
	#ifndef ONLINE_JUDGE
	freopen(".in.txt", "r", stdin);
	freopen(".out.txt", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, k; cin >> n >> k;
	vector<int> a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	for(int i = k; i < n; i++) cout << (a[i] > a[i - k] ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 3988
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,v,n,i;
    cin>>a>>b>>c;
    int d=min(a,b);
    int e=max(a,b);
    int f=min(e,c);
    cout<<d+f<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>//printf("%.9f\n",*********);
#include<vector>//文字列.erase(n),vector
#include<algorithm>//next_permutation
#include<set>
#include<string>//char(小文字-32=大文字) to_string,string,char
#include<sstream>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>//min,max
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)//start==1
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)//end==1
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define Yay(ans) if(ans)cout<<"Yay!"<<rt;else cout<<":("<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//標準=昇順
#define reve(s) reverse(s.begin(),s.end())//反転
#define str string
#define please return
#define AC 0
#define rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define pi 3.1415926535897932384626//pi
#define nine 1000000000//10^9

using namespace std;
typedef vector<int> vint;
typedef long double ldouble;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

int SED(int n) { //Sum of Each Digit
	int sum = 0;
	while (n > 0) {
		sum += n % 10; n /= 10;
	}
	return sum;
}

unsigned ND(unsigned num) {//Number of Digits
	return std::to_string(num).length();//outmax=10
}//stringのほうが効率よくないか？

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */


int main(void) {
	rapid_pleaseAC_fast;

	double a;
	cin >> a;

	a /= 3;

	printf("%.15f\n", a * a * a);

	please AC;
}


Measured memory_bytes: 256
/*
AizuOnline A0005
GCD and LCM
*/
#include <stdio.h>


long int long_gcd(long int x,long int y)
{    long   int w;
     if (x < y)
       { w = x;
         x = y;
         y = w;
       }
  if(x % y == 0)
            return(y);
  else
            return(long_gcd(x % y,y));
  
}

main()
{
  long int a,b;
  long int lcm,gcd;

  while(EOF != scanf("%ld %ld",&a,&b))
        {
          gcd = long_gcd(a,b);
          lcm = (a/gcd)*b;
          printf("%ld %ld\n",gcd,lcm);

        }

        
      
return(0);
}

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

int main(){
	int a,b,c;
	
	cin >> a >> b >> c;
	if(b < c) swap(b,c);
	if(a < c) swap(a,c);
	if(a < b) swap(a,b);
	
	int x1 = a-b,x2 = a-c;
	if(x1%2==0&&x2%2==0) cout << x1/2+x2/2;
	else if(x1%2&&x2%2) cout << x1/2+x2/2+1;
	else cout << x1/2+x2/2+2;
}

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

int main() {
    int N;
    cin >> N;
    vector<ll>X(N);
    vector<ll>L(N);
    for (int i = 0; i < N; ++i) {
        cin >> X[i] >> L[i];
    }
    vector<pair<ll, int>>R(N);
    for (int i = 0; i < N; ++i) {
        R[i] = pair<ll, int>(X[i]+L[i], i);
    }
    sort(R.begin(), R.end());

    ll cur = INT_MIN;
    int ans = 0;
    for (int i = 0; i < N; ++i) {
        int j = R[i].second;
        if (cur <= X[j] - L[j]) {
            ans++;
            cur = X[j] + L[j];
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3328
import java.util.Scanner;

public class Main {

    public Main() {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();

        if (400 <= N && N < 600)
            System.out.println("8");
        else if (600 <= N && N < 800)
            System.out.println("7");
        else if (800 <= N && N < 1000)
            System.out.println("6");
        else if (1000 <= N && N < 1200)
            System.out.println("5");
        else if (1200 <= N && N < 1400)
            System.out.println("4");
        else if (1400 <= N && N < 1600)
            System.out.println("3");
        else if (1600 <= N && N < 1800)
            System.out.println("2");
        else if (1800 <= N && N < 2000)
            System.out.println("1");
    }

    public static void main(String[] args) {
        new Main();
    }
}


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

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

using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b && a == c) cout << 1;
    else if (a == b || a == c || b == c) cout << 2;
    else cout << 3;
}


Measured memory_bytes: 3628
import java.util.*;
import java.util.stream.IntStream;

class Main {

    public static void main(String args[]){
        Scanner s=new Scanner(System.in);
        int n= s.nextInt();
        int k= s.nextInt();

        double buf=0;
        int count=0;
        double maxValue=0;
        List<Double> list=new ArrayList<>();
        for (int i = 0; i <n ; i++) {
            int a= s.nextInt();
            double exp=IntStream.range(0,a+1).sum()/(double)(a);
            list.add(exp);
            buf+=exp;
            count++;
            if(count==k){
                if(maxValue<buf){
                    maxValue=buf;
                }
                count--;
                buf-= list.get(i - (k-1));
            }
        }
        System.out.println(maxValue);

    }

}

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

int main(void){
    int n, a[100], path[110][2], max, min;
    cin >> n;
    for(int i=0;i<n;++i){
        cin >> a[i];
    }
    for(int i=0;i<110;++i){
        for(int j=0;j<2;++j){
            path[i][j] = 0;
        }
    }
    max = a[0];
    min = a[0];
    int map = 0, mip = 0, cnt=0;
    for(int i=0;i<n;++i){
        if(max < a[i]){
            max = a[i];
            map = i;
        }
        if(min > a[i]){
            min = a[i];
            mip = i;
        }
    }
    if(abs(max) >= abs(min)){
        for(int i=0;i<n;++i){
            path[cnt][0] = map+1;
            path[cnt][1] = i+1;
            ++cnt;
            a[i] += a[map];
        }
        for(int i=1;i<n;++i){
            if(a[i] < a[i-1]){
                path[cnt][0] = i;
                path[cnt][1] = i + 1;
                ++cnt;
                a[i] += a[i-1];
            }
        }
    }else{
        for(int i=0;i<n;++i){
            path[cnt][0] = mip+1;
            path[cnt][1] = i+1;
            ++cnt;
            a[i] += a[mip];
        }
        for(int i=n-2;i>=0;--i){
            if(a[i] > a[i+1]){
                path[cnt][0] = i+2;
                path[cnt][1] = i+1;
                ++cnt;
                a[i] += a[i+1];
            }
        }
    }
    cout << cnt << endl;
    for(int i=0;i<cnt;++i){
        cout << path[i][0] << " " << path[i][1] << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int X = sc.nextInt();
		loop:for( int i=X; i<=X*2; i++ ){
          if( i==2 ){
					System.out.println(i);
 					break loop;                 
                } 
			for( int j=2; j*j<=i; j++ ){                
				if( i%j==0 ){
					break;
				}
				if( (j+1)*(j+1)>i ){
					System.out.println(i);
					break loop;
				}
			}
		}
	}
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 600005

int N;
int table[SIZE];
int BASE = 300000;


int main(){

	int head = BASE,tail = BASE;

	scanf("%d",&N);

	int tmp;

	for(int i = 0; i < N; i++){

		scanf("%d",&tmp);

		if(i%2 == 0){

			table[tail++] = tmp;
		}else{

			table[--head] = tmp;
		}
	}
	if(N == 1){
		printf("%d\n",tmp);
		return 0;
	}

	if(N%2 == 0){
		printf("%d",table[head]);

		for(int i = head+1; i < tail; i++){

			printf(" %d",table[i]);
		}

	}else{
		printf("%d",table[--tail]);

		for(int i = tail-1; i >= head; i--){

			printf(" %d",table[i]);
		}
	}

	printf("\n");

	return 0;
}


Measured memory_bytes: 4508
//http://www.cplusplus.com/reference/algorithm/next_permutation/
//https://ravesli.com/urok-61-struktury/#toc-0
#include<bits/stdc++.h>
#define FILE
#define ll long long
#define pb push_back
#define pf push_front
#define fr first
#define sc second
#define r_0 return 0
#define ld long double
#define TIME ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
    const ll N = 2e5 + 7;
    const ll mod = 1e9 + 7;

int main(){
    TIME
    #ifdef FILEs
        freopen("army.in", "r", stdin);
        freopen("army.out", "w", stdout);
    #endif
    string s , t , u;
    cin >> s >> t;
    int x , y;
    cin >> x >> y;
    cin >> u;
    if(u == s)x --;
    else y --;
    cout << x << " " << y;
}

///...


Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(in);
		int N = sc.nextInt();
		int[] A = new int[N+1];
		for(int i=0;i<N+1;i++) {
			A[i] = sc.nextInt();
		}
		
		long ret = 0;
		for(int i=0;i<N;i++) {
			int b = sc.nextInt();
			if(A[i]-b>=0) {
				ret += b;
				continue;
			}
			else {
				ret += A[i];
				b = b - A[i];
				ret += Math.min(A[i+1], b);
				A[i+1] -= Math.min(A[i+1], b);
			}
		}
		
		out.println(ret);
		sc.close();
	}
}

Measured memory_bytes: 65312
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>

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

#define debug(vec) for(auto v : vec) cout << v << " "; cout << endl;

#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cout << v << " "; cout << endl; } 

using namespace std;

typedef long long ll;

const long long int INF = 1 << 30; //10^10
//const ll MOD = 998244353;
const ll MOD = 1000000007;


int main() {
	int k, x;
	cin >> k >> x;

	if (500 * k >= x) cout << "Yes" << endl;
	else cout << "No" << endl;
}


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

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007; //998244353;

template<class _T> static void get(_T& a) {
	std::cin >> a;
}
template<class _T> static void get(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void get(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}
template <class _T> static _T tp_abs(_T a) {
	if (a < (_T)0) {
		a *= (_T)-1;
	}
	return a;
}

static void exec();

int main()
{
	exec();
	fflush(stdout);
	return 0;
}

static void in(int& D, std::vector<int>& ci, std::vector<std::vector<int>>& sdi)
{
	get(D);

	for (auto& c : ci) {
		get(c);
	}
	
	sdi.resize(D);
	for (int i = 0; i < D; i++) {
		sdi[i].resize(26);
		for (auto& s : sdi[i]) {
			get(s);
		}
	}
}

static std::vector<int> calc(int& D, std::vector<int>& ci, std::vector<std::vector<int>>& sdi, std::vector<int>& ti)
{
	LLONG ans = 0;
	std::vector<int> last(26, 0), vi(D, 0);
	
	for (int d = 0; d < D; d++) {
		if (d) vi[d] = vi[d - 1];

		LLONG best = 0;
		int contest = 0;
		for (int held = 0; held < 26; held++) {
			LLONG tmp = sdi[d][held];
			int lastDayTmp = last[held];
			last[held] = d + 1;
			for (int c = 0; c < 26; c++) {
				tmp -= ci[c] * ((d + 1) - last[c]);
			}
			last[held] = lastDayTmp;
			if (tmp > best) {
				best = tmp;
				contest = held;
			}
		}
		ti[d] = contest;
		last[contest] = d + 1;
		vi[d] += best;
	}
	return vi;
}

static void exec()
{
	int D = 0;
	std::vector<int> ci(26);
	std::vector<std::vector<int>> sdi;

	in(D, ci, sdi);
	std::vector<int> ti(D);
/*
	for (auto& t : ti) {
		get(t);
		t--;
	}
*/
	auto vi = calc(D, ci, sdi, ti);
	for (auto v : ti) {
		printf("%d\n", v + 1);
	}
}


Measured memory_bytes: 3748
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define divup(a,b) ( ( (a) + ( (b) - 1u) ) / (b) ) // a/b の余り切り上げ
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int mod = 1000000007;

int main(){
    ll n;
    cin>>n;
    vector<pair<string,pair<ll,ll>>> p(n);
    rep(i,n){
        int k;
        cin>>p[i].first>>k;
        p[i].second.first=200-k;
        p[i].second.second= i;
    }
    sort(p.begin(),p.end());
    rep(i,n) p[i].second.first = 200-p[i].second.first;
    rep(i,n){
        cout<<1+p[i].second.second<<endl;
    }
}


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

signed main(void)
{
	int a, b, c, d, e, f;
	int ans_w, ans_s;
	double mx;
	set<int> water, suger;

	cin >> a >> b >> c >> d >> e >> f;
	for(int i = 0; i <= 30; i++) for (int j = 0; j <= 30; j++)
	{
		int x = i * 100 * a + j * 100 * b;
		if (x <= f)
		{
			water.insert(x);
		}
	}	
	for(int i = 0; i <= f; i++) for (int j = 0; j <= f; j++)
	{
		int y = i * c + j * d;
		if (y <= f)
		{
			suger.insert(y);
		}
	}
	mx = 0;
	ans_w = ans_s = 0;
	for(int w : water)
	{
		for(int s : suger)
		{
			if ((double)w * e / 100 >= s)
			{
				int sum = w + s;
				if (sum <= f && (double)100 * s / (w + s) >= mx)
				{
					mx = (double)100 * s / (w + s);
					ans_w = sum;
					ans_s = s;
				}
			}
		}
	}
	cout << ans_w << " " << ans_s << endl;
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define pii pair<int, int>
#define pll pair<long long, long long>
#define rep(i,l,r) for(long long i = l;i<r;i++)

#define fastout  ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
using namespace __gnu_pbds;

typedef tree<pll,null_type,less<pll>,rb_tree_tag,tree_order_statistics_node_update> order_set;

const int INF = (int)1e9 + 7;
const long long LLINF = (long long)1e18 + 7;

mt19937 mt('O' + '4' + 'K' + 'O');

void kekek()
{
    
    mt();
    #ifdef EB_UG
        freopen("in.txt", "r", stdin), freopen("out.txt", "w", stdout);
    #endif
    #ifndef EB_UG
        ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    #endif
}

int main() {
    kekek();
    int a, b;
    cin >> a >> b;
    if (!(1 <= a && a <= 9) || !(1 <= b && b <= 9)) {
        cout << -1;
        return 0;
    }
    cout << a * b;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()

template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
template<class T>inline int cmp(vector<T>&v,T &a){
	return lower_bound(all(v),a)-v.begin();
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;

int f(int x){
	if(x%4==0)return x;
	if(x%4==1)return 1;
	if(x%4==2)return x+1;
	return 0;
}
signed main(){
	int A,B;cin>>A>>B;
	cout<<(f(B)^f(A-1))<<"\n";
}


Measured memory_bytes: 3584
#include<iostream>
#include<map>
using namespace std;
int main(){
	map<string,int>m;
	int q;
	cin>>q;
	while(q--){
		int c;
		string k;
		cin>>c>>k;
		if(c==0){
			int x;
			cin>>x;
			m[k]=x;
		}
		else if(c==1){
			cout<<m[k]<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 27704
#include <stdio.h>
int main(void){
    int N;
    scanf("%d", &N);
    int array[N+1];
    for(int i=N-1; i>=0; i--){
        scanf("%d", &array[i]);
    }
    for(int j=0; j<N; j++){
        if(j==N-1)printf("%d\n",array[j]);
        else printf("%d ", array[j]);
    }
}

Measured memory_bytes: 1796
import java.util.*;
public class Main {
	public static void main(String[] args){
    //データ取り込み
		Scanner sc = new Scanner(System.in);
		//String S = sc.next();
    //int B = sc.nextInt();
    //System.out.println();
		int N = sc.nextInt();
		int M = sc.nextInt();
		if(N%500 ==0 || N%500<=M){
			System.out.println("Yes");
		}else{
			System.out.println("No");	
		}
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
    using namespace std;
    int main(){
    	long long n,a,b,c,d;
    	cin>>a>>b>>c>>d;
    	while(a>0 && b>0){
    		c-=b;
    		a-=d;
    	}
    	if(c<=0){
    		cout<<"Yes"<<endl;
    	}
    	else{
    		cout<<"No"<<endl;
    	}
      return(0);
    }

Measured memory_bytes: 3620
#include <iostream>
using namespace std;
int main() {
    long long int a, b, c, d;
    cin >> a >> b >> c >> d;

    long long int ans = a * c;
    ans = max(ans, a * d);
    ans = max(ans, b * c);
    ans = max(ans, b * d);

    cout << ans << endl;


}

Measured memory_bytes: 3612
#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];
}
long long sum = 0;
for(int i = 0; i < n; ++i){
	for(int j = i + 1; j < n; ++j){
		sum += a[i]*a[j];
	}
}
cout << sum;
return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl '\n'
using namespace std;
int main()
{
    fastio;
    long long n,w,i,j;
    cin>>n>>w;
    long long value[n+1],weight[n+1],total_val=0,ans=0;
    for(i=1;i<=n;i++)
    {
        cin>>weight[i]>>value[i];
        total_val=total_val+value[i];
    }
    long long matrix[n+1][total_val+1];
    memset(matrix,-1,sizeof(matrix));
    for(i=0;i<=n;i++)
    {
        matrix[i][0]=w;
    }
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=total_val;j++)
        {
            if(value[i]>j)
            {
                matrix[i][j]=matrix[i-1][j];
            }
            else
            {
                matrix[i][j]=max(matrix[i-1][j-value[i]]-weight[i], matrix[i-1][j]);
            }

            if(matrix[i][j]>=0)
            {
                ans=max(ans,j);
            }
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 79232
from collections import defaultdict,deque, Counter
import sys,heapq,bisect,math,itertools,string,queue,copy,time
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

n = inp()
A = np.array([inp() for _ in range(n)])
mA = max(A)
smA = np.sort(A)[::-1][1]
for i in range(n):
    if A[i] == mA: print(smA)
    else: print(mA)

Measured memory_bytes: 21864
str = input()
acgt = set({'A','C','G','T'})

max_len = 0
work_len = 0
for c in str:
    if c in acgt:
        work_len += 1
    else:
        if max_len < work_len:
            max_len = work_len
        work_len = 0
if work_len > max_len:
    max_len = work_len
print(max_len)


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

long long N, K;
int mod = 1e9 + 7;

int main() {
    cin >> N >> K;
    vector<pair<int, int>> sushi(N);
    for (int i = 0; i < N; i++) {
        cin >> sushi[i].second >> sushi[i].first;
    }
    sort(sushi.begin(), sushi.end(), greater<pair<int, int>>());
    
    vector<long long> T(N + 1), S(N + 1);
    map<int, bool> flag;
    int s = 1, t = 1;
    for (int i = 0; i < N; i++) {
        if (flag[sushi[i].second]) {
            S[s] = S[s - 1] + sushi[i].first;
            s++;
        } else {
            T[t] = T[t - 1] + sushi[i].first;
            flag[sushi[i].second] = true;
            t++;
        }
    }
    
    long long ans = 0;
    for (long long k = 1; k <= K; k++) {  //k種類たべる
        if (T[k] == 0) break;
        long long p = T[k] + S[K - k] + k * k;
        ans = max(p, ans);
    }
    cout << ans << endl;
}


Measured memory_bytes: 7296
#include <iostream>
using namespace std;
char s[52][52];
int h,w,cnt;
int main(){
	cin >>h>>w;
	for(int i=1;i<=h;i++) {
		for (int j=1;j<=w;j++)cin>>s[i][j];
	}
	for (int i=1;i<=h;i++) {
		for (int j=1;j<=w;j++) {
			if (s[i][j]=='#'&&s[i][j-1]!='#'&&s[i-1][j]!='#'&&s[i][j+1]!='#'&&s[i+1][j]!='#')cnt=1;
		}
	}
	if(!cnt)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;


int main() {
	int N, M; cin >> N >> M;
	vector<vector<ld>>pers(M +1,vector<ld>(M +1));
	pers[0][0] = 1;
	for (int i = 1; i <= M; ++i) {
		for (int j = 0; j < M; ++j) {
			pers[i][j] += pers[i - 1][j] *2 / 3;
			pers[i][j + 1]+= pers[i - 1][j] / 3;
		}
		
	}
	for (int i = 1; i <= M; ++i) {
		for (int j = M; j >0; --j) {
			pers[i][j - 1] += pers[i][j];
		}
	}
	
	vector<int>pluspoints{ 5,3,2 };
	vector<int>mys(3);
	vector<vector<int>>ops(3);
	vector<vector<ld>>kitaitis(3,vector<ld>(M+1));
	{
		cin >> mys[0] >> mys[1] >> mys[2];
	}
	for (int  i = 1; i < N; i++)
	{
		int vi, da, vo; cin >> vi >> da >> vo;
		ops[0].push_back(vi);
		ops[1].push_back(da);
		ops[2].push_back(vo);
	}
	for (int perform = 0; perform < 3; ++perform) {
		for (int chal = 0; chal <= M; ++chal) {
			ld kitai = 0;
			int mypoint = chal*mys[perform];
			vector<ld>losepers(N - 1);
			for (int op = 0; op < N - 1; ++op) {
				int needchal = (mypoint - 1) / ops[perform][op] + 1;
				if (mypoint == 0)needchal = 0;
				if (needchal > M) {
					losepers[op] = 0;
				}
				else {
					losepers[op] = pers[M][needchal];
				}
			}
			vector<vector<ld>>windp(N, vector<ld>(4));
			windp[0][0] = 1;
			for (int op = 0; op < N-1; ++op) {
				for (int j = 0; j < 3; ++j) {
					windp[op + 1][j] += windp[op][j] * (1 - losepers[op]);
					windp[op + 1][j + 1] += windp[op][j] * losepers[op];
				}
			}
			kitai += (windp[N - 1][0] + windp[N - 1][1] + windp[N - 1][2])*pluspoints[perform];

			ld biri = 1;
			for (int op = 0; op < N - 1; ++op) {
				biri *= losepers[op];
			}
			kitai -= biri;
			kitaitis[perform][chal] = kitai;
		}
	}
	ld ans = -1e18;
	for (int a = 0; a <= M; ++a) {
		for (int b = 0; b <= M - a; ++b) {
			int c = M - a - b;
			if (ans<kitaitis[0][a] + kitaitis[1][b] + kitaitis[2][c])
			{
				ans = max(ans, kitaitis[0][a] + kitaitis[1][b] + kitaitis[2][c]);
			}

		}
	}
	cout << fixed<<setprecision(22)<<ans << endl;


	return 0;
}

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

const ll mod=1e9+7;

template<typename T>inline bool chmax(T &a,const T &b){if(a>=b){return false;}a=b;return true;}
template<typename T>inline bool chmin(T &a,const T &b){if(a<=b){return false;}a=b;return true;}

/*-------------------------------------------*/

template<typename T>T mpow(T x,T n){
    T ret=1;
    while(n>0){
        if(n&1)(ret*=x)%=mod;
        (x*=x)%=mod;
        n=n>>1;
    }
    return ret;
}

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

    ll n;
    cin>>n;
    
    vector<ll>c(n);
    rep(i,n)cin>>c[i];
    ll ans=0;

    sort(c.begin(),c.end(),greater<ll>());
    rep(i,n)(ans+=(i+2)*c[i])%=mod;
    cout<<(ans*mpow(2ll,n*2-2))%mod<<endl;
}

Measured memory_bytes: 1792
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let h: usize = iterator.next().unwrap().parse().unwrap();
    let w: usize = iterator.next().unwrap().parse().unwrap();
    let k: usize = iterator.next().unwrap().parse().unwrap();
    let mut map: Vec<Vec<char>> = Vec::new();
    for _ in 0..h {
        map.push(iterator.next().unwrap().chars().collect());
    }

    let mut ans: usize = 0;
    for i in 0..2_i32.pow(h as u32) {
        let bi: Vec<char> = binary_string(i as usize, h).chars().collect();
        for j in 0..2_i32.pow(w as u32) {
            let bj: Vec<char> = binary_string(j as usize, w).chars().collect();
            let mut count = 0;
            for hi in 0..h {
                for wi in 0..w {
                    if bi[hi] != '1' && bj[wi] != '1'
                        && map[hi][wi] == '#' {
                        count += 1;
                    }
                }
            }
            if count == k {
                ans += 1;
            }
        }
    }
    ans.to_string()
}

fn binary_string(n: usize, keta: usize) -> String {
    return format!("{:0>1$b}", n, keta);
}


Measured memory_bytes: 2164
#include <stdio.h>

int main(void){
  int time[5], wait_time, dif[5], max_dif, max_i, i;

  for(i=0;i<5;i++){
    scanf("%d", &time[i]);
  }
  for(i=0;i<5;i++){
    if(time[i]%10==0){
      dif[i]=0;
    }else{
      dif[i]=(time[i]/10+1)*10-time[i];
    }
  }
  max_dif=0;
  for(i=0;i<5;i++){
    if(dif[i]>max_dif){
      max_dif=dif[i];
      max_i=i;
    }
  }
  wait_time=0;
  for(i=0;i<5;i++){
    if(i==max_i){
      wait_time+=time[i];
    }else if(time[i]%10==0){
      wait_time+=time[i];
    }else{
      wait_time+=(time[i]/10+1)*10;
    }
  }
  printf("%d\n", wait_time);
  return 0;
}


Measured memory_bytes: 128
N = int(input())
l_a = list(map(int,input().split()))
l_b = sorted(l_a)
if l_a[0] != 1:
    k = l_a.index(1)
    l_a[0],l_a[k] = l_a[k],l_a[0]
else:
    for i in range(1,N):
        if l_a[i] != l_a[i-1]+1:
            k = l_a.index(i+1)
            l_a[i],l_a[k] = l_a[k],l_a[i]
            break
if l_a == l_b:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3064
#include"bits/stdc++.h"
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
#define MX 100999 
#define INF 100000000009
using namespace std;
 
int main(){
    int n;
    int d[MX];
    cin>>n;
    rep(i,n)d[i]=0;
  	int di;
  	cin>>di;
  	if(di!=0){
      cout<<0<<endl;
      return 0;
    }
  	d[0]++;
    rep(i,n-1){
        cin>>di;
        d[di]++;
    }
    ll ans=1;
    int k=0;
    rep(i,n-1){
        if(d[i]==0)break;
        rep(j,d[i+1]){
            k++;
            ans*=d[i];
            ans%=998244353;
        }
    }
    if(k==n-1)cout<<ans<<endl;
    else cout<<0<<endl;
    return 0;
}

Measured memory_bytes: 640
using System;

namespace ABC178C
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = long.Parse(Console.ReadLine());
            var mod = 1000000007L;
            var all = 1L;
            var except0and9 = 1L;
            var except0 = 1L;
            var except9 = 1L;
            for (var i = 0; i < n; i++)
            {
                all = (all * 10) % mod;
                except0and9 = (except0and9 * 8) % mod;
                except0 = (except0 * 9) % mod;
                except9 = (except9 * 9) % mod;
            }

            var answer = (all - except0 - except9 + except0and9 + mod * 4) % mod;
            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 27432
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int MAP[100][100]={};
int a,b;
int ans=0;
void dfs(int x,int y){
  if(x==a&&y==b){
    ans++;
    return;
  }
  if(x+1>0&&x+1<=a&&!MAP[x+1][y])
    dfs(x+1,y);
  if(y+1>0&&y+1<=b&&!MAP[x][y+1])
    dfs(x,y+1);
}
int main(){
  while(cin>>a>>b,a+b){
    int n;
    for(int i=0;i<100;i++)
      for(int j=0;j<100;j++)
	MAP[i][j]=0;
    ans=0;
    cin>>n;
    for(int i=0;i<n;i++){
      int x,y;
      cin>>x>>y;
      MAP[x][y]=1;
    }
    dfs(1,1);
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3036
#include <cstdio>
#include <cstdlib>
#define INF (__INT32_MAX__ / 2);
#define MAX 30

using namespace std;

int n, m;
int A[MAX];

int main(int argc, char **argv) {
    scanf("%d", &n);
    scanf("%d", &m);

    for(int i = 0; i < n; ++i) {
        int k;
        scanf("%d", &k);

        for(int j = 0; j < k; ++j) {
            int food;
            scanf("%d", &food);
            A[food - 1]++;
        }
        
    }

    int res = 0;
    for(int i = 0; i < m; ++i) {
        if(A[i] == n)
            ++res;
    }
    printf("%d\n", res);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; ++i)
using ll = long long;
const ll MOD = 1000000007;//998244353;
int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   int a, b; cin >> a >> b;
   cout << max(max(a+b ,a-b),a*b) << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
const int MOD=1e9+7;
 
int main() {
    int n;
    cin >> n;
    cout << n/2+(n%2) << endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define _abs(x)((x) < 0 ? (x) * -1 : (x))
#define _max(x, y)(max(0, max((x), (y))))
#define _min(x, y)(max(0, min((x), (y))))

static const ll MOD = 1e9 + 7;

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    //freopen("debug.txt", "w", stderr);

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll q, h, s, d;
    ll n;

    cin >> q >> h >> s >> d;
    cin >> n;

    vector<pair<ll, float> > v(4);
    pair<ll, float> p;
    ll price, div, rem;
    ll ans = 0;

    int i;

    v[0] = make_pair(q * 8LL, 0.25f);
    v[1] = make_pair(h * 4LL, 0.5f);
    v[2] = make_pair(s * 2LL, 1.0f);
    v[3] = make_pair(d, 2.0f);

    sort(v.begin(), v.end());

    while (0 < n) {
        for (i = 0; i < 4; i++) {
            p = v[i];

            if (p.second == 2.0f && 1 < n) {
                div = n / 2;
                rem = n % 2;

                ans += d * div;

                n = rem;

                break;
            } else if (p.second != 2.0f) {
                if (p.second == 0.25f) price = q * 4LL;
                else if (p.second == 0.5f) price = h * 2LL;
                else if (p.second == 1.0f) price = s;

                ans += price * n;

                n = 0;

                break;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;

using ll = int64_t;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = INT_MAX;
constexpr ll L_INF = LLONG_MAX;

//===

using Graph = std::vector<std::vector<int>>;

int N, M;
Graph g;
ll ans = 0;

void dfs(int n, int a, vector<bool> chkd)
{
	if (n == N - 1) {
		++ans;
	}

	chkd[a] = true;

	for (const auto& to : g[a]) {
		if (chkd[to]) continue;
		dfs(n + 1, to, chkd);
	}
}



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

	cin >> N >> M;
	g.resize(N);


	for (int i = 0; i < M; ++i) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		g[a].push_back(b);
		g[b].push_back(a);
	}

	dfs(0, 0, vector<bool>(N));

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
def primes(n):
  l = [1 for i in range(n+1)]
  l[0] = l[1] = 0
  for i in range(2,int((n)**(1/2))+1):
    if l[i] == 1:
      for j in range(2,n//i+1):
        l[i*j] = 0
  return l

l = primes(50000)
while True:
  n = int(input())
  if n == 0:
    break
  count = 0
  if not(n%2):
    for i in range(3,n//2+1,2):
      if (l[i] and l[n-i]):
        count += 1
    if n == 4:
      count = 1
  else:
    if l[n-2]:
      count += 1
  print(count)

Measured memory_bytes: 7820
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int i=0;i<n;++i)
struct edge {
    int to, cost;
};
typedef vector<vector<edge> > AdjList;
AdjList graph;

typedef pair<int, int> P;

const int INF = 10000000;

vector<int> dist; 
vector<int> prever;

void dijkstra(int n, int s){
    dist = vector<int>(n,INF);
    prever = vector<int>(n,-1);
    dist[s] = 0;

    priority_queue<P, vector<P>, greater<P> > que;
    que.push(P(0,s));

    while(!que.empty()){
        P p = que.top();
        que.pop();
        int v = p.second;
        if(dist[v] < p.first){
            continue;
        }
        for(int i=0;i<graph[v].size();i++){
            edge e = graph[v][i];
            if(dist[e.to] > dist[v] + e.cost){
                dist[e.to] = dist[v] + e.cost;
                prever[e.to] = v;
                que.push(P(dist[e.to],e.to));
            }
        }
    }
}

vector<int> get_path(int t){ //頂点tへの最短路
    vector<int> path;
    for(; t != -1;t=prever[t]){
        path.push_back(t);
    }

    reverse(path.begin(), path.end());
    return path;
}

int main(void){
    int n, m;
    cin >> n >> m;
    graph = AdjList(n);
    for(int i=0;i<m;i++){
        int from, to;
        cin >> from >> to;
        from--; to--;
        graph[from].push_back((edge){to,1});
        graph[to].push_back((edge){from,1});
    }
    dijkstra(n,0);
    for(int i=0;i<n;++i){
        if(dist[i]==INF){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    for(int i=1;i<n;++i){
        cout << prever[i]+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 13636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;

#define INF 1LL << 60
#define MOD 1000000007;
#define pb push_back

#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPR(i, b, e) for (int i = (b); i <= (e); i++)
#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUGA(a) cout << #a << ": " << endl; for (const auto& v: (a)) cout << v << endl

ll N;

int main() {
    cin.tie(0);
    cin >> N;

    ll sum = 0;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i != 0) {
            continue;
        }
        ll m = N / i - 1;
        if (m > 0 && N / m == N % m) sum += m;
    }
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
Ap = [int(x) for x in input().split()]
A = sorted([Ap[i]  -i-1 for i in range(N)])

if N % 2 != 0:
    b = A[(N+1)//2 - 1]
    print( sum( [abs(x-b) for x in A] ) )
else:
    mf,mb = A[N//2-1], A[N//2]
    if mb - mf >= 2:    b = mb -1
    else:  b = mb
    print( sum( [abs(x-b) for x in A] ) )


Measured memory_bytes: 27848
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <cctype>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <set>
#include <deque>
#include <map>
#include <bitset>
#include <functional>
#include <cmath>

#define INF 1000000000
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> v(n);

    int i;
    int tmp = 0;
    for(i = 0; i < n; i++){
        cin >> v[i];
        tmp ^= v[i];
    }

    for(i = 0; i < n; i++){
        int ans = tmp^v[i];
        cout << ans << endl;
    }
}


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

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

	ll N,M;
	cin >> N >> M;
	priority_queue<ll> A;
	for(int i=0;i<N;i++){
		ll a;
		cin >> a;
		A.push(-a);
	}
	priority_queue< pair<ll,ll> > B;
	for (int i = 0; i < M; ++i){
		ll b,c;
		cin >> b >> c;
		B.push({c,b});
	}
	B.push({-1,1e16});
	ll ans = 0;
	for (int i = 0; i < N; ++i){
		ll a = -A.top();
		A.pop();
		if(a>=B.top().first){
			ans += a;
		}else{
			ans += B.top().first;
			auto x = B.top();
			B.pop();
			x.second--;
			if(x.second)B.push(x);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3188
import java.util.*;

public class Main {

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();

        long c = a(a, b);
        int res = 1;
        for(long i=2; i*i <= c; i++) {
            boolean d = false;
            while(c % i == 0) {
                c /= i;
                d = true;
            }
            if(d) res++;
        }
        if(c > 1) res ++;
        System.out.println(res);
    }

    public static long a(long a, long b) {
        if(a==b) return a;
        if(b > a) {
            return a(b, a);
        }
        if(a % b == 0) {
            return b;
        }
        return a(b, a%b);
    }
}


Measured memory_bytes: 23636
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
int main()
{
  int n,k; cin >> n >> k;
  int x = 1;
  rep(i,n) {
    if(x < k) x *= 2;
    else x += k;
  }
  cout << x << "\n";
  return 0;
}


Measured memory_bytes: 3528
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;

int main() {
	int N;
	cin >> N;
	vector<string> s(N);
	long long ans = 0;
	map<string, int> count;
	for (int i = 0; i < N; i++) {
		cin >> s.at(i);
		sort(s.at(i).begin(), s.at(i).end());
		ans += count[s.at(i)];
		count[s.at(i)] += 1;
	}

	cout << ans << endl;
}


Measured memory_bytes: 18176
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <stack>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#include <numeric>
#define int long long
#define ll long long
#define double long double
#define mod 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用
#define MIN -(9223372036854775807 / 2)
#define INF 9223372036854775807 / 2
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define mp make_pair


using namespace std;

std::mt19937 mt((int)time(0));

int dx[4] = { 0, 1, 0, -1 }; // x軸方向への変位
int dy[4] = { 1, 0, -1, 0 }; // y軸方向への変位

using Weight = int;
using Flow = int;
struct Edge {
	int src, dst;
	Weight weight;
	Flow cap;
	Edge() : src(0), dst(0), weight(0) {}
	Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;

void add_edge(Graph &g, int a, int b, Weight w = 1) {
	g[a].emplace_back(a, b, w);
	g[b].emplace_back(b, a, w);
}
void add_arc(Graph &g, int a, int b, Weight w = 1) { g[a].emplace_back(a, b, w); }

struct uf_tree {
	std::vector<int> parent;
	int __size;
	uf_tree(int size_) : parent(size_, -1), __size(size_) {}
	void unite(int x, int y) {
		if ((x = find(x)) != (y = find(y))) {
			if (parent[y] < parent[x]) std::swap(x, y);
			parent[x] += parent[y];
			parent[y] = x;
			__size--;
		}
	}
	bool is_same(int x, int y) { return find(x) == find(y); }
	int find(int x) { return parent[x] < 0 ? x : parent[x] = find(parent[x]); }
	int size(int x) { return -parent[find(x)]; }
	int size() { return __size; }
};



//!!!問題をちゃんと読む!!!
//!!!問題をちゃんと読め!!!
//!!!問題は読みましたか？!!!



signed main() {
	int A,B;
	cin >> A >> B;
	if (A >= 13) {
		cout << B << "\n";
	}
	else if (A >= 6) {
		cout << B/2 << "\n";
	}
	else {
		cout << 0 << "\n";
	}



	return 0;
}

Measured memory_bytes: 256
n,a,b = gets.chomp.split
s = gets.chomp

a = a.to_i
b = b.to_i
n = n.to_i
ab_cnt = a+b

pass = 0
b_rnk = 1
# p n,a,b

n.times do |i|
  if s[i] == 'c'
    puts 'No'
  elsif pass < ab_cnt
    if s[i] == 'a'
      puts 'Yes'
      pass += 1
    elsif s[i] == 'b' && b_rnk <= b
      puts 'Yes'
      pass += 1
      b_rnk += 1
    else
      puts 'No'
    end
  else
    puts 'No'
  end
end


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

ll dp[1000002][101],w[101],v[101],W,n;

void boost()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

ll solve(ll i,ll s)
{
	if(s>W)
		return -100000000007;
	if(i>n || s==W)
		return 0;
	if(dp[s][i]!=-1)
		return dp[s][i];
	dp[s][i] = max(solve(i+1,s),solve(i+1,s+w[i])+v[i]);
	return dp[s][i];
}

int main()
{
	int i;
	boost();
	memset(dp,-1,sizeof(dp));
	cin>>n>>W;
	for(i=1;i<=n;i++)
		cin>>w[i]>>v[i];
	cout<<solve(1,0)<<endl;
	return 0;
}

Measured memory_bytes: 789376
#include <iostream>

using namespace std;

int main()
{
    int a , b, c;
    cin>>a;
    for(int i=9; i>=1; --i)
    {
        if(a%i==0 && a/i<10) {cout<<"Yes"; return 0;}
    }
    cout<<"No";
    return 0;
}


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

struct node {
	int car;
	int cdr;
	int parent;
	int sibling;
};

void
preorder(struct node *a, int x)
{
	printf(" %d", x);

	if (a[x].car >= 0)
		preorder(a, a[x].car);

	if (a[x].cdr >= 0)
		preorder(a, a[x].cdr);
}

void
inorder(struct node *a, int x)
{
	if (a[x].car >= 0)
		inorder(a, a[x].car);

	printf(" %d", x);

	if (a[x].cdr >= 0)
		inorder(a, a[x].cdr);
}

void
postorder(struct node *a, int x)
{
	if (a[x].car >= 0)
		postorder(a, a[x].car);

	if (a[x].cdr >= 0)
		postorder(a, a[x].cdr);

	printf(" %d", x);
}

int
main(void)
{
	int i, j, n, r;
	struct node *a;

	scanf("%d", &n);

	a = (struct node *)malloc(sizeof(struct node) * n);
	if (a == NULL)
		return 1;

	for (i = 0; i < n; i++) {
		a[i].parent = -1;
		a[i].sibling = -1;
	}

	for (i = 0; i < n; i++) {
		int id, car, cdr;
		scanf("%d%d%d", &id, &car, &cdr);
		a[id].car = car;
		a[id].cdr = cdr;
		car >= 0 && (a[car].parent = id);
		cdr >= 0 && (a[cdr].parent = id);
		if (car >= 0 && cdr >= 0)
			a[cdr].sibling = car, a[car].sibling = cdr;
	}

	for (r = 0; r < n - 1; r++)
		if (a[r].parent == -1)
			break;

	printf("Preorder\n");
	preorder(a, r);
	printf("\n");

	printf("Inorder\n");
	inorder(a, r);
	printf("\n");

	printf("Postorder\n");
	postorder(a, r);
	printf("\n");

	return 0;
}



Measured memory_bytes: 2096
#include <iostream>
using namespace std;
int main()
{
int a[10],i,j;
while(scanf("%1d",&a[0])!=EOF){
for(i=1;i<10;i++)scanf("%1d",&a[i]);
for(i=9;i>=0;i--)
for(j=0;j<i;j++)
a[j]=a[j]+a[j+1]-((a[j]+a[j+1])/10)*10;
cout<<a[0]<<endl;
}
return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std; 
#define mod 1000000007
#define N 100005
#define ll long long
#define ull unsigned long long
#define loop1(i, j, k, step) for (int i=j; i<k; i+=step)
#define loop(i, j, k) for (int i=j; i<k; i++) 
#define rloop1(i, j, k, step) for (int i=j; i>=k; i-=step)
#define rloop(i, j, k) for(int i=j; i>=k; i--)
#define rep(i, k) for(int i = (0); i < (k); i++ )
#define rrep(i, k) for(int i = k-1; i >= 0; i-- )

#define forall(it, l) for(auto it=l.begin(); it != l.end(); it++)
#define mp make_pair
#define pb push_back
#define pop pop_back
#define F first
#define S second
#define sz(x) (int)(x).size()
#define endl "\n"
#define Max (int)INT_MAX
#define Min (int)INT_MIN
#define MEM(a, b) memset(a, (b), sizeof(a))
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;


void solve()
{
	int n,i,j,k,l;
	string s;
	cin>>s;
	if(s=="ABC")
		cout<<"ARC";
	else
		cout<<"ABC";
}
int  main() 
{
	auto start=clock();
	fast_io;
    int t=1;
    //cin>>t;
    while(t--)
    	solve();
    auto stop =clock();
    cerr<<"time taken:"<<double(stop-start)/double(CLOCKS_PER_SEC)<<" s"<<endl;
	return 0; 
}

Measured memory_bytes: 3844
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

int matrix[1000][1000] = {};
class UnionFind
{
public:
	UnionFind(int min, int max)
		: elems_(max - min + 1)
		, min_(min)
		, rank_(max - min + 1)
	{
		for (int i = min; i <= max; i++) {
			Elem& elem = this->elems_[i - min];
			elem.i = i;
			elem.num = 1;
		}
	}

	int find(int i) {
		int idx = i - this->min_;
		if (this->elems_[idx].i == i) return i;

		int root = this->find(this->elems_[idx].i);
		this->elems_[idx].i = root; // 簡略化
		return root;
	}

	int size(int i) {
		int root = this->find(i);
		int idx = root - this->min_;
		return this->elems_[idx].num;
	}

	int rank() {
		return rank_;
	}

	void merge(int i, int j) {
		int i_root = this->find(i);
		int j_root = this->find(j);
		if (i_root == j_root) return;

		int i_idx = i_root - this->min_;
		int j_idx = j_root - this->min_;

		int i_size = this->elems_[i_idx].num;
		int j_size = this->elems_[j_idx].num;

		if (i_size < j_size) {
			this->elems_[i_idx].i = j_root;
			this->elems_[j_idx].num += this->elems_[i_idx].num;
		}
		else {
			this->elems_[j_idx].i = i_root;
			this->elems_[i_idx].num += this->elems_[j_idx].num;
		}
		this->rank_--;
	}

private:
	struct Elem {
		int i;
		int num; // root 以外は無効
	};

	vector<Elem> elems_;
	int          min_;
	int          rank_;
};

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

	int h, w, a, b; cin >> h >> w >> a >> b;

	FOR_LT(i, 0, b) {
		FOR_LT(j, 0, a) {
			cout << 0;
		}
		FOR_LT(j, a, w) {
			cout << 1;
		}
		cout << endl;
	}
	FOR_LT(i, b, h) {
		FOR_LT(j, 0, a) {
			cout << 1;
		}
		FOR_LT(j, a, w) {
			cout << 0;
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1280