akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	vector <string> s1(n), s2(n);
	for (int i = 0; i < n; ++i)
	{
		cin>>s1[i];
	}
	int ans = 0;
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < n; ++j)
		{
			s2[j] = s1[j].substr(i) + s1[j].substr(0, i);
		}
		bool ok = true;
		for (int j = 0; j < n; ++j)
		{
			for (int k = 0; k < n; ++k)
			{
				if(s2[j][k] != s2[k][j])
					ok = false;
			}
		}
		if(ok)
			ans+=n;
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;

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

const int INF = 1000000007;

int main(void){
	int n; cin>>n;
	int l[10010] = {0};
	for(int i=0;i<n;i++) cin>>l[i];

	int maxl = 0, sum = 0;
	for(int i=0;i<n;i++) maxl = max(maxl, l[i]);

	for(int i=0;i<n;i++) {
		sum += l[i];
	}
	sum -= maxl;
	if(maxl < sum) cout<< "Yes" <<endl;
	else cout<< "No" <<endl;
	
	return 0;
}

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

int main() {
  int N;
  cin>>N;
  vector<int> A(N),B(N),C(N-1);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
  for(int i=0;i<N;i++){
    cin>>B.at(i);
  }
  for(int i=0;i<N-1;i++){
    cin>>C.at(i);
  }
  int ans=B.at(A.at(0)-1);
  for(int i=1;i<N;i++){
    ans+=B.at(A.at(i)-1);
    if(A.at(i)==A.at(i-1)+1){
      ans+=C.at(A.at(i)-2);
    }
  }
  cout<<ans<<endl;
}

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

using namespace std;

#define int long long

const int INF = (1e18);
const int MOD = 1000000007;

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

  bool flag = true;
  int N, K;
  vector<int> dis, in;
  vector<vector<int>> tree;
  vector<pair<int,int>> P;
  priority_queue<pair<pair<int,int>,pair<int,int>>,vector<pair<pair<int,int>,pair<int,int>>>, greater<pair<pair<int,int>,pair<int,int>>>> Q;
 priority_queue<pair<int,int>,vector<pair<int,int>>, greater<pair<int,int>>> Q2;
  cin>>N;

  tree.resize(N);
  P.resize(N, {INF,INF});
dis.resize(N,INF);
  for(int i = 0; i < N-1; i++){
    int a, b;

    cin>>a>>b;

    a--, b--;

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

  cin>>K;

  for(int i = 0; i < K; i++){
    int v, p;

    cin>>v>>p;

  v--;

dis[v] = p;
    P[v] = {p,p};
    Q.push({{0,v},{p,p}});
	Q2.push({p,v});
  }
  
while(Q2.size()){
    pair<int,int> p = Q2.top(); Q2.pop();
	int now = p.second, d = p.first;
	// cout<<"d "<<d<<" now "<<now<<endl;
	if(dis[now] < d) continue;
	// cout<<"{}{} "<<endl;
	
    for(int next : tree[now]){
		if(dis[next] > d + 1) {
			dis[next] = d + 1;
			// cout<<"d + 1 "<<d+1<<" next "<<next<<endl;
			Q2.push({d+1,next});
		}
    }
  }
 
  // cout<<"Z"<<endl;
  
  for(int i = 0; i < N; i++){
	  for(int node : tree[i]){
		  if(abs(dis[i] - dis[node]) != 1) {
			  flag = false;
		  }
	  }
	  if(P[i].first != INF && P[i].first != dis[i]) flag = false;
  }

 
  for(int i = 0; i < N; i++){
	P[i] = {dis[i], dis[i]};
  }
  if(flag == false) { 
    cout<<"No"<<endl;
    return 0;
  }

// exit(1);
  cout<<"Yes"<<endl;

  for(int i = 0; i < N; i++){
    cout<<P[i].first<<endl;
  }

  return 0;
}


