akhauriyash/Code-Regression huggingface dataset:
/*
    JAI JAGANNATH!
*/
//@Author : zanj0
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int lli;
#define ff              first
#define ss              second
#define pb              push_back
#define mp              make_pair
#define pii             pair<lli,lli>
#define vi              vector<lli>
#define mii             map<lli,lli>
#define pqb             priority_queue<lli>
#define pqs             priority_queue<lli,vi,greater<lli> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            lli x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<lli, null_type, less<lli>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void zanj0()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  
}
void solve() {

	string s1, s2;
	cin >> s1 >> s2;
	bool ok = s1.size() < s2.size();
	if (ok) {
		for (int i = 0; i < s1.size(); i++) {
			if (s1[i] != s2[i]) ok = false;
		}
	}
	if (ok) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}
int main()
{
	zanj0();
	solve();
	return 0;
}

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

vector<int> plus2(vector<int> a)
{
    a[0] ++;
    for(int i = 0;i<a.size()-1;i++)
    {
        if(a[i] == 10)
        {
            a[i+1]++;
            a[i] = 0;
        }
    }
    if(a[a.size()-1] == 10)
    {
        a[a.size()-1] = 0;
        a.push_back(1);
    }
    return a;
}

vector<int> plus1(vector<int> a, int k)
{
    if(k==0)
    {
        a = plus2(a);
        return a;
    }
    for(int i = 0;i<k-1;i++)
    {
        a[i] = 0;
    }
    a[k-1] = a[k];
    if(a[k] != 0 && k > 1)
    {
        a[k-2] = a[k] - 1;
    }
    a[k]++;
    
    for(int i = k;i<a.size();i++)
    {
        if(a[i] == 10)
        {
            if(a.size() == i)
            {
                a.push_back(1);
            }
            else
            {
                a[i+1]++;
            }
        }
    }
    
    return a;
}



int main()
{
    int K;
    cin >> K;
    vector<int> l;
    l.push_back(0);
    vector<int> temp;
    temp.push_back(0);
    
    for(int i = 0;i<K;i++)
    {
        l = plus2(l);
        bool run = true;
        while(run)
        {
            run = false;
            for(int j = (int)l.size()-1; j > 0;j--)
            {
                if(l[j]-l[j-1] < -1)
                {
                    l = plus1(l,j);
                    run = true;
                    break;
                }
                else if(l[j] - l[j-1] > 1)
                {
                    l = plus1(l,j-1);
                    run = true;
                    break;
                }
            }
        }
    }
    
    for(int i = 0;i<l.size();i++)
    {
        cout << l[l.size()-1-i];
    }
    
    cout << endl;

    
    return 0;
}

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

using namespace std;

