akhauriyash/Code-Regression huggingface dataset:
PROGRAM-ID.                      ABC_105_D.
ENVIRONMENT                      DIVISION.
INPUT-OUTPUT                     SECTION.
FILE-CONTROL.
    SELECT SYSIN ASSIGN TO KEYBOARD ORGANIZATION LINE SEQUENTIAL.

DATA                             DIVISION.
FILE                             SECTION.
    FD  SYSIN.
        01 INDATA PIC X(1100000).

WORKING-STORAGE                  SECTION.
    01 NM      PIC X(17).
    01 N       PIC 9(6).
    01 M       PIC 9(10).
    01 INP     PIC X(1100000).

    01 X_MAX   PIC 9(10) VALUE 9999999999.

    01 X1.
        03 X PIC 9(10) OCCURS 100000 DEPENDING maxlen.

    01 Y1.
        03 YNUM PIC 9(6) VALUE ZERO.
        03 Y11 OCCURS 100000.
            05 Y PIC 9(10).
            05 YCNT PIC 9(6) VALUE ZERO.

    01 flg     PIC 9(1).

    01 xd      PIC 9(15).
    01 xr      PIC 9(10).

    01 tmp     PIC 9(10).
    01 r       PIC 9(10).

    01 sm      PIC 9(18).

    01 maxlen  PIC 9(7).
    01 cur     PIC 9(7) VALUE 1.
    01 i       PIC 9(7) VALUE 1.
    01 j       PIC 9(7).
    01 len     PIC 9(7).

    01 bk      PIC 9(10).

    01 ans     PIC X(18).

    01 ZS      PIC Z(18)9.
    01 DUMMY   PIC X(1).

PROCEDURE                        DIVISION.
    ACCEPT NM.

    UNSTRING NM
    DELIMITED BY SPACE
    INTO N M.

    OPEN INPUT SYSIN.

    READ SYSIN INTO INP.

    CLOSE SYSIN.

    MOVE N TO maxlen.

    MOVE ZERO TO sm.

    PERFORM maxlen TIMES

        PERFORM VARYING j FROM cur BY 1
            UNTIL INP(j:1) = SPACE
        END-PERFORM

        COMPUTE len = j - cur

        MOVE INP(cur:len) TO tmp

        ADD tmp TO sm

        DIVIDE M INTO sm GIVING xd REMAINDER xr

        MOVE xr TO X(i)

        COMPUTE cur = j + 1

        ADD 1 TO i

    END-PERFORM.

    SORT X ASCENDING X.

    MOVE X_MAX TO bk.

    PERFORM VARYING i FROM 1 BY 1 UNTIL maxlen < i

        IF bk = X(i) THEN
            ADD 1 TO YCNT(YNUM)
        ELSE
            MOVE X(i) TO bk
            ADD 1 TO YNUM
            MOVE X(i) TO Y(YNUM)
            ADD 1 TO YCNT(YNUM)
        END-IF

    END-PERFORM.

    MOVE ZERO TO sm.

    PERFORM VARYING i FROM 1 BY 1 UNTIL YNUM < i
*> pair
        COMPUTE sm = sm + YCNT(i) * (YCNT(i) - 1) / 2
*> alone
        IF ZERO = Y(i)
            COMPUTE sm = sm + YCNT(i)
        END-IF
    END-PERFORM.

    MOVE sm TO ZS.

    PERFORM UNANS.

    DISPLAY ans(1:FUNCTION STORED-CHAR-LENGTH(ans)).
    STOP RUN.

UNANS                            SECTION.
    UNSTRING
        ZS DELIMITED BY ALL SPACE
        INTO DUMMY ans
    END-UNSTRING.


Measured memory_bytes: 6012
import itertools

N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

Pcount = 0
Qcount = 0
counter = 1
for tmp in itertools.permutations(sorted(P)):
    if list(tmp) == P: Pcount += counter
    if list(tmp) == Q: Qcount += counter
    if Pcount != 0 and Qcount != 0: break
    else: counter += 1

print(abs(Pcount - Qcount))

Measured memory_bytes: 3064
D, G = map(int, input().split())
P = []
C = []
score = 0
number = 1000

for i in range(D):
  p, c = map(int, input().split())
  P.append(p)
  C.append(c)

for i in range(2**D):
  ts = 0
  mp = 0
  memo = [i+1 for i in range(D)]
  
  for j in range(D):
    if ((i >> j) & 1):
      ts += P[j] * 100 * (j+1) + C[j]
      mp += P[j]
      memo[j] = 0
  m = max(memo)
  p = P[m-1]
  
  if ts >= G:
    number = min(number, mp)
  elif m >= 1 and ts + (p-1) * 100 * m >= G:
    for i in range(p):
      if ts + i * 100 * m >= G:
        number = min(number, mp+i)
  else:
    continue

print(number)

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

#define mod 1000000007

using namespace std;
typedef long long ll; 
 
int main(void){
	
	string N;
	
	cin >> N;
	
	if((N[0] == N[1] && N[1] == N[2]) || (N[1] == N[2] && N[2] == N[3]))
		cout << "Yes";
	else
		cout << "No";
	
	return 0;
}

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

int main(){
  int n,a[100010]={},k,cnt=0;
  cin>>n;
  for(int i=0;i<n;++i){
    cin>>k;
    if(k<=1e5)a[k]++;
    else cnt++;
  }

  for(int i=1;i<=1e5;++i){
    if(a[i]<i)cnt+=a[i];
    else cnt+=a[i]-i;
  }
  cout << cnt << endl;
  return 0;
}


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

