akhauriyash/Code-Regression huggingface dataset:
import itertools
import heapq
import copy

def inv(l):
    return list(map(lambda x: x*-1, l))

def solve(A,B,C, K):
    A,B,C = inv(A), inv(B), inv(C)
    A = sorted(A)
    B = sorted(B)
    C = sorted(C)
    ind = set([(0,0,0)])

    h = [(A[0]+ B[0]+ C[0], (0,0,0))]
    res = []

    for _ in range(K):
        h2 = copy.copy(h)
        val, (i,j,k) = heapq.heappop(h)
        res += [-val]
        if i+1 < len(A) and (i+1,j,k) not in ind:
            heapq.heappush(h, (A[i+1]+B[j]+C[k], (i+1, j, k)))
            ind |= set([(i+1,j,k)])
        if j+1 < len(B) and (i,j+1, k) not in ind:
            heapq.heappush(h, (A[i]+B[j+1]+C[k], (i, j+1, k)))
            ind |= set([(i,j+1,k)])
        if k+1 < len(C) and (i,j, k+1) not in ind:
            heapq.heappush(h, (A[i]+B[j]+C[k+1], (i, j, k+1)))
            ind |= set([(i,j,k+1)])
    for r in res:
        print(r)

la,lb,lc,K = list(map(int, input().split(' ')))
A = list(map(int, input().split(' ')))
B = list(map(int, input().split(' ')))
C = list(map(int, input().split(' ')))

solve(A,B,C,K)

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

int main(){
	
	string s;
	cin >> s;
	
	int st = -1;
	for(int i = 0 ; i < s.size() ; i ++){
		if(s[i] == 'A'){
			st = i;
			break;
		}
	}
	
	int en = -1;
	for(int i = s.size() - 1 ; i >= 0 ; i --){
		if(s[i] == 'Z'){
			en = i;
			break;
		}
	}
	
	if(st < 0 || en < 0) cout << "0\n";
	else cout << en - st + 1 << "\n";
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
  int R,C,x,y,W=0;cin>>R>>C;
  pair<int,int>s=make_pair(0,0),g=make_pair(R-1,C-1);
  int N[R][C];char M[R][C];
  for(int i=0;i<R;i++)for(int j=0;j<C;j++){
    cin>>M[i][j];
    if(M[i][j]=='.')W++;
  }
  for(int i=0;i<R;i++)for(int j=0;j<C;j++)N[i][j]=W+1;
  N[0][0]=1;
  queue<pair<int,int>>X;
  X.push(s);
  while(X.front()!=g&&X.size()){
    x=X.front().first;y=X.front().second;
    if(x<R-1&&M[x+1][y]=='.'&&N[x+1][y]==W+1){X.push(make_pair(x+1,y));N[x+1][y]=N[x][y]+1;}
    if(x>0&&M[x-1][y]=='.'&&N[x-1][y]==W+1){X.push(make_pair(x-1,y));N[x-1][y]=N[x][y]+1;}
    if(y<C-1&&M[x][y+1]=='.'&&N[x][y+1]==W+1){X.push(make_pair(x,y+1));N[x][y+1]=N[x][y]+1;}
    if(y>0&&M[x][y-1]=='.'&&N[x][y-1]==W+1){X.push(make_pair(x,y-1));N[x][y-1]=N[x][y]+1;}
    X.pop();
  }
  cout<<W-N[R-1][C-1]<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <set>
#include <unordered_set>
#include <queue>
#include <boost/math/constants/constants.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, n, m) for(int i=n; i<m; ++i)

const ll M = 1000000007;

vector<ll> fac(666670); //n!(mod M)
vector<ll> ifac(666670); //k!^{M-2} (mod M)
//a,bの範囲的にこれだけ配列を用意していけば十分

ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}

ll comb(ll a, ll b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}