Measured memory_bytes: 15980
#include <iostream>
#include <algorithm>
#include <vector>
#include <list>
#include <map>
#include <string>
#include <functional>
#include <math.h>
#include <utility>
using namespace std;
int main()
{
	int p[3],j[2],ans;
	cin>>p[0]>>p[1]>>p[2]>>j[0]>>j[1];
	ans=min(p[0],min(p[1],p[2]))+min(j[0],j[1])-50;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1160
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

def main():
    H, W = LI()
    S = []
    for _ in range(H):
        S.append(SI())

    # print(S)

    # 横方向に探索
    yoko = [ [-1]*W for _ in range(H)]
    for i in range(H):
        beginning = True
        continuous = 0
        for j in range(W):
            if beginning:
                if S[i][j] == '#':
                    continue
                if S[i][j] == '.':
                    beginning = False
                    continuous += 1
            else:
                if S[i][j] == '#':
                    for k in range(j-continuous, j):
                        yoko[i][k] = continuous
                    beginning = True
                    continuous = 0
                if S[i][j] == '.':
                    continuous += 1
        if continuous:
            for k in range(W-continuous, W):
                yoko[i][k] = continuous

    # 縦方向に探索
    tate = [ [-1]*W for _ in range(H)]
    for j in range(W):
        beginning = True
        continuous = 0
        for i in range(H):
            if beginning:
                if S[i][j] == '#':
                    continue
                if S[i][j] == '.':
                    beginning = False
                    continuous += 1
            else:
                if S[i][j] == '#':
                    for k in range(i-continuous, i):
                        tate[k][j] = continuous
                    beginning = True
                    continuous = 0
                if S[i][j] == '.':
                    continuous += 1
        if continuous:
            for k in range(H-continuous, H):
                tate[k][j] = continuous

    ans = 1  # ぜったい1マスは光る。
    for i in range(H):
        for j in range(W):
            ans = max(ans, tate[i][j] + yoko[i][j] - 1)

    print(ans)

main()

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

int main() {
  
  string S;
  cin >>S;
  
  if(S[2] == S[3] && S[4] == S[5]) {
    
    cout << "Yes" <<endl;
  }
  
  else {
    cout <<"No" <<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int n, k, pie = 0;
  scanf("%d %d", &n, &k);
  if(k >= 0){
    for(int i = 0; i < n - 1; i++){
      pie += k + 1 + i;
    }
    printf("%d\n", pie);
  }else if(n + k > 0){
    for(int i = 0; i < n; i++){
      pie += k + i;
    }
    printf("%d\n", pie);
  }else{
    for(int i = 0; i < n - 1; i++){
      pie += k + i;
    }
    printf("%d\n", pie);
  }
  return 0;
}

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

int is_month(int a) { return 1 <= a && a <= 12; }

int main()
{
	string s;
	cin >> s;
	int a, b;
	a = (s[0] - '0') * 10 + (s[1] - '0');
	b = (s[2] - '0') * 10 + (s[3] - '0');
	if (is_month(a) && is_month(b))
		cout << "AMBIGUOUS" << endl;
	else if (is_month(a))
		cout << "MMYY" << endl;
	else if (is_month(b))
		cout << "YYMM" << endl;
	else
		cout << "NA" << endl;
	return 0;
}


Measured memory_bytes: 256
if __name__ == '__main__':
    s = input().rstrip().split(' ')
    N,M = int(s[0]), int(s[1])
    adj = []
    for _ in range(N):
        adj.append(set())
    s = input().rstrip().split(' ')
    height = [int(elem) for elem in s]
    for _ in range(M):
        s = input().rstrip().split(' ')
        A,B = int(s[0])-1, int(s[1])-1
        adj[A].add(B)
        adj[B].add(A)


    count = 0
    for i in range(N):
        flag = True
        for adj_n in adj[i]:
            if height[adj_n] >= height[i]:
                flag = False
                break

        if flag == True:
            count += 1

    print(count)

Measured memory_bytes: 46952
#include <bits/stdc++.h> 
#include <chrono>
using namespace std;
 
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;
 
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a)  (a).begin(),(a).end()
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const int MAX_N=2e5+3;


const unsigned long long B=1e12+7;

int A[12][12];
int main(){
    int N,M,X;
    cin>>N>>M>>X;
    vector<int>C(N);
    CLR(A);
    REP(i,N){
        cin>>C[i];
        REP(j,M){
            cin>>A[i][j];
        }
    }
    int res=INT_MAX;
    for (int bit = 0; bit < (1<<N); ++bit){
        vector<int>sumv(N,0);
        int tmp=0;
        for (int i = 0; i < N; ++i) {
            if (bit & (1<<i)) {
                tmp+=C[i];
                REP(j,M)sumv[j]+=A[i][j];
            }
        }
        bool flag=true;
        REP(j,M)if(sumv[j]<X)flag=false;
        if(flag)res=min(res,tmp);
    }
    if(res<INT_MAX)cout<<res<<endl;
    else cout<<-1<<endl;
    return 0;
}

Measured memory_bytes: 3592
from collections import deque

import sys
input = sys.stdin.readline
N, M = map(int, input().split())
G = [[] for _ in [0]*N]
for _ in [0]*M:
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    G[a].append(b)
    G[b].append(a)

visited = [0]*N
path = [0]*N

q = deque()
q.append((0, -1))

while q:
    v, p = q.popleft()
    if visited[v]:
        continue

    visited[v] = 1
    path[v] = p

    for u in G[v]:
        if visited[u]:
            continue
        q.append((u, v))

print('Yes')
for p in path[1:]:
    print(p+1)


Measured memory_bytes: 40936
#include <bits/stdc++.h>
using namespace std;
#define INF 2000000000
#define V 10
int d[V];
bool used[V];
int cost[V][V];
void dijkstra(int s)
{
    fill(d,d+V,INF);
    fill(used, used + V, false);
    d[s]=0;
    
    while(true)
    {
        int v = -1;
        for(int u = 0; u < V; u++)
        {
            if(!used[u] && (v == -1 || d[u] < d[v]))
            {
                v = u;
            }
        }
        
        if(v == -1)
        {
            break;
        }
        used[v] = true;
        
        for(int u = 0; u < V; u++)
        {
            d[u] = min(d[u], d[v] + cost[v][u]);
        }
    }
}


int h, w;
int ans = 0;
int main()
{
    cin >> h >> w;
    for(int i = 0; i < 10; i++)
    {
        for(int j = 0; j < 10; j++)
        {
            int k;
            cin >> k;
            cost[j][i] = k;
        }
    }
    dijkstra(1);

    for(int i = 0; i < h; i++)
    {
        for(int j = 0; j < w; j++)
        {
            int c;
            cin >> c;
            if(c != -1)
            {
                ans = ans + d[c];
            }
        }
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

int main()
{
    int n, m1, m2, sum = 0, sum1 = 0, sum2 = 0;
    cin >> n;
    int array[n];

    for (int i = 0; i < n; i++){
    	cin >> array[i];
    }
    
    for (int i = 0; i < n; i++){
    	sum = sum + array[i];
    }
    

    m1 = sum/n;
    m2 = (sum/n) +1;
    
    
    
    for (int i = 0; i < n; i++){
    	sum1 = (array[i] - m1)*(array[i] - m1) + sum1;
    }
    
    

    for (int i = 0; i < n; i++){
    	sum2 = (array[i] - m2)*(array[i] - m2) + sum2;
    }

    if (sum1 > sum2){
    	cout << sum2;
    }
    else{
    	cout << sum1;
    }
	return 0;
}



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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int n, m;
vector<vector<int>> p;
vector<int> pre, low;
int bridge = 0;

int pr = 1;

int dfs(int i, int from) {
  if (pre[i] > 0) return low[i];
  pre[i] = pr;
  low[i] = pr;
  for (auto &j : p[i]) {
    if (j == from) continue;
    pr++;
    int to = dfs(j, i);
    if (to < pre[i]) {
      low[i] = min(low[i], to);
    } else {
      if (low[j] == pre[j]) bridge++;
    }
  }
  return low[i];
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cin >> n >> m;
  p.resize(n);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    p[a].push_back(b);
    p[b].push_back(a);
  }
  pre.resize(n);
  low.resize(n);
  dfs(0, -1);
  cout << bridge << endl;

  return 0;
}


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

using namespace std;

#define MP make_pair
#define PB push_back
#define f first
#define s second

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

//int dr1[] = {-1, 0, 1, 0};
//int dc1[] = {0, 1, 0, -1};
//int dr3[] = {0, 1, 2, 3, 2, 1, 0, -1, -2, -3, -2, -1, -1, 1, 0, 0};
//int dc3[] = {3, 2, 1, 0, -1, -2, -3, -2, -1, 0, 1, 2, 0, 0, -1, 1};
const int MOD = 1000000007;
const int INF = 1000000007;

ll modx(ll a)
{
    return (a%MOD+MOD)%MOD;
}

ll times(ll a, ll b)
{
    return modx(modx(a)*modx(b));
}

ll add(ll a, ll b)
{
    return modx(modx(a)+modx(b));
}

ll sub(ll a, ll b)
{
    return modx(MOD+modx(a)-modx(b));
}

ll fastExp(ll base, ll exp)
{
    if(exp == 0LL)
    {
        return 1LL;
    }

    if(exp%2==0)
    {
        return fastExp(times(base, base), exp/2);
    }
    else
    {
        return times(base, fastExp(times(base, base), exp/2));
    }
}


const int MAXN = (int)1e5+1;
int N;


int main()
{
    //freopen("input.in","r",stdin);
    //freopen("output.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    int r;
    cin >> r;
    cout << r*r;
    return 0;
}


Measured memory_bytes: 256
import math


D,G = map(int, input().split())
PC = [tuple(map(int, input().split())) for _ in range(D)]


"""
Dがちいさいのでビット全探索させたそう
中途半端に色んな得点の問題を解くより、全部解く問題と部分的に解く問題に分かれるはず。
で、部分的に解く問題は、残りの中で一番得点が高い物を選ぶのがよい。
で、それを必要な分（あるいは全部-1）解いて得られる点がGを超えていれば、答えの候補になる
候補の中から最小のを選んで終わり
"""

ans = []
for bit in range(1 << D):
    point = 0
    cnt = 0
    for i in range(D):
        if bit & (1 << i):
            point += 100*(1+i)*PC[i][0] + PC[i][1]
            cnt += PC[i][0] 

    idx = -1
    for i in range(D):
        if not bit & (1 << i):
            idx = i

    if idx == -1:
        ans.append(cnt)
    else:
        rem = max(0, G - point)
        if rem == 0:
            ans.append(cnt)
        else:
            extr_cnt = math.ceil(rem / (100*(idx+1)))
            if extr_cnt <= PC[idx][0]-1:
                ans.append(cnt+extr_cnt)


print(min(ans))

Measured memory_bytes: 3064
from collections import Counter
S = input()
T = input()
cts = Counter(S)
ctt = Counter(T)
if set(ctt.keys()) - set(cts.keys()):
  print(-1)
  exit()

previdx = {}
L = len(S)
for i, c in enumerate(S):
  if c not in previdx:
    previdx[c] = i

keys = list(previdx.keys())
nxts = [{} for _ in range(L)]
for i in range(L-1, -1, -1):
  nxt = nxts[i]
  for k in keys:
    a = previdx[k] - i
    if a == 0:
      nxt[k] = L
    else:
      nxt[k] = a % L
  previdx[S[i]] = i

ans = previdx[T[0]]
pos = ans
for c in T[1:]:
  d = nxts[pos][c]
  ans += d
  pos = (pos + d) % L
print(ans+1)

Measured memory_bytes: 374620
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: i64 = read();
    let y: i64 = read();
    for i in 0..n + 1 {
        for j in 0..n - i + 1 {
            let k = n - i - j;
            if y - 10000 * i - 5000 * j == 1000 * k {
                println!("{} {} {}", i, j, k);
                return;
            }
        }
    }
    println!("-1 -1 -1");
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


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

using namespace std;

int main(){
	

	int n;
	cin >> n;
	
	int y[n],m[n],d[n];
	
	for(int i=0;i<n;i++){
		cin >> y[i] >> m[i] >> d[i];
		
		int a=0;
		
		int tm=0;
		
		for(int j=1;j<m[i];j++){
			if(y[i]%3==0){
				tm+=20;
			}else if(j%2==0) tm+=19;
			else tm+=20;
		}
		
		a=195*(y[i]-1)+(y[i]-1)/3*5+tm+d[i];
		
		int n=195*999+333*5+1;
		cout << n-a << endl;
	}
}



Measured memory_bytes: 3096
import std.conv, std.stdio;
import std.algorithm, std.array, std.string, std.range;

void main()
{
    auto
        buf = readln.chomp.split.to!(int[]),
        n = buf[0], x = buf[1] - 1, y = buf[2] - 1,
        d = new int[][](n, n);
    foreach (i; 0..n)
        foreach (j; i..n)
            d[i][j] = j - i;
    int[int] c;
    foreach (i; 1..n)
        c[i] = n - i;
    c[d[x][y]] -= 1;
    d[x][y] = 1;
    c[1] += 1;
    foreach (i; 0..n)
        foreach (j; i..n)
        {
            c[d[i][j]] -= 1;
            d[i][j] = d[i][j].min(d[i.min(x)][i.max(x)] + 1 + d[j.min(y)][j.max(y)]);
            c[d[i][j]] += 1;
        }
    foreach (i; 1..n)
        c[i].writeln;
}


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

int main(){
//srandom((unsigned long)time(NULL));
long long n,m;
cin>>n>>m;
vector<tuple<long long,string>> a;
pair<long long,int> b[n];
for(long long i=0;i<n;i++){
    b[i].first=0;
    b[i].second=0;
}
for(long long i=0;i<m;i++){
    long long p;
    string s;
    cin>>p>>s;
    a.emplace_back(p,s);
}
long long ans=0;
long long fs=0;

for(tuple<long long,string> v:a){
    long long p;
    string s;
    tie(p,s)=v;
    if(s=="WA")b[p-1].first++;
    if(s=="AC"){
        if(b[p-1].second==0){
            ans++;
            fs+=b[p-1].first;
            b[p-1].second=1;
        }

    }

}



cout<<ans<<" "<<fs<<endl;


return 0;
}


Measured memory_bytes: 8048
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#include<bits/stdc++.h>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define rep(i,n) for(i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define vvc vector<vector<char> >
#define vvs vector<vector<string> >
#define P 1000000007
using namespace std;
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 long long LLINF=1LL<<60;
//set<int>::iterator it;


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
	
	
	int i,n,m,a,b,l,r;
	cin>>n>>m;
	l=1;r=n;
	rep(i,m){
		cin>>a>>b;
		if(a>l){
			l=a;
		}
		if(b<r){
			r=b;
		}
		
//		cout<<"      "<<l<<" "<<r<<endl;
	}
	cout<<max(r-l+1,0)<<endl;
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
//////////////////////////////////////////////////////
return 0;}











Measured memory_bytes: 256
#define _CRT_NO_SECURE_WARNINGS
#pragma warning(disable:4996)

#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <string>
#include <iomanip>
#include <set>
#include <map>

using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
	~debug() { cerr << endl; }
	eni(!= ) cerr << boolalpha << i; ris;
}
eni(== ) ris << range(begin(i), end(i));
}
sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
	sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using namespace std;