int main()
{
        int ans=0;
        vector<int> v;
        int tmp;
        for(int i=0;i<3;i++){
                cin>>tmp;
                v.push_back(tmp);
        }
        sort(v.begin(),v.end(),greater<int>());

        if(((v[0]-v[1])%2)!=((v[0]-v[2])%2)){
                v[0]++; v[2]++;
                ans++;
        }

        ans+=v[0]-v[1];
        v[2]+=v[0]-v[1];
        ans+=(v[0]-v[2])/2;
        cout<<ans<<endl;

        return 0;


}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(void){
	int n,a,f[100000]={0},i,c=0;
	long long ans=1;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a);
		f[a]++;
	}
	if(!(f[0]==0||f[0]==1)){
		puts("0");
		return 0;
	}
	for(i=1;i<n;i++){
		if(f[i]%2){
			puts("0");
			return 0;
		}
		if(f[i]){
			c++;
		}
	}
	while(c--){
		ans=(ans*2)%1000000007;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define f first
#define s second
typedef pair<int,int> pi;
#define FAST ios_base::sync_with_stdio(0);
const int maxn = 500010;

string S;
int min1[maxn],min2[maxn];
int32_t main() {
	cin >> S;
	int n = S.length();
	int cur = 0;
	for (int i =0;i<n;i++) {
		if (S[i] == '<') cur++;
		else cur = 0;
		min1[i+1] = cur;
	}
	cur = 0;
	for (int i =n-1;i>=0;i--) {
		if (S[i] == '>') cur++;
		else cur = 0;
		min2[i] = cur;
	}
	int ans = 0;
	for (int i =0;i<=n;i++) {
		ans += max(min1[i],min2[i]);
	}
	cout << ans;
}





Measured memory_bytes: 8708
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,a,n) for(ll (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(ll (i)=(a);(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL << 62;
constexpr auto mod = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }

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

    ll l, r;
    cin >> l >> r;

    chmin(r, l + 2019);
    ll ans = INF;
    eFOR(i, l, r)eFOR(j, i + 1, r) {
        chmin(ans, i * j % 2019);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a;
	int b;

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

	if(a < b){
		printf("a < b\n");
	}else if(b < a){
		printf("a > b\n");
	}else{
		printf("a == b\n");
	}

	return 0;
}

Measured memory_bytes: 580
#include<iostream>
using namespace std;
 
int main(){
int W,H,x,y,r;
 
cin >> W >> H >> x >> y >> r;
 
if(x+r <= W && x-r >= 0){
  if(y+r <= H && y-r >= 0){
  cout << "Yes" << endl;
  return 0;
  }
}
 
cout << "No" <<endl;
return 0;
 
}

Measured memory_bytes: 1156
#define _CRT_SECURE_NO_WARNINGS
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <array>
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <bitset>
#include <utility>
#include <assert.h>
#include <regex>
using namespace std;

typedef unsigned long long ull;
typedef signed long long ll;
#define INF (1LL << 48)

struct PT { ll x; ll y; };
string to_s(ull x) { return to_string(x); }
string to_s(ll x) { return to_string(x); }
ll to_ll(const string& x) { return stoll(x); }
ull to_ull(const string& x) { return stoull(x); }




int main(int argc, char* argv[])
{
	for (;;) {
		ll A, B, C, X, Y;
		cin >> A >> B >> C >> X >> Y;
		if (cin.fail()) break;

		ll c1 = min(X, Y);
		ll c2 = max(X, Y);
		ll price_a = max((X - c1), 0LL) * A + max((Y - c1), 0LL) * B + c1 * 2 * C;
		ll price_b = max((X - c2), 0LL) * A + max((Y - c2), 0LL) * B + c2 * 2 * C;
		ll price_c = X * A + Y * B;

		cout << min(min(price_a, price_b), price_c) << endl;
	}

	return 0;
}

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

int main() {
    int n;
    cin >> n;
    n %=10;
    if(n==2 || n == 4 || n == 5 || n == 7 || n ==9) cout << "hon" << endl;
    else if(n==3) cout << "bon" << endl;
    else cout << "pon" << endl;
    return 0;
}

Measured memory_bytes: 3636
n = int(input())
w = [[] for i in range(n)]
for i in range(n):
    a = int(input())
    for j in range(a):
        w[i].append([int(x) for x in input().split()])

ans = 0
for i in range(2**n):
    flag = 1
    f = [0]*n
    num = 0
    for j in range(n):
        if i & 1<<j:
            f[j] = 1
            num += 1
    for j in range(n):
        if f[j]==1:
            for k in w[j]:
                if k[1]!=f[k[0]-1]:
                    flag = 0
    
    if flag == 1:
        ans = max(ans,num)
print(ans)

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

using namespace std;

void solve() {
  int n, m;
  cin >> n >> m;
  int wa_cnt = 0;
  int ac_cnt = 0;
  unordered_map<int, bool> done;
  unordered_map<int, int> wa;
  for (int i = 0; i < m; ++i) {
    int p;
    string s;
    cin >> p >> s;
    if (s == "AC") {
      if (!done[p]) {
        wa_cnt += wa[p];
        ++ac_cnt;
        done[p] = true;
      }
    } else if (!done[p]) {
      ++wa[p];
    }
  }
  cout << ac_cnt << " " << wa_cnt << endl;
}


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


Measured memory_bytes: 8520
//#include "debug.h"
#include <string.h>
#include <limits.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

#define MAXN 50
#define MAXZ 50*50

int n, avg;
int a[MAXN];
long dp[MAXN+1][MAXZ+1];

int input() {
	if (scanf("%d %d", &n, &avg) < 0) return 0;
	for (int i=0; i<n; i++) scanf("%d", &a[i]);
	return 1;
}

void init() {
}

long solve() {
	memset(dp, 0, sizeof(dp));
	dp[0][0] = 1;
	for (int i=0; i<n; i++) {
		for (int k=n; k>0; k--) {
			for (int j=MAXZ; j>=a[i]; j--) {
				dp[k][j] += dp[k-1][j-a[i]];
			}
		}
	}
	long s = 0;
	for (int i=1; i<=n; i++)
		s += dp[i][avg*i];
	return s;
}

void output(long ans) {
	printf("%ld\n", ans);
}

void cleanup() {
}

int main() {
	//int ca; scanf("%d", &ca);
	while (input()) {
		init();
		output(solve());
		cleanup();
		//break;
	}
}





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

int main(){
  int N,ans=0;
  double D,x,y;
  cin>>N>>D;
  for(int i=0; i<N; ++i){
    cin>>x>>y;
    if(x*x+y*y<=D*D)
      ++ans;
  }
  cout<<ans;
}

Measured memory_bytes: 3784
S = input()
nums = [S.count(x) for x in 'abc']
nums.sort()
nums[-1] -= nums[0]
nums[1] -= nums[0]

def check():
    if nums[1] == 0 and nums[-1] > 1:
        return False
    if nums[1] > 1 or nums[-1] > 1: 
        return False
    return True

print("YES" if check() else "NO")


Measured memory_bytes: 3188
//Author: Fuadul Hasan(fuadul202@gmail.com)
//BSMRSTU,Gopalganj
#include<bits/stdc++.h>
using namespace std;int tc = 1;
#define happy ios::sync_with_stdio(false);
#define coding  cin.tie(0);
#define pb  push_back
#define mp make_pair
#define ll long long
#define pr pair<int, int> 
#define vpr vector<pr> 
#define vi std::vector<int>
#define vll std::vector<ll>
#define all(n) n.begin(),n.end()
#define Unique(c) (c).resize(unique(all(c))-(c).begin())
#define Test printf("Case %d: ",tc++);
#define YES printf("YES\n");
#define NO printf("NO\n");
#define Yes printf("Yes\n");
#define No printf("No\n");
#define pi 3.14159265358979323846
const int mod = 1e9 + 7;
const ll  Inf = (ll)2e18 + 5;
const int N   = 2e5 + 5;

int solve() 
{
	//happy coding

	double n;
	cin>>n;
	cout<<setprecision(20)<<(2*n*pi)<<endl;

	return 0;
}
int main(){
	int test = 1;
	//scanf("%d", &test);
	while (test--)solve();return 0;
}

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

typedef unsigned long long ull;

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

	int N, x;
	int a[2000];
	int b[2000];

	cin >> N >> x;
	for(int i=0; i<N; i++) cin >> a[i];

	ull res = 0;
	for(int i=0; i<N; i++){
		res += a[i];
	}

	for(int m=1; m<N; m++){
		ull tot = m * x;
		for(int i=0; i<N; i++){
			b[i] = min(a[i], a[(i-1+N) % N]);
			tot += b[i];
		}
		for(int i=0; i<N; i++) a[i] = b[i];
		res = min(res, tot);
	}
	cout << res << endl;
	return 0;
}


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

int main() {
	int n,i,flag=0;
	scanf("%d",&n);
	char s[110];
	scanf("%s",s);
	if(n%2!=0)
	printf("No");
	else{
		for(i=0;i<n/2;i++){
			if(s[i]!=s[n/2+i]){
				flag=1;
				break;
			}
		}
		if(flag==0)
		printf("Yes");
		else
		printf("No");
	}
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
	return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
	var tmp = ReadIntArray();
	int a = tmp[0], b = tmp[1];
	WriteLine(a - (b < a? 1 : 0));
    }
}


Measured memory_bytes: 13268
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 heapq import heappush, heappop


def dijkstra(graph: list, node: int, start: int) -> list:
    # 未探索のノードは距離INF
    INF = float("inf")
    dist = [INF] * node

    # 始点ノードの距離を0とし、dfsのためのpriority queを作成
    dist[start] = 0
    heap = [(0, start)]

    # 未探索のノードをpriority queueに入れる
    while heap:
        cost, cur_node = heappop(heap)

        for nex_cost, nex_node in graph[cur_node]:
            dist_cand = dist[cur_node] + nex_cost
            if dist_cand < dist[nex_node]:
                dist[nex_node] = dist_cand
                heappush(heap, (dist[nex_node], nex_node))

    return dist

n = ni()
graph = [[] for _ in range(n)]
for _ in range(n-1):
    u,v,w = li()
    u -= 1
    v -= 1
    graph[u].append((w, v))
    graph[v].append((w, u))

dist = dijkstra(graph, n, 0)

for di in dist:
    if di%2:
        print(1)
    else:
        print(0)

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

using namespace std;

#define MOD 1000000007

int main() {
	int n,m; cin >> n >> m;
	long long sumx=0,sumy=0;
	for(int i=0;i<n;++i) {
		long long x; cin >> x;
		(sumx+=i*x)%=MOD;
		(sumx-=(n-i-1)*x)%=MOD;
	}
	for(int i=0;i<m;++i) {
		long long y; cin >> y;
		(sumy+=i*y)%=MOD;
		(sumy-=(m-i-1)*y)%=MOD;
	}
	int ans = (sumx*sumy%MOD+MOD)%MOD;
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 380
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>



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

using namespace std;
string a,b;

int main(){
  cin >> a >> b;
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  reverse(b.begin(),b.end());
  if(a<b) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

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

		while(true){
			int n = sc.nextInt();
			int m = sc.nextInt();
			if(n == 0 && m == 0) break;

			int s = sc.nextInt();
			int g = sc.nextInt();

			Edge[][] map = new Edge[n+1][n+1];
			for(int i=0;i<m;i++){
				int from = sc.nextInt();
				int to = sc.nextInt();
				double d = sc.nextDouble();
				double c = sc.nextDouble();
				map[from][to] = new Edge(from,to,d,c);
				map[to][from] = new Edge(to,from,d,c);
			}

			PriorityQueue<State> open = new PriorityQueue<State>();
			HashSet<State> closed = new HashSet<State>();
			State ans = null;
			open.add(new State(s,-1,0,0));

			while(!open.isEmpty()){
				State st = open.poll();

				if(st.n == g && st.v == 1){
					ans = st;
					break;
				}

				open.addAll(st.nexts(map,closed));
			}

			if(ans == null) System.out.println("unreachable");
			else System.out.printf("%.4f\n",ans.cost);
		}
	}
}

class State implements Comparable<State>{
	int n,before;
	double cost,v;

	State(int n,int before,double cost,double v){
		this.n = n;
		this.before = before;
		this.cost = cost;
		this.v = v;
	}

	List<State> nexts(Edge[][] map,HashSet<State> closed){
		int m = map.length;
		List<State> sts = new ArrayList<State>();

		for(int i=1;i<m;i++){
			if(map[n][i] != null && before != i){
				for(int j=-1;j<=1;j++){
					if(v + j > 0 && v + j <= map[n][i].c){
						State nst = new State(i,n,cost+map[n][i].d/(v+j),v+j);
						if(closed.contains(nst)) continue;
						sts.add(nst);
						closed.add(nst);
					}
				}
			}
		}
		return sts;
	}

	public int compareTo(State st){
		if(cost < st.cost) return -1;
		if(cost > st.cost) return 1;
		return 0;
	}

	public boolean equals(Object o){
		State st = (State)o;
		return n == st.n && before == st.before && v == st.v;
	}

	public int hashCode(){
		return n + 100 * before + 10000 * (int)v;
	}
}

class Edge{
	int from,to;
	double d,c;

	Edge(int from,int to,double d,double c){
		this.from = from;
		this.to = to;
		this.d = d;
		this.c = c;
	}
}

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

using namespace std;

int main(){
	string s;
	int n;
	int c = 0;
	cin >> n;
	cin >> s;
	int m=0;
	for(int i=0;i<n;i++){
		if (s[i]=='I') c++;
		if (s[i]=='D') c--;
		m = max(m,c);
	}
	cout << m;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i= (a); i < (b); ++i)
typedef long long ll;
typedef pair<int,int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
int main() { string S;
  cin >> S;
  REP(i, S.size() - 8) { cout << S[i]; }
  cout << "\n";
}

Measured memory_bytes: 3592
import sys
import math
import fractions
from collections import deque
from collections import defaultdict
sys.setrecursionlimit(10**7)

A, B, C, D = map(int, input().split())
while True:
    C -= B
    if C <= 0:
        print('Yes')
        break
    A -= D
    if A <= 0:
        print('No')
        break


Measured memory_bytes: 72672
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}
int mpow(int base, int exp); 
void ipgraph(int n, int m);
void dfs(int u, int par);

