akhauriyash/Code-Regression huggingface dataset:
import bisect
n=int(input())
a=sorted(list(map(int,input().split())))
b=sorted(list(map(int,input().split())))
c=sorted(list(map(int,input().split())))
ans=0
for i in range(n):
  ans+=bisect.bisect_left(a,b[i])*(n-bisect.bisect_right(c,b[i]))
print(ans)


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

int main(){
  string s;
  cin >> s;
  int n=s.size();
  int l=-1,r=n;
  for(int i=0;i<n;i++){
    if(s[i]=='A'){
      l=i; break;
    }
  }
  for(int i=n-1;i>=0;i--){
    if(s[i]=='Z'){
      r=i; break;
    }
  }
  cout << r-l+1 << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define FOR(a, c) for (int(a) = 0; (a) < (c); (a)++)
#define FORL(a, b, c) for (int(a) = (b); (a) <= (c); (a)++)
#define FORR(a, b, c) for (int(a) = (b); (a) >= (c); (a)--)
#define INF 1000000000000000003
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define F first
#define S second
#define pb push_back 
#define pob pop_back
#define mp make_pair

int main(){

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,d;
    cin>>n>>d;
    ll cnt=0;
    FOR(i,n){
    	ll x,y;
    	cin>>x>>y;
    	if((x*x)+(y*y)<=d*d) cnt++;
    }
    cout<<cnt;
    return 0;
}

Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

ll n;
Vi a;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    cin>>n;
    a.resize(3*n);
    rep(i,3*n){
        cin>>a[i];
    }
    priority_queue< ll ,vector<ll>,greater<ll>> fr;
    priority_queue<ll> bk;
    ll sfr=0;
    rep(i,n){
        sfr += a[i];
        fr.push(a[i]);
    }
    Vi frs(n+1,0);
    Vi bks(n+1,0);
    frs[0] = sfr;
    rep(i,n){
        ll tp = fr.top();
        if(tp > a[n+i]){
            frs[i+1] = sfr;
            continue;
        }
        fr.pop();
        fr.push(a[n+i]);
        sfr += a[n+i] - tp;
        frs[i+1] = sfr;
    }
    ll sbk=0;
    rep(i,n){
        sbk +=  a[3*n-1-i];
        bk.push(a[3*n-1-i]);
    }
    bks[0] = sbk;
    rep(i,n){
        ll tp = bk.top();
        if(tp < a[2*n-1-i]){
            bks[i+1] = sbk;
            continue;
        }
        bk.pop();
        bk.push(a[2*n-1-i]);
        sbk += a[2*n-1-i] - tp;
        bks[i+1] = sbk;
    }
    ll ans = -INT64_MAX;
    rep(i,n+1){
        chmax(ans,frs[i]-bks[n-i]);
        //cout<<frs[i]<<" "<<bks[n-i]<<endl;
    }
    print(ans);
    return 0;
}

Measured memory_bytes: 6516
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff first
#define ss second
#define u128 __int128
#define pb push_back

#define N 100010
#define MOD 1000000007
int n;


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

	ll c = 0;
	cin >> n;
	int a[n + 1], b[n];
	for (int i = 0; i < n + 1; ++i)
	{
		cin >> a[i];
	}
	for (int i = 0; i < n; ++i)
	{
		cin >> b[i];
	}

	for (int i = 0; i < n; ++i)
	{
		// cout << a[i] << " " << b[i] << "\n";
		if(a[i] >= b[i])
		{
			a[i] -= b[i];
			c += b[i];
		}
		else
		{
			b[i] -= a[i];
			c += a[i];
			a[i] = 0;
			if(a[i + 1] >= b[i])
			{
				a[i + 1] -= b[i];
				c += b[i];
			}
			else
			{
				c += a[i + 1];
				a[i + 1] = 0;
			}
		}

		// cout << c << "\n";
	}

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



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

using namespace std;

#define PB push_back
#define MP make_pair
#define f first
#define s second
#define FOR(i,a,b) for (int i = a; i < b; ++i)
#define RFOR(i, b, a) for (int i = b-1; i>=a; --i)
#define FILL(a, b) memset(a, b, sizeof a)
#define ALL(a) a.begin(), a.end()
#define SZ(a) ((int)a.size())
#define MAGIC0
mt19937 rnd(time(0)); //rnd()

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = 1LL * INF*INF;
const int MAX = 1e5 + 7;
const double PI = acos(-1.);
const double EPS = 1e-8;
const int MOD = 998244353;

#define int LL

char x[405][405];
LL dp[405][405];
int was[405][405];
int cnt[3004040], kol[3000330];

int n, m, col;
void go(int i, int j)
{
	if (i < 1 || j < 1 || i > n || j > m || was[i][j]) return;
	was[i][j] = col;
	if (x[i + 1][j] != x[i][j])
	{
		go(i + 1, j);
	}
	if (x[i - 1][j] != x[i][j])
	{
		go(i - 1, j);
	}
	if (x[i][j + 1] != x[i][j])
	{
		go(i, j + 1);
	}
	if (x[i][j - 1] != x[i][j])
	{
		go(i, j - 1);
	}
}