int main()
{
    //ll n,k;
    //cin >> n >> k;
  ll a, b;
  cin >> a >> b;
  
  ll c, n, k;
  
  if((a+b)%3!=0){
    cout << 0 << endl;
    return 0;
  }else{
    c=(a+b)/3;
  }
  
  n = c;
  k = (a+b)/2 - abs(a-b)/2 - c;
  
  if(k<0){
    cout << 0 << endl;
    return 0;
  }
  
  //cout << n << k << endl;
  
    //大した量ではないので，先にfax[i]とifax[i]を全て計算しておく
    fac[0] = 1;
    ifac[0] = 1;
    for(ll i = 0; i<666669; i++){
        fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
        ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
    }


    ll ans=0;
    ans = comb(n, k)%M;
    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

string S;
int z[26];
int a = -1;

int main(){
	cin >> S;/*
	for(auto c : S){
		++z[c-'a'];
	}
	repp(i,0,26){
		if(i=='x'-'a' || z[i]%2==0) continue;
		if(a<0) a = i;
		else a = 100;
	}
	if(a == 100){
		cout << -1 << endl;
		return 0;
	}*/
	int ans = 0;
	int p = 0 , q = S.size() - 1;
	while(p < q){
		if(S[p] == S[q]){
			++p; --q;
		} else if(S[p] == 'x'){
			++p;
			++ans;
		} else if(S[q] == 'x'){
			--q;
			++ans;
		} else {
			cout << -1 << endl;
			return 0;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;

#define MOD 1000000007;

int N, T[100000], A[100000];

int main()
{
	//ifstream cin("input.txt");

	cin >> N;
	int index_max_T = -1, index_max_A = -1;
	for (int i = 0; i < N; ++i)
	{
		cin >> T[i];
		if (index_max_T < 0 || T[index_max_T] < T[i])
			index_max_T = i;
	}
	for (int i = 0; i < N; ++i)
	{
		cin >> A[i];
		if (index_max_A < 0 || T[index_max_A] <= A[i])
			index_max_A = i;
	}

	if (index_max_T > index_max_A || T[index_max_T] != A[index_max_A])
	{
		cout << 0 << endl;
		return 0;
	}

	long long result = 1;
	for (int i = 0; i < N; ++i)
	{
		if (i == index_max_T || i == index_max_A || i == 0 || i == N - 1)
			continue;

		if (T[i] > T[i - 1] || A[i] > A[i + 1])
			continue;

		result = (result * min(T[i], A[i])) % MOD;
	}

	cout << result << endl;

	return 0;
}


Measured memory_bytes: 1024
import java.util.*;
 
public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        int[] a = new int[m];
        int[] b = new int[m];
        int[] ans = new int[n];
        boolean[] visited = new boolean[n];
        List<Integer>[] g = new ArrayList[n];
        List<Integer> queue = new ArrayList<>();
        for(int i=0; i<n; i++) {
            g[i] = new ArrayList<>();
            visited[i] = false;
            ans[i] = -1;
        }
        
        for(int i=0; i<m; i++) {
            a[i] = Integer.parseInt(sc.next())-1;
            b[i] = Integer.parseInt(sc.next())-1;
            g[a[i]].add(b[i]);
            g[b[i]].add(a[i]);
        }
        
        queue.add(0);
        while(queue.size() != 0) {
            int x = queue.get(0);
            queue.remove(0);
            for(int i : g[x]) {
                if(visited[i] == false){
                    queue.add(i);
                    if(ans[i] == -1){
                        ans[i] = x;
                        visited[i] = true;
                    }
                } 
            }
        }
        
        int[] copyans = Arrays.copyOfRange(ans, 1, ans.length);
        if(Arrays.asList(ans).contains(-1)) System.out.println("No");
        else {
            System.out.println("Yes");
            for(int i : copyans) {
                System.out.println(i+1);
            }
        }
    }
    
    
}

Measured memory_bytes: 78900
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
//FILE *fi = freopen("1.txt", "r", stdin);
//FILE *fo = freopen("1", "w", stdout);
//FILE *fi = freopen("P.inp", "r", stdin);
//FILE *fo = freopen("P.out", "w", stdout);
int n;
long long ans;
int main()
{
    //------------------------------
    // Faster
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //-------------------------------
    cin >> n;
    for (int len = 1; len <= n; len++)
    {
        ans += 1LL * len * (n - len + 1);
    }
    for (int i = 1; i < n; i++)
    {
        int u, v;
        cin >> u >> v;
        if (u > v)
            swap(u, v);
        ans -= 1LL * u * (n - v + 1);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
using namespace std;
typedef pair<int,int> pii;
static const int INF = 3355224;

int dp[2][2][2][2001][2001];
int N,M;
string S,T;


int solve(int n1,int n2,int p,int s,int t){
    if(dp[n1][n2][p][s][t]!=-1)return dp[n1][n2][p][s][t];
    if(s>N||t>M){
        return -INF;
    }
    if(s==N&&t==M){
        if(p==0)return -INF;
        else return 0;
    }
    int res=0;
    int sx,tx;
    {
        if(s==N)sx=p;
        if(t==M)tx=p;
        if(S[s]=='I')sx=1;
        if(S[s]=='O')sx=0;
        if(T[t]=='I')tx=1;
        if(T[t]=='O')tx=0;
    }
    if(n1==0&&n2==0){
        if(p!=sx&&p!=tx){
            res+=max(solve(0,0,p,s+1,t),
                    max(solve(0,0,p,s,t+1),
                        max(solve(1,0,sx,s+1,t)+1,
                            max(solve(0,1,tx,s,t+1)+1,res))));
        }
        else if(p!=sx&&p==tx){
            res+=max(solve(0,0,p,s+1,t),
                    max(solve(0,0,p,s,t+1),
                        max(solve(1,0,sx,s+1,t)+1,res)));
        }
        else if(p==sx&&p!=tx){
           res+=max(solve(0,0,p,s+1,t),
                   max(solve(0,0,p,s,t+1),
                           max(solve(0,1,tx,s,t+1)+1,res)));
        }
        else{
            res+=max(solve(0,0,p,s+1,t),
                   max(solve(0,0,p,s,t+1),res));
        }
    }

    else if(n1==0&&n2!=0){
        if(p!=sx&&p!=tx){
            res+=max(solve(0,n2,p,s+1,t),
                        max(solve(1,n2,sx,s+1,t)+1,
                            max(solve(0,n2,tx,s,t+1)+1,res)));
        }
        else if(p!=sx&&p==tx){
            res+=max(solve(0,n2,p,s+1,t),
                        max(solve(1,n2,sx,s+1,t)+1,res));
        }
        else if(p==sx&&p!=tx){
           res+=max(solve(0,n2,p,s+1,t),
                        max(solve(0,n2,tx,s,t+1)+1,res));
        }
        else{
            res+=max(solve(0,n2,p,s+1,t),res);
        }
    }

    else if(n1!=0&&n2==0){
        if(p!=sx&&p!=tx){
            res+=max(solve(n1,0,p,s,t+1),
                        max(solve(n1,0,sx,s+1,t)+1,
                            max(solve(n1,1,tx,s,t+1)+1,res)));
        }
        else if(p!=sx&&p==tx){
            res+=max(solve(n1,0,p,s,t+1),
                        max(solve(n1,0,sx,s+1,t)+1,res));
        }
        else if(p==sx&&p!=tx){
           res+=max(solve(n1,0,p,s,t+1),
                        max(solve(n1,1,tx,s,t+1)+1,res));
        }
        else{
            res+=max(solve(n1,0,p,s,t+1),res);
        }
    }
    else {
        if(p!=sx&&p!=tx){
            res+=max(solve(n1,n2,sx,s+1,t)+1,
                    max(solve(n1,n2,tx,s,t+1)+1,res));
        }
        else if(p!=sx&&p==tx){
            res+=max(solve(n1,n2,sx,s+1,t)+1,res);
        }
        else if(p==sx&&p!=tx){
           res+=max(solve(n1,n2,tx,s,t+1)+1,res);
        }
        else if(p==0)return -INF;
    }
    return dp[n1][n2][p][s][t]=res;
}


int main(){
    memset(dp,-1,sizeof(dp));
    cin>>N>>M;
    cin>>S>>T;
    cout<<solve(0,0,0,0,0)<<endl;
}

Measured memory_bytes: 128820
#include<bits/stdc++.h>
 
using namespace std;
int dp[30001][4];
int n;
string s;

int f(int i, int j) {
    if(j == 3)
        return 1;
    if(i == n)
        return 0;
    
    auto& ret = dp[i][j];
    if(ret != -1)
        return ret;
    
    ret = 0;
    for(auto k = 0; k <= 9; ++k) {
        for(auto l = i; l < n; ++l) {
            if(s[l] == '0' + k) {
                ret += f(l+1, j+1);
                break;
            }
        }
    }

    return ret;
}

void solve() {
    cin >> n >> s;

    memset(dp, -1, sizeof(dp));
    cout << f(0, 0) << endl;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 
    int t;
    //cin >> t;
    //for(auto i = 0; i < t; ++i)
        solve();
}


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

a_lis = []
b_lis = []

for _ in range(M):
    a, b = map(int, input().split())
    a_lis.append(a)
    b_lis.append(b)
 

new_lis = a_lis + b_lis
set_new_lis = sorted(set(new_lis))
set_new_lis

for i in range(1,N+1):
    print(new_lis.count(i))

Measured memory_bytes: 3064
import sys
sys.setrecursionlimit(10 ** 6)
readline = sys.stdin.readline
directions = [(-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 1), (1, -1), (1, 0), (1, 1)]

class Ans():

    def __init__(self, H, W, mat):
        self.H = H
        self.W = W
        self.mat = mat
        self.visited = [[False] * W for _ in range(H)]

    def dfs(self, h, w):
        if self.mat[h][w] == 0 or self.visited[h][w] == True:
            return
        
        self.visited[h][w] = True
        for dh, dw in directions:
            if not (0 <= h + dh < self.H and 0 <= w + dw < self.W):
                continue
            if self.mat[h+dh][w+dw] == 0 or self.visited[h+dh][w+dw] == True:
                continue
            self.dfs(h+dh, w+dw)
        return

def main():
    while 1:
        W, H = map(int, readline().rstrip().split())
        if W == H == 0:
            break

        mat = [list(map(int, readline().rstrip().split())) for _ in range(H)]
        ans = Ans(H, W, mat)

        res = 0
        for h in range(H):
            for w in range(W):
                if ans.mat[h][w] == 1 and ans.visited[h][w] == False:
                    res += 1
                ans.dfs(h, w)

        print(res)

if __name__ == '__main__':
    main()


Measured memory_bytes: 7988
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import _collections
import string
from functools import lru_cache
import heapq

class cin():
    def int():
        return int(sys.stdin.readline().rstrip())
    def string():
        return sys.stdin.readline().rstrip()
    def mapInt():
        return [int(x) for x in cin.string().split()]
    def stringList(n):
        return [input() for i in range(n)]
    def intListList(n):
        return [cin.mapInt() for i in range(n)]
    def intColsList(n):
        return [int(input()) for i in range(n)]
        
class Math():
    def gcd(a,b):
        if b == 0:
            return a
        return Math.gcd(b,a % b)
    def lcm(a,b):
        return (a * b) // Math.gcd(a,b)
    def roundUp(a,b):
        return -(-a // b)
    def toUpperMultiple(a,x):
        return Math.roundUp(a,x) * x
    def toLowerMultiple(a,x):
        return (a // x) * x
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

MOD = int(1e09) + 7

def main():
    N = cin.int()
    S = cin.string()
    ans = 1
    for i in range(N - 1):
        if S[i + 1] != S[i]:
            ans+=1
    print(ans)
    return

if __name__ == "__main__":
    main()


Measured memory_bytes: 40304
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
using namespace std;
int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int x,y;
	cin>>x>>y;
	REP(i,x+1)
	{
		if((y-i*2)%4==0 && (y-i*2)/4+i==x)
		{
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3588
#include<iostream>
#include<vector>

using namespace std;

int main(){
	int n,k;
	cin >> n >> k;
	vector<int> a;
	for(int i = 0;i <n;i++){
		int ta;
		cin >> ta;
		a.push_back(ta);
	}
	int ans = (n-1) / (k-1);
	if((n-1) % (k-1) == 0){
		
	}else{
		ans++;
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()

constexpr int MOD = 1000000007;

class mint {
  int n;
public:
  mint(int n_ = 0) : n(n_) {}
  explicit operator int() { return n; }
  friend mint operator-(mint a) { return -a.n + MOD * (a.n != 0); }
  friend mint operator+(mint a, mint b) { int x = a.n + b.n; return x - (x >= MOD) * MOD; }
  friend mint operator-(mint a, mint b) { int x = a.n - b.n; return x + (x < 0) * MOD; }
  friend mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
  friend mint &operator+=(mint &a, mint b) { return a = a + b; }
  friend mint &operator-=(mint &a, mint b) { return a = a - b; }
  friend mint &operator*=(mint &a, mint b) { return a = a * b; }
  friend bool operator==(mint a, mint b) { return a.n == b.n; }
  friend bool operator!=(mint a, mint b) { return a.n != b.n; }
  friend istream &operator>>(istream &i, mint &a) { return i >> a.n; }
  friend ostream &operator<<(ostream &o, mint a) { return o << a.n; }
};

mint modpow(mint a, long long b) {
  mint res = 1;
  while (b > 0) {
    if (b & 1) res *= a;
    a *= a;
    b >>= 1;
  }
  return res;
}

mint modinv(mint n) {
  int a = (int)n, b = MOD;
  int s = 1, t = 0;
  while (b != 0) {
    int q = a / b;
    a -= q * b;
    s -= q * t;
    swap(a, b);
    swap(s, t);
  }
  return s >= 0 ? s : s + MOD;
}

vector<mint> F_{1, 1}, R_{1, 1}, I_{0, 1};

void check_fact(int n) {
  for (int i = I_.size(); i <= n; i++) {
    I_.push_back(I_[MOD % i] * (MOD - MOD / i));
    F_.push_back(F_[i - 1] * i);
    R_.push_back(R_[i - 1] * I_[i]);
  }
}

mint I(int n) { check_fact(n); return n < 0 ? 0 : I_[n]; }
mint F(int n) { check_fact(n); return n < 0 ? 0 : F_[n]; }
mint R(int n) { check_fact(n); return n < 0 ? 0 : R_[n]; }
mint C(int n, int r) { return F(n) * R(n - r) * R(r); }
mint P(int n, int r) { return F(n) * R(n - r); }
mint H(int n, int r) { return n == 0 ? (r == 0) : C(n + r - 1, r); }

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k; cin >> n >> k;
  if (n <= k) {
    cout << H(n, n) << endl;
    return 0;
  }
  mint ans = 0;
  for (int i = k; i >= 0; i--) {
    ans += C(n, i) * H(n - i, i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 5204
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string a,b;
	char x[10001],y[10001],z[10001];
	cin>>a>>b;
	int js1=0,js2=0,js3=0;
	for(int i=0;i<a.size();i++)
	  {
	  	js1++;
	  	x[js1]=a[i];
	  }
	for(int i=0;i<b.size();i++)
	  {
	  	js2++;
	  	y[js2]=b[i];
	  }
	js3=js1+js2;
	js1=0;
	js2=0;
	for(int i=1;i<=js3;i++)
	  {
	  	if(i%2==1)
	  	  {
	  	  	js1++;
			z[i]=x[js1];
		  }
		if(i%2==0)
	  	  {
	  	  	js2++;
			z[i]=y[js2];
		  }
	  }
	for(int i=1;i<=js3;i++)
	  cout<<z[i]; 
}

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

class Main {
  public static final int MOD = 1000000007;
  public static final int INF = 1000000000;
  public static void main(String[] args) {
    Scanner sc = new Scanner(in);
    int N = sc.nextInt();
    int A = N / 1000;
    int B = N % 1000 / 100;
    int C = N % 100 / 10;
    int D = N % 10;
    boolean check = true;
    for(int i=0; i<2; i++){
      if(check == false) break;
      for(int j=0; j<2; j++){
        if(check == false) break;
        for(int k=0; k<2; k++){
          int tmp;
          if(i == 0) tmp = A+B;
          else tmp = A-B;
          if(j == 0) tmp += C;
          else tmp -= C;
          if(k == 0) tmp += D;
          else tmp -= D;
          if(tmp == 7){
            String op1, op2, op3;
            if(i == 0) op1 = "+";
            else op1 = "-";
            if(j == 0) op2 = "+";
            else op2 = "-";
            if(k == 0) op3 = "+";
            else op3 = "-";
            out.println(A + op1 + B + op2 + C + op3 + D + "=7");
            check = false;
            break;
          }
        }
      }
    }
      
  }

  public static int gcd(int a, int b){
    if(b == 0) return a;
    return gcd(b, a%b);
  }
}

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

int main() {
  int n;
  cin >> n;
  vector<int> l(n * 2);
  int i;
  for (i = 0; i < n * 2; i++) {
    cin >> l[i];
  }
  sort(l.begin(), l.end());
  int count = 0;
  for (i = 0; i < n * 2; i++) {
    if (i % 2 == 0) {
      count += l[i];
    }
  }
  cout << count << endl;
  return 0;
}


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

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

  int x, a, b;
  cin >> x >> a >> b;

  cout << (x - a) % b << '\n';

  return (0);
}


Measured memory_bytes: 3556
object Main extends App {
  
  val sc = new java.util.Scanner(System.in)
  val a = sc.next()
  val b = sc.next()
  
  if (a.length > b.length) {
    println("GREATER")
  } else if (a.length < b.length) {
    println("LESS")
  } else {
    a.zip(b).find{case (x, y) => x != y} match {
      case Some((x, y)) if x > y => println("GREATER")
      case Some((x, y)) if x < y => println("LESS")
      case None => println("EQUAL")
    }
  }  
}

Measured memory_bytes: 55332
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

int main(){
  IOS();
  lf x,t;
  cin >> x >> t;
  cout << fixed << setprecision(10) << x/t << endl;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
a=[int(x) for x in input().split()]
s=sum(a)

candidates=set()
for i in range(1,int(s**0.5)+1):
  if s%i==0:
    candidates.add(i)
    candidates.add(s//i)

ans=0
for cdd in candidates:
  div_cdd=[0]*n
  for i in range(n):
    div_cdd[i]=a[i]%cdd
  div_cdd=sorted(div_cdd)
  # calc need
  idx=n-sum(div_cdd)//cdd
  need=0
  for i in range(idx):
    need+=div_cdd[i]
  ans=max(ans,cdd) if need<=k else ans
    
print(ans)

Measured memory_bytes: 9516
n,k,q = map(int,input().split())
a = [int(input()) for i in range(q)]
from collections import Counter
a = Counter(a)
for i in range(1,n+1):
    if not i in a:
        a[i] = 0
for i in range(1,n+1):
    if k+a[i]-q >0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 16112
def resolve():
    def COMinit(n, MOD):
        fact = [1, 1]
        fact_inv = [1, 1]
        inv = [0, 1]
        for i in range(2, n + 1):
            fact.append((fact[-1] * i) % MOD)
            inv.append((-inv[MOD % i] * (MOD // i)) % MOD)
            fact_inv.append((fact_inv[-1] * inv[i]) % MOD)
        return fact, fact_inv

    # 二項係数計算
    def Combination(n, k, MOD=10 ** 9 + 7):
        # fac, finv = COMinit(n, MOD)
        if n < k: return 0
        if n < 0 or k < 0: return 0
        ret = fac[n] * (finv[k] * finv[n - k] % MOD) % MOD
        return ret

    MOD = 10 ** 9 + 7
    K = int(input())
    S = input()
    N = len(S)

    fac, finv = COMinit(N + K, MOD)
    pow25 = 1
    pow26 = pow(26, K, MOD)
    inv26 = pow(26, MOD - 2, MOD)
    ans = 0
    for i in range(K + 1):
        ans += pow25 * Combination(N - 1 + i, N - 1) * pow26
        ans %= MOD
        pow25 = pow25 * 25 % MOD
        pow26 = pow26 * inv26 % MOD

    print(ans)

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 226648
#include <stdio.h>
     
    int main()
    {
      int L, R, i, j;
      scanf("%d%d", &L, &R);
      int a = L / 2019 * 2019;
      L -= a;
      R -= a;
      if(R > L+2019*2) R = L+2019*2;
      int min = 2019;
      for(i = L; i <= R; i++)
      {
        for(j = i+1; j <= R ; j++)
        {
          if(i * j % 2019 < min)
          {
          	min = i * j % 2019;
          }
        }
      }
      printf("%d\n", min);
    }

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

int main(void) {
  int N;
  cin >> N;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    int cnt = 0;
    while (a % 2 == 0) {
      cnt++;
      a /= 2;
    }
    ans += cnt;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
cor = set()
pens = {}
for i in range(m):
  p,s = input().split()
  if s=="AC":
    cor.add(p)
  else:
    if not p in cor:
      if p in pens:
        pens[p] += 1
      else:
        pens[p] = 1
pen = 0
for x in cor:
  if x in pens:  
    pen += pens[x]
print(str(len(cor))+" "+str(pen))

Measured memory_bytes: 14052
class DP
  attr_accessor :value
end

def chmin(dp_object, value)
  if dp_object.value != nil
    if (dp_object.value > value)
      dp_object.value = value
      return dp_object.value
    end
    return dp_object.value
  else
    dp_object.value = value
    return dp_object.value
  end
end

def chmax(dp_object, value)
  if dp_object.value != nil
    if (dp_object.value < value)
      dp_object.value = value
      return dp_object.value
    end
    return dp_object.value
  else
    dp_object.value = value
    return dp_object.value
  end
end

def action_handler(a, b, c, d)
  return 0 if b <= c || d <= a
  start_dp = DP.new
  stop_dp = DP.new

  chmax(start_dp, a)
  chmax(start_dp, c)

  chmin(stop_dp, b)
  chmin(stop_dp, d)

  result = stop_dp.value - start_dp.value
  return result
end
a, b, c, d = gets.chop.split.map(&:to_i)

p action_handler(a, b, c, d)


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

typedef long long ll;

#define PB push_back
#define MP make_pair

int n;

int dfs(ll x, bool a, bool b, bool c) {
    if (x > n) return 0;
    return dfs(x * 10 + 3, true, b, c) 
         + dfs(x * 10 + 5, a, true, c)
         + dfs(x * 10 + 7, a, b, true)
         + (a && b && c);
}


int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    cout << dfs(0, false, false, false) << "\n";
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* print new lines
*/

Measured memory_bytes: 3644
/*Lucky_Glass*/
#include<map>
#include<cmath>
#include<vector>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
int main(){
	ll L,R;
	scanf("%lld%lld",&L,&R);
	if((L-1)/2019!=R/2019){
		printf("0\n");
		return 0;
	}
	ll ans=2019;
	for(ll i=L;i<=R;i++)
		for(ll j=i+1;j<=R;j++)
			ans=min(ans,i*j%2019);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
mod = 10**9+7
M = 2*10**6

fact = [1]*(M+1)
factinv = [1]*(M+1)
inv = [1]*(M+1)
for n in range(2,M+1):
    fact[n] = n*fact[n-1]%mod
    inv[n] = -inv[mod%n]*(mod//n)%mod
    factinv[n] = inv[n]*factinv[n-1]%mod

def comb(n,k):
    return fact[n]*factinv[k]*factinv[n-k]%mod

S = int(input())
ans = 0

for n in range(1,S//3+1):
    ans += comb(S-3*n+n-1,n-1)
    ans %= mod
print(ans)

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

void solve() {
  int64 N;
  cin >> N;
  vector<vector<int64>> ls(N+1), rs(N+1);
  vector<int64> K(N), L(N), R(N);
  int64 res = 0;
  REP(i, N) {
    cin >> K[i] >> L[i] >> R[i];
    K[i]--;
    if (L[i] >= R[i]) {
      ls[K[i]].push_back(L[i] - R[i]);
      res += L[i];
    } else {
      rs[K[i]+1].push_back(R[i] - L[i]);
      if (K[i] + 1 < N)
        res += R[i];
      else
        res += L[i];
    }
  }
  priority_queue<int64, vector<int64>, greater<int64>> pq, pq2;
  REP(i, N) {
    for (auto&& x : ls[i]) pq.push(x);
    while (pq.size() > i + 1) {
      res -= pq.top();
      pq.pop();
    }
  }
  for (int64 i = N-1; i >= 0; i--) {
    for (auto&& x : rs[i]) pq2.push(x);
    while (pq2.size() > N - i) {
      res -= pq2.top();
      pq2.pop();
    }
  }

  cout << res << endl;
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int64 T;
	cin >> T;
	REP(_, T) {
	  solve();
	}
}


Measured memory_bytes: 24416
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int n, ai;
    cin >> n;

    vector<int> a(n,0);

    for (int i = 0; i < n-1; i++) {
        scanf("%d", &ai);
        a[--ai]++;
    }

    for (int i = 0; i < n; i++) {
        printf("%d\n", a[i]);
    }    
    
    return 0;
}


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

using namespace std;

int l[55], t[55], r[55], b[55];
vector<int> x;
vector<int> y;
int sum[1010][1010];

int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};

void compress(int n)
{
  sort(x.begin(), x.end());
  sort(y.begin(), y.end());
  x.erase(unique(x.begin(), x.end()), x.end());
  y.erase(unique(y.begin(), y.end()), y.end());
  for(int i = 0; i < n; i++){
    l[i] = find(x.begin(), x.end(), l[i]) - x.begin();
    t[i] = find(y.begin(), y.end(), t[i]) - y.begin();
    r[i] = find(x.begin(), x.end(), r[i]) - x.begin();
    b[i] = find(y.begin(), y.end(), b[i]) - y.begin();
  }
}

void dfs(int yy, int xx)
{
  sum[yy][xx] = 1;
  for(int i = 0; i < 4; i++){
    int nx = xx + dx[i], ny = yy + dy[i];
    if(0 <= nx && nx < x.size() && 0 <= ny && ny < y.size() && sum[ny][nx] == 0) dfs(ny, nx);
  }
}

int main()
{
  int n;
  while(cin >> n, n){
    x.clear();
    y.clear();
    for(int i = 0; i < n; i++){
      cin >> l[i] >> t[i] >> r[i] >> b[i];
      l[i] = l[i]*2;
      t[i] = t[i]*2;
      r[i] = r[i]*2;
      b[i] = b[i]*2;
      x.push_back(l[i]-1); y.push_back(t[i]-1);      
      x.push_back(l[i]);   y.push_back(t[i]);
      x.push_back(l[i]+1); y.push_back(t[i]+1);
      x.push_back(r[i]-1); y.push_back(b[i]-1);      
      x.push_back(r[i]);   y.push_back(b[i]);
      x.push_back(r[i]+1); y.push_back(b[i]+1);            
    }
    compress(n);
    memset(sum, 0, sizeof(sum));
    for(int i = 0; i < n; i++){
      for(int j = t[i]; j >= b[i]; j--) sum[j][l[i]] = sum[j][r[i]] = 1;
      for(int j = l[i]; j <= r[i]; j++) sum[t[i]][j] = sum[b[i]][j] = 1;
    }    
    int ans = 0;
    for(int i = 0; i < y.size(); i++){
      for(int j = 0; j < x.size(); j++){
	if(sum[i][j] == 0){
	  ans++;
	  dfs(i, j);
	}
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 6300
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_4_A
AC
"""
import sys
from sys import stdin
from bisect import bisect_right, bisect_left
input = stdin.readline


def main(args):
    N, V = map(int, input().split())
    A = [int(x) for x in input().split()]
    B = [int(x) for x in input().split()]
    C = [int(x) for x in input().split()]
    D = [int(x) for x in input().split()]

    AB = tuple(a+b for a in A for b in B)

    CD = [c+d for c in C for d in D]
    CD.append(float('-inf'))
    CD.append(float('inf'))
    CD.sort()

    count = 0
    for ab in AB:
        i = bisect_left(CD, V - ab)
        j = bisect_right(CD, V - ab)
        count += (j-i)

    print(count)


if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 102568
#include <algorithm>
#include <cstdio>

using namespace std;

long cnt = 0;

void sum(long a) {
  cnt += a;
  if (a == 0) return;
  sum(a - 1);
}

int main() {
  long n;
  scanf("%ld", &n);
  sum(n - 1);
  printf("%ld\n", cnt);
  return 0;
}


Measured memory_bytes: 128
#ifndef LOCAL
#pragma GCC optimize ("O3")
#endif
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define mor > muu & operator << (
#define R22(r) sim > typename \
  enable_if<1 r sizeof dud<c>(0), muu&>::type operator<<(c g) {
sim > struct rge { c b, e; };
sim > rge<c> range(c h, c n) { return {h, n}; }
sim > auto dud(c* r) -> decltype(cerr << *r);
sim > char dud(...);
struct muu {
#ifdef LOCAL
stringstream a;
~muu() { cerr << a.str() << endl; }
R22(<) a << boolalpha << g; ris; }
R22(==) ris << range(begin(g), end(g)); }
sim, class b mor pair < b, c > r) { ris << "(" << r.first << ", " << r.second << ")"; }
sim mor rge<c> u) {
  a << "[";
  for (c i = u.b; i != u.e; ++i)
    *this << ", " + 2 * (i == u.b) << *i;
  ris << "]";
}
#else
sim mor const c&) { ris; }
#endif
muu & operator()() { ris; }
};
#define imie(r...) "[" #r ": " << (r) << "] "
#define imask(r...) "[" #r ": " << bitset<8 * sizeof(r)>(r) << "] "
#define arr(a, i) "[" #a imie(i) ": " << a[i] << "] "
#define arr2(a, i, j) "[" #a imie(i) imie(j) ": " << a[i][j] << "] "
#define debug (muu() << __FUNCTION__ << "#" << __LINE__ << ": ")

const int N = 3e3 + 7;
int a[N];
long long dp[N][N];
int n;

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) scanf("%d", a + i);
    
    for (int i = 1; i <= n; ++i) {
        if (n % 2 == 1) dp[i][i] = a[i];
        else dp[i][i] = -a[i];
    }
    
    for (int l = 2; l <= n; ++l) {
        for (int i = 1; i + l - 1 <= n; ++i) {
            int j = i + l - 1;
            if (l % 2 == n % 2) dp[i][j] = max(a[i] + dp[i + 1][j], a[j] + dp[i][j - 1]);
            else dp[i][j] = min(-a[i] + dp[i + 1][j], -a[j] + dp[i][j - 1]);
        }
    }
    
    printf("%lld\n", dp[1][n]);
    return 0;
}


Measured memory_bytes: 70016
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <sstream>
#include <iterator>

using namespace std;

#define endl ("\n")
#define pi (3.141592653589)
#define mod 1000000007
#define int long long
#define float double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(c) c.begin(), c.end()
#define min3(a, b, c) min(c, min(a, b))
#define min4(a, b, c, d) min(d, min(c, min(a, b)))
#define rrep(i, n) for(int i=n-1;i>=0;i--)
#define rep(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)

struct debugger
{
    template<typename T> debugger& operator , (const T& v)
    {    
        cerr<<v<<" ";    
        return *this;    
    }
} dbg;

int32_t main() 
{
    fast;
	string t;
	cin >> t;
	bool flag = false;
    for(auto num: t){
        if (num == '7'){
            flag = true;
        }
    }
    if(flag){
        cout << "Yes";
    } else {
        cout << "No";
    }
}




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

int N;
string S,T;

int ok(int s){
  if(S.substr(s,N-s)==T.substr(0,N-s)) return 1;
  else return 0;
}

int main(){
  cin>>N>>S>>T;
  int ind=N;
  rep(i,N){
    if(ok(i)) ind=min(ind,i);
  }
  cout<<N+ind<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<queue>
#include<stack>
#include<utility>
#include<vector>
using namespace std;

typedef long long lint;

int main(){
    int x, t;
    cin >> x >> t;
    cout << max(x-t, 0) << endl;
    return 0;
}

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

using namespace std;

int main( void ) {

    string s, t;
    cin >> s;
    cin >> t;

    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<int>());

    if ( s.compare(t) < 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
int main(void)
{
  int a, b, c;
  long long k;
  std::cin >> a >> b >> c >> k;
  if(k % 2 == 0) std::cout << a - b << std::endl;
  else std::cout << b - a << std::endl;
  return 0;
}

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

using namespace std;

int main()
{
	int N,K;
	long long int min=1000000000;
	cin >> N >> K;
	vector<int> v(N);
	
	for(int i=0;i<N;i++){
		cin >> v[i];
	}
	sort(v.begin(),v.end(),greater<int>());
	
	for(int i=0;i<N-K+1;i++){
		if(min > v[i]-v[i+K-1])min= v[i]-v[i+K-1];
	}
	
	cout << min << endl;
	return 0;
}


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

int main(){
    //cout << endl;
    int n,m;
    cin >> n >> m;
    vector<pair<int,vector<int>>> tenbou(n);
    for(int i=0;i<n;i++) cin >> tenbou.at(i).first;
    for(int i=0;i<m;i++){
        int x,y;
        cin >> x >> y;
        tenbou.at(x-1).second.push_back(y);
        tenbou.at(y-1).second.push_back(x);
    }

    /*for(int i=0;i<n;i++){
        cout << tenbou.at(i).first << " ";
        for(int j=0;j<tenbou.at(i).second.size();j++){
            //cout << tenbou.at(i).second.at(j) << " ";
        }
        //cout << endl;
    }*/


    int cnt = 0;
    for(int i=0;i<n;i++){
        vector<int> arr = tenbou.at(i).second;
        int height = tenbou.at(i).first;
        bool flag = true;
        for(int j=0;j<arr.size();j++){
            int idx = arr.at(j)-1;
            if(height <= tenbou.at(idx).first){
                flag = false;
                break;
            }
        }
        //cout << i << " " << flag << endl;
        if(flag){
            cnt++;
        }
        
    }
    cout << cnt << endl;
}

Measured memory_bytes: 9180
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		int[] h = new int[N];
		int max = 0;
		int sum = 0;
		for (int i = 0; i < N; i++) {
			int temp = sc.nextInt();
			if (max < temp) {
				sum += max;
				max = temp;
			} else {
				sum += temp;
			}
		}
		String ans = "No";
		if (max < sum) {
			ans = "Yes";
		}
		System.out.println(ans);
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

Measured memory_bytes: 21204
#include<iostream>
#include<map>
using namespace std;
int main(){
    int N,K;
    cin >> N >> K;
    map<int,int> mp;
    while(K!=0){
	int d;
	cin >> d;
	for(int i=0;i<d;i++){
	    int temp;
	    cin >>temp;
	    mp[temp] = 1;
	}
	K--;
    }
    int res = 0;
    for(int i=1;i<=N;i++){
	if (mp.count(i)==0) res++;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF 99999999



int main(){
    int n,m;
    while(cin>>n>>m&&n&&m){
        static int data[10001][1261-500];//500テ」ツつ津ィツカツウテ」ツ??
        memset(data,0,sizeof(data));
        int r;
        cin>>r;
        rep(i,r){
            int a,b,c,d;
            cin>>a>>b>>c>>d;
            if(d!=0){
                data[c][a-500]++;
            }else{
                data[c][a-500]--;
            }
        }
        rep(i,m+1){
            rep(j,1261-500-1){
                data[i][j+1]+=data[i][j];
//                cout<<data[i][j];
            }
//            cout<<endl;
        }
        int q;
        cin>>q;
        rep(i,q){
            int s,e,v;
            cin>>s>>e>>v;
            int sum=0;
            for(int j=s-500;j<e-500;j++)sum+=!!data[v][j];
            cout<<sum<<endl;
        }
    }
    
}

Measured memory_bytes: 30896
base_answer = 0

ba = 0
bo = 0
oa = 0

$stdin.each_line.drop(1).each do |line|
  line.chomp!
  base_answer += line.scan("AB").count

  b = line[0] == 'B'
  a = line[-1] == 'A'
  if a && b
    ba += 1
  elsif a
    oa += 1
  elsif b
    bo += 1
  end
end

if ba == 0
  puts base_answer + [oa, bo].min
else
  ba_answer = (oa > 0 ? 1 : 0) + (ba - 1) + (bo > 0 ? 1 : 0)
  rest_oa_bo_answer = [[oa - 1, bo - 1].min, 0].max

  puts base_answer + ba_answer + rest_oa_bo_answer
end


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

int main(){
	int n, m, l;
	cin >> n >> m >> l;
	int* a = new int[n*m];
	int* b = new int[m*l];
	for (int i = 0; i < n; i++){
		for (int j = 0; j < m; j++){
			cin >> a[i*m + j];
		}
	}
	for (int j = 0; j < m; j++){
		for (int k = 0; k < l; k++){
			cin >> b[j*l + k];
		}
	}
	long int val = 0;
	for (int i = 0; i < n; i++){
		for (int j = 0; j < l; j++){
			val = 0;
			for (int k = 0; k < m; k++){
				val += a[i*m + k] * b[k*l + j];
			}
			cout << val << ((j == l - 1) ? "" : " ");
		}
		cout << endl;
	}
	delete[] a;
	delete[] b;
}

Measured memory_bytes: 3180
#include <bits/stdc++.h>
        #include <set>
        #include <stdio.h>
#include <string.h>
#include <vector>

#define ll long long
#define f first
#define s second
ll arr[500000];
 using namespace std;
 const ll MAX = 5000002; 
 vector<ll>p;
   unsigned ll phi[MAX+1]; 
 
int main()
{
               
    size_t found;
    long long c=0, c1=1,c2=1,g=1,h=1,z=4,k=1,maxi=1e10,msize,sum=0,sum1=0,sumi=0,sumf=0,ans=0;
    ll n,m,e,count=0,a=125,b,in,mod,gauss,mod1=0,euclid,cx1=0,cx2=0,c101=0,c102=0;
    ll expo;
 string s1="",s20="",x="",sx="",s="";
     bool t=0,t1=0,t2=0;
     cin>>a>>b>>c;
  
     cout<<min(a+b+1+b,b+c);

     
     
}
 

Measured memory_bytes: 2304
#include<iostream>
#include<vector>
#include<utility>
#include<string>
#include<algorithm>

using namespace std;

// 単語の区切りはistreamに任せる
// 単語はベクターに保持する。
// 出現頻度最多、最長文字数の単語はそれぞれ1つなので、
// すべての単語を入力後、それぞれに該当するものを探す。

int main() {
	// 単語の入力
	string input_str;
	vector<string> units;
	while (cin >> input_str) {
		units.push_back(move(input_str));
	}

	// 文字列は無駄にコピーさせないためポインタで記録しておく
	string* max_count_str = nullptr;
	auto max_count = 0;
	string* max_len_str = nullptr;
	auto max_len = 0;
	for (auto& a : units) {
		// 出現頻度が多いものを探す
		int temp_count = count(units.begin(), units.end(), a);
		if (max_count < temp_count) {
			max_count = temp_count;
			max_count_str = &a;
		}
		// 最も長い文字列を探す
		if (max_len < a.length()) {
			max_len = a.length();
			max_len_str = &a;
		}
	}

	cout << *max_count_str << ' ' << *max_len_str << endl;

	return 0;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
using namespace std;
 
#define sd(mark) scanf("%d",&mark)
#define ss(mark) scanf("%s",mark)
#define sl(mark) scanf("%lld",&mark)
#define debug(mark) printf("check%d\n",mark)
#define clr(mark) memset(mark,0,sizeof(mark))
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ll long long
#define N 1010
// #define eps (double)1e-12
// int parent[N];
// int Rank[N];
// int find(int cur)
// {
// 	if(parent[cur]==cur)
// 		return cur;
// 	return parent[cur]=find(parent[cur]);
// }

// void Union(int x,int y)
// {
// 	int xroot=find(x);
// 	int yroot=find(y);

// 	if(Rank[xroot]<Rank[yroot])
// 		parent[xroot]=yroot;
// 	else if(Rank[xroot]>Rank[yroot])
// 		parent[yroot]=xroot;
// 	else
// 	{
// 		Rank[xroot]++;
// 		parent[yroot]=xroot;
// 	}
// }
// void init(int n)
// {
// 	int i;
// 	for(i=0;i<=n;++i)
// 	{
// 		Rank[i]=0;
// 		parent[i]=i;
// 	}
// }

double x[N],y[N],r[N],adj[N][N];

double sq(double x)
{
	return x*x;
}
double point_dist(int i,int j)
{
	return sqrt(sq(x[i]-x[j])+sq(y[i]-y[j]));
}
double dist(int i,int j)
{
	return max((double)0.0,point_dist(i,j)-r[i]-r[j]);
}
#define INF 1e18
bool mark[N];
double d[N];

double dijkstra(int st,int en,int n)
{
	int i;
	int cur;
	for(i=0;i<N;++i)
	{
		mark[i]=0;
		d[i]=INF;
	}
	priority_queue<pair<double,int> > q;

	d[st]=0;
	q.push(MP(0,st));
	while(!q.empty())
	{
		pair<double,int> p=q.top();
		cur=p.S;
		if(cur==en)
			return d[cur];
		q.pop();
		if(!mark[cur])
		{
			mark[cur]=1;
			for(i=0;i<n;++i)
			{
				if(d[i]>(d[cur]+adj[cur][i]))
				{
					d[i]=(d[cur]+adj[cur][i]);
					q.push(MP(-d[i],i));
				}
			}
		}
	}
	return d[en];
}
int main()
{
	int n,i,j,k;
	scanf("%lf %lf %lf %lf",&x[0],&y[0],&x[1],&y[1]);
	r[0]=r[1]=0;
	sd(n);
	n+=2;
	for(i=2;i<n;i++)
		scanf("%lf %lf %lf",&x[i],&y[i],&r[i]);
	for(i=0;i<n;i++)
		for(j=0;j<n;j++)
			adj[i][j]=dist(i,j);
	printf("%.10lf\n",dijkstra(0,1,n));
}

Measured memory_bytes: 12400