const int mod = 1'000'000'007;
const int N = 3e5, M = N;
//=======================
/*Advanced
vi g[N];
int a[N];
*/
void solve() {
  int i, j, n, m;
}


int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	int x;
	cin >> x;
	if(x >= 30) cout << "Yes";
	else cout << "No";
	
    return 0;
}
/*
int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
    u--, v--;
		g[u].pb(v);
		g[v].pb(u);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}
*/


Measured memory_bytes: 3620
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define rep(i,n) for(ll i = 0; i < (n); ++i)
#define rep1(i, n) for(ll i = 1; i < (n); ++i)
#define rep4(i, start, end, step) for (ll i = (start); i < (end); i += (step))

#define BIG_PRIME 1000000007
#define BP_remainder(x) ((x) % BIG_PRIME)

#define INF 0x3fffFFFF
#define INF_NEG (INF * -1)
#define INF_LONG (INF << 32)
#define INF_LONG_NEG (INF_LONG * -1L)

typedef long long ll;
typedef char str255[256];
// char *用、strlen の ll 版
ll StrLen(char *s) { for(ll ptr = 0L;; ++ptr) if(!s[ptr]) return ptr; } 
// char * の後ろから n 文字削除, 削除後の文字数を返す
ll StrDel(char *s, int n) { ll l = StrLen(s); s[l - n + 1L] = '\0'; return l - n; }
// 正の整数の桁数
ll NumDigits(ll l){ char s[30]; sprintf(s, "%lld", l); return StrLen(s); }