main()
{
	ios_base::sync_with_stdio(0);
	cin >> n >> m;
	FOR(i, 1, n+1)
	{
		FOR(j, 1, m+1)
		{
			cin >> x[i][j];
		}
	}

	FOR(i, 1, n + 1)
	{
		FOR(j, 1, m + 1)
		{
			if (!was[i][j] && x[i][j] == '#')
			{
				++col;
				go(i, j);
			}
		}
	}

	LL ans = 0;
	FOR(i, 1, n + 1)
	{
		FOR(j, 1, m + 1)
		{
			kol[was[i][j]]++;
			if (x[i][j] == '#')
			{
				cnt[was[i][j]]++;
			}
//			cout << was[i][j] << ' ';
		}
//		cout << endl;
	}
	for(int i = 1;i <= col;++i)
	{
//		cout << kol[i] << " " << cnt[i] << endl;
		ans += (kol[i] - cnt[i]) * cnt[i];
	}

	cout << ans;

	return 0;
}


Measured memory_bytes: 19072
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
int main(void){
	int a[300000];
	priority_queue<int> max;
	priority_queue<int> min;
	int n;
	long long amax[100001];
	long long amin[100001];
	long long ans;
	ans = -1000000000000000;
	for (int i = 0; i < 100001; i++){
		amax[i] = 0;
		amin[i] = 0;
	}
	scanf("%d", &n);
	for (int i = 0; i < 3 * n; i++){
		scanf("%d", &a[i]);
		if (i < n){
			max.push(-a[i]);
			amax[0] = amax[0] + a[i];
		}
		if (i >= 2 * n) {
			min.push(a[i]);
			amin[0] = amin[0]+a[i];
		}
	}
	for (int i = 0; i < n; i++){
		if (a[n+i] > -(max.top())){
			amax[i+1] = amax[i] + a[n+i] + (max.top());
			max.pop();
			max.push(-a[n + i]);
		}
		else amax[i + 1] = amax[i];
	}
	for (int i = 1; i <= n; i++){
		if (a[2*n - i] < (min.top())){
			amin[i] = amin[i-1] + a[2*n - i] - (min.top());
			min.pop();
			min.push(a[2*n - i]);
		}
		else amin[i ] = amin[i-1];
	}
	for (int i = 0; i <= n; i++){
		if (ans < amax[i] - amin[n - i])ans = amax[i] - amin[n - i];
	}
	printf("%lld\n", ans);
	return 0;
}


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

goto_N = [0]*N
from_1 = [0]*N

for _ in range(M):
    a,b = map(int,input().split())
    if a == 1:
        from_1[b] = 1
    elif b == N:
        goto_N[a] = 1

for i in range(N):
    if goto_N[i] and from_1[i]:
        print("POSSIBLE")
        exit()

print("IMPOSSIBLE")

Measured memory_bytes: 6132
#include <iostream>
using namespace std;
int main() {
	int k, n, a[200000],max=0;
	cin >> k >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n-1; i++) {
		if (a[i + 1] - a[i] > max) {
			max = a[i + 1] - a[i];
		}
	}
	if (a[0] + k - a[n - 1] > max) {
		max = a[0] + k - a[n - 1];
	}
	cout << k - max << endl;
	return 0;
}

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
"""
Created on Mon Apr 30 11:33:59 2018
ALDS1-4a_r  バイナリサーチ

@author: maezawa
"""

def binary_search(a, key):
    n = len(a)
    left = 0
    right = n
    while left < right:
        #print(left, right)
        mid = (right+left)//2
        if a[mid] == key:
            return mid
        elif a[mid] > key:
            right = mid
        else:
            left = mid + 1
    return n

n = int(input())
s = list(map(int, input().split())) # in演算子を使うためにはsはlistである必要がある。
q = int(input())
t = map(int, input().split())

cnt = 0
for i in t:
    if binary_search(s, i) < n:
        cnt += 1

print(cnt)


Measured memory_bytes: 16720
#include<bits/stdc++.h>
using namespace std;
string s;
int main(){
	getline(cin,s);
	for(int i=0;i<s.size();i++){
		if(i%2==0){
			if(s[i]!='R'&&s[i]!='U'&&s[i]!='D'){
				cout<<"No";
				return 0;
			}
		}else{
			if(s[i]!='L'&&s[i]!='U'&&s[i]!='D'){
				cout<<"No";
				return 0;
			}
		}
	}
	cout<<"Yes";
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int x = sc.nextInt();
        int [] cost = new int [n+1];
        for(int i = 0; i < m; i++) {
        	cost[sc.nextInt()]++;
        }
        int left = cost(cost,0,x);
        int right = cost(cost,x,n);
        System.out.println(Math.min(left,right));
    }

    static int cost(int[]cost,int start, int end) {
    	int r = 0;
    	for(int i = start; i <= end; i++) {
    		r += cost[i];
        }
    	return r;
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(v) v.begin(), v.end()
#define revall(v) v.rbegin(), v.rend()
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){ if(y<h && y>=0 && x<w && x>=0) return true; return false; }
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; }






int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b;cin >> a >> b;
	if(a >= 13) cout << b << endl;
	else if(a >= 6) cout << b / 2 << endl;
	else cout << 0 << endl;
}


Measured memory_bytes: 256
/*JAI SHREE RAM
HAR HAR MAHADEV*/
 
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef stack<ll> sll;
typedef queue<ll> qll;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<string> vs;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef pair<ll, pll> ppll;
typedef vector<vector<ll>> vvll;
typedef priority_queue<ll> pqll;
 