typedef long long ll;

void solve() {
	int n, m;
	cin >> n >> m;
	vector<int>a(n);
	int count = 0;
	double sum = 0.0;
	while (count < n) {
		cin >> a[count];
		sum += (double)a[count];
		count++;
	}
	/*cout << imie(sum);
	cout << endl;*/
	sort(a.rbegin(), a.rend());
	count = 0;
	double check = 1.0 / (4.0 * m);
	/*cout << imie(check);
	cout << endl;*/
	for (int s : a) {
		if (s >= (check * sum)) {
			++count;
		}
	}
	count >= m ? puts("Yes") : puts("No");
}
	
int main(){
	ios_base::sync_with_stdio(NULL);
	cin.tie(0);
//freopen("solver.txt", "r", stdin);
	/*int t;
	cin >> t;
	while (t--) {
		solve();
	}*/
	solve();
}




Measured memory_bytes: 256
#include "bits/stdc++.h"
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define ALLR(X) (X).rbegin(), (X).rend()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second

using namespace std;
 
template<class T> void max_self(T & a, const T & b) { if(a < b) a = b; }
template<class T> void min_self(T & a, const T & b) { if(a > b) a = b; }
typedef long long LL;
const int INF = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = (1e-9);



int main(){
	FAST_IO
	
	set<char> distinct;
	
	for(int rep = 0; rep < 3; ++rep){
		char c;
		cin >> c;
		distinct.insert(c);
	}
	
	if(SZ(distinct) > 1) cout << "Yes\n";
	else cout << "No\n";
	
	return 0;
}