int isFirst = 1;
void print(ll l) { if (isFirst) printf("%lld", l), isFirst = 0; else printf(" %lld", l); }

void chmin(ll *a, ll b) { if (*a > b) *a = b; }
void chmax(ll *a, ll b) { if (*a < b) *a = b; }

typedef struct pair_t{ ll A; ll B;} pair;
int sort_by_B(const void *p, const void *q)
{ return ((pair *)p)->B - ((pair *)q)->B; }

signed main()
{
    ll N; scanf("%lld", &N);
    pair *AB = (pair *)malloc(sizeof(pair) * N);
    rep(i, N) scanf("%lld %lld", &(AB[i].A), &(AB[i].B));

    qsort(AB, N, sizeof(pair), sort_by_B);

    int able = 1;
    ll time = 0L;
    rep(i, N){
        time += AB[i].A; // 所要時間
        if (time > AB[i].B){ // 制限時刻
            able = 0;
            break;
        }
    }

    if (able) puts("Yes");
    else puts("No");

    free(AB);
    return 0;
}


Measured memory_bytes: 6396
from re import match
A = r"^>'(=+)#\1~$"
B = r"^>\^(Q=)+~~$"
for _ in xrange(input()):
    s = raw_input()
    if match(A,s) != None:
        print "A"
    elif match(B,s) != None:
        print "B"
    else:
        print "NA"

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

int main(){
    int n, m, k;
    cin >> n >> m >> k;
    vector<pair<int,int>> v(n);
    for(int i = 0; i < n; i++)  cin >> v[i].first;
    for(int i = 0; i < n; i++)  cin >> v[i].second;
    int ans = 0;
    for(int i = 1; i < 1<<n; i++){
        vector<pair<int,int>> vp;
        for(int j = 0; j < n; j++){
            if((i>>j)&1)    vp.push_back(v[j]);
        }
        if(vp.size() > k)   continue;
        sort(vp.rbegin(), vp.rend());
        int tmp = 0, res = m;
        for(int i = 0; i < vp.size(); i++){
            int take = min(res, vp[i].second);
            tmp += take * vp[i].first;
            res -= take;
        }
        ans = max(ans, tmp+res);
    }
    cout << ans << endl;
    return 0;
}


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

int comp(const void *a, const void *b)
{
	unsigned long x = *(unsigned long *)a;
	unsigned long y = *(unsigned long *)b;
	if (x == y)
		return 0;
	if (x > y)
		return 1;
	return -1;
}

int main(void)
{
	unsigned long n, k;
	unsigned long *h;
	unsigned long i;
	unsigned long s = 0;

	scanf("%lu %lu", &n, &k);

	h = malloc(n * sizeof(unsigned long));

	for (i = 0; i < n; i++)
	{
		scanf("%lu", h + i);
	}

	qsort(h, n, sizeof(unsigned long), comp);

	if (k > n)
	{
		printf("0\n");
		return 0;
	}

	for (i = 0; i < n - k; i++)
	{
		s += h[i];
	}

	printf("%lu\n", s);

	return 0;
}


Measured memory_bytes: 3324
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from collections import Counter


def main():
    N = int(input())
    A = list(map(int, input().split()))

    count = Counter(A)

    result = 0
    for x in range(1, 10**5):
        result = max(result, count[x - 1] + count[x] + count[x + 1])

    print(result)


if __name__ == "__main__":
    main()


Measured memory_bytes: 14564
def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    
    ans = 0
    for i in range(n):
        ans += min(a[i], b[i])
        b[i] = max(b[i] - a[i], 0)
        if b[i] > 0:
            ans += min(a[i + 1], b[i])
            a[i + 1] -=  min(a[i + 1], b[i])
            
    print(ans)
            

if __name__ == '__main__':
    main()


Measured memory_bytes: 18624
import java.util.*;