#define mod 1000000007
#define pb push_back
#define mp make_pair
#define pob pop_back
#define beg begin
#define gcd __gcd
#define bs binary_search
#define lbd lower_bound
#define ubd upper_bound
#define npr next_permutation
#define ppr prev_permutation
#define bp __builtin_popcountll
#define ff first
#define ss second
#define pi 3.1415926535
#define TEST unsigned long long T; cin>>T; while(T--)
 
const char nl='\n';
const ll MAX=INT_MAX;
const ll MIN=INT_MIN;

bool sortbysec(const pair<int,int> &a, const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
} 

void solve()
{
    ll n,i,x,y,j,f=0,c=0;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>x>>y;
        if(x==y)
        {
            c++;
            if(c>=3)
            f=1;
        }
        else
        c=0;
    }
    if(f)
    cout<<"Yes"<<nl;
    else
    cout<<"No"<<nl;
}

int main() 
{ 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout<<fixed<<setprecision(20);
    #ifndef ONLINE_JUDGE
    freopen("i.txt", "r", stdin);
    freopen("o.txt", "w", stdout);    
    #endif
    //cout<<fixed<<setprecision(20);
   //TEST
    solve();
    
return 0;
}

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

int main(){
    int n, x[100];
    cin >> n;

    rep(i,n) cin >> x[i];

    ll min = 9223372036854775807;

    rep(i,100){
        int sum = 0;
        rep(j,n) sum += (i - x[j]) * (i - x[j]);
        if (sum < min) min = sum;
    }

    cout << min << endl;

    return 0;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string a;
    cin>>a;
    string b=a;
    reverse(a.begin(),a.end());
    for(int i=0;i<a.size();++i)
    {
        if(a[i]=='b') a[i]='d';
        else if(a[i]=='d') a[i]='b';
        else if(a[i]=='p') a[i]='q';
        else if(a[i]=='q') a[i]='p';
    }
    if(a==b) cout<<"Yes";//判断
    else cout<<"No";
}

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

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;

using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

int n,m;
pii v[125252];