Measured memory_bytes: 256
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))
temp_a = [float("inf")]*n
for i in range(n):
    temp = t-h[i]*0.006
    temp_a[i] = abs(temp-a)
print(temp_a.index(min(temp_a))+1)

Measured memory_bytes: 38384
#include <iostream>
#include <sstream>
#include <string>

using namespace std;

typedef unsigned long long BigInt;

BigInt int_to_index(BigInt n) {
    int d;
    BigInt r = 10;
    BigInt index = 4 * ((n - 1) / 3 + (n - 1) / 5);
    for (d = 1; n  >= r; ++d) {
        index += d * (r - r / 10);
        index -= d * ((r - 1) / 3 - (r / 10 - 1) / 3);
        index -= d * ((r - 1) / 5 - (r / 10 - 1) / 5);
        index += d * ((r - 1) / 15 - (r / 10 - 1) / 15);
        r *= 10;
    }
    index += d * (n - r / 10);
    index -= d * ((n - 1) / 3 - (r / 10 - 1) / 3);
    index -= d * ((n - 1) / 5 - (r / 10 - 1) / 5);
    index += d * ((n - 1) / 15 - (r / 10 - 1) / 15);
    ++index;
    return index;
}

string fizzbuzz(BigInt n) {
    if (n % 15 == 0) {
        return "FizzBuzz";
    } else if (n % 3 == 0) {
        return "Fizz";
    } else if (n % 5 == 0) {
        return "Buzz";
    } else {
        stringstream ss;
        ss << n;
        return ss.str();
    }
}