public class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    String O = sc.next(), E = sc.next();
    int o = O.length(), e=E.length();
    
    for(int i=0; i<e; i++) {
        System.out.print(O.substring(i,i+1));
        System.out.print(E.substring(i,i+1));
    }
    if(o!=e) {
      System.out.print(O.substring(o-1,o));
    }
  }
}

Measured memory_bytes: 35728
#include <iostream>
using namespace std; 
int abss(int a){
  int b = a;
  if(b < 0) b *= -1;
  return b;
}
int main(){
  string ok = "No";
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if(abss(a-c)<= d) ok = "Yes";
  if(abss(a-b)<=d && abss(b-c)<=d) ok = "Yes";
  cout << ok << endl;
  return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from sys import stdin
from operator import itemgetter
from collections import deque, Counter
import math
import pprint
from functools import reduce
# stdin = open("sample.txt")

MOD = 1000000007

def keta(kazu):
    kazu_str = str(kazu)
    kazu_list = [int(kazu_str[i]) for i in range(0, len(kazu_str))]
    return kazu_list

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def combination(m,n):
    if n > m:
        return 'すまん'
    return math.factorial(m) // (math.factorial(m-n) * math.factorial(n))

def main():
    a = int(stdin.readline().rstrip())
    target = a % 10
    
    if target == 2 or target == 4 or target == 5 or target == 7 or target == 9:
        print('hon')
    elif target == 0 or target == 1 or target == 6 or target == 8:
        print('pon')
    else:
        print('bon')
main()

Measured memory_bytes: 9976
n,k=map(int,input().split())
a=list(map(int,input().split()))
a=list(map(lambda x:x-1 ,a))

if k==1:
    print(0)
    exit()
s=[0]
for i in range(n):
    s.append(s[-1]+a[i])
s=list(map(lambda x:x%k,s))
from collections import defaultdict
d=defaultdict(int)
d[0]=1
ans=0

for i in range(1,n+1):
    ans+=d[s[i]]
    d[s[i]]+=1
    if i>=k-1:
        d[s[i-k+1]]-=1
print(ans)


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

using ll = long long;

int main(int argc, char const *argv[]) {
    ll N;
    cin >> N;
    ll min = N + 1;
    ll r = int(sqrt(N));

    for (int i = 1; i <= r; i++) {
        if (N % i == 0 && i + (N/i) < min) {
            min = i + (N/i);
        }
    }
    cout << min - 2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <set>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
using namespace std;
bool test(int n)
{
    int s=0;
    for(int i=1;i<=n;i++){
        if(n%i==0&&i%2==1) s++;
    }
    if(s==8) return true;
    else return false;
}
int main()
{
    int n;
    while(cin>>n){
        int t=0;
        for(int i=1;i<=n;i++){
            if(test(i)){
                t++;
            }
        }
        cout<<t<<endl;
    }
    return 0;
}


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

void read(int &x) {
    x=0;int f=1;char ch=getchar();
    for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-f;
    for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';x*=f;
}

void print(int x) {
    if(x<0) putchar('-'),x=-x;
    if(!x) return ;print(x/10),putchar(x%10+48);
}
void write(int x) {if(!x) putchar('0');else print(x);putchar('\n');}

#define lf double
#define ll long long 

#define pii pair<int,int >
#define vec vector<int >

#define pb push_back
#define mp make_pair
#define fr first
#define sc second

#define FOR(i,l,r) for(int i=l,i##_r=r;i<=i##_r;i++)

const int maxn = 1e6+10;
const int inf = 1e9;
const lf eps = 1e-8;
const int mod = 1e9+7;

char s[maxn];
int f[maxn][3];

int main() {
    scanf("%s",s+1);int n=strlen(s+1);
    for(int i=1;i<=n;i++) {
        if(s[i]==s[i-1]) f[i][1]=f[i-1][2]+1;
        else f[i][1]=f[i-1][1]+1;
        if(i>=2) {
            f[i][2]=f[i-2][1]+1;
            if(s[i]!=s[i-2]||s[i-1]!=s[i-3]) f[i][2]=max(f[i][2],f[i-2][2]+1);
        }
        // printf("%d %d\n",f[i][1],f[i][2]);
    }write(max(f[n][1],f[n][2]));
    return 0;
}


Measured memory_bytes: 6400
#include<stdio.h>

int main(viod)
{
	int S,h,m,s;
	scanf("%d",&S);
	h = S / 3600;
	m = (S % 3600) / 60;
	s = S % 60;
	printf("%d:%d:%d\n",h,m,s);
	
	return 0;
 } 


Measured memory_bytes: 2120
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <utility>
#include <tuple>
#include <map>
#include <ctime>
#include <cstdlib>
#include <random>
using namespace std;

int main(){

	int a[33] = {0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int k;
	cin >> k;

	cout << a[k] << endl;

	return 0;
}

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

#define INF 100000000000000

int main(){
  long long n,h;
  cin >> n >> h;
  long long a[n],b[n];
  for(int i=0;i<n;i++){
    cin >> a[i] >> b[i];
  }
  long long count = 0;
  sort(a,a+n);
  reverse(a,a+n);
  sort(b,b+n);
  reverse(b,b+n);
  for(int i=0;i<n;i++){
    if(b[i] < a[0]) break;
    h -= b[i];
    count += 1;
    if(h <= 0) break;
  }
  if(h > 0) count += (h-0.1)/a[0]+1;
  cout << count << endl;


  return 0;
}


Measured memory_bytes: 1792
# -*- coding: utf-8 -*-
str = raw_input()
for _ in xrange(input()):
 ops = raw_input().split()
 na = int(ops[1])
 nb = int(ops[2]) + 1
 op = ops[0]
 if op[0]=="p": print str[na:nb]
 elif op[2]=="v": str = str[:na] + "".join(reversed(str[na:nb])) + str[nb:]
 else: str = str[:na] + ops[3] + str[nb:]

Measured memory_bytes: 6464
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<deque>
using namespace std;
typedef long long ll;
ll n;
deque<int>x,y;
int t=2;
int main()
{
    scanf("%lld",&n);
    n++;
    int cnt=0;
    int f=0;
    while(1ll<<(f+1)<=n)
        f++;
    for(int i=f-1;i>=0;i--){
            t++;
            cnt+=2;
            x.push_front(t);
            y.push_front(t);
        if(n&1ll<<i){
            t++;
            cnt+=2;
            x.push_front(t);
            y.push_back(t);
        }
    }
    printf("%d\n",cnt);
    while(!x.empty()){
        printf("%d ",x.front());
        x.pop_front();
    }
    while(!y.empty()){
        printf("%d ",y.front());
        y.pop_front();
    }
}


Measured memory_bytes: 256
#Solve this by Rerooting
import sys
from itertools import accumulate
import queue
input = sys.stdin.buffer.readline

N = int(input())
adj = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int, input().split())
    adj[a-1].append(b-1)
    adj[b-1].append(a-1)


#bfs、直すの面倒なので読み替えて。
dfs_order = []
parent = [-1] * N
root = 0
#queue
stack = queue.Queue()
stack.put(root)
while not stack.empty():
    node = stack.get()
    dfs_order.append(node)
    for next_node in adj[node]:
        if next_node != parent[node]:
            parent[next_node] = node
            stack.put(next_node)

dp1 = [1] * N
for node in reversed(dfs_order):
    for next_node in adj[node]:
        if next_node != parent[node]:
            dp1[node] = max(dp1[node], dp1[next_node] + 1)

dp2 = [1] * N
for node in dfs_order:
    around = [dp1[next_node]+1 if next_node != parent[node] else dp2[node] for next_node in adj[node]]
    from_left = [1] + list(accumulate(around, max))[:-1]
    from_right = list(accumulate(reversed(around), max))[-2::-1] + [1]
    without = [max(l, r) + 1 for l, r in zip(from_left, from_right)]
    for next_node, value in zip(adj[node], without):
        if next_node != parent[node]:
            dp2[next_node] = value

dp = [v1 + v2 - 1 for v1, v2 in zip(dp1, dp2)]

length = max(dp)

if length % 3 == 2:
    print("Second")
else:
    print("First")

Measured memory_bytes: 172656
#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];
        a[i]--;
    }
    int count=0;
    for(int i=0;i<n;i++){
        if(i==a[a[i]]) count++;
    }
    cout << count/2 << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
int main()
{
    string s,t;
    cin>>s>>t;
    int s_len=s.length();
    s=s+s;

    vector<vector<int>> next(s_len,vector<int>('z'-'a'+1,-1));

    ll out=0;
    int j=0;
    int j0,jstop;
    for (int i = 0; i < t.length(); i++) {
      j0=j;
      if(next[j0][t[i]-'a']>=0){
        j=next[j0][t[i]-'a'];
      } else {
        jstop=j+s_len;
        for(; t[i]!=s[j]; ){
          if(j==jstop){
            cout<<-1<<endl;
            return 0;
          }
          j++;
        }
        next[j0][t[i]-'a']=j;
      }
      j++;
      out+=j-j0;
      if(j>=s_len) j-=s_len;
    }

    cout<<out<<endl;
    return 0;
}


Measured memory_bytes: 13824
import java.util.*;

public class Main {

    private static int N;
    private static int M;
    private static int[] L;
    private static int[] R;

    private static void read() {
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        M = sc.nextInt();
        L = new int[M]; R = new int[M];
        for (int i = 0; i < M; i += 1) {
            L[i] = Integer.parseInt(sc.next());
            R[i] = Integer.parseInt(sc.next());
        }
    }

    public static void main(String[] args) {
        read();

        int maxL = Integer.MIN_VALUE;
        int minR = Integer.MAX_VALUE;
        for (int i = 0; i < M; i += 1) {
            if (maxL < L[i]) {
                maxL = L[i];
            }
            if (minR > R[i]) {
                minR = R[i];
            }
        }

        if (minR - maxL + 1 >= 0) {
            System.out.println(minR - maxL + 1);
        } else {
            System.out.println(0);
        }
    }
}


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

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

  int a, b, c, d;
  cin >> a >> b >> c >> d;

  int l = a + b, r = c + d;
  if (l > r) cout << "Left\n";
  else if (l < r) cout << "Right\n";
  else cout << "Balanced\n";

  return (0);
}


