akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i ++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i ++)
#define MP make_pair

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int INF = 1e9 + 7;

int n, m;
vector<int> G[100005];
bool vis[100005];

void dfs(int v)
{
	vis[v] = true;
	rep(i, G[v].size()) {
		int u = G[v][i];
		if(!vis[u]) dfs(u);
	}
}

int main()
{
	scanf("%d%d", &n, &m);
	rep(i, m) {
		int u, v;
		scanf("%d%d", &u, &v);
		G[u].push_back(v);
		G[v].push_back(u);
	}
	
	rep1(i, n) if(G[i].size() & 1) {
		printf("No\n");
		return 0;
	}
	
	int cnt = 0, cnt1 = 0, cnt2 = 0;
	rep1(i, n) if(!vis[i]) {
		dfs(i);
		cnt ++;
	}
	rep1(i, n) if(G[i].size() == 4) cnt1 ++;
	else if(G[i].size() > 4) cnt2 ++;
	
	if(cnt > 3) printf("No\n");
	else if(cnt == 3) printf("Yes\n");
	else if(cnt == 2) printf(cnt1 + cnt2 > 0 ? "Yes\n" : "No\n");
	else {
		if(cnt2 > 0) printf("Yes\n");
		else if(cnt1 > 2) printf("Yes\n");
		else if(cnt1 == 2) {
			int u = -1, v = -1;
			rep1(i, n) if(G[i].size() == 4) {
				if(u == -1) u = i;
				else v = i;
			}
			
			rep1(i, n) vis[i] = false;
			vis[v] = true;
			dfs(u);
			bool ok = false;
			rep1(i, n) if(!vis[i]) ok = true;
			if(ok) printf("Yes\n");
			else printf("No\n");
		} else printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 8960
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


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

    res = N

    for i in range(M):
        res -= A[i]
        if res < 0:
            res = -1
            break

    print(res)



main()


Measured memory_bytes: 9876
import java.util.*;

public class Main {
	//static_val

	public static void main(String[] args){
		int N;
		int A,B,C;
		Scanner scanner = new Scanner(System.in);

		N = scanner.nextInt();
		A = scanner.nextInt();
		B = scanner.nextInt();
		C = scanner.nextInt();

		int[] cal = new int[N];

		for(int k=0;k<N;k++){
			cal[k] = scanner.nextInt();
		}
		Arrays.sort(cal);
		int max=C/A;
		int sum_money=A;
		int sum_cal=C;
		for(int i=cal.length-1;i>=0;i--){
			sum_cal+=cal[i];
			sum_money+=B;
			if(max<sum_cal/sum_money){
				max=sum_cal/sum_money;
			}
		}
		System.out.println(max);
	}
}

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

#define ll long long int
using namespace std;

int main() {
    ll n, m, k;
    cin >> n >> m >> k;
    ll A[n]; ll B[m]; ll preA[n+1]; ll preB[m+1];
    preA[0] = 0; preB[0] = 0;
    for (ll i = 0; i < n; ++i) {
        cin >> A[i];
        preA[i+1] = preA[i] + A[i];
    }
    for (ll i = 0; i < m; ++i) {
        cin >> B[i];
        preB[i+1] = preB[i] + B[i];
    }
    ll ans=0;
    ll index = m;
    for (ll i = 0; i <= n; ++i) {
        ll Left = k - preA[i];
        if (Left < 0){
            break;
        }
       ll index=upper_bound(preB,preB+m+1,Left)-preB;
       //cout<<"index"<<index<<endl;
         index--;
        ans=max(ans,index+i);
    }
    cout << ans<<endl;
}

Measured memory_bytes: 9860
#include <iostream>

using namespace std;

int main() {
    int h, w;
    char c;
    char map_[101][101];
    while (true) {
        cin >> h >> w;
        if (w == 0) {
            break;
        }
        for (int i=0; i<h; i++) {
            for (int j=0; j<w; j++) {
                cin >> map_[j][i];
            }
        }
        int x = 0;
        int y = 0;
        while (true) {
            if (map_[x][y] == '.') {
                cout << x << ' ' << y << endl;
                break;
            }
            if (map_[x][y] == 'L') {
                cout << "LOOP" << endl;
                break;
            }
            c = map_[x][y];
            map_[x][y] = 'L';
            switch (c) {
                case '>':
                    x++;
                    break;
                case '<':
                    x--;
                    break;
                case 'v':
                    y++;
                    break;
                case '^':
                    y--;
                    break;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1168
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>


#define REP(i,N) for(auto i = 0; i <N; i++)
using namespace std;
typedef long long ll;


int in(){
    int temp;
    scanf("%d",&temp);
    return temp;
}

ll lin(){
    ll temp;
    scanf("%lld",&temp);
    return temp;
}



int main() {

    int N = in();
    
    vector<ll> A;
    
    ll dist = 0;
    A.push_back(0);
    for(auto i = 1; i <= N; i++){
        auto pre = A.back();
        A.push_back(in());
        
        dist += abs(A.back() - pre);
        
    }
    
    dist += abs(A[N]);
    
    for(auto i = 0; i < N-1; i++){
        
        cout << dist - abs(A[i+1]-A[i]) - abs(A[i+1]-A[i+2]) + abs(A[i]-A[i+2]) << endl;
        
    }
    
//    for(auto i = 0; i < N-1; i++){
//
//        if ((A[i] < A[i+1] && A[i+2] < A[i]) || (A[i+1] < A[i] && A[i] < A[i+2])){
//
//            cout << dist - abs(A[i+1]-A[i])*2 << endl;
//
//        }else if ((A[i] < A[i+2] && A[i+2] < A[i+1]) || (A[i+1] < A[i+2] && A[i+2] < A[i])){
//
//            cout << dist - abs(A[i+2]-A[i+1])*2 << endl;
//
//        }else{
//
//            cout << dist << endl;
//
//        }
//
//    }
//
    cout << dist -abs(A[N]-A[N-1]) - abs(A[N]) + abs(A[N-1]) << endl;
    
    
    
    
    
    return 0;
}




                          




Measured memory_bytes: 2164
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Diagnostics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Runtime.CompilerServices;
using static System.Math;

class P
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        //全てに合格
        int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int[] b = Console.ReadLine().Split().Select(int.Parse).ToArray();

        int[] diff = a.Zip(b, (x, y) => x - y).ToArray();
        int[] amari = diff.Where(x => x > 0).OrderByDescending(x => x).ToArray();
        int[] dame = diff.Where(x => x < 0).ToArray();

        Queue<long> q = new Queue<long>();
        foreach (var item in amari) q.Enqueue((long)item);

        long currentCount = 0;
        long currentUsed = 0;
        foreach (var item in dame)
        {
            while(currentUsed + item < 0)
            {
                if(q.Count == 0)
                {
                    Console.WriteLine(-1);
                    return;
                }
                currentUsed += q.Dequeue();
                currentCount++;
            }
            currentUsed += item;
            currentCount++;
        }
        Console.WriteLine(currentCount);
    }
}


static class Writer
{
    public static void WriteLine<T>(this T item) => Console.WriteLine(item);

    public static void WriteLog<T>(this T item) => Debug.WriteLine(item);
}


Measured memory_bytes: 31688
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

const int mod = 1e9 + 7;

int main() {
  // 考察1. 最終状態を考える
  // 最終状態は 1, 0 か 0, 1のいずれか
  // 考察2. 最終状態になるように石をとる
  // 常に相手の番で|X - Y| <= 1となるようにできれば勝ち
  // 相手はどうあがいても|X - Y| <= 1 の状態からは |X - Y| > 1の状態へにしか変化させられない
  // 自分は|X - Y| > 1 であれば |X - Y| <= 1 にするような手を打つことができる

  ll X, Y;
  cin >> X >> Y;
  cout << (abs(X - Y) > 1 ? "Alice" : "Brown") << endl; 
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        std::cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
    }
} fast;

/* define */
#define FOR(I, X, Y) for (long long(I) = (X); (I) < (Y); (I)++)
#define REP(I, X, Y) for (long long(I) = (Y)-1; (I) >= (X); (I)--)
#define ALL(X) (X).begin(), (X).end()
#define pb push_back
#define COUNT(V, X)                           \
    (upper_bound((V).begin(), (V).end(), X) - \
     lower_bound((V).begin(), (V).end(), X))
#define debug(x) cerr << #x << ':' << x << endl;
#define DEBUG(v)                             \
    {                                        \
        cerr << #v << ':';                   \
        for (auto xv : v) cerr << xv << ' '; \
        cerr << endl;                        \
    }
#define Yes(X) cout << (X ? "Yes" : "No") << endl;
#define YES(X) cout << (X ? "YES" : "NO") << endl;
#define ctoi(C) (C - '0')
#define pow2(x) ((long long)((long long)1 << x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int, int>;
using pl = pair<long long, long long>;
template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1, 0, -1, 0};
const long long dy[] = {0, 1, 0, -1};
const long long dx8[] = {1, 1, 0, -1, -1, -1, 0, 1};
const long long dy8[] = {0, 1, 1, 1, 0, -1, -1, -1};
const long long dx9[] = {1, 1, 0, -1, -1, -1, 0, 1, 0};
const long long dy9[] = {0, 1, 1, 1, 0, -1, -1, -1, 0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T1, typename T2>
inline bool chmin(T1 &a, const T2 &b) {
    if (a > b) a = b;
    return a > b;
}
template <typename T1, typename T2>
inline bool chmax(T1 &a, const T2 &b) {
    if (a < b) a = b;
    return a < b;
}
long long max(long long x, int y) {
    return max(x, (long long)y);
}
long long max(int x, long long y) {
    return max((long long)x, y);
}
long long min(long long x, int y) {
    return min(x, (long long)y);
}
long long min(int x, long long y) {
    return min((long long)x, y);
}

/* liblary */

/* main */

void solve(ll l, ll k) {
    // DP[i][j] := 高さi、一番上が(j ? 黒 : 白)のときの場合の数
    ll DP[l + 1][2];
    FOR(i, 0, l + 1) {
        FOR(j, 0, 2) {
            DP[i][j] = 0;
        }
    }
    DP[1][1] = 1;
    DP[1][0] = 0;
    FOR(i, 2, l + 1) {
        if (i - k) {
            DP[i][1] = DP[i - 1][0] + (i - k >= 0 ? DP[i - k][0] : 0);
        } else {
            DP[i][1] = DP[i - 1][0] + 1;
        }
        DP[i][0] = DP[i - 1][1];
    }
    ll ans = 0;
    FOR(i, 0, l + 1) {
        ans += DP[i][1];
    }
    cout << ans << endl;
}

signed main() {
    ll l, k;
    cin >> l >> k;
    solve(l, k);
}


Measured memory_bytes: 3216
n = int(input())
a = [int(x) for x in input().split()]
count = 1

if a.count(1) == 0:
    print(-1)
else:
    ans = 0
    for i in range(len(a)):
        if a[i] != count:
            ans += 1
        else:
            count += 1
    print(ans)


Measured memory_bytes: 24744
#include<iostream>
#include<cmath>
#include <iomanip>
using namespace std;

int main(void){
  double x1,y1,x2,y2,res;
  cin>>x1>>y1>>x2>>y2;
  x1=x1-x2;
  y1=y1-y2;
  res=sqrt(x1*x1+y1*y1);
  cout<<setprecision(10)<<res<<endl;
  return 0;
}



Measured memory_bytes: 3272
A,B,C,D,E,F = map(int,input().split())

water_sugar = []
sugar_best = []

for a in range(0,31):
    water = A*a
    sugar = E*water
    if water==0:
        pass
    elif (water*100)>F:
        break
    elif (water*100)+sugar>F:
        water_sugar.append([water*100,F-(water*100)])
    elif (water*100)+sugar<=F:
        water_sugar.append([water*100,sugar])
    for b in range(1,31):
        water += B
        sugar = E*water
        if (water*100)>F:
            break
        elif (water*100)+sugar>F:
            water_sugar.append([water*100,F-(water*100)])
        elif (water*100)+sugar<=F:
            water_sugar.append([water*100,sugar])

#print(water_sugar)

for ws in water_sugar:
    sugar = []
    c=0
    while(True):
        s = c*C
        if s<=ws[1]:
            sugar.append(s)
        else:
            break
        while(True):
            s += D
            if s<=ws[1]:
                sugar.append(s)
            else:
                break
        c+=1
    ws[1] = max(sugar)
    sugar_best.append((100*ws[1])/(ws[0]+ws[1]))
    
best = water_sugar[sugar_best.index(max(sugar_best))]

print(best[0]+best[1],best[1])

Measured memory_bytes: 5332
import sys

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MATINT(h): return [list(map(int, input().split())) for _ in range(h)]
def MATSTR(h): return [input() for _ in range(h)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

def main():
    N = INT()
    A = LIST()
    sum = 0
    for aa in A:
        sum += 1/aa
    print(1/sum)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
N = int(input())
A = [int(input()) for i in range(N)]
tmp = max(A)
li = list(A)
li.sort(reverse=True)
if len(li)==1:
    tmp2 = li[0]
else:
    tmp2 = li[1]
for i in range(N):
    if A[i] != tmp:
        print(tmp)
    else:
        print(tmp2)


Measured memory_bytes: 14112
import java.util.*;
public class Main {
	public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      String str = sc.nextLine();
      int strLn =str.length();
      char strMin = str.charAt(0);
      char strMax = str.charAt(strLn-1);
      if(strMin==strMax && (strLn%2==0)){
        System.out.println("First");
      } else if(strMin != strMax && (strLn%2!=0)){
        System.out.println("First"); 
      }else{
         System.out.println("Second");
      }
	}
}

Measured memory_bytes: 26452
import fractions
n,x = map(int, input().split())
lis = [int(i) for i in input().split()]
lis2 = []
for nums in lis:
  lis2.append(abs(nums-x))
ans = 10000000000000
if n == 1:
  g = lis2[0]
else:
  i = 2
  g = fractions.gcd(lis2[0],lis2[1])
  while i < n:
    g = fractions.gcd(g,lis2[i])
    i += 1
print(g)

Measured memory_bytes: 16284
#include <bits/stdc++.h>
using namespace std;
#define itn int

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<vector<int>> as(m);
    for (int i = 0; i < m; i++) {
        int k;
        cin >> k;
        for (int j = 0; j < k; j++) {
            int a;
            cin >> a;
            a--;
            as[i].push_back(a);
        }
    }
    vector<int> ps(m);
    for (int i = 0; i < m; i++) cin >> ps[i];
    int cnt = 0;
    for (int i = 0; i < 1 << n; i++) {
        bool ok = true;
        for (int j = 0; j < m; j++) {
            int tmp = 0;
            for (int a : as[j]) {
                if (i >> a & 1) tmp++;
            }
            if (tmp % 2 != ps[j]) {
                ok = false;
                break;
            }
        }
        if (ok) cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
def gcd(m, n):
    x = max(m, n)
    y = min(m, n)
    if x % y == 0:
        return y
    else:
        while x % y != 0:
            z = x % y
            x = y
            y = z
        return z


def lcm(m, n):
    return (m * n) // gcd(m, n)


# input
A, B = map(int, input().split())

# lcm
snack = lcm(A, B) 

print(snack)


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

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

using namespace std;
using ll = long long;
int mod = 1000000007;

void solve();

int main(void){
    int N, K; cin >> N >> K;
    //二部グラフ ノード数をA, N-Aに分ける
    //これ、最小はN-2じゃないですか…?
    //連結なので最低N-1本の辺が必要
    //各頂点について、木の根となる部分を除くと距離2の頂点は根の子が2以上あれば存在
    //よって、K < N-2 は無理
    //では、N-2から一本辺を増やしてみよう
    //いくつ距離2の頂点の組が増えるか

    //到底しんどい
    //というか最短距離って単語を見逃してた
    //1を作るにはどうする?
    //完全グラフが0なことを利用
    //完全グラフのあるノードから一本辺を除去するとその辺の結んでいた頂点の組の最短距離が2になる
    if(K > ((N-1)*(N-2))/2){
        cout << -1 << endl;
        return 0;
    }
    //えー、今回は隣接行列を作成します
    int adj[N][N];
    rep(i, N){
        rep(j, N){
            if(i == j) adj[i][j] = 0;
            else adj[i][j] = 1;
        }
    }
    int cnt = 0;
    bool cont = true;
    for(int i = 1; i < N; i++){
        for(int j = i+1; j < N; j++){
            //iとjの辺を切っていきます
            if(cnt == K){
                cont = false;
                break;
            }
            adj[i][j] = 0; adj[j][i] = 0;
            cnt++;
        }
        if(!cont) break;
    }
    //完全グラフの辺の数はN(N-1)/2. cnt本切断しました
    cout << N*(N-1)/2 - cnt << endl;
    for(int i = 0; i < N; i++){
        for(int j = i; j < N; j++){
            if(adj[i][j] == 1) cout << i+1 << " " << j+1 << endl;
        }
    }

    return 0;
}

void solve(){}

Measured memory_bytes: 256
#include<iostream>
#include <bits/stdc++.h>
#include<cmath>
using namespace std;
int main()
{
    cout<<fixed<<setprecision(12);

    double a, b ,c ;
    cin >> a >> b >>c ;
    
    double pi = acos(-1.0) ;
    double rad = c*pi/180.0 ;

    cout << 0.5*sin(rad)*a*b << endl;
    cout << sqrt(a*a+b*b-2.0*b*a*cos(rad))+a+b << endl;
    cout << sin(rad)*b << endl;
    
    return 0;
}





Measured memory_bytes: 3536
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
#define endl "\n"
using namespace std;

constexpr int inf = 2147483647;
constexpr int64_t inf64 = 9223372036854775807;
constexpr int mod = 1e9+7;

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

  int n, x;
  cin >> n >> x;
  vector<int> candy(n);
  rep(i,n) cin >> candy[i];
  sort(candy.begin(), candy.end());

  rep(i,n) {
    if(x < 0) continue;
    int a = min(candy[i], x);
    candy[i] -= a;
    x -= a;
  }

  int res = 0;
  rep(i,n) if(candy[i] == 0) res++;
  if(x > 0) res--;

  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
long long int MOD=1000000007;
#define SIZE 200005

int main(){
	ll a,b;
	cin>>a>>b;
	if(a>0)cout<<"Positive"<<endl;
	else if(b<0){
		if((b-a)%2==0){
			cout<<"Negative"<<endl;
		}else{
			cout<<"Positive"<<endl;
		}
	}else{
		cout<<"Zero"<<endl;
	}
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define Sort(x) sort((x).begin(), (x).end())
#define Reverse(x) reverse((x).begin(), (x).end())
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define INF INT_MAX
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15) //15桁まで表示
#define str string
typedef std::pair<int,int> pii;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<ui,ui> puu;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<str> vs;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a * b / gcd(a, b);};
int floor(int a,int b){return (a+b-1)/b;};
int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
template<class T>inline bool chmax(T& a,T b){if(a < b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a > b){a=b;return true;}return false;};

int main() {
    int k;
    vi a(5);
    bool ans=true;
    rep(i,5) cin >> a[i];
    cin >> k;
    if (a[4]-a[0]>k){
        ans=false;
    }
    if(ans){
        cout << "Yay!" << endl;
    }
    else{
        cout << ":(" << endl;
    }
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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;
}
int64_t abs(int64_t n) {
  if (n < 0) {
    n = -n;
  }
  return n;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}

int main() {
  int64_t n, k, q;
  cin >> n >> k >> q;
  vector <int64_t> v(n, 0);
  rep(i, q) {
    int64_t a;
    cin >> a;
    v.at(a-1)++;
  }
  rep(i, n) {
    if (k - (q-v.at(i)) > 0) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 1408
n = int(input())
a = list(map(int, input().split()))

INF = float('inf')
dp = [[INF] * (n+1) for _ in range(n+1)]

# 累積和は0を含んだ半開区間（1-indexed)でかく
acum = [0] * (n+1)
for i, ai in enumerate(a):
    acum[i+1] += acum[i] + ai

# 初期化
for i in range(n+1):
    dp[i][i] = 0
    if i+1 <= n:
        dp[i][i+1] = 0

# 区間dp
for l in range(2, n+1):
    for i in range(n-l+1):
        j = i + l
        for k in range(i+1, j):
            dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j] + acum[j] - acum[i])

print(dp[0][n])



Measured memory_bytes: 46684
//https://atcoder.jp/contests/abc152/tasks/abc152_a
#include <bits/stdc++.h>
using namespace std;

#define el '\n'
#define pb push_back
#define sp ' '
#define all(x) (x).begin(), (x).end()
#define mset(x, y) memset(x, y, sizeof(x))
#define ff first
#define ss second

// clang-format off
#ifndef ONLINE_JUDGE
template <typename T, size_t N> int SIZE(const T (&t)[N]){ return N; } template<typename T> int SIZE(const T &t){ return t.size(); } string to_string(const string s, int x1=0, int x2=1e9){ return '"' + ((x1 < (int)s.size()) ? s.substr(x1, x2-x1+1) : "") + '"'; } string to_string(const char* s) { return to_string((string) s); } string to_string(const bool b) { return (b ? "true" : "false"); } string to_string(const char c){ return string({c}); } template<size_t N> string to_string(const bitset<N> &b, int x1=0, int x2=1e9){ string t = ""; for(int __iii__ = min(x1,SIZE(b)),  __jjj__ = min(x2, SIZE(b)-1); __iii__ <= __jjj__; ++__iii__){ t += b[__iii__] + '0'; } return '"' + t + '"'; } template <typename A, typename... C> string to_string(const A (&v), int x1=0, int x2=1e9, C... coords); int l_v_l_v_l = 0, t_a_b_s = 0; template <typename A, typename B> string to_string(const pair<A, B> &p) { l_v_l_v_l++; string res = "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; l_v_l_v_l--; return res; } template <typename A, typename... C> string to_string(const A (&v), int x1, int x2, C... coords) { int rnk = rank<A>::value; string tab(t_a_b_s, ' '); string res = ""; bool first = true; if(l_v_l_v_l == 0) res += el; res += tab + "["; x1 = min(x1, SIZE(v)), x2 = min(x2, SIZE(v)); auto l = begin(v); advance(l, x1); auto r = l; advance(r, (x2-x1) + (x2 < SIZE(v))); for (auto e = l; e != r; e = next(e)) { if (!first) { res += ", "; } first = false; l_v_l_v_l++; if(e != l){ if(rnk > 1) { res += el; t_a_b_s = l_v_l_v_l; }; } else{ t_a_b_s = 0; } res += to_string(*e, coords...); l_v_l_v_l--; } res += "]"; if(l_v_l_v_l == 0) res += el; return res; } void dbgm(){;} template<typename Heads, typename... Tails> void dbgm(Heads H, Tails... T){ cout << to_string(H) << " | "; dbgm(T...); } 
#define dbg(...) cout << "[" << #__VA_ARGS__ << "]: "; cout << to_string(__VA_ARGS__) << endl
#define dbgm(...) cout << "[" << #__VA_ARGS__ << "]: "; dbgm(__VA_ARGS__); cout << endl
#else
#define dbg(...) ;
#define dbgm(...) ;
#endif
// clang-format on

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppi;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vll> vvll;

const int inf = 1e09 + 5e3;
const ll linf = 2e18 + 5e3;
const int mod = 1e9 + 7;
const int mxn = 1e5;

int main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

    int a,b;
    cin >> a >> b;
    string as = string(a,'0' + b);
    string bs = string(b,'0' + a);
    cout << min(as,bs);
}


Measured memory_bytes: 3524
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
)

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

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

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	if x == 2 {
		return true
	}
	if x%2 == 0 {
		return false
	}

	b := true
	rootx := int(math.Sqrt(float64(x)))
	i := 3
	for i <= rootx {
		if x%i == 0 {
			b = false
			break
		}
		i += 2
	}
	return b
}

func PrimeFactors(n int) (pfs []int) {
	// Get the number of 2s that divide n
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

var N int

func main() {
	sc.Split(bufio.ScanWords)

	N = nextInt()

	A := make([]int, N+1)
	B := make([]int, N+1)
	for i := 1; i <= N; i++ {
		A[i] = nextInt()
		B[i] = A[i]
	}

	sort.Ints(B)
	for i := 1; i <= N; i++ {
		if B[N] != A[i] {
			fmt.Println(B[N])
		} else {
			fmt.Println(B[N-1])
		}
	}
}


Measured memory_bytes: 7680
#include <bits/stdc++.h>
using namespace std;
long long d[2005][2005];
int n,m;
int a[2005],b[2005];

int main()
{
    scanf("%d %d", &n, &m);
    for(int i = 1;i <= n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(int i = 1;i <= m;i++)
    {
        scanf("%d",&b[i]);
    }
    for(int i = 0;i <= n;i++)
    {
        d[i][0] = 1;
    }
    for(int i = 0;i <= m;i++)
    {
        d[0][i] = 1;
    }
    for(int i = 1;i <= n;i++)
    {
        for(int j = 1;j <= m;j++)
        {
            d[i][j] = d[i-1][j]+d[i][j-1];
            if(a[i] != b[j]) d[i][j] -= d[i-1][j-1];
            d[i][j] = (d[i][j]+1000000007)%1000000007;
        }
    }
    printf("%lld",d[n][m]);
}


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

#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RALL(x) (x).rbegin(),(x).rend()
#define F first
#define S second

void solve(int n, int m) {
    vector<pair<int,int>> data(n); // (p,d)
    for(auto& i : data) cin >> i.S >> i.F;
    sort(RALL(data));

    int ans = 0;
    for(auto& i : data) {
        if(m - i.S >= 0) {
            m -= i.S;
        } else {
            ans += i.F * (i.S - m);
            m = 0;
        }
    }
    cout << ans << "\n";
}

int main() {
    int n,m;
    while(cin>>n>>m, n) solve(n,m);
    return 0;
}

Measured memory_bytes: 3172
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9;
const int mod = 1e9+7;
#define ll long long
signed main() {
  string s;
  cin >> s;
  int ans = 700;
  rep(i,s.length()) {
    if(s[i]=='o') {
      ans += 100;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define REP(i,n)   for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(long long i=(a);((a)<(b)?i<=(b):i>=(b));((a)<(b)?++i:--i))
#define ALL(v)     (v).begin(),(v).end()
#define debug(x)   cerr<<#x<<": "<<(x)<<endl
using namespace std;
using llong = long long;
using vi    = vector<int>;
using vvi   = vector<vi >;
using vvvi  = vector<vvi >;
using pii   = pair<int,int>;
constexpr int    INF=1e9;
constexpr double EPS=1e-9;
constexpr int    MOD=1e9+7;
template<class Type>
void line(const Type &a){int cnt=0;for(const auto &elem:a){cerr<<(cnt++?' ':'>');cerr<<elem;}cerr<<endl;}

int main(){
	int n;
	cin>>n;
	
	vi x(n),y(n),h(n);
	REP(i,n) cin>>x[i]>>y[i]>>h[i];
	
	FOR(cy,0,100)FOR(cx,0,100){
		set<int> s;//可能性のある高さの集合.
		int upper=2e9;//最大の高さ.
		REP(i,n){
			int tmp=h[i]+abs(cy-y[i])+abs(cx-x[i]);
			if(h[i]==0) upper=min(upper,tmp);
			else s.insert(tmp);
		}
		//line(s);
		//debug(under);
		
		if(s.size()==1 and *s.begin()<=upper){
			cout<<cx<<' '<<cy<<' '<<*s.begin()<<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3636
use std::io::*;
use std::str::FromStr;
use utils::*;

pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(i.lock(), &mut o);
    stdout().write_all(&o).unwrap();
}

fn run<R: BufRead, W: Write>(i: R, o: &mut W) {
    let mut i = CpReader::new(i);
    let (n, m) = i.read2::<usize, usize>();
    let s: Vec<_> = i
        .read_line()
        .as_bytes()
        .iter()
        .map(|&x| if x == b'A' { 0 } else { 1 })
        .collect();

    let mut abs = Vec::new();
    for _ in 0..m {
        let (a, b) = i.read2::<usize, usize>();
        abs.push((a - 1, b - 1));
    }
    let r = if solve(n, &s, &abs) { "Yes" } else { "No" };
    writeln!(o, "{}", r).unwrap();
}
fn solve(n: usize, s: &[usize], abs: &[(usize, usize)]) -> bool {
    let mut c = vec![[0; 2]; n];
    let mut edges = vec![Vec::new(); n];
    for &(a, b) in abs {
        c[a][s[b]] += 1;
        c[b][s[a]] += 1;
        edges[a].push(b);
        edges[b].push(a);
    }
    let mut is_enabled = vec![true; n];
    let mut count_enabled = n;
    let mut q: Vec<usize> = (0..n).collect();

    while let Some(i) = q.pop() {
        if is_enabled[i] && (c[i][0] == 0 || c[i][1] == 0) {
            is_enabled[i] = false;
            count_enabled -= 1;
            let si = s[i];
            for &j in &edges[i] {
                if is_enabled[j] {
                    c[j][si] -= 1;
                    if c[j][si] == 0 {
                        q.push(j);
                    }
                }
            }
        }
    }
    count_enabled != 0
}

mod utils {
    use super::*;

    pub struct CpReader<R: BufRead> {
        r: R,
        s: String,
    }

    macro_rules! fn_read {
        { $f:ident($($t:ident),*) } => {
            #[allow(dead_code)]
            pub fn $f<$($t: FromStr),*>(&mut self) -> ($($t),*) {
                let i = &mut self.read_line().split(' ');
                ($(read_next::<$t,_>(i)),*)
            }
        };
    }

    impl<R: BufRead> CpReader<R> {
        pub fn new(r: R) -> Self {
            CpReader {
                r: r,
                s: String::new(),
            }
        }
        pub fn read_line(&mut self) -> &str {
            self.s.clear();
            self.r.read_line(&mut self.s).unwrap();
            self.s.trim()
        }

        fn_read! { read2(T1, T2) }
        fn_read! { read3(T1, T2, T3) }
        fn_read! { read4(T1, T2, T3, T4) }
        fn_read! { read5(T1, T2, T3, T4, T5) }
    }
    fn read_next<'a, T: FromStr, I: Iterator<Item = &'a str>>(i: &mut I) -> T {
        i.next().unwrap().parse().ok().unwrap()
    }

}


Measured memory_bytes: 24820
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int minpasta;
		int minjuice;
		int menu;
		minpasta = in.nextInt();
		for(int i = 0; i < 2; i++){
			menu = in.nextInt();
			if(menu < minpasta){
				minpasta = menu;
			}
		}
		minjuice = in.nextInt();
		menu = in.nextInt();
		if(menu < minjuice)	minjuice = menu;
		System.out.println((minpasta + minjuice - 50));
	}
}

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

#define M_PI       3.14159265358979323846   // pi

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

#define rep(a,n) for(int a = 0;a < n;a++)
#define repi(a,b,n) for(int a = b;a < n;a++)


const ll mod = 1000000007;

int main(void)
{
	string s;
	cin >> s;
	int n = s.size();
	vector<char> cs;
	cs.reserve(n);

	rep(i, n - 1) {
		if (s[i] == 'B' && s[i + 1] == 'C') {
			cs.push_back('D');
			i++;
		}
		else {
			cs.push_back(s[i]);
		}
	}
	auto csSize = cs.size();
	ll total = 0;
	int aCount = 0;
	rep(i, csSize) {
		if (cs[i] == 'A') {
			aCount++;
		}
		else if (cs[i] == 'D') {
			if (aCount > 0) {
				total += aCount;
			}
		}
		else {
			aCount = 0;
		}
	}
	std::cout << total << endl;
	return 0;
}


Measured memory_bytes: 772
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using VI=vector<ll>;
using VD=vector<ld>;
using VVI=vector<VI>;
using VC=vector<char>;
using VVC=vector<VC>;
using VS=vector<string>;
using PLL =pair<ll,ll>;
using PLD=pair<ld,ld>;
using VPLL=vector<PLL>;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element((x).begin(),(x).end())
#define MIN(x) *min_element((x).begin(),(x).end())
#define SORTR(x) sort((x).rbegin(),(x).rend())
#define SORT(x) sort((x).begin(),(x).end())
#define SUM(x) accumulate((x).begin(),(x).end(), 0)
#define FILL(x,a) fill(x.begin(),x.end(),a)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)

const long long  int INF = 1e18;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
#define COUT(x) cout<<x<<"\n"

void Main()
{
	ll N,T;
	ll result=0;
	cin>>N>>T;
	VI vec(N);
	REP(i, N) cin >> vec[i];
	REP(i,N-1){
		ll diff=vec[i+1]-vec[i];
		if(diff<T){
			result+=diff;
		}
		else result+=T;
	}
	result+=T;//最後のぶん
	cout << result << "\n";
	return;
}

int main()
{
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


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

int main() {
    int n;
    scanf("%d",&n);
    int f = n/100;
    int l = n%100;
    if(f>=1 && f<=12 && l>=1 && l<=12) {
        printf("AMBIGUOUS\n");
    }
    else if(f>12 &&l==0) {
        printf("NA\n");
    }
    else if(f>=1 && f<=12 && l==0) {
        printf("MMYY\n");
    }
    else if(f==0 && l>12) {
        printf("NA\n");
    }
    else if(f==0 && l>=1 && l<=12) {
        printf("YYMM\n");
    }
    else if(f>12 && l>=1 && l<=12) {
        printf("YYMM\n");
    }

    else if(f>=1 && f<=12 && l>12) {
        printf("MMYY\n");
    }
    else {
        printf("NA\n");
    }
    return 0;
}


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

int main(){
    int N;
    int M;
    cin >> N >> M;
    vector<int> A(N, 0);
    double sum = 0;
    for(int i = 0;i < N;i++){
        cin >> A.at(i);
        sum += A.at(i);
    }
    int ans = 0;
    double check = sum / 4.0 / M;
    for(int i = 0;i < N;i++){
        if(A.at(i) >= check) ans++;
    }
    if(ans >= M) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
import math
Q = int(input())#numの数の個数
Query = []
maxn=0
for _ in range(Q):
    l,r = map(int,input().split())
    Query.append((l,r))
    maxn = max(maxn,r)
N = maxn
num = [0]*(N+2)#部分和を計算したい数列
def souwa(left,right,ruisekiwa):#0based,numの[left,right)間の総和を計算
   return ruisekiwa[right]-ruisekiwa[left]
def using_sqrt(N):#入力 対象の整数,出力,素数ならば1,合成数ならば1
    flag = 0
    for i in range(2,math.floor(math.sqrt(N))+1):
        if N % i == 0:
            flag = 1
            break
        else:
            continue
    if flag == 1:
        return 0
    else:
        return 1

for i in range(1,N+2,2):
    if using_sqrt(i)==1 and using_sqrt((i+1)//2)==1:
        num[i] = 1
ruisekiwa = [0]*(N+2)
ruisekiwa[0] = 0
num[1] =0
for i in range(1,N+2):#累積和の前処理
    ruisekiwa[i]=num[i-1]+ruisekiwa[i-1]

for q in Query:
    print(souwa(q[0],q[1]+1,ruisekiwa))

    



Measured memory_bytes: 21112
'use strict'
import heapq

N, M = map(int, input().split())
goods_price_list = [-int(_) for _ in input().split()]

heapq.heapify(goods_price_list)

for i in range(M):
  heapq.heappush(goods_price_list, -((-heapq.heappop(goods_price_list) // 2)))

print(-sum(goods_price_list))

Measured memory_bytes: 14180
#include <iostream>
#include <iomanip>
#include <algorithm>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int main()
{
    int n;
    cin >> n;
    int a[n];
    repi(i, n, 0)
    {
        cin >> a[i];
    }
    sort(a, a + n);
    ll cnt = 0, sum = 0, ans = 0;
    repi(i, n, 1)
    {
        sum += a[i - 1];
        cnt++;
        if (a[i] > sum * 2)
        {
            ans += cnt;
            cnt = 0;
        }
    }
    cout << n - ans << endl;
    return 0;
}

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

int A[200][200];
int w,h;

bool input()
{
    cin>>h>>w;
    if(!h&&!w)return false;
    char tmp;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>tmp;
            if(tmp=='#')A[i][j]=0;
            if(tmp=='*')A[i][j]=1;
            if(tmp=='@')A[i][j]=2;
        }
    }
    return true;
}

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

void dfs(int x, int y, int valid)
{
    if(A[x][y]==valid)A[x][y] = -1;
    else return;
    int nx, ny;
    for(int i=0;i<4;i++){
        nx = x+dx[i];
        ny = y+dy[i];
        if(0<=nx&&nx<h && 0<=ny&&ny<w){
            dfs(nx, ny, valid);
        }
    }
}

int solve()
{
    int res=0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(A[i][j]!=-1){
                dfs(i, j, A[i][j]);
                res++;
            }
        }
    }
    return res;
}

int main()
{
    while(input()){
        cout<<solve()<<endl;
    }
    return 0;
}



Measured memory_bytes: 3548
h,w = [int(x) for x in input().split()]
l = []
for _ in range(h):
    l.append(list(input()))
possible = True
tmplst = []

for i in range(h):
    for y in range(1,w-1):
        if l[i][y-1] == l[i][y+1] == '.' and l[i][y] == '#':
            tmplst.append([i,y])

for x in tmplst:
    if x[0] == 0:
        if l[0][x[1]] == '.':
            possible = False
    elif x[0] == h-1:
        if l[h-1][x[1]] == '.':
            possible = False
    else:
        if l[x[0]-1][x[1]] == l[x[0]+1][x[1]] == '.':
            possible = False

if possible:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int N, M;
	cin >> N >> M;
	int S[2000], T[2000];
	rep(i, N) cin >> S[i];
	rep(i, M) cin >> T[i];

	ll mod = 1e9 + 7;
	int dp[4001];
	int dpsa[4001] = {};

	rep(i, N + M + 1) dp[i] = 1;
	for (int i = N; i > 0; i--) {
		for (int j = i; j < i + M; j++) {
			if (S[N - i] == T[j - i]) {
				dp[j] = dp[j - 1] + dp[j + 1];
				dpsa[j] = dp[j + 1];
			}
			else {
				dp[j] = dp[j - 1] + dpsa[j + 1];
				dpsa[j] = dpsa[j + 1];
			}
			if (dp[j] >= mod) dp[j] -= mod;
		}
	}
	co(dp[M]);

	Would you please return 0;
}

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

int main() {
    int a,b;
    cin >> a >> b;

    int ret = 0;
    if (a > b) {
        ret += a;
        a--;
    } else {
        ret += b;
        b--;
    }

    if (a > b) {
        ret += a;
        a--;
    } else {
        ret += b;
        b--;
    }

    cout << ret << endl;
}


Measured memory_bytes: 256
// AOJ 2438: YAML
// 2017.12.30 bal4u@uu

#include <stdio.h>
#include <string.h>

char *property[21];
char *line[1000];
char buf[100010];

int main()
{
	int n, m, i, t, ln, indent, cnt;
	char *p, *q, c;

	fgets(buf, 50010, stdin);
	n = 0, p = buf+1; while (*p >= ' ') {
		property[n++] = p;
		while (*p >= ' ' && *p != '.') p++;
		if (*p == '.') *p++ = 0;
	}
	*p = 0;

	p++, m = 0;
	while (fgets(p, 50010, stdin) != NULL) {
		line[m++] = p; while (*p >= ' ') p++;
		*p++ = 0;
	}

	ln = indent = 0;
	for (i = 0; i < n; i++) {
		while (ln < m) {
			cnt = 0, p = line[ln];
			while (*p == ' ') p++, cnt++;
			if (cnt < indent) goto done;
			if (cnt > indent) { ln++; continue; }

			q = p; while (*p && *p != ':') p++;
			c = *p, *p = 0;
			t = strcmp(q, property[i]);
			*p = c;

			if (t) { ln++; continue; }
			if (i == n-1) {
				if (*(p+1) == 0) puts("object");
				else printf("string \"%s\"\n", p+2);
				return 0;
			}
			if (ln >= m-1) goto done;
			indent = 0, p = line[++ln];
			while (*p == ' ') p++, indent++;
			break;
		}
	}
done:
	puts("no such property");
	return 0;
}

Measured memory_bytes: 1880
#include<iostream>
#include <algorithm>
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
using namespace std;
long long N;
int main(){
	cin>>N;
	long long t=1,ans=0,l=1,an=0;
	while(1){
		if(N/t<t)break;
		if(N%t==0)ans=N/t;
		++t;
	}
	while(1){
		if(ans>=l)++an;
		else break;
		l*=10;
	}
	cout<<an<<endl;;
	return 0;
}


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

int main() {

  string S;
  cin >> S;

  if (S=="ABC"){ cout << "ARC" << endl;}
  else { cout << "ABC" << endl;}

}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <cmath>
#include <iomanip>
using namespace std;
int main(void){
    int n;
    cin>>n;
    vector<vector<double>> t(n, vector<double>(2));
    vector<int> array(n);
    for(int i=0; i<n; i++){
        for(int j=0; j<2; j++){
            cin>>t.at(i).at(j);
        }
        array.at(i)=i;
    }
    
    double preans=0;
    do{
        for(int i=0; i<n-1; i++){
            preans+=sqrt(pow(t.at(array.at(i)).at(0)-t.at(array.at(i+1)).at(0), 2.0)+pow(t.at(array.at(i)).at(1)-t.at(array.at(i+1)).at(1), 2.0));
        }
    }while(next_permutation(array.begin(), array.end()));
    
    int kaijo=1;
    for(int i=1; i<n+1; i++){
        kaijo*=i;
    }
    double ans = preans/kaijo;
    cout << fixed << setprecision(10) << ans << endl;
}


Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        int sum = 0;
        int x = n;
        while (x > 0)
        {
            sum += x % 10;
            x /= 10;
        }
        Console.WriteLine(n % sum == 0 ? "Yes" : "No");
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<cmath>
#include<string>
#include<map>
#include<queue>
using namespace std;
#define N 3
#define N2 9

struct Puzzle{
    int f[N2];
    int space;
    string path;
    
    bool operator < ( const Puzzle &p) const{
        for(int i=0;i<N2;i++){
            if(f[i]==p.f[i]) continue;
            return f[i] > p.f[i];
        }
        return false;
    }
};

static const int dx[4] = {-1,0,1,0};
static const int dy[4] = {0,-1,0,1};
static const char dir[4] = {'u','l','d','r'};

bool isTarget(Puzzle p){
     for(int i=0;i<N2;i++)
         if(p.f[i]!=(i+1)) return false;
         return true;
}

string bfs(Puzzle s){
    queue<Puzzle> Q;
    map<Puzzle,bool> V;
    Puzzle u,v;
    s.path = "";
    Q.push(s);
    V[s]=true;
    
    while(!Q.empty()){
        u = Q.front();
        Q.pop();
        if(isTarget(u)) return u.path;
        int sx=u.space/N;
        int sy=u.space%N;
        for(int r=0;r<4;r++){
            int tx = sx +dx[r];
            int ty = sy +dy[r];
            if(tx<0 || ty <0 || tx >=N || ty >=N) continue;
            v =u;
            swap(v.f[u.space], v.f[tx*N+ty]);
            v.space = tx*N+ty;
            if(!V[v]){
                V[v] = true;
                v.path += dir[r];
                Q.push(v);
            }
        }
    }
    
    return "unsolvable";
}

int main(){
    Puzzle in;
    
    for(int i=0;i<N2;i++){
        cin >> in.f[i];
        if(in.f[i] == 0){
            in.f[i] = N2;
            in.space = i;
        }
    }
    string ans = bfs(in);
    cout << ans.size() << endl;
    
    return 0;
}


Measured memory_bytes: 30612