string solve(BigInt s) {
    BigInt a = 1;
    BigInt ai = int_to_index(a);
    BigInt b = s;
    string str;
    while (b - a > 1) {
        BigInt c = (a + b) / 2;
        BigInt i = int_to_index(c);
        if (i <= s) {
            a = c;
            ai = i;
        } else {
            b = c;
        }
    }
    str = fizzbuzz(a).substr(s - ai);
    for (BigInt i = a + 1; str.length() < 20; ++i) {
        str += fizzbuzz(i);
    }
    return str.substr(0, 20);
}

int main() {
    BigInt s;
    cin >> s;
    cout << solve(s) << endl;
    return 0;
}

Measured memory_bytes: 1216
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()
	x := readInt()
	t := readInt()

	println(maxInt(0, x-t))
}

// -----------------------------------------------------------------------------

func minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

func maxInt(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int **weight_arr;
int **dp;
int N;

int recursion(int day, int action)
{
    if (day == N) return 0;

    if (day == 0) 
        return max(recursion(day + 1, 0) + weight_arr[0][0], max(recursion(day + 1, 1) + weight_arr[0][1], recursion(day + 1, 2) + weight_arr[0][2]));

    if(action == 0)
        return max(recursion(day+1, 1) + weight_arr[day][1], recursion(day+1, 2) + weight_arr[day][2]);
    if(action == 1)
        return max(recursion(day+1, 0) + weight_arr[day][0], recursion(day+1, 2) + weight_arr[day][2]);
    if(action == 2)
        return max(recursion(day+1, 0) + weight_arr[day][0], recursion(day+1, 1) + weight_arr[day][1]);
}


int main()
{


    cin >> N;
    
    weight_arr = new int*[N];
    dp = new int*[N];
    for(int i = 0; i < N; i++) 
    {
        weight_arr[i] = new int[3];
        dp[i] = new int[3];
        cin >> weight_arr[i][0] >> weight_arr[i][1] >> weight_arr[i][2];
    }

    dp[0][0] = weight_arr[0][0];
    dp[0][1] = weight_arr[0][1];
    dp[0][2] = weight_arr[0][2];

    for (int i = 1; i < N; i++)
    {
        dp[i][0] = weight_arr[i][0] + max(dp[i-1][1], dp[i-1][2]);
        dp[i][1] = weight_arr[i][1] + max(dp[i-1][0], dp[i-1][2]);
        dp[i][2] = weight_arr[i][2] + max(dp[i-1][0], dp[i-1][1]);
    }

    cout << max(dp[N-1][0], max(dp[N-1][1], dp[N-1][2])) << endl;


    // for(int i = 0; i < N; i++)
    // {
    //     for(int j = 0; j < 3; j++)
    //     {
    //         cout << weight_arr[i][j] << " ";
    //     }
    //     cout << endl;
    // }

    // cout << recursion(0, -1) << endl;


}

Measured memory_bytes: 11416
#include <iostream>
#include <map>
#include <vector>
#include <cstring>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <string>
#include <stack>
#include <set>
#include <deque>
#define mp make_pair
using namespace std;
int n,cnt;
map <int,int> ma;
int main(){
	ios::sync_with_stdio(false);
	cin>>n;
	for (int i=0;i<n;i++){
		int a;
		cin>>a;
		ma[a]++;
	}
	for (map <int,int>::iterator it=ma.begin();it!=ma.end();it++){
		if (it->second<it->first) cnt+=it->second; else cnt+=it->second-it->first;
	}
	cout<<cnt;
	return 0;
}

Measured memory_bytes: 4736
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <functional>
#define MOD 1000000007

int i,j,k;

struct edge {
    int to;
    int cost;
};

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

bool compare_by_b(pair<int,pair<string,int>> a, pair<int,pair<string,int>> b) {
    if(a.second.first != b.second.first){
        return a.second.first < b.second.first;
    }else{
    return a.second.second > b.second.second;
    }
}

int main(void) {
    int p,q,r;
    cin >> p >> q >> r;
    int ans = min(p+q,min(q+r,r+p));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/


int solve(){
    string s;
    cin >> s;
    ll n = s.size();

    vector<int> v[26];
    rep(i,n){
        int c = s[i]-'a';
        v[c].pb(i);
    }

    ll cnt = 0;
    rep(i,26){
        ll t = v[i].size();
        ll p = t * (t-1) / 2;
        cnt += p;
    }

    ll sum = n * (n-1) / 2;
    sum -= cnt;
    sum++;
    assert(sum>=0);
    cout << max<ll>(1,sum)<< endl;
}

int main(){
solve();
}


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

template <typename T> T gcd(T a, T b) { while (a) { b %= a; swap(a, b); } return b; }

ll N;
vector<ll> A;

ll gcd_l[MAX_N];    // [0, i] の gcd 結果
ll gcd_r[MAX_N];    // [i, N-1] の gcd 結果

signed main()
{
    cin >> N;
    A.resize(N);
    REP(i, N) { cin >> A[i]; }

    // gcd_l, r の作成
    gcd_l[0] = A[0];
    for(int i = 1; i < N; ++i) {
        gcd_l[i] = gcd(A[i], gcd_l[i-1]);
    }
    gcd_r[N-1] = A[N-1];
    for(int i = N-2; i >= 0; --i) {
        gcd_r[i] = gcd(A[i], gcd_r[i+1]);
    }

    ll ans = max(gcd_l[N-2], gcd_r[1]);
    for(int i = 1; i < N-1; ++i) {
        // i を抜いたときの gcd
        ll gcd_ex_i = gcd(gcd_l[i-1], gcd_r[i+1]);
        ans = max(ans, gcd_ex_i);
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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(int argc, char const *argv[]) {
  int a;
  string s;
  cin >> a >> s;
  if(a>=3200) cout << s << endl;
  else cout << "red" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Fr(i,a,b) for(int i=(a);i<=(int)(b);++i)
#define Dr(i,a,b) for(int i=(a);i>=(int)(b);--i)
using namespace std;
typedef long long ll;
const int inf=0x3f3f3f3f;
#define debug(x,y) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl
#define bug(x) cout<<#x<<"="<<x<<" "
int main() {
	ll L,R;
	cin>>L>>R;
	ll S=0;
	while(S<R) {
		S+=2019;
		if(S>=L&&S<=R)puts("0"),exit(0);
	}
	if(S>=L&&S<=R)puts("0");
	else {
		S=inf;
		Fr(i,L,R) {
			Fr(j,i+1,R) {
				S=min(S,1ll*i*j%2019);
			}
		}
		cout<<S<<endl;
	}
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 1000000007;
const long long inf = 1ll<<61;
typedef pair<int, int> P;
typedef pair<P, int> PP;
typedef pair<int, PP> PPP;
struct edge { int to; int to2; int cost; };
string a = "ACGT", b = "TGCA";
signed main() {
	char c; cin >> c;
	rep(i, 4) {
		if (a[i] == c)cout << b[i] << endl;
	}
}

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

ll solve() {
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    for ( int i = 0; i < N; i++ ) cin >> A[i];
    lld EPS = (lld)1e-10;

    auto within_k = [&](lld x) {
        ll n = 0;
        for ( int i = 0; i < N; i++ ) {
            n += (ll)((A[i] - EPS) / x);
        }
        return n <= K;
    };
    
    lld l = 1e-10, r = 1e9+1;
    while ( abs(r-l) > EPS ) {
        lld m = (l+r)/2;
        if ( within_k(m) ) r = m;
        else l = m;
    }
    // 切り上げ
    ll ans = (ll)(r + 1 - EPS);
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 4752
import math 
A,B = map(int,input().split())

a_sita = A/0.08 
a_ue = (A+1)/0.08 

b_sita = B/0.10
b_ue = (B+1)/0.10

if a_ue <= b_sita or b_ue <= a_sita:
  print(-1)

else:
  ans = max(a_sita,b_sita)
  ans = math.ceil(ans)
  print(int(ans))

Measured memory_bytes: 3060
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A - Pair
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int k;
  scanf("%d", &k);

  int on = (k + 1) / 2, en = k / 2;
  printf("%d\n", on * en);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

int_fast32_t bs(vector<int>& v, int key) {
  int l = -1;
  int r = v.size();

  while (r - l > 1) {
    int mid = l + (r - l) / 2;

    if (v[mid] >= key) {
      r = mid;
    } else {
      l = mid;
    }
  }

  return r;
}

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

  int n;
  cin >> n;
  vector<int> s(n);
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }

  int q;
  cin >> q;
  vector<int> t(n);
  for (int i = 0; i < q; i++) {
    cin >> t[i];
  }

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

  int ans = 0;
  for (int i = 0; i < q; i++) {
    int key = t[i];

    int lb = bs(s, key);

    if (s[lb] == key) {
      ans++;
    }
  }

  cout << ans << ln;

  return 0;
}


Measured memory_bytes: 3540
#include <stdio.h>
#include <math.h>
const int N=3e3+10;
const long double pi=acos(-1);
int main(){
	int n,a[N],pos,l;
	long double x=0,y=0;
  	scanf("%d%d",&n,&l);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)for(int j=i+1;j<=n;j++){
		long double theta=(a[i]+a[j])*pi/l;
      	int cnt1=j-i-1;
      	int cnt2=n-2-cnt1;
		x+=cos(theta)*(cnt2-cnt1);
		y+=sin(theta)*(cnt2-cnt1);
	}
	long long int tot=1LL*n*(n-1)*(n-2)/6;
	printf("%.20Lf %.20Lf\n",x/tot,y/tot);
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){

	int a, b, c, count;
	cin >> a>> b>> c;
	count = 0;

	for (int x = a ; x <= b; x++){
		if (c%x == 0){
			count ++;
		}
	}

	cout << count << endl;

	return 0;
}


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

#define ll long long
#define mp make_pair
#define X first
#define Y second
#define pb push_back
#define pii pair<int, int>

using namespace std;

int solve();

int main()
{
    #ifdef DEBUG
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif // DEBUG
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    solve();
}

const int MAXN = (int)3e5 + 10;

int pref[MAXN];

int solve()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    for (int i = 1; i <= n; i++)
    {
        pref[i] = pref[i - 1];
        if (s[i - 1] == 'W')
            pref[i]++;
    }
    int ans = n + 10;
    for (int i = 1; i <= n; i++)
    {
        int cur = pref[i - 1] + (n - i - (pref[n] - pref[i]));
        ans = min(ans, cur);
    }
    cout << ans << endl;
}



Measured memory_bytes: 1812
#include <bits/stdc++.h>
#define INF 100000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main()
{
  ll N;
  cin >> N;
  double ans = 0;
  for (ll i = 0; i < N; ++i)
  {
    double x;
    string u;
    cin >> x >> u;
    if (u == "BTC")
    {
      ans += x * 380000;
    }
    else
    {
      ans += x;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
package main
import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
	"strconv"
)
 
var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}
 
func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
 
func nextInt64() int64 {
	sc.Scan()
	i, _ := strconv.ParseInt(sc.Text(), 10, 64)
	return i
}

type Item struct {
  Price int
}

type PriorityQueue []*Item

func (pq PriorityQueue) Len() int {
  return len(pq)
}

func (pq PriorityQueue) Less(i, j int) bool {
  return pq[j].Price < pq[i].Price
}

func (pq PriorityQueue) Swap(i, j int) {
  pq[i], pq[j] = pq[j], pq[i]
}

func (pq *PriorityQueue) Pop() interface{} {
  old := *pq
  n := len(old)
  item := old[n-1]
  *pq = old[0:n-1]
  return item
}

func (pq *PriorityQueue) Push(x interface{}) {
  item := x.(*Item)
  *pq = append(*pq, item)
}

func main() {
  sc.Buffer(make([]byte, 500000), 500000)
  sc.Split(bufio.ScanWords)
 
  n := nextInt()
  m := nextInt()
  
  as := make([]int, n)
  for i := 0; i < n; i++ {
    as[i] = nextInt()
  }
  priorityQueue := make(PriorityQueue, n, 1000*n)
  for i, a := range as {
    item := Item{}
    item.Price = a
    priorityQueue[i] = &item 
  }
  heap.Init(&priorityQueue)
  
  for i := 0; i < m; i++ {
    item := heap.Pop(&priorityQueue).(*Item)
    newPrice := item.Price/2
    newItem := Item{}
    newItem.Price = newPrice
    heap.Push(&priorityQueue, &newItem)
  }
  result := int64(0)
  for i := 0; i < n; i++ {
    item := heap.Pop(&priorityQueue).(*Item)
    result += int64(item.Price)
  }
  fmt.Println(result)
  
  
}

Measured memory_bytes: 32000
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 99999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(150) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define Lower(v,X) lower_bound(v.begin(),v.end(),X)-v.begin();
#define mod 1000000007
#define MAX 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  lli A,B,C,D,E,F,N,M,K,L,R,X,Y,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> A >> B;
  if(A-2*B<0)Out(0);
  else Out(A-2*B);
}

Measured memory_bytes: 256
H, W, D = map(int, input().split())
A = []
for i in range(H):
    A.append(list(map(int, input().split())))

Q = int(input())
L = []
R = []
for i in range(Q):
    l, r = map(int, input().split())
    L.append(l)
    R.append(r)

M = dict()
for y, line in enumerate(A):
    for x, square in enumerate(line):
        M[square] = (x, y)

S = [[] for _ in range(D)]
for i in range(H * W):
    i += 1
    S[i % D].append(M[i])

CS = [[0] for _ in range(D)]
for i in range(D):
    for j in range(1, len(S[i])):
        CS[i].append(CS[i][j-1] + abs(S[i][j-1][0] - S[i][j][0]) + abs(S[i][j-1][1] - S[i][j][1]))

for i in range(Q):
    cumsum = CS[L[i] % D]
    left = (L[i]-1) // D
    right = (R[i]-1) // D
    print(cumsum[right] - cumsum[left])

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

int main(){
  int x, a, b;
  cin >> x >> a >> b;
  if(a >= b){
    cout << "delicious";
  }else if(b-a <= x){
    cout << "safe";
  }else{
    cout << "dangerous";
  }
  cout << endl;
  
}


Measured memory_bytes: 256
/*。*/
#include <iostream>
#include<stdio.h>
#include <cmath>
using namespace std;

class saikoro{
public:
    int s1,s2,s3,s4,s5,s6;
    
public:saikoro(int* mas);
    void west();
    void north();
    void east();
    void sauth();
    void kaiten();
    
};
saikoro::saikoro(int* mas){
    s1=mas[0];
    s2=mas[1];
    s3=mas[2];
    s4=mas[3];
    s5=mas[4];
    s6=mas[5];
}
void saikoro::east(){
    int u=s6;
    s6=s3;
    s3=s1;
    s1=s4;
    s4=u;
    
}
void saikoro::north(){
    int u=s6;
    s6=s5;
    s5=s1;
    s1=s2;
    s2=u;
}
void saikoro::west(){
    int u=s6;
    s6=s4;
    s4=s1;
    s1=s3;
    s3=u;
}
void saikoro::sauth(){
    int u=s6;
    s6=s2;
    s2=s1;
    s1=s5;
    s5=u;
}
void saikoro::kaiten(){
    int u=s2;
    s2=s3;
    s3=s5;
    s5=s4;
    s4=u;
}
int main(){
   int  masu1[6];
    int masu2[6];
    for(int i=0;i<6;i++){
        cin>>masu1[i];
    }
    for(int i=0;i<6;i++){
        cin>>masu2[i];
    }
    // saikoro sai(masu);
    
   
        saikoro sai(masu1);
        saikoro sai2(masu2);
        int flag=0;
        for(int j=0;j<4;j++){
            sai.east();
            for(int k=0;k<4;k++){
                sai.sauth();
                for(int g=0;g<4;g++){
                    sai.kaiten();
                    if(sai.s1==sai2.s1&&sai.s2==sai2.s2&&sai.s3==sai2.s3&&sai.s4==sai2.s4&&sai.s5==sai2.s5){
                   cout<<"Yes"<<endl;
                   return 0;
                }
   
            }
             
        }
        
    
        }
    cout<<"No"<<endl;
    

return 0;
}


Measured memory_bytes: 3136
public partial class IntroductionToProgramming{
    public static void Main(){
        string[] line = System.Console.ReadLine().Split(' ');
 
        int h = int.Parse(line[0]);
        int w = int.Parse(line[1]);
 
        string es = string.Empty;
        string os = string.Empty;
        for (int i = 0; i < 300; i++)
        {
            es += i % 2 == 0 ? "#" : ".";
            os += i % 2 == 0 ? "." : "#";
        }
 
        while (!(h == 0 && w == 0))
        {
            for (int i = 0; i < h; i++ )
            {
                System.Console.WriteLine(i % 2 == 0 ? es.Substring(0, w) : os.Substring(0, w));
            }
            System.Console.WriteLine(string.Empty);
 
            string[] line2 = System.Console.ReadLine().Split(' ');
 
            h = int.Parse(line2[0]);
            w = int.Parse(line2[1]);
        }
    }
}
 

Measured memory_bytes: 9092
#include <cstdio>
#include <cstring>

const int MOD = (int)1e9 + 7;

const int N = 200000;
const int M = 2001;

int n, a[N], b[N], dp[M << 1][M << 1];

void update(int& x, int a)
{
    x += a;
    if (x >= MOD) {
        x -= MOD;
    }
}

int main()
{
    dp[0][0] = 1;
    for (int i = 0; i < M << 1; ++ i) {
        for (int j = 0; j < M << 1; ++ j) {
            if (i) {
                update(dp[i][j], dp[i - 1][j]);
            }
            if (j) {
                update(dp[i][j], dp[i][j - 1]);
            }
        }
    }
    int result = 0;
    scanf("%d", &n);
    for (int i = 0; i < n; ++ i) {
        scanf("%d%d", a + i, b + i);
        update(result, MOD - dp[a[i] << 1][b[i] << 1]);
    }
    memset(dp, 0, sizeof(dp));
    for (int i = 0; i < n; ++ i) {
        dp[M - a[i]][M - b[i]] ++;
    }
    for (int i = 1; i < M << 1; ++ i) {
        for (int j = 1; j < M << 1; ++ j) {
            update(dp[i][j], dp[i - 1][j]);
            update(dp[i][j], dp[i][j - 1]);
        }
    }
    for (int i = 0; i < n; ++ i) {
        update(result, dp[M + a[i]][M + b[i]]);
    }
    printf("%d\n", (int)(result * 500000004LL % MOD));
}

Measured memory_bytes: 64256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N=510000;
int n,q;
int a[N],d[N];
ll b[N];
int main()
{
	//freopen("tt.in","r",stdin);
	scanf("%d%d",&n,&d[0]);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	b[n+1]=1;
	for(int i=n;i>=1;i--)
	{
		if(a[i]/2>=b[i+1])b[i]=b[i+1];
		else b[i]=b[i+1]+a[i];
	}
	for(int i=1;i<=n;i++)
		d[i]=min(d[i-1],abs(d[i-1]-a[i]));
	scanf("%d",&q);
	for(int i=1,t;i<=q;i++)
	{
		scanf("%d",&t);
		puts(b[t+1]<=d[t-1] ? "YES" : "NO");
	}
	return 0;
}


Measured memory_bytes: 9856
N=parse(Int,readline())
S=Array{String}(0)
T=Array{Int}(0)
for i=1:N
	s,t=split(readline())
	push!(S,String(s))
	push!(T,parse(Int,t))
end
id=1:N
for i=sort(id,lt=(a,b)->S[a]<S[b]||S[a]==S[b]&&T[a]>T[b])
	println(i)
end


Measured memory_bytes: 116488
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


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

    string s;
    cin >> s;

    int num0 = 0, num1 = 0;
    int ans = 0;
    rep (i, s.size())
    {
        if (s[i] == '0')
        {
            if (num1 > 0)
            {
                --num1;
                ans += 2;
            }
            else
            {
                ++num0;
            }
        }
        else if (s[i] == '1')
        {
            if (num0 > 0)
            {
                --num0;
                ans += 2;
            }
            else
            {
                ++num1;
            }
        }
    }

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



Measured memory_bytes: 512
import java.util.*;
import static java.lang.System.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int A = 0;
		for (int i=0; i<4; i++) {
			A += sc.nextInt();
		}
		
		int B = 0;
		for (int i=0; i<4; i++) {
			B += sc.nextInt();
		}
		
		out.println(Math.max(A,B));
	}
}


Measured memory_bytes: 26256
#include<bits/stdc++.h>
using namespace std;
int n,ans=1;
int main()
{
	cin>>n;
	if(n==1||n==2||n==4)
	{cout<<4;return 0;}
	while(n!=4)
	{
		if(n%2==0)
		{n=n/2;ans++;}
		else
		{n=3*n+1;ans++;}
	}
	cout<<ans+3;
	return 0;
}

Measured memory_bytes: 256