Measured memory_bytes: 3604
from collections import Counter
s = input()
c = Counter(s)

if len(c) == 4:
    print('Yes')
elif len(c) == 3:
    print('No')
elif len(c) == 1:
    print('No')
elif len(c) == 2:
    if c['N'] > 0 and c['S'] > 0:
        print('Yes')
    elif c['W'] > 0 and c['E'] > 9:
        print('Yes')
    else:
        print('No')



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

int main (void) {
    char in[100];
    int count = 0;
    scanf("%s", in);
    int len = strlen(in);

    for (int i = 0; i < len / 2; i++) {
        if (in[i] != in[len - i - 1]) {
            count++;
        }
    }

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


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

#define M 1000000


void result() {
	long long int a,b,k,left,num=0;
	cin >> a >> b >> k;
	
	left = k;
	if(a <= k) {
		left -= a;
		cout << 0 << " " << max(num, b-left) << endl;
	} else {
		cout << a-k << " " << b << endl;
	}
}
		
			
		

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (int i = 0; i < n; i++)
#define IREP(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(a, b) for (int i = a; i < b + 1; i++)
#define MOD 1000000007
#define int long long
using namespace std;
typedef long long ll;

signed main() {
	int a,b,c;
	int x,y;
	cin >> a >> b >> c >> x >> y;
	int ans;
	if(a+b<c*2){
		ans=(a+b)*min(x,y);
	}
	else{
		ans=c*min(x,y)*2;
	}
	if(x<y){
		ans+=min((y-x)*b,(y-x)*c*2);
	}
	else if(x>y){
		ans+=min((x-y)*a,(x-y)*c*2);
	}
	cout << ans << endl;
}

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

long long X,Y;
int main(){
	while(cin >> X >> Y){
		int ans = 0;
		long long  n = X;
		//cout << Y/X << endl;
		while(n<=Y){
			ans++;
			n *= 2;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 256
import math


def get_prime_list(n):
    prime = [2]
    for i in range(3, n+1):
        flag = True
        for j in range(2, i):
            if i%j == 0:
                flag = False
                break
        if flag:
            prime.append(i)
    return prime


def main():
    n = int(input())

    prime = get_prime_list(n)
    d = dict()
    for i in prime:
        cnt = 0
        for j in range(2, n+1):
            while j>1:
                if j%i == 0:
                    cnt += 1
                    j //= i
                else:
                    j = 0
        d[i] = cnt

    ans = 1
    for key, value in d.items():
        if value != 0:
            ans = ans * (value+1) % (10**9+7)
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3444
#include <stdio.h>
#include <math.h>

int main(void)
{
	double x1, x2, y1, y2;

	scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
	printf("%lf\n", sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)));

	return 0;
}



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

int main(){
    ll N, K; cin >> N >> K;
    ll R, S, P; cin >> R >> S >> P;
    string T; cin >> T;
    ll ans = 0;
    vector<bool> v(N,false);
    rep(i, 0, N){
        if(i >= K && T[i] == T[i-K] && !v[i-K]){
            v[i] =true;
            continue;
        }
        if(T[i] == 'r') ans += P;
        if(T[i] == 's') ans += R;
        if(T[i] == 'p') ans += S;
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    static class BCardGameforTwo
    {        
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var an = Console.ReadLine().Split(' ');

            var orderedCards = an.Select(x => int.Parse(x)).OrderByDescending(x => x).ToArray();

            int alice = 0;
            int bob = 0;

            for (int i = 0; i < orderedCards.Length; i++)
            {
                if (i % 2 == 0)
                {
                    alice += orderedCards[i];
                }
                else
                {
                    bob += orderedCards[i];
                }
            }

            Console.WriteLine(alice - bob);
            Console.ReadLine();
        }
  }
}

Measured memory_bytes: 13396
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int n,k;
  cin >> n >> k;
  vector<int>a(n);
  if(n==k) cout<< 1 <<endl;
  else{
    int num = k - 1;
    int num2 = n - k ;
    if(num2 % num ==0) cout<< num2/ num +1<<endl;
    else cout << num2 / num +2 <<endl;
  }
  
}

Measured memory_bytes: 640
N = int(input())
h_list = list(map(int, input().split()))
dp = [float('INF') for i in range(N)]
dp[0] = 0

def calc_cost(now, next):
  global h_list
  global dp
  global N
  if next > N - 1: return
  if dp[next] > dp[now] + abs(h_list[next] - h_list[now]):
    dp[next] = dp[now] + abs(h_list[next] - h_list[now])
  return

for i in range(N):
  calc_cost(i, i + 1)
  calc_cost(i, i + 2)

print(dp[N - 1])

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

int main(){
  int D;
  cin >> D;
  vector<int> C(26);
  for(int i=0;i<26;i++){
    cin >> C.at(i);
  }
  vector<vector<int>> S(D,vector<int> (26));
  for(int i=0;i<D;i++){
    for(int j=0;j<26;j++){
      cin >> S.at(i).at(j);
    }
  }
  for(int i=0;i<14;i++){
    for(int j=0;j<26;j++){
      cout << j+1 << endl;
    }
  }
  cout << 2 << endl;
}


Measured memory_bytes: 3680
#include <bits/stdc++.h>
    using namespace std;
    int main(){
    	int n,x,sum=0;
    	bitset<2000005> bs(1);
    	for(cin>>n;n--&&cin>>x;sum+=x) bs|=bs<<x;
    	for(int i=sum+1>>1;i<=sum;++i)
    		if(bs[i]) return cout<<i,0;
    }

Measured memory_bytes: 1152
import java.io.*;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder keepfile = new StringBuilder();
		
        String[] str;

		while(true) {
	//??\???????????????????????????
		str = br.readLine().split(" ");	
		int n = Integer.parseInt(str[0]);
		int x = Integer.parseInt(str[1]);;
		if(n == 0 & x == 0) break;
		
	//?¨???????????????????????????????	 
		else if(n != 0 & x != 0 | n >= 3 & n <= 100 | x >= 0 & x <= 300) {
			int N = 0 ;         //N ???????¨????x??¨????????????????????????????????°??§???
			for(int i = 1; i <= n ; i++) {
			   for(int j = (i+1) ; j <= n ; j++) {
				   int k = 0 ;
					   k = x-i-j ;         //x = i+j+k ???????????????k=x-i-j ??¨?????????
					   if(j < k & k <= n) N++; 
			  }
			   
		   }
			 keepfile.append(N).append("\n");
		}
		
	  }
		
	//??????????????????????????????
		   System.out.print(keepfile);
	
	   br.close();
	}

}