int main(){
  int n,r=0;
  cin>>n;
  string s;
  cin>>s;
  for(int i=0;i<n;i++){
    if(s[i]=='R') r++;
    }
  int c=0;
  for(int i=0;i<r;i++){
    if(s[i]=='W') c++;
    }
cout<<c;
  
  return 0;
  }


Measured memory_bytes: 3736
#include<algorithm>
#include<iostream>
#include<functional>
#include<cmath>
#include<iomanip>
using namespace std;
int main(){
  long int n,count=0,x[11000];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>x[i];
  }
  for(int j=0;j<n;j++){
    for(int k=1;k<=30;k++){
      if(x[j]%2==0){
        x[j]/=2;
        count++;
      }
      else
        break;
    }
  }
  cout<<count<<endl;
}

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

#define int long long

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

int H, W, A, B;
int fact[200001], fact_inv[200001];
int mod = 1e9 + 7;

int extgcd(int a, int b, int& x, int &y) {
    int d = a;
    if (b != 0) {
        d = -extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    } else {
        x = 1;
        y = 0;
    }
    return d;
}

int mod_inverse(int a, int m) {
    int x, y;
    extgcd(a, m, x, y);
    return (m + x % m) % m;
}

int comb(int n, int r, int m) {
    return fact[n] * fact_inv[n - r] % mod * fact_inv[r] % mod;
}