int main(){
    multiset<int> S;
    scanf("%d%d",&n,&m);
    REP(i,n){
        int a;
        scanf("%d",&a);
        S.insert(a);
    }
    REP(i,m){
        int b,c;
        scanf("%d%d",&b,&c);
        v[i] = pii(c,b);
    }
    sort(v,v+m);
    reverse(v,v+m);
    ll ans = 0;
    REP(i,m){
        int c = v[i].first;
        int b = v[i].second;
        while(S.size() > 0 && *S.rbegin() >= c){
            int x = *S.rbegin();
            S.erase(S.find(x));
            ans += x;
        }
        while(b-->0 && S.size()>0){
            S.erase(S.begin());
            ans += c;
        }
    }
    while(S.size()>0){
        ans += *S.begin();
        S.erase(S.begin());
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 5760
package main

import (
	"fmt"
)

func main() {
	var s, t, u string
	var a, b int
	fmt.Scan(&s, &t, &a, &b, &u)

	if s == u {
		a--
		fmt.Println(a, " ", b)
	} else {
		b--
		fmt.Println(a, " ", b)
	}
}


Measured memory_bytes: 1828
#include <iostream>
using namespace std;
int main(void){
    int x, y;
    
    for (x = 1; x <= 9; x++) {
        for (y = 1; y <= 9; y++) {
            cout << x << "x" << y << "=" << x*y << endl;
        }
    }// Your code here!
    return 0;
}



Measured memory_bytes: 3080
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <math.h>
#include <queue>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> P;
#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.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 INF = 1<<30;
const int mod = 1000000007;

int main(){
	int n;
	cin >> n;
	pair<pair<string, int>, int> P[n];
	rep(i,n){
		string s;
		int p;
		cin >> s >> p;
		P[i] = make_pair(make_pair(s, -p), i+1);
	}
	sort(P, P+n);
	rep(i,n) cout << P[i].second << endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
s = [input() for i in range(n)]
ac = s.count('AC')
wa = s.count('WA')
tle = s.count('TLE')
re = s.count('RE')

print('AC x '+str(ac))
print('WA x '+str(wa))
print('TLE x '+str(tle))
print('RE x '+str(re))

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

int main(){
    long int N,M;
    cin>>N>>M;
    long int A[N],sum=0;
    for (long int i=0;i<N;i++){
        cin>>A[i];
        sum+=A[i];
    }
    sort(A,A+N);
    if (4*M*A[N-M]<sum) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define loop for(;;)
using i64 = int64_t;

int main() {
    loop {
        std::string s;
        i64 y, m, d;
        std::cin >> s;
        if (s == "#") {
            break;
        }
        std::cin >> y >> m >> d;
        if (y * 1000000 + m * 1000 + d >= 31 * 1000000 + 5 * 1000 +1) {
            printf("? %ld %ld %ld\n", y-30, m, d);
        }
        else {
            printf("HEISEI %ld %ld %ld\n", y, m, d);
        }
    }
}



Measured memory_bytes: 3184
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;

int main (){
  int N;
  cin >>N;
  ll M=0,A=0,R=0,C=0,H=0;
  ll ans=0;
  string s;
  for(int i=1;i<=N;i++){
    cin >> s;
    if(s[0]=='M')M++;
    if(s[0]=='A')A++;
    if(s[0]=='R')R++;
    if(s[0]=='C')C++;
    if(s[0]=='H')H++;
  }
    ans=(M*A*R)+(M*A*C)+(M*A*H)+(A*R*C)+(A*C*H)+(R*C*H)+(M*R*H)+(A*R*H)+(C*H*M)+(C*R*M);
    cout << ans;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
int H[100000];
int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> H[i];
	}
	H[0]--;
	for (int i = 1; i < N; i++) {
		if (H[i - 1] > H[i]) {
			cout << "No" << endl;
			return 0;
		}
		else if (H[i - 1] < H[i]) {
			H[i]--;
		}
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
using namespace std;
long long n , mod = 1e9+7;
long long sol()
{
	long long a=1 ,b=1 ,c=1 ,res = 0 ,t=0;
	while(t++<n)
	{
		a = (a*10)%mod; 
		b = (b*9)%mod; 
		c = (c*8)%mod;
	} 
	b = (b*2)%mod;
	res = (a-b+mod+c)%mod;
	return res;				
}

int main() 
{	
	cin >> n;
	cout<<sol()<<'\n';
}

Measured memory_bytes: 3136
(* O(n^2) *)
let n = Scanf.scanf " %d" @@ (+) 0
let xys = Array.init n @@ fun _ -> Scanf.scanf " %d %d" @@ fun a b -> a, b
let h = Hashtbl.create @@ n * n
let _ =
  if n = 1 then (print_endline "1"; exit 0);
  (xys |> Array.iteri @@ fun i (x0, y0) ->
    xys |> Array.iteri @@ fun j (x, y) ->
      if i <> j then
        let p, q = x - x0, y - y0 in
        try let e = Hashtbl.find h (p, q) in Hashtbl.add h (p, q) @@ e + 1 with
        _ -> Hashtbl.add h (p, q) 1);
  Hashtbl.fold (fun _ e acc -> min acc @@ n - e) h max_int |> Printf.printf "%d\n"

Measured memory_bytes: 768
object Main extends App {
	val Array(n,m,c) = scala.io.StdIn.readLine.split(" ").map(_.toInt)
	val b = scala.io.StdIn.readLine.split(" ").map(_.toInt)

	var ans = 0

	for(i<-0 until n){
		val tp = scala.io.StdIn.readLine.split(" ").map(_.toInt)
		var tq = c
		for(j<-0 until m){
			tq = tq + tp(j)*b(j)
		}

		if(tq > 0) ans = ans + 1
	}

	println(ans)

}

Measured memory_bytes: 25536
#include <algorithm>
#include <bitset>
#include <boost/dynamic_bitset.hpp>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeindex>
#include <typeinfo>
#include <vector>

#define DEBUG(x) cout << #x << ": " << x << endl
#define INFILE() freopen("input.txt", "r", stdin)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define ALL(s) begin(s), end(s)
#define RALL(s) rbegin(s), rend(s)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_i = pair<ll, int>;
using i_ll = pair<int, ll>;
using d_i = pair<double, int>;
using ll_ll = pair<ll, ll>;
using d_d = pair<double, double>;

static constexpr ll LL_MOD = 1000000009;
static constexpr int I_MOD = 1000000007;
static constexpr double EPS = numeric_limits<double>::epsilon();
static constexpr double PI = 3.14159265358979323846264338327950288;

template <class T> static void scan(vector<T> &v);
static void scan(vector<string> &v, bool isWord = true);
static boost::dynamic_bitset<> scan(char trueValue = 'o');

int main(int argc, char *argv[]) {
  // INFILE();
	int a, b, c, d;
	cin >> a >> b >> c >> d;

	int areaA = a * b, areaB = c * d;

	cout << max(areaA, areaB) << endl;
  return 0;
}

template <class T> static void scan(vector<T> &v) {
  map<type_index, const char *const> m = {{typeid(int), "%d"},
                                          {typeid(ll), "%lld"},
                                          {typeid(double), "%lf"},
                                          {typeid(char), "%c"}};

  auto tFormat = m[typeid(T)];

  for (T &n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string> &v, bool isWord) {
  if (isWord) {
    for (auto &n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

static boost::dynamic_bitset<> scan(char trueValue) {
  string s;
  getline(cin, s);

  if (s.size() == 0) {
    getline(cin, s);
  }

  for_each(begin(s), end(s),
           [trueValue](char &c) { c = (c == trueValue) ? '1' : '0'; });
  return boost::dynamic_bitset<>(string(rbegin(s), rend(s)));
}


Measured memory_bytes: 256
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <valarray>
using namespace std;
#define INF 100000000

typedef long long ll;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
int M, N, D;

int solve(valarray<valarray<int> >& A) {
    int p = 0;
    for (int i = 0; i < M*N; i++) {
        int r;
        for (r = p; r < M*N; r++) {
            if (A[r][i] != 0) break;
        }
        if (r == M*N) continue;
        swap(A[p], A[r]);
        for (int j = p+1; j < M*N; j++) {
            if (A[j][i]) {
                A[j] += A[p];
                A[j] %= 2;
            }
        }
        p++;
    }
    for (int r = 0; r < M*N; r++) {
        if (A[r][M*N] != 0) {
            int i;
            for (i = 0; i < M*N; i++) {
                if (A[r][i] != 0) break;
            }
            if (i == M*N) return 0;
        }
    }
    return 1;
}

int main(void) {
    while (cin >> M >> N >> D && M) {
        valarray<valarray<int> > A(valarray<int>(0, M*N+1), M*N);
        for (int i = 0; i < M*N; i++) {
            cin >> A[i][M*N];
            int x0 = i % M, y0 = i / M;
            for (int j = 0; j < M*N; j++) {
                int x1 = j%M, y1 = j/M;
                int d = abs(x0 - x1) + abs(y0 - y1);
                if (d == 0 || d == D) A[i][j] = 1;
            }
        }
        cout << solve(A) << endl;
    }
    return 0;
}

Measured memory_bytes: 2640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll dp[1 << 17];
int n;
ll t[100][100];

int main() {
	while (cin >> n&&n) {
		fill(dp, dp + (1 << 17), INF);
		dp[0] = 0;
		rep(i, n) {
			rep(j, n + 1)cin >> t[i][j];
		}
		rep(i, (1 << n)) {
			rep(j, n) {
				if (i&(1 << j))continue;
				ll num = t[j][0];
				rep(k, n) {
					if (i&(1 << k))num = min(num, t[j][k + 1]);
				}
				dp[(i | (1 << j))] = min(dp[i | (1 << j)], dp[i] + num);
			}
		}
		cout << dp[(1 << n) - 1] << endl;
	}
}


Measured memory_bytes: 4104
r,c = map(int,input().split())
a = []
x = []

for i in range(c+1):
    x.append(0)

for i in range(r):
    b = [int(s) for s in input().split()]
    b.append(sum(b))
    a.append(b)


for i in range(c+1):
    for j in range(r):
        x[i] = x[i] + a[j][i]
        
a.append(x)


for i in range(r+1):
    print(" ".join(map(str,a[i])))



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

int main(){
  int n;
  cin >> n;
  long long ans=0;
  int a=100000;
  int b;
  for(int i=0; i<n-1; i++){
    cin >> b;
    ans += min(a,b);
    a = b;
  }
  //cin >> b;
  ans += b;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <cstdint>

int main() {
  std::int64_t N, Q;
  std::cin >> N >> Q;
  std::vector<std::map<int, int>> counts(2);
  for (int i = 0; i < 2; ++i) {
    counts[i][N] = N - 2;
  }
  std::int64_t stones = (N - 2) * (N - 2);
  for (int i = 0; i < Q; ++i) {
    int d, x;
    std::cin >> d >> x;
    const auto [y, count] = *counts[d - 1].upper_bound(x);
    stones -= count;
    if (x - 2 < counts[2 - d].begin()->second) {
      counts[2 - d][count + 2] = x - 2;
    }
  }
  std::cout << stones << std::endl;
  return 0;
}


Measured memory_bytes: 8104
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll n, m;
    cin >> n >> m;
    string s, t;
    cin >> s >> t;
    rep(i, 0, n) {
        if ((i*m) % n == 0) {
            if (s[i] == t[i*m/n]) continue;
            else {
                cout << -1 << endl;
                return 0;
            }
        }
    }
    cout << n * m / __gcd(n, m) << endl;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int x = sc.nextInt();
        boolean flg = false;
        if(k*500>=x) {
            // System.out.println("k:"+k*500+"x:"+x);
            System.out.println("Yes");
        } else {
            // System.out.println("k:"+k*500+"x:"+x);
            System.out.println("No");
        }

    }
}

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

#define times(n, i)      uptil(0, n, i)
#define upto(f, t, i)    for(decltype(t) _##i = (t), i = (f); i <= _##i; i++)
#define uptil(f, t, i)   for(decltype(t) _##i = (t), i = (f); i < _##i; i++)
#define downto(f, t, i)  for(decltype(t) _##i = (t), i = (f); i >= _##i; i--)
#define downtil(f, t, i) for(decltype(t) _##i = (t), i = (f); i > _##i; i--)
#define unless(c) if(!(c))
#define until(c) while(!(c))
#define loop while(true)

#define all(v) v.begin(), v.end()
#define ln << "\n"

struct line{};

template<class T> istream& operator>>(istream& in, vector<T>& v) {
    times(v.capacity(), i) in >> v[i];
    return in;
}

template<class T> const ostream& operator<<(ostream& out, const vector<T>& v) {
    times(v.size(), i) out << (i ? " " : "") << v[i];
    return out;
}

template<class T, class...U> typename enable_if<is_same<T, line>::value, string>::type next(istream& in, const U&... args) {
    string s;
    getline(in, s, args...);
    return move(s);
}

template<class T, class...U> typename enable_if<!is_same<T, line>::value, T>::type next(istream& in, const U&... args) {
    T t(args...);
    in >> t;
    return move(t);
}
template<class T, class...U> auto next(const U&... args) -> decltype(next<T>(cin)) {
    return next<T>(cin, args...);
}

template<class T> T sum(const vector<T>& v) {
    T ans = T();
    for(const T& t : v) ans += t;
    return ans;
}

template<class T> T sum(const typename vector<T>::iterator& begin, const typename vector<T>::iterator& end) {
    T ans = T();
    for(typename vector<T>::iterator t = begin; t != end; t++) ans += *t;
    return ans;
}

template<class T> T min(const vector<T>& v) {
    return *min_element(v.begin(), v.end());
}

template<class T> T min(const typename vector<T>::iterator& begin, const typename vector<T>::iterator& end) {
    return *min_element(begin, end);
}

template<class T> T max(const vector<T>& v) {
    return *max_element(v.begin(), v.end());
}

template<class T> T max(const typename vector<T>::iterator& begin, const typename vector<T>::iterator& end) {
    return *max_element(begin, end);
}

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

    int H = next<int>(), W = next<int>();

    times(H, _) {
        auto C = next<string>();
        int t = -1;
        times(W, i) {
            if(C[i] == 'c') t = 0;
            else if(t != -1) t++;
            cout << (i ? " " : "") << t;
        }
        cout ln;
    }

    return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
#include <fstream>
#include <vector>
#include <bitset>
#include <unordered_map>
#include <algorithm>
#include <queue>
#include <math.h>
#include <iomanip>

using namespace std;

/********** TEMPLATE STARTS HERE ***********/

#define IOS ios::sync_with_stdio(false), cin.tie(0);
#define all(v) v.begin(), v.end()
#define F first
#define S second
#define pb push_back
#define PI 3.1415926535897932384626433832795
#define gcd __gcd 
#define digits(n) (int)(log10(n) + 1)

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <long long> vl;
typedef vector <pll> vll;
typedef vector <pii> vii;

const int INF = 0x3f3f3f3f;
const int LINF = 0x3f3f3f3f3f3f3f3f;

template <typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template <typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

/********** TEMPLATE ENDS HERE ***********/

main()
{
	IOS
	
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	
	cout << min(a, b) + min(c, d);
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a_po;
  cin >> a_po;
  int a[a_po];
  int count = 0;
  for(int i = 0; a_po > i;i++){
    cin >> a[i];
  }
  int b_po;
  cin >> b_po;
  int b[b_po];
  for(int i = 0;b_po > i; i++){
    cin >> b[i];
  }
  int c_po;
  cin >> c_po;
  int c[c_po];
  for(int i = 0;c_po > i; i++){
    bool have = false;
    bool bs = false;
    bool a_s = false;
    cin >> c[i];
    for(int j=0; a_po > j; j++){
      if(c[i] == a[j]){
        a_s = true;
        for(int k = 0; b_po > k; k++){
          if(c[i] == b[k]){
            have = true;
            bs = true;
            break;
          }
        }
        if(bs){
          break;
        }
      }
    }
    if(!a_s){
      have = true;
    }
    if(have) count++;
  }
  cout << count << endl;
}


Measured memory_bytes: 3096
import math
N = int(input())
count = 0
def divisoros_count(n):
    num = 0
    for i in range(1,int(math.sqrt(n))+1):
        if n % i == 0:
            num += 1
            if n != i**2:
                num += 1
    return num

for i in range(1,N+1,2):
    if divisoros_count(i) == 8:
        count += 1

print(count)

Measured memory_bytes: 9088
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

sum_counter = 0

for i in range(N):
    num = a[i] - 1
    sum_counter += b[num]

    if i < N-1 and a[i+1] - 1 == a[i]: 
        sum_counter += c[num]

print(sum_counter)

Measured memory_bytes: 3064
#include <stdio.h>

int main() {
    int k, a, b, i, mult=0;
    scanf("%d", &k);
    scanf("%d%d", &a, &b);
    for(i=a; b>=i; ++i){
        if(i%k==0){
            mult = mult + i;
        }
    } 
    if(mult>0){
        printf("OK");
    } else{
        printf("NG");
    }
    return 0;
}


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

using ll = long long;
const ll MOD = 998244353;

int main() {
    int N;
    cin >> N;
    vector<ll> A(N), B(N), C(N);
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];
    rep(i, N) cin >> C[i];
    sort(A.begin(), A.end());
    sort(C.begin(), C.end());
    ll ans = 0;
    rep(i, N) {
        int x = lower_bound(A.begin(), A.end(), B[i]) - A.begin();
        int y = upper_bound(C.begin(), C.end(), B[i]) - C.begin();
        ans += 1LL * x * (N - y);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 2560
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iostream>

using namespace std;

#define FOR(i, a, b)   for(int i = (a); i < (b); i++)
#define RFOR(i, a, b)  for(int i = (a); i > (b); i--)
#define rep(i, n)	   for(int i = 0; i < (n); i++)
#define all(c)		   begin(c), end(c)
#define rall(c)		   rbegin(c), rend(c)
#define foritr(itr, c) for(auto itr = begin(c); itr != end(c); itr++)
#define SZ(a)		   ((ll) a.size())

typedef long long int		   ll;
typedef long long unsigned int llu;

void solve(string A, string B, string C) {
	auto s1 = end(A);
	s1--;
	auto s2 = begin(B);
	auto s3 = end(B);
	s3--;
	auto s4 = begin(C);
	if(*s1 == *s2 and * s3 == *s4) printf("YES");
	else printf("NO");
}

int main() {
	string A;
	string B;
	string C;
	cin >> A;
	cin >> B;
	cin >> C;
	solve(A, B, C);
	return 0;
}


Measured memory_bytes: 256
def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))

    ans = []
    for i in range(k, n):
        if a[i-k] < a[i]:
            ans.append('Yes')
        else:
            ans.append('No')

    for x in ans:
        print(x)


if __name__ == '__main__':
    main()


Measured memory_bytes: 31488
#include<bits/stdc++.h>
#include <algorithm>
#include <cctype>
#include <iostream>
#include <string>
using namespace std;

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

const ll MOD = 1e9+7;

// Combinationの使い方
// vector<vector<ll>> v(N+1, vector<ll>(N+1, 0));
// comb(v);
void comb(vector<vector<ll>> &v){
    for(int i = 0; i < v.size(); i++){
        v[i][0] = 1;
        v[i][i] = 1;
    }
    for(int k = 1; k < v.size(); k++){
        for(int j = 1; j < k; j++){
            v[k][j] = (v[k-1][j-1] + v[k-1][j]);
            //余りを求める問題は毎回計算ごとにやる
            // v[k][j] = (v[k-1][j-1] + v[k-1][j]) % MOD;
        }
    }
}

// Union Find
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

// vector<tuple<long,long>> items; // (value, weight)
// auto item = items[i];
// long v = get<0>(item);
// long w = get<1>(item);
// long v, w;
//   for( int i = 0; i < N; i++ ){
//     cin >> v >> w;
//     items.push_back( make_tuple(v, w) ); // item : (value, weight)
//   }

// 1 << 3 : int "3" change to bit "100"
// rep(pattern, 1 << N) if (pattern & (1 << x)) cnt++

int main(){
    string s;
    cin >> s;
    cout << s[0] << s.size()-2 << s[s.size()-1] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll T, a, b, c, d;
int main() {
	cin >> T;
	while (T--) {
		cin >> a >> b >> c >> d;
		if (d < b || a < b) {
			puts("No");
			continue;
		}
		if (c >= b) {
			puts("Yes");
			continue;
		}
		a -= a / b * b;
		if (a > c) {
			puts("No");
			continue;
		}
		d -= d / b * b;
		if (d == 0) {
			puts("Yes");
			continue;
		}
		ll t1 = c - a;
		ll t2 = b - a;
		ll g = __gcd(d, b);
		if (t1 / g * g + g < t2) 
			puts("No");
		else 
			puts("Yes");
	}
}

Measured memory_bytes: 256
N = int(input())
abc = [ [int(i) for i in input().split()] for i in range(N)]

a = [0]*(N+1)
b = [0]*(N+1)
c = [0]*(N+1)

for i in range(0, N):
    a[i+1] = max(b[i]+abc[i][0], c[i]+abc[i][0])
    b[i+1] = max(a[i]+abc[i][1], c[i]+abc[i][1])
    c[i+1] = max(a[i]+abc[i][2], b[i]+abc[i][2])
  
print(max(a[-1],b[-1],c[-1]))

Measured memory_bytes: 36172
#include <cstdio>
#include <string>
struct Istream {
	Istream() {
#ifdef DEBUG
		freopen("input","r",stdin);
#endif
	}
	template <class T> 
	Istream &operator >>(T &x) {
		static char ch;static bool neg;
		for(ch=neg=0;ch<'0' || '9'<ch;neg|=ch=='-',ch=getchar());
		for(x=0;'0'<=ch && ch<='9';(x*=10)+=ch-'0',ch=getchar());
		x=neg?-x:x;
		return *this;
	}
}is;
struct Ostream {
	template <class T>
	Ostream &operator <<(T x) {
		x<0 && (putchar('-'),x=-x);
		static char stack[233];static int top;
		for(top=0;x;stack[++top]=x%10+'0',x/=10);
		for(top==0 && (stack[top=1]='0');top;putchar(stack[top--]));
		return *this;
	}
	Ostream &operator <<(char ch) {
		putchar(ch);
		return *this;
	}
}os;
#define int64 long long
#include <iostream>
const int MAXN=500+11;
int main() {
	int H,W,h,w;
	is>>H>>W>>h>>w;
	if(h==1 && w==1) {
		std::cout<<"No"<<'\n';
		return 0;
	} 
	int t=(int)((int)(1e9-1)%(h*w)==0?1e9-2:1e9-1)/(h*w-1),x=-((h*w-1)*t+1);
	static int map[MAXN][MAXN];
	int64 sum=0;
	for(int i=1;i<=H;++i) {
		for(int j=1;j<=W;++j) {
			sum+=map[i][j]=i%h==0 && j%w==0?x:t;
		}
	}
	if(sum>0) {
		std::cout<<"Yes"<<'\n';
		for(int i=1;i<=H;++i) {
			for(int j=1;j<=W;++j) {
				os<<map[i][j]<<(j==W?'\n':' ');
			}
		}
	} else {
		std::cout<<"No"<<'\n';
	}
	return 0;
}


Measured memory_bytes: 3968
n = int(input())
P = list(map(int, input().split()))

res = 0
for i in range(n):
    if i + 1 == P[i]:
        if i == n - 1:
            res += 1
        else:
            P[i], P[i + 1] = P[i + 1], P[i]
            res += 1
print(res)

Measured memory_bytes: 14008
import java.util.LinkedList;
import java.util.Scanner;
import java.util.ArrayList;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if (n >= 30){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }

        //何回かやったそのうち一番良い結果になった物を出力（学習させていく感じ）
        //LinkedList?をn回繰り返して最良の物を選ぶ？
    }
}


Measured memory_bytes: 35612
#include<bits/stdc++.h>
#define st first
#define nd second
#define PQ priority_queue

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

int main(){
	int n, x, t;
	scanf("%d %d %d", &n, &x, &t);
	printf("%d", ((n + x - 1) / x) * t);	


}

Measured memory_bytes: 3808
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from itertools import accumulate

n = ni()
a = list(li())

a.sort()

cum = list(accumulate(a))

ans = 1

for i in range(len(a) - 2, -1, -1):
    if a[i+1] > 2*cum[i]:
        break

    ans += 1

print(ans)


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

#include <unistd.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
 
 
typedef long long ll;
//#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx_ori[4] = { -1,0, 1,0 }, dy_ori[4] = { 0,1,0,-1 };
int dx[4] = {0, 0, 0, 0}, dy[4] = {0, 0, 0, 0};
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'

signed main() {
  string s;
  cin >> s;
  int n = s.size();
  int ans = 0;
  for (int i = 0; n - i - 1 > i; i++) {
    if (s[i] != s[n - 1 - i]) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<vector>
#include<string>
#include <ios>     
#include <iomanip> 
using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

const llong MOD = 1000000007;

llong gcd(llong a, llong b) {
	if (a < b) swap(a, b);
	if (a % b == 0) return b;
	else return gcd(b, a % b);
}

llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}

//ここまで共通

int N, Y;

int main() {

	cin >> N >> Y;
	bool flag = false;
	for (int i = 0; i <= Y / 10000 && i <= N; i++) {
		for (int j = 0; j <= (Y - i * 10000)/5000 && i + j <= N; j++) {
			if (i * 10000 + 5000 * j + (N - i - j) * 1000 == Y) {
				flag = true;
				cout << i << " " << j << " " << N - i - j;
				break;
			}
			if (flag) break;
		}
		if (flag) break;
	}

	if (!flag) cout << "-1 -1 -1";
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass
{
    static void Main()
    {
        var NMK = ReadLine().Split().Select(int.Parse).ToArray();
        int N = NMK[0];
        int M = NMK[1];
        long K = NMK[2];
        var A = ReadLine().Split().Select(long.Parse).ToArray();
        var B = ReadLine().Split().Select(long.Parse).ToArray();
        var da = new long[N + 1];
        var db = new long[M + 1];

        for (int i = 0; i < N; i++)
        {
            da[i + 1] = da[i] + A[i];
        }
        for (int i = 0; i < M; i++)
        {
            db[i + 1] = db[i] + B[i];
        }
        long ans = 0;
        for (int i = 0; i < N+1; i++)
        {
            long timeleft = K - da[i];
            if (timeleft < 0) break;

            int lb = 0, ub = M+1;
            while (ub - lb > 1)
            {
                var mid = (lb + ub) / 2;
                if (timeleft-db[mid]>=0) lb = mid;
                else ub = mid;
            }
            ans = Max(ans, i + lb);
        }
        WriteLine(ans);
    }
}



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

using namespace std;

int main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout<<fixed;*/

    int n,k;cin>>n>>k;
    string s;cin>>s;
    s[k-1]=s[k-1]+32;
    cout<<s;


    return 0;
}

Measured memory_bytes: 256
n, k = gets.split.map(&:to_i)
ary = []
(k*2).times do 
  ary << gets.split.map(&:to_i)
end
ans = Array.new(n, 0)
ary.each_with_index do |k, i|
  if i.odd?
    k.each do |l|
      ans[l-1]+=1
    end
  end
end
count = 0
ans.each do |m|
  count+=1 if m==0
end
puts count



Measured memory_bytes: 14380
/* ***********************************************
Author        :devil
************************************************ */
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <stdlib.h>
#define inf 0x3f3f3f3f
#define LL long long
#define rep(a,b) for(int i=a;i<=b;i++)
#define dec(a,b) for(int i=a;i>=b;i--)
#define ou(a) printf("%d\n",a)
#define pb push_back
#define mkp make_pair
template<class T>inline void rd(T &x){char c=getchar();x=0;while(!isdigit(c))c=getchar();while(isdigit(c)){x=x*10+c-'0';c=getchar();}}
#define IN freopen("in.txt","r",stdin);
#define OUT freopen("out.txt","w",stdout);
using namespace std;
const int mod=1e9+7;
const int N=2e3+10;
int n,x,a[N],mi[N][N];
LL ans;
int main()
{
    rd(n),rd(x);
    rep(1,n) rd(a[i]),ans+=a[i];
    rep(1,n) for(int j=i;j<=n;j++) mi[i][j]=(j==i)?a[i]:min(a[j],mi[i][j-1]);
    for(int l=1;l<n;l++)
    {
        LL now=(LL)l*x;
        rep(1,n) now+=(i>l)?mi[i-l][i]:min(mi[1][i],mi[i+n-l][n]);
        ans=min(ans,now);
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 14080
import java.util.*;
// import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{

	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
	    int[] h = new int[n];
	    int[] dp = new int[n];
	   // int i =0;
	   // List<node> order = new ArrayList<node>();
		for(int i=0;i<n;i++)
		{
		    h[i] = sc.nextInt();
		    if(i==0)
		        dp[i]=0;
		    else if(i==1)
		        dp[i] = dp[0]+Math.abs(h[i]-h[0]);
		    else
		        dp[i] = Math.min(dp[i-1]+Math.abs(h[i]-h[i-1]),dp[i-2]+Math.abs(h[i]-h[i-2]));
		}
		System.out.print(dp[n-1]);
	}
}


Measured memory_bytes: 52156