Measured memory_bytes: 24896
import java.util.Arrays;
import java.util.Scanner;

class Main {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int H = scanner.nextInt();
    int W = scanner.nextInt();
    String[] S = new String[H];
    for (int i = 0; i < H; i++) {
      S[i] = scanner.next();
    }
    int[] xs = { -1, 1, 0, 0 };
    int[] ys = { 0, 0, 1, -1 };
    for (int y = 0; y < H; y++) {
      for (int x = 0; x < W; x++) {
        boolean[] ks = new boolean[4];
        Arrays.fill(ks, false);
        if (S[y].charAt(x) == '#') {
          for (int k = 0; k < 4; k++) {
            if (0 <= x + xs[k] && x + xs[k] < W && 0 <= y + ys[k] && y + ys[k] < H
                && S[y + ys[k]].charAt(x + xs[k]) == '#') {
              ks[k] = true;
            }
          }
          boolean ans = false;
          for (int i = 0; i < 4; i++) {
            if (ks[i]) {
              ans = true;
            }
          }
          if (!ans) {
            System.out.println("No");
            return;
          }
        }
      }
    }
    System.out.println("Yes");
  }

}


Measured memory_bytes: 22100
use proconio::{input,fastout};

#[derive(Debug)]
struct Book {
  pub c: isize,
  pub a: Vec<usize>
}