signed main() {
    cin >> H >> W >> A >> B;
    fact[0] = fact_inv[0] = 1;
    for (int i = 1; i < 200001; i++) {
        fact[i] = fact[i - 1] * i % mod;
        fact_inv[i] = mod_inverse(fact[i], mod);
    }
    int ans = 0;
    for (int i = 1; i <= H - A; i++) {
        ans = (ans + comb(i + B - 2, B - 1, mod) * comb(H + W - B - i - 1, W - B - 1, mod) % mod) % mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3328
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}
struct Mint {
    static unsigned MOD;
    unsigned x;

    Mint() : x(0) {}
    Mint(const Mint &y) : x(y.x) {}
    Mint(unsigned y) { if (MOD <= y) y %= MOD; x = y; }
    Mint(int y) { if (y < 0 || (long long)MOD <= y) y %= MOD; if (y < 0) y += MOD; x = y; }
    Mint(unsigned long long y) { if (MOD <= y) y %= MOD; x = y; }
    Mint(long long y) { if (y < 0 || MOD <= y) y %= MOD; if (y < 0) y += MOD; x = y; }

    Mint& operator+=(const Mint &y) { if ((x += y.x) >= MOD) x -= MOD; return *this; }
    Mint& operator-=(const Mint &y) { if ((x += MOD - y.x) >= MOD) x -= MOD; return *this; }
    Mint& operator*=(const Mint &y) { x = (unsigned long long)x * y.x % MOD; return *this; }
    Mint& operator/=(const Mint &y) { x = (unsigned long long)x * y.inv().x % MOD; return *this; }
    Mint operator-() const { return x? MOD - x: 0; }

    int geti() const { return x; }

    Mint inv() const {
	unsigned a = MOD, b = x; int u = 0, v = 1;
	while (b) {
	    int t = a / b;
	    a -= t * b; swap(a, b);
	    u -= t * v; swap(u, v);
	}
	if (u < 0) u += MOD;
	return Mint(u);
    }

    Mint pow(long long y) const {
	Mint b = *this, r = 1;
	if (y < 0) { b = b.inv(); y = -y; }
	for (; y; y>>=1) {
	    if (y&1) r *= b;
	    b *= b;
	}
	return r;
    }

    friend Mint operator+(Mint x, const Mint &y) { return x += y; }
    friend Mint operator-(Mint x, const Mint &y) { return x -= y; }
    friend Mint operator*(Mint x, const Mint &y) { return x *= y; }
    friend Mint operator/(Mint x, const Mint &y) { return x /= y; }
    friend bool operator<(const Mint x, const Mint y) { return x.x < y.x; }
    friend bool operator==(const Mint x, const Mint y) { return x.x == y.x; }
    friend bool operator!=(const Mint x, const Mint y) { return x.x != y.x; }
};
unsigned Mint::MOD;

int N;

Mint dp[5011][5011];

void MAIN() {
    scanf("%d", &N);
    scanf("%u", &Mint::MOD);

    dp[0][0] = 1;
    REP (i, N-1) {
	int c = min(i+1, N-i);
	REP (j, N+1) {
	    if (j + c <= N) dp[i][j+c] += dp[i][j];
	    dp[i+1][j] += dp[i][j];
	}
    }

    Mint ans = 0;
    REP (c, N) ans += dp[N-1][c] * (N - c);
    printf("%d\n", ans.geti());
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 98432
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
vector<string> split(string s, char p){vector<string>v;stringstream m(s);string b;while(getline(m,b,p))v.push_back(b);return v;}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
struct nya{ nya(){ cin.tie(0); ios::sync_with_stdio(false); } }nyan;


int main(){
    string S, T;
    cin >> S >> T;
    ll l = S.length();
    if (T.substr(0, l) == S) cout << "Yes\n";
    else cout << "No\n";
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
int main() {
    string s; cin >> s;
    vector<char> ans;
    for(int c = 0; c < s.length(); c++) {
        cout << "x";
    }
    cout << "\n";

    return 0;
}


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

int main(){
    int N;
    cin >> N;
    int X[N];
    int i = 0, sum = 0, mean, ans=0;
    for(i = 0; i < N; i++){
        cin >> X[i];
        sum += X[i];
    }
    mean = round(float(sum) / N);
    for (i = 0; i < N; i++){
        ans += (X[i] - mean) * (X[i] - mean);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;

int main()
{
	ll N, M, C;
	cin >> N >> M >> C;
	vector<ll> B(M, 0);
	for (int i = 0; i < M; ++i) {
		cin >> B[i];
	}
	int ans = 0;
	for (int i = 0; i < N; ++i) {
		int target = C;
		int temp = 0;
		for (int j = 0; j < M; ++j) {
			cin >> temp;
			target += temp * B[j];
		}
		if (target > 0) ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#l=list(map(int, input().split()))
a,b=map(int, input().split())
#l=list(map(int, input().split()))
#n = int(input())
def divisor(n): #nの約数を全て求める
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table
def is_prime(n):
    for i in range(2, n + 1):
        if i * i > n:
            break
        if n % i == 0:
            return False
    return n != 1

ans = 1
hoge = divisor(a)
hoge2 = divisor(b)

temp = []
for i in hoge:
    if i in hoge2:
        temp.append(i)

for i in temp:
    if is_prime(i):
        ans += 1

print (ans)



Measured memory_bytes: 4148
#include <bits/stdc++.h>
#include <boost/functional/hash.hpp>

#define debug 0
#define esc(ret) cout << (ret) << endl,quick_exit(0)
#define fcout(d) cout << fixed << setprecision(d)
#define repU(i,s,t) for(int i = (int)(s); i <= (int)(t); ++i)
#define repD(i,s,t) for(int i = (int)(s); i >= (int)(t); --i)
#define rep(i,n) repU(i,0,(n) - 1)
#define rep1(i,n) repU(i,1,(n))
#define all(v) begin(v),end(v)
#define vct vector
#define prique priority_queue
#define l_bnd lower_bound
#define u_bnd upper_bound
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define mkp make_pair
#define mkt make_tuple
#define ins insert
#define emp emplace
#define era erase
#define fir first
#define sec second
#define odd(x) ((x) & 1)
#define even(x) (!odd(x))

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int,int> pii;
typedef pair<db,int> pdi;
typedef tuple<int,int,int> tiii;

const int dir[][2] = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const int mod = 1e9 + 7;
const int inf32 = (1 << 30) - 1;
const ll inf64 = (1LL << 62) - 1;

template <class T, class U> T qceil(T x, U y) { return x > 0 ? (x - 1) / y + 1 : x / y; }
template <class T, class U> bool parity(T x, U y) { return odd(x) ^ even(y); }
template <class T, class U> bool chmax(T &m, U x) { if(m < x) { m = x; return 1; } return 0; }
template <class T, class U> bool chmin(T &m, U x) { if(m > x) { m = x; return 1; } return 0; }
template <class T> bool cmprs(T &v) {
    T tmp = v;
    sort(all(tmp));
    tmp.erase(unique(all(tmp)),end(tmp));
    for(auto it = begin(v); it != end(v); ++it) *it = l_bnd(all(tmp),*it) - begin(tmp) + 1;
    return v.size() > tmp.size();
}

int h,w;
queue<pair<pii,pii>> opr;
vct<int> col;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
	
	cin>>h>>w;
	rep1(i,h){
		int t=0;
		rep1(j,w){
			int a;
			cin >> a;
			if(odd(a+t)){
				t=1;
				if(j<w) opr.push({{i,j},{i,j+1}});
				else col.pub(i);
			}else{
				t=0;
			}
		}
	}
	int l=col.size();
	rep(i,l/2){
		int f=2*i;
		for(int j = col[f];j<col[f+1];++j) opr.push({{j,w},{j+1,w}});
	}
	cout<<(int)(opr.size())<<endl;
	while(!opr.empty()){
		auto tp=opr.front();
		opr.pop();
		int x1=tp.fir.fir;
		int y1=tp.fir.sec;
		int x2=tp.sec.fir;
		int y2=tp.sec.sec;
		cout << x1<<' '<<y1<<' '<<x2<<' '<<y2<<endl;
	}
}


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

typedef long long ll;
using namespace std;
const int N = 100010;
int _w;

int n, k, a[N], ans;

int main() {
	_w = scanf( "%d%d", &n, &k );
	for( int i = 1; i <= n; ++i )
		_w = scanf( "%d", a+i );
	for( int i = 1; i < n; i += k-1 ) ++ans;
	printf( "%d\n", ans );
	return 0;
}


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

int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int n;
    const int mod = 1e9 + 7;
    cin >> n;
    vector<int64_t> dp(n + 1);
    dp[0] = 1;
    for (int i = 3; i <= n; i++) {
        for (int j = i - 3; j >= 0; j--) {
            dp[i] += dp[j];
        }
        dp[i] %= mod;
    }
    cout << dp[n] << '\n';
    return 0;
}

Measured memory_bytes: 3612
import sys
from collections import deque


def input():
    return sys.stdin.readline().rstrip()


def main():
    N =int(input())
    l=[]
    for i in range(N):
        k,s = input().split()
        s = int(s)
        l.append([k,s,i+1])



    l.sort(reverse=True)
    mem =""
    q=[]
    for i in range(N):
        k,s,j = l.pop()
        if mem ==k:
            q.append([s,j])
            mem =k
        else:
            q.sort(reverse=True)
            for o,p in q:
                print(p)
            q=[]
            q.append([s, j])
            mem =k
    q.sort(reverse=True)
    if q:
        for o, p in q:
            print(p)






if __name__ == "__main__":
    main()


Measured memory_bytes: 65524
stack = []
ls = list(input().split())

for i in range(len(ls)):
    if str.isdecimal(ls[i]):
        stack.append(ls[i])
    elif ls[i] == "+":
        f2 = int(stack.pop(-1))
        f1 = int(stack.pop(-1))
        stack.append(f1 + f2)
    elif ls[i] == "-":
        f2 = int(stack.pop(-1))                                                          
        f1 = int(stack.pop(-1))
        stack.append(f1 - f2) 
    elif ls[i] == "*":
        f2 = int(stack.pop(-1))                                                          
        f1 = int(stack.pop(-1))
        stack.append(f1 * f2)
    else:
        print("エラー ls[i]:",ls[i],"\nスタック:",stack)

print(stack[0])
        



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

#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << " = " << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define SP << " " <<

typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;

const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const int INF = (1LL << 60); // 1152921504606846976
const double PI = (3.141592653589794);
const double EPS = (0.0000000001);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> inline T ceil(T a, T b) {return T((a + b - 1) / b);}
template<class T> inline T round(T a, T b) {return T(a / b);}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
template <class T> inline void out(T &a) { bool flag=true; for(auto&x:a){if(flag) {flag=false;} else{ cout << ' '; } cout<<x; } cout << endl; }



//----------------------------------------------------------------
int nmax=200000; // 2*(10^5)
vvec g(nmax);





void solve4ts()
{
    
    int k,a,b;
    cin>>k>>a>>b;
    int ok=0;
    for(int i=a;i<=b;i++){
        if(i%k==0) ok++;
    }
    if(ok==0) cout<<"NG"<<endl;
    else cout<<"OK"<<endl;
}
//-----------------------------------------------------------------

signed main(){ ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15);
    int repeat = 1;
    // cin >> repeat;
    while(repeat--) solve4ts();
}

Measured memory_bytes: 7820
#include <stdio.h>
int main (){
	
	int a, b,c,d,e,k;
	
	scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &k);
	
	if((e - a) > k){
		printf(":(");
	}
	else{
		printf("Yay!");
	}
	
	
	
	
	
	
	return 0;
}

Measured memory_bytes: 128
import java.util.*;
public class Main {
	public static void main(String[] args){
      	//データ取り込み
		Scanner sc = new Scanner(System.in);
      	
		int N = sc.nextInt();
      	int lines[] =new int[N];
      	for(int i=0;i<N;i++){
        	lines[i]=sc.nextInt();
        }
      	Arrays.sort(lines);
      	int cnt =0;
      	for(int i=0;i<N-1;i++){
        	cnt+= lines[i];
        }
      	if(cnt>lines[N-1]){
        	System.out.println("Yes");
        }else{
        System.out.println("No");
        }
    }
}

Measured memory_bytes: 23764
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;

    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);

    private void solve(Scanner sc) {
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] a = new int[M];
        int[] b = new int[M];
        int[] c = new int[M];
        for (int i = 0; i < M; ++i) {
            a[i] = sc.nextInt() - 1;
            b[i] = sc.nextInt() - 1;
            c[i] = sc.nextInt() * -1;
        }

        // based on ベルマンフォード法
        long[] dist = new long[N];
        Arrays.fill(dist, Long.MAX_VALUE);
        dist[0] = 0;

        for (int i = 0; i < N - 1; ++i) {
            for (int j = 0; j < M; ++j) {
                if (dist[a[j]] == Long.MAX_VALUE) {
                    continue;
                }

                if (dist[b[j]] > dist[a[j]] + c[j]) {
                    dist[b[j]] = dist[a[j]] + c[j];
                }
            }
        }

        long ans = -dist[N - 1];

        boolean[] neg = new boolean[N];
        for (int i = 0; i < N; ++i) {
            for (int j = 0; j < M; ++j) {
                if (dist[a[j]] == Long.MAX_VALUE) {
                    continue;
                }

                if (dist[b[j]] > dist[a[j]] + c[j]) {
                    dist[b[j]] = dist[a[j]] + c[j];
                    neg[b[j]] = true;
                }

                if (neg[a[j]]) {
                    neg[b[j]] = true;
                }
            }
        }

        if (neg[N - 1]) {
            _out.println("inf");
        } else {
            _out.println(ans);
        }
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();

        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Measured memory_bytes: 28492
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>
#include <complex>
#include <functional>
#include <tuple>
#include <new>

//#include "All.h"

using namespace std;

#define EPS (1e-9)
#define INF (1e9)
#define MOD (1e9 + 7)
#define PI (acos(-1))
#define REP(i,a,n) for(int i=a;i<n;i++)
#define rep(i, n) REP(i,0,n)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" ; "IMPOSSIBLE")

using ll = long long int;

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

ll beki(ll a, ll b) {
    ll tmp = 1;
    rep(i, b) tmp *= a;
    return tmp;
}

char a;

int main() {
    cin >> a;
    if (a - 'a' >= 0 && a - 'z' <= 0) {
        cout << 'a' << endl;
    }
    else {
        cout << 'A' << endl;
    }
}

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

int main() {
    int N, i;
    int j, p, w, g, y;
    j = p = w = g = y = 0;
    string color;

    cin >> N;

    for (i = 0; i < N; i++)
        {
            cin >> color;

            if (color == "P")
            {
                p++;
                continue;
            }
            else if (color == "W")
            {
                w++;
                continue;
            }
            else if (color == "G")
            {
                g++;
                continue;
            }
            else if (color == "Y")
            {
                y++;
                continue;
            }

        }

    if (p > 0)
        j++;
    if (w > 0)
        j++;
    if (g > 0)
        j++;
    if (y > 0)
        j++;

    if (j == 4)
        cout << "Four" << endl;
    else if (j == 3)
        cout << "Three" << endl;
}

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

using namespace std;

#define ll long long

int bin_pow(int a, int pow) {
    if (pow == 0) return 1;
    if (pow == 1) return a;
    if (pow % 2 == 0) {
        int tmp = bin_pow(a, pow / 2);
        return tmp * tmp;
    }
    return a * bin_pow(a, pow - 1);
}

int fact(int x) {
    int ans = 1;

    for (int i = 1; i <= x; i++) ans *= i;
    return ans;
}

int count(vector<int> a) {
    int ans = 0;
    unordered_set<int> was;
    for (int i = 0; i < a.size(); i++) {
        int count = a[i] - 1;
        for (int j = 1; j < a[i]; j++) {
            count -= was.count(j);
        }
        ans += count * fact(a.size() - i - 1);
        was.insert(a[i]);
    }

    return ans;
}

ll m = 1000000007;

bool isPrime(int x) {
    for (int i = 2; i * i <= x; i++) {
        if (x % i == 0) return false;
    }
    return true;
}

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

    int a;
    cin >> a;
    cout << a * a;
    return 0;
}

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

using i64 = int64_t;

int v[102]={0};

void init(){
    for(int i=0;i<=100;++i)v[i]=0;
}

int main(){
    int n, m;
    while(cin >> n >> m, n != 0){
        init();
        for(int i=0;i<n;++i){
            int di, vi;
            cin >> di >> vi;
            v[di] = max(v[di], vi);
        }
        int sum = 0;
        for(int i=1;i<=m;++i)sum += v[i];
        cout << sum << endl;
    }

    return 0;
}



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

int main(){
	string s;cin>>s;
	//vector<int>v;
	// int cnt=0;
	// char c='g';
	// for(auto u:s){
	// 	if(c==u)cnt++;
	// 	else{
	// 		v.push_back(cnt);
	// 		cnt=1;
	// 		c=u;
	// 	}
	// }
	// if(cnt)v.push_back(cnt);
	// v.push_back(0);
	//int ans=0;
	int cnt=0;
	for(auto u:s){
		if(u=='g')cnt++;
	}
	cout<<(cnt-(s.size()-cnt))/2;
	// int left=0;
	// for(int i=0;i<v.size()-1;i++){
	// 	int need=v[i+1];
	// 	if(i%2==0){
	// 		need-=left;
	// 		left=0;
	// 		if(need<=v[i]){v[i]-=need;need=0;}
	// 		else {need-=v[i];v[i]=0;}
	// 		ans+=v[i]/2;
	// 		left+=(v[i]%2);
	// 		ans-=need;
	// 	}
	// }
	//cout<<ans;
	return 0;
}

Measured memory_bytes: 3720
Input = list(map(int,input().split()))
S = input()

N = Input[0]
A = Input[1]
B = Input[2]
Pass = 0
B_Pass = 0
for iter in range(N):
    if S[iter] == 'a' and Pass < A+B:
        Pass += 1
        print("Yes")
    elif S[iter] == 'b' and Pass < A+B and B_Pass < B:
        Pass += 1
        B_Pass += 1
        print("Yes")
    else:
        print("No")
    


Measured memory_bytes: 9212
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
 
using namespace std;
int main()
{
  int A;
  int B;
  int C;
  
  cin >> A >> B >> C;
  
  cout << C << " " <<A << " "<<B << endl;
     return 0;
}

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

int main() {
  int H,A;
  cin >> H >> A;
  
  int count = 0;
  
  rep(i,10000){
    if(H>0){
      H-=A;
      count++;
    }
    else{
      break;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
let () = Scanf.scanf "%s" @@ fun s ->
  let n = String.length s in
  let sum = List.fold_left (fun acm i -> 
    let num = Char.code s.[i] - 48 in acm + num)
    0 @@ List.init n Fun.id in
  let ans = if sum mod 9 = 0 then "Yes\n" else "No\n" in
  Printf.printf "%s" ans

Measured memory_bytes: 14964
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ld long double
#define dd double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;
typedef vector<pll> vplll;
ll mod = 1e9+7;
const ld PI = 2 * acos(0.0);
const vector<ll> dx = {1, -1, 0, 0};
const vector<ll> dy = {0, 0, 1, -1};
#define round(x, y) ((x + y - 1) / y)
#define ce(x, y) ((x + y - 1) / y)
#define amax(x, y) \
    if (y > x)     \
        x = y;
#define amin(x, y) \
    if (y < x)     \
        x = y;
#define lcm(x, y) ((x) * (y) / __gcd(x, y))
#define len(x) (ll) x.length()
#define sq(x) ((x) * (x))
#define cb(x) ((x) * (x) * (x))
    	ll ar[400005], br[400005];
    // map<ll,ll> m1;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,c,t,n,m,k,q; 
    t = 1;
    // cin>>t;
    while(t--)
    {
    	cin>>n;
    	for(int i=0;i<n;i++)
    	{
    		cin>>a;
    		if(a>200000)
    			continue;
    		br[i+a+200000]++;
    		ar[i-a+200000]++;
    	}
    	ll ans = 0;
    	for(int i=0;i<=400000;i++)
    	{
    		ans += ar[i]*(br[i]);
    	}
    	cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 8344
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 5LL << 60;
const ll mod = 1e9 + 7;

int main() {
	int N;
	cin >> N;
	int H[N];
	for(int i = 0; i < N; i++) cin >> H[i];
	H[0]--;
	for(int i = 1; i < N; i++) {
		if(H[i - 1] > H[i]) {
			cout << "No\n";
			return 0;
		} else if(H[i - 1] < H[i])
			H[i]--;
	}
	cout << "Yes\n";
	return 0;
}


Measured memory_bytes: 640
word1 = input()
word2 = input()

def cnt_element(x):
    dict = {}
    for i in x:
        if i not in dict:
            dict[i] = 1
        else:
            dict[i] += 1
    return  sorted([x for x in dict.values()],reverse=True)

if cnt_element(word1) == cnt_element(word2):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3632
import scala.io.Source.stdin

object Main extends App {
  val O = 'o';val X = 'x'
  stdin.getLines.foreach { s =>
    val r = s.toArray match {
      case Array(O,O,O,_*) | Array(_,_,_,O,O,O,_*) | Array(_,_,_,_,_,_,O,O,O)
      | Array(O,_,_,O,_,_,O,_*) | Array(_,O,_,_,O,_,_,O,_) | Array(_,_,O,_,_,O,_,_,O)
      | Array(O,_,_,_,O,_,_,_,O) | Array(_,_,O,_,O,_,O,_*)  => O
      case Array(X,X,X,_*) | Array(_,_,_,X,X,X,_*) | Array(_,_,_,_,_,_,X,X,X)
      | Array(X,_,_,X,_,_,X,_*) | Array(_,X,_,_,X,_,_,X,_) | Array(_,_,X,_,_,X,_,_,X)
      | Array(X,_,_,_,X,_,_,_,X) | Array(_,_,X,_,X,_,X,_*)  => X
      case _ => 'd'
    }
    println(r)
  }
}

Measured memory_bytes: 43904
def f(n, c)
  if n == "6174"
    return c
  else
    c += 1
    s = n.split("").sort.join
    l = s.reverse 
    f("%04d" % (l.to_i - s.to_i), c)
  end
end

until (n = gets.chomp) == "0000"
  puts n.to_i % 1111 == 0 ? "NA" : f(n, 0)
end

Measured memory_bytes: 9612
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
//絶対値
long long int change_plus(long long int a) {
	if (a < 0) { return -a; }
	if (a >= 0) { return a; }
}
//大小比較(大)
long long int big(long long int a, long long int b) {
	if (a >= b) {
		return a;
	}
	else {
		return b;
	}
}

//大小比較(小)
long long int small(long long int a, long long int b) {
	if (a >= b) {
		return b;
	}
	else {
		return a;
	}
}

main() {
	long long int n, m, k = 0;
	char str[5];
	scanf("%lld%lld%lld",&n,&m,&k);
	if ((10*m+k)%4==0) { printf("YES"); }
	else { printf("NO"); }
	

}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int C = scan.nextInt();
		scan.close();
		double S = (a * b) / 2 * Math.sin(Math.toRadians(C));
		double c = Math.sqrt(a * a + b * b - (2 * a * b * Math.cos(Math.toRadians(C))));
		double L = a + b + c;
		double h = S * 2 / a;
		System.out.println(S);
		System.out.println(L);
		System.out.println(h);
	}
}

Measured memory_bytes: 26288
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		long y = sc.nextLong();
		if(x < y) {
			System.out.println(x);
		} else if(x == y || y == 1) {
			System.out.println(-1);
		} else if(x % y == 0) {
			System.out.println(-1);
		} else {
			System.out.println(x);
		}

	}
}


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

#define BUF_SIZE 12
int main(void) {
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return 0;
  int length = strlen(line) - 1;

  int i, j;
  long ans[11] = {0};
  ans[1] = line[0] - '0';
  long whole = ans[1];

  for(i = 2; i <= length; i++) {
    whole = whole*10 + line[i-1]-'0';
    long digit = 1;
    ans[i] += whole;
    for(j = i-1; j > 0 ; j--) {
      digit *= 10;
      ans[i] += (ans[j] + (long)(whole%digit) * (long)(1<<(j-1)));
    }
  }
  printf("%ld\n", ans[length]);
  return 0;
}

Measured memory_bytes: 128
//#pragma GCC optimize "trapv"
#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rand rng
#define fios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define M_PI 3.14159265358979323846
typedef long long ll;



int main() {
	int n;
	ll mod = 1e9 + 7;
	cin >> n;
	vector<ll> a(n);
	for(auto& x: a) cin >> x;

	ll sm = a[0], ans = 0;
	for(int i = 1; i < n; i++) {
		ans = (ans + sm * a[i]) % mod;
		sm = (sm + a[i]) % mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 4776
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <list>
#include <array>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__)
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    ll a, b, n;
    cin >> a >> b >> n;
    ll t = min(b - 1, n);
    cout << a * t / b << endl;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5;
char str[N];
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    scanf("%s",str);

    str[k-1]=str[k-1]-'A'+'a';
    printf("%s\n",str);
    //cout << "Hello world!" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int s = 0;
	scanf("%d", &s);

	int h = s / 3600;
	s %= 3600;

	int m = s / 60;
	s %= 60;

	printf("%d:%d:%d\n", h, m, s);

	return 0;
}

Measured memory_bytes: 1792
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
//max_element


signed main()
{
	int A, V, B, W, T;
	cin >> A >> V;
	cin >> B >> W;
	cin >> T;

	if (A == B)
	{
		cout << "YES" << endl;
	}
	else if (A < B)
	{
		YESNO(A + V * T >= B + W * T);
	}
	else
	{
		YESNO(A - V * T <= B - W * T);
	}
}




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

int main() {
    int N;
    int ans = 0;
  	cin >> N;
    char str[N];
    for(int i=0; i<N; i++) cin >> str[i];
    for(int i=0; i<N-2; i++){
        if(str[i]=='A'&&str[i+1]=='B'&&str[i+2]=='C'){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(A: "List[int]"):
    As = sorted(A, reverse=True)
    ans = 0
    for i in range(len(As) - 1):
            ans += abs(As[i] - As[i + 1])
    print(ans)
# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    A = list(map(int, input().split()))
    solve(A)

if __name__ == '__main__':
    main()


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

int main(){
  int n,array[500],color[8]={},ans=0,tourist=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>array[i];
    if(array[i]>=3200){
      tourist++;
    }else{
      color[array[i]/400]++;
    }
  }
  for(int i=0;i<8;i++){
    if(color[i]){
      ans++;
    }
  }
  if(ans){
    cout<<ans<<" "<<ans+tourist<<endl;
  }else{
    cout<<1<<" "<<tourist<<endl;
  }
}
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll ZERO = 0;
const int Inf = 1e9;
const ll INF= 1e18;
const ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

int main() {
    int N,M;
    cin >> N >> M;
    vector<int> vec(N,1);
    vector<bool> cnt(N);
    cnt.at(0) = true;
    int itr = 0;
    for(int i = 0;i < M;i++) {
        int A,B;
        cin >> A >> B;
        A--;
        B--;
        if(cnt.at(A) == true && vec.at(A) == 1) {
            cnt.at(A) = false;
            cnt.at(B) = true;
        }
        else if(cnt.at(A) == true) {
            cnt.at(B) = true;
        }
        vec.at(A)--;
        vec.at(B)++;
    }
    int ret = 0;
    for(int i = 0;i < N;i++) {
        if(cnt.at(i) == true) {
            ret++;
        }
    }
    cout << ret << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<sstream>
#include<iomanip>
#include<stdlib.h>
#include<string>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<set>
#include<queue>
#include<stack>
#include<map>
#include<utility>
#include<algorithm>
#include<complex>
using namespace std;
#define loop(i,l,r) for(int (i)=(int)(l);(i)<(int)(r);(i)++)
#define rloop(i,l,r) for(int (i)=(int)(l);(i)>(int)(r);(i)--)
#define rep(i,n) loop(i,0,n)
#define rrep(i,n) rloop(i,n-1,-1)
#define INF 0x3f3f3f3f
#define mod 1000000007LL
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef complex<double> C;

vector<string> split(stringstream& ss){
	string str;
	vector<string> res;
	while(ss>>str)res.push_back(str);
	return res;
}

int main(){
		int n,d,res;
		while(1){
				cin>>n;
				if(n==0)break;
				res=0;
				rep(i,n*(n-1)/2){
						cin>>d;
						res+=d;
				}
				cout<<res/(n-1)<<endl;
		}
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  ll h, w;
  cin >> h >> w;
  ll ans;
  if(h==1||w==1) {
    ans = 1;
  }else ans=(h*w+1)/2;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>

using namespace std;
std::vector<long long> adj[100007];
long long dp[100007];
bool vis[100007];
long long dfs(long long x)
{
    long long ans=0;
    long long val=0;
    vis[x]=true;
    if(dp[x]!=-1){return dp[x];}
    for(auto itr:adj[x])
    {
        ans=0;
        if(!vis[itr]){ans+=dfs(itr)+1;}
        else{ans=dp[itr]+1;}
        val=max(val,ans);
    }
    dp[x]=val;
    return val;
}

int main()
{
    long long bro=0,vv,n,m,i,x,y;
    cin>>n>>m;
    for(i=0;i<=n;i++){dp[i]=-1;vis[i]=false;}
    for(i=0;i<m;i++)
    {
        cin>>x>>y;
        adj[x].push_back(y);
    }
    for(i=1;i<=n;i++)
    {
        if(!vis[i]){vv=dfs(i);bro=max(bro,vv);}
    }
    cout<<bro;
    return 0;
}


Measured memory_bytes: 12712
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(){
    string s;
    cin >> s;

    string ans;
    if(s.back() == '2' || s.back() == '4' || s.back() == '5' || s.back() == '7' || s.back() == '9'){
        ans = "hon";
    }else if( s.back() == '0' || s.back() == '1' || s.back() == '6' || s.back() == '8' ){
        ans = "pon";
    }else if(s.back() == '3'){
        ans = "bon";
    }
    cout << ans << endl;
}

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

int main() {
   string s;
   cin >> s;

   if(s[2] == s[3] && s[4] == s[5]) {
      cout << "Yes" << endl;
   } else {
      cout << "No" << endl;
   }

   return 0;
}

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

int main(){

    int N;
    int h[100007];
    cin >> N;
    long long int dp[100007];
    for (int i=0;i<N;i++){
        cin >> h[i];
        dp[i] = 0;
    }

    dp[1] = abs(h[1] - h[0]);
    for(int low=2; low < N; low++)
        dp[low] = min(dp[low-1] + abs(h[low] - h[low-1]), dp[low-2] + abs(h[low] - h[low-2]));
    cout << dp[N-1] << "\n";
    
    return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<cstring>
#include<queue>
#include<algorithm>

using namespace std;

#define REP(i, n) for(int i=0;i<(int)n;i++)
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define reep(i, s, t) for(int i=s;i<(int)t;i++)
#define irep(i, n) for(int i=(int)n-1;i>=0;i--)
#define ireep(i, n, s) for(int i=(int)n-1;i>=s;i--)
#define all(v) v.begin(), v.end()
#define vc vector
#define pb push_back

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

int n,m;
const int INF = 1<<25;
int dp[1005];
int main(){
	cin >> n;
	REP(i, 400) dp[i] = -INF;
	dp[0] = 0;
	REP(tttt, n){
		int s, t, w;
		cin >> s >> t >> w;
		rep(i, 400){
			for(int j=s;j<=t;j++) dp[i+j] = max(dp[i+j], dp[i] + w);
		}
	}
	vi ans;
	int f = 1;
	cin >> m;
	REP(i, m){
		int x;
		cin >> x;
		ans.pb(dp[x]);
		if(dp[x] < 0) f = 0;
	}
	if(!f) cout << -1 << endl;
	else{
		for(int v : ans) cout << v << endl;
	}
	return 0;
}

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

//#include <atcoder/all>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i < i##_len; i++)
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#ifdef _DEBUG
#define PRE_COMMAND             \
    std::cin.rdbuf(in.rdbuf()); \
    std::cout << fixed << setprecision(15);
#else
#define PRE_COMMAND cout << fixed << setprecision(15);
#endif
const double EPS = 1e-10, PI = acos(-1.0);
template <class T> auto MAX(T& seq) {
    return *max_element(seq.begin(), seq.end());
}
template <class T> auto MIN(T& seq) {
    return *min_element(seq.begin(), seq.end());
}
template <class T> auto SUM(T& seq) {
    T temp{0};
    auto& temp2 = temp[0];
    return accumulate(seq.begin(), seq.end(), temp2);
}
template <class T> void SORT(T& seq) { sort(seq.begin(), seq.end()); }
template <class T, class S> void SORT(T& seq, S& sort_order) {
    sort(seq.begin(), seq.end(), sort_order);
}
template <class T> void SORTR(vector<T>& seq) {
    sort(seq.begin(), seq.end(), greater<T>());
}
template <class T, class S, class R> long long pow(T n_0, S k_0, R mod_0) {
    long long n = n_0, k = k_0, mod = mod_0, now = 1;
    while (true) {
        if (k & 1) { now = now * n % mod; }
        if ((k >>= 1) == 0) { return now; }
        n = (n * n) % mod;
    }
}

ll floor_sum(ll n, ll m, ll a, ll b) {
    ll ret = 0;
    if (b >= m) {
        ret += n * (b / m);
        b %= m;
    }
    if (a >= m) {
        ret += n * (n - 1) * (a / m) / 2;
        a %= m;
    }
    ll y = (a * n + b) / m;
    if (y == 0) { return ret; }
    b = a * n - m * y + b;
    ret += floor_sum(y, a, m, b);
    return ret;
}

int main() {
    PRE_COMMAND
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    cout << (h2 * 60 + m2 - h1 * 60 - m1 + 24 * 60) % 1440 - k << endl;
}


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

int n, A, x[55];
long long rec[55][55][3025];

long long dp(long long num, long long pick, long long sum)
{
    if(rec[num][pick][sum]!=-1) return rec[num][pick][sum];
    long long ans = 0;
    if(num==n) {
        if(pick==0) return 0;
        if((long double)sum/pick==(long double)A) return 1;
        else return 0;
    } else {
        ans = dp(num+1, pick, sum) + dp(num+1, pick+1, sum+x[num]);
    }

    return rec[num][pick][sum] = ans;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n >> A;
    for(int i=0; i<n; i++) cin >> x[i];
    memset(rec, -1, sizeof(rec));
    cout << dp(0, 0, 0) << endl;

    return 0;
}


Measured memory_bytes: 71808
#include<bits/stdc++.h>
#define Rint register int
using namespace std;
const int N = 15;
int n, m, lim, wsum, edge[N][N], sum[1 << N], dp[N][1 << N];
inline int cost(int S, int T){return sum[S | T] - sum[S] - sum[T];}
inline bool chkmax(int &a, int b){return (a < b) ? (a = b,1) : 0;}
int main(){
	scanf("%d%d", &n, &m); lim = 1 << n;
	for(Rint i = 1;i <= m;i ++){
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c); -- a; -- b;
		edge[a][b] = edge[b][a] = c; wsum += c;
	}
	for(Rint S = 1;S < lim;S ++)
		for(Rint i = 0;i < n;i ++) if((S >> i) & 1)
			for(Rint j = i + 1;j < n;j ++) if((S >> j) & 1)
				sum[S] += edge[i][j];
	memset(dp, 0x80, sizeof dp);
	dp[0][1] = 0;
	for(Rint S = 1;S < lim;S += 2)
		for(Rint t = 0;t < n;t ++) if((S >> t) & 1){
			for(Rint u = 0;u < n;u ++) if(!((S >> u) & 1) && edge[t][u])
				chkmax(dp[u][S | (1 << u)], dp[t][S] + edge[t][u]);
			int SS = (lim - 1) ^ S;
			for(Rint T = SS;T;T = (T - 1) & SS)
				chkmax(dp[t][S | T], dp[t][S] + sum[T | (1 << t)]);
		}
	printf("%d\n", wsum - dp[n - 1][lim - 1]);
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
constexpr char ln = '\n';

const int mx=200010;
const ll mod=1e9+7;
 
int main(){
  int x,y;
  cin >> x >> y;
  if(x%y==0){
    cout << -1 << ln;
  } else {
    cout << x << ln;
  }
  return 0;
}

Measured memory_bytes: 3572