#[fastout]
fn main() {
  input!{n: usize, m: usize, x: usize};
  let mut books: Vec<Book> = Vec::new();
  for _ in 0..n {
    input!{c: isize, a: [usize;m]};
    books.push(Book {
      c: c,
      a: a.into_iter().collect()
    });
  }

  let mut min_cost = -1; // output
  for flags in 0..(2usize.pow(n as u32)) {
    let mut cost = 0;
    let mut skills = vec![0; m];
    for i in 0..n {
      if flags & 2usize.pow(i as u32) != 0 {
        cost += books[i].c;
        for j in 0..m {
          skills[j] += books[i].a[j];
        }
      }
    }
    if skills.into_iter().all(|s| s >= x) && (min_cost == -1 || min_cost > cost) {
      min_cost = cost;
    }
  }

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

Measured memory_bytes: 2192
import collections
n, k = map(int, input().split())
dat = list(map(int, input().split()))
dat.sort(reverse=True)
dat = collections.deque(dat)
res = 0
#print(dat)
for _ in range(min(k, len(dat) )):
    _ = dat.popleft()
    #print(dat)

res += sum(dat)
#print(dat)
print(res)

Measured memory_bytes: 90828
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <unordered_set>
using namespace std;
#define inf 999999999
#define loop(i, a, b) for (int i = (a), i##len = (b); i < i##len; ++i)
#define rep(i, n) loop(i, 0, n)
#define lin long long

int main(void)
{
    int n;
    cin >> n;

    if(n == 3)
    {
        cout << "2 5 63" << endl;
        return 0;
    }
    else if(n == 4)
    {
        cout << "2 5 63 20" << endl;
        return 0;
    }

    vector<int> res;
    int team2Set = min(5000, (n - 3) / 2);
    rep(i, team2Set)
    {
        res.push_back(i * 6 + 2);
        res.push_back(i * 6 + 4);
    }

    int team3Count = n - team2Set * 2;
    int team3Set = team3Count / 4;
    rep(i, team3Set)
    {
        res.push_back(i * 12 + 3);
        res.push_back(i * 12 + 6);
        res.push_back(i * 12 + 9);
        res.push_back(i * 12 + 12);
    }

    int team3Mod = team3Count % 4;
    int team3ModBase = team3Set * 12;
    if(team3Mod == 1)
    {
        res.push_back(team3ModBase + 6);
    }
    else if(team3Mod == 2)
    {
        res.push_back(team3ModBase + 3);
        res.push_back(team3ModBase + 9);
    }
    else if(team3Mod == 3)
    {
        res.push_back(team3ModBase + 3);
        res.push_back(team3ModBase + 6);
        res.push_back(team3ModBase + 9);
    }

    rep(i, n - 1)
    {
        cout << res[i] << " ";
    }
    cout << res[n - 1] << endl;

    return 0;
}


Measured memory_bytes: 512
#pragma region kyomukyomupurin

/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-05-05 15:46:20
 **/

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

using int64 = long long;

template <class T>
using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int flag = 0;
  for (auto e : vec) os << (flag++ ? ", " : "{") << e;
  return os << (vec.empty() ? "{}" : "}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int flag = 0;
  for (auto e : st) os << (flag++ ? ", " : "{") << e;
  return os << (st.empty() ? "{}" : "}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int flag = 0;
  for (auto e : mp) os << (flag++ ? ", " : "{") << e;
  return os << (mp.empty() ? "{}" : "}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

#pragma endregion kyomukyomupurin

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

  int n, s; cin >> n >> s;
  vector<int> a(n); cin >> a;

  int r = 0;
  int sum = 0;

  int ans = (int)1e9;

  for (int l = 0; l < n; ++l) {
    while (r < n && sum < s) {
      sum += a[r];
      ++r;
    }
    int len = r - l;
    if (sum >= s) ans = min(ans, len);
    if (r == l) {
      ++r;
    } else {
      sum -= a[l];
    }
  }

  if (ans == (int)1e9) ans = 0;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3368
n, m, c = map(int, input().split())
bl = [int(i) for i in input().split()]
ans = 0
for i in range(n):
  al = [int(j) for j in input().split()]
  ans += sum([bl[j] * al[j] for j in range(m)]) + c > 0
print(ans)

Measured memory_bytes: 3060
zz = input().split()

W = int( zz[0])
H = int( zz[1])
x = int( zz[2])
y = int( zz[3])
r = int( zz[4])

if (x - r) >= 0 and (x + r) <= W:
    if (y - r) >= 0 and (y + r) <= H:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Measured memory_bytes: 7660