akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <math.h>
// math.hのライブラリをリンクする必要がある
// gcc d.c -o c -lm

int main(int argc, char const *argv[]) {

    int n;
    scanf("%d", &n);

    int x[n], y[n];
    long long int d, D1 = 0, D2 = 0, D3 = 0, Dmax = -1;

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

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


    for (int i = 0; i < n; i++) {
        if (x[i] > y[i]) {
            d = x[i] - y[i];
        } else {
            d = y[i] - x[i];
        }

        D1 += d;
        D2 += d * d;
        D3 += d * d * d;

        if (Dmax < d) {
            Dmax = d;
        }    
    }

    double d1, d2, d3, dmax;
    d1 = (double)D1;
    d2 = sqrt((double)D2);
    d3 = pow((double)D3, 1.0/3);
    dmax = (double)Dmax;

    printf("%.10f\n", d1);
    printf("%.10f\n", d2);
    printf("%.10f\n", d3);
    printf("%.10f\n", dmax);

}



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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> vec(N);
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    vec.at(a - 1) += 1;
    vec.at(b - 1) += 1;
  }
  for (int i = 0; i < N; i++) {
    cout << vec.at(i) << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#define max 30
#define NIL -1
  
typedef struct node_ {
    int parent;
    int left;
    int right;
} Node;
  
Node N[max];
  
void pre(int s) {
    if (s == -1) return;
  
    printf(" %d", s);
    pre(N[s].left);
    pre(N[s].right);
}
  
void in(int t) {
    if (t == -1) return;
  
    in(N[t].left);
    printf(" %d", t);
    in(N[t].right);
}
  
void post(int u) {
    if (u == -1) return;
  
    post(N[u].left);
    post(N[u].right);
    printf(" %d", u);
}
  
int main(void) {
    int i, n;
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        N[i].parent = -1;
        N[i].left = -1;
        N[i].right = -1;
    }
  
    for (i = 0; i < n; i++) {
        int id, left, right;
        scanf("%d %d %d", &id, &left, &right);
        N[id].left = left;
        N[id].right = right;
        if (left != NIL) N[left].parent = id;
        if (right != NIL) N[right].parent = id;
    }
  
    int r;
    for (i = 0; i < n; i++) {
        if (N[i].parent == -1) r = i;
    }
  
    printf("Preorder\n");
    pre(r);
    printf("\n");
    
    printf("Inorder\n");
    in(r);
    printf("\n");
    
    printf("Postorder\n");
    post(r);
    printf("\n");
  
    return 0;
}


Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int32_t main()
{
	long long int n,k;
	cin>>n>>k;
	vector<long long int>v(n);
	
	for(long long int i=0;i<n;i++)
	{
		cin>>v[i];
	}
	
	sort(v.begin(),v.end());
	long long int ans = 0;
	for(long long int i=0;i<k;i++)
	{
		ans+=v[i];
	}
	cout<<ans;
	return 0;
}



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

int sq[1000][1000];
string b[1000];

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

	int n;
	while (cin >> n , n) {
		for (int i = 0; i < n; i++) {
			cin >> b[i];
		}

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				sq[i][j] = b[i][j] == '.' ? 1 : 0;
			}
		}

		int ans = 0;
		for (int i = 1; i < n; i++) {
			for (int j = 1; j < n; j++) {
				if (b[i][j] == '*') continue;
				int m = min(sq[i - 1][j - 1], sq[i - 1][j]);
				m = min(m, sq[i][j - 1]);
				sq[i][j] = m + 1;
				ans = max(ans, sq[i][j]);
			}
		}

		cout << ans << endl;
	}
}

Measured memory_bytes: 6172
import java.util.*;

public class Main{
    static int w, h;
    static int[][] t;
    static int dx[] = {-1, 0, 1, -1, 1, -1, 0, 1};
    static int dy[] = {-1, -1, -1, 0, 0, 1, 1, 1};

    static void dfs(int x, int y){
        t[y][x] = 0;

        for(int i = 0; i < 8; i++){
            int nx = x + dx[i];
            int ny = y + dy[i];

            if(nx < 0 || w <= nx || ny < 0 || h <= ny || t[ny][nx] == 0) continue;

            dfs(nx, ny);
        }
    }

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

        while(true){
            w = sc.nextInt();
            h = sc.nextInt();
            if(w == 0 && h == 0) break;

            t = new int[h][w];

            for(int i = 0; i < h; i++){
                for(int j = 0; j < w; j++){
                    t[i][j] = sc.nextInt();
                }
            }

            int ans = 0;

            for(int i = 0; i < h; i++){
                for(int j = 0; j < w; j++){
                    if(t[i][j] == 1){
                        dfs(j, i);
                        ans++;
                    }
                }
            }

            System.out.println(ans);
        }
    }
}

Measured memory_bytes: 13000
#!/usr/bin/env python3
import sys
from itertools import product
def input():
    return sys.stdin.readline()[:-1]

def main():
    N, M, X = map(int, input().split())
    A = [list(map(int, input().split())) for _ in range(N)]

    for m in range(1, M + 1):
        s = 0
        for n in range(N):
            s += A[n][m]
        if s < X:
            print(-1)
            exit()

    # bit全探索
    # repeat=2だと(0,0), (0,1), (1,0), (1,1)になる
    ans = 10 ** 15
    for i in product([0,1], repeat=N):
        c = 0
        for m in range(1, M + 1):
            s = 0
            for n in range(N):
                if i[n] == 1:
                    s += A[n][m]
            if s >= X:
                c += 1
        if c == M:
            money = 0
            for n in range(N):
                if i[n] == 1:
                    money += A[n][0]
            ans = min(ans, money)
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 73892
def main():
    n, k = map(int, input().split())
    h_list = list(map(int, input().split()))
    h_list.sort(reverse=True)

    if n <= k:
        ans = 0
    else:
        ans = sum(h_list[k:])

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 105076
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define all(a) a.begin(), a.end()
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

const int MAXN = 105000;

int x, y, a, b, c;
int p[MAXN], q[MAXN], r[MAXN];
long long ans = 0;
vector <int> pv, qv;

int main() {

    cin >> x >> y >> a >> b >> c;
    for (int i = 0; i < a; i++) {
        scanf("%d", &p[i]);
    }
    for (int i = 0; i < b; i++) {
        scanf("%d", &q[i]);
    }
    for (int i = 0; i < c; i++) {
        scanf("%d", &r[i]);
    }
    
    sort(p, p + a);
    reverse(p, p + a);
    sort(q, q + b);
    reverse(q, q + b);
    sort(r, r + c);
    reverse(r, r + c);

    for (int i = 0; i < x; i++) {
        pv.push_back(p[i]);
        ans += p[i];
    }
    for (int i = 0; i < y; i++) {
        qv.push_back(q[i]);
        ans += q[i];
    }
    reverse(all(pv));
    reverse(all(qv));

    int p1 = 0, p2 = 0;
    for (int i = 0; i < min(c, x + y); i++) {
        if (p2 == sz(qv) || (p1 < sz(pv) && pv[p1] < qv[p2])) {
            if (r[i] > pv[p1]) {
                ans -= pv[p1];
                ans += r[i];
                p1++;
            } else {
                break;
            }
        } else {
            if (r[i] > qv[p2]) {
                ans -= qv[p2];
                ans += r[i];
                p2++;
            } else {
                break;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2552
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py

    def same_group_or_not(self,x,y):
        return self.findroot(x) == self.findroot(y)

N,M = map(int,input().split())
un = UnionFind(N)
xyz = [list(map(int,input().split())) for i in range(M)]
for i in range(M):
    un.union(xyz[i][0]-1,xyz[i][1]-1)
ans = 0
for i in range(N):
    if un.findroot(i) == i:
        ans += 1

print(ans)

Measured memory_bytes: 32212
N, T = map(int, input().split())
ct = [list(map(int, input().split())) for _ in range(N)]
minC = 1001
for i, v in enumerate(ct):
  if v[1] <= T:
    if minC > v[0]:
      minC = v[0]
if minC > 1000:
    print("TLE")
else:
    print(minC)

Measured memory_bytes: 3060
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n =INT()
    a,c =LISTS()
    b = []
    for i in range(n):
        b.append(a[i])
        b.append(c[i])
    print(*b, sep='')
if __name__ == '__main__':
    do()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
//#pragma GCC optimize("O3")
//#pragma GCC target("sse4")
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))
 
#define SZ(a) (int)((a).size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
 
typedef long long LL;
typedef pair<int, int> PII;
 
const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = (LL)INF * INF;

const int MAX = 1 << 17;

PII p[MAX];

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	FOR(i, 0, n)
	{
		int x, l;
		cin >> x >> l;
		p[i] = MP(x + l, x - l);
	}
	sort(p, p + n);
	int last = -INF, ans = 0;
	FOR(i, 0, n)
	{
		if(p[i].second >= last)
		{
			ans++;
			last = p[i].first;
		}
	}
	cout << ans << "\n";
	return 0;
}


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

struct Disc {
  int x, y, r, on, id;
};

const int MAX_N = 24;
int N;
vector<Disc> vd[4];
char T[1<<MAX_N];

int isIntersect(const Disc &a, const Disc &b) {
  int dx = a.x - b.x;
  int dy = a.y - b.y;
  int sr = a.r + b.r;
  if(dx*dx+dy*dy == sr*sr) return 1;
  if(dx*dx+dy*dy < sr*sr) return 2;
  return 0;
}

char rec(int S) {
  if(T[S] == -1) {
    T[S] = 0;
    for(int i = 0; i < 4; ++i) {
      for(int j = 0; j < vd[i].size(); ++j) {
	if(S & (1<<vd[i][j].id)) continue;
	if((S & vd[i][j].on) != vd[i][j].on) continue;
	for(int k = j+1; k < vd[i].size(); ++k) {
	  if(S & (1<<vd[i][k].id)) continue;
	  if((S & vd[i][k].on) != vd[i][k].on) continue;
	  T[S] = max(T[S], (char)( rec(S | (1<<vd[i][j].id) | (1<<vd[i][k].id))+2 ));
	  /*
	  if(N - T[S] <= 1) {
	    for(int i = 0; i < N; ++i) {
	      cout << (bool)(S & 1<<i) << " ";
	    }
	    cout << endl;
	    return T[S];
	  }
	  */
	}
      }
    }
  }
  return T[S];
}

int main() {
  while(cin >> N && N) {
    int id = 0;
    for(int i = 0; i < 4; ++i) vd[i].clear();
    for(int i = 0; i < N; ++i) {
      Disc d;
      int c;
      cin >> d.x >> d.y >> d.r >> c;
      --c;
      d.id = id++;
      d.on = 0;
      for(int i = 0; i < 4; ++i) {
	for(int j = 0; j < vd[i].size(); ++j) {
	  if(isIntersect(d, vd[i][j]) == 2) d.on |= 1<<vd[i][j].id;
	}
      }
      vd[c].push_back(d);
    }
    fill(T, T+(1<<N), (char)(-1));
    cout << (int)rec(0) << endl;
  }
  return 0;
}

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

int n, k;
ll h[202020];

int main(){
  cin >> n >> k;
  rep(i, n) cin >> h[i];
  sort(h, h + n);
  reverse(h, h + n);
  rep(i, k) h[i] = 0;
  ll res = 0;
  rep(i, n) res += h[i];
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
            using namespace std;
            typedef long long ll;
            ll INF =1e9+7;
            typedef pair<ll,ll> ii;
            #define f(i,a,b) for(long long i = a;i < b;i++)
            #define rf(i,a,b) for(long long i=a;i>=b;i--)
            #define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
            #define w(t) while(t--)
            #define c(n); cin>>n;
            #define p(n) cout<<n;
            #define pl(n) cout<<n<<endl;
            #define ps(n); cout<<n<<" ";
            int main(void){
                fastio;
                ll t1,t2,a1,a2,b1,b2;
                c(t1);
                c(t2);
                c(a1);
                c(a2);
                c(b1);
                c(b2);
                ll ans=0;
                if(t1 * a1 + t2 * a2 == t1 * b1 + t2 * b2){
                    pl("infinity");
                    return 0;
                }
              	if(max(a1,b1) == a1 && t1 * a1 + t2 * a2 > t1 * b1 + t2 * b2){
                  pl(0);
                  return 0;
                }
              	if(max(a1,b1) == b1 && t1 * a1 + t2 * a2 < t1 * b1 + t2 * b2){
                  pl(0);
                  return 0;
                }
                ll t = 1;
                ll d = abs((t1 * a1 + t2 * a2) - (t1 * b1 + t2 * b2));
                ans = (t1 * abs(a1-b1))/d;
                if( (t1 * abs(a1-b1)) % d == 0){
                    t = 0;
                }
                pl(2*ans+t)
            }

Measured memory_bytes: 256
def main():
    import sys
    import bisect
    from itertools import accumulate

    m, d = map(int, input().split())
    if d < 22:
        print(0)
        return

    count = 0
    for i in range(22, d + 1):
        d1 = int(str(i)[1])
        d10 = int(str(i)[0])

        x = d1 * d10
        if 1 <= x <= m and d1 >= 2:
            count += 1
    print(count)


if __name__ == '__main__':
    main()


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

int main(){
    int n,m;
    while(true){
        cin >> n >> m;
        if(!n && !m) break;
        int ans = 0;
        for(int i=1;i<=n-2;++i){
            for(int j=i+1;j<=n-1;++j){
                for(int k=j+1;k<=n;++k){
                    if(i+k+j == m) ans++;
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3092
#include <stdio.h>
int main(void){
	int n,i,max=0,sum=0,L;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&L);
		sum += L;
		if(L>max){
			sum += max;
			max = L;
			sum -= max;
		}
	}
	if(max < sum)printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define pb push_back
#define SZ(x) ((ll).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repi(i, a, b) for(ll i = ll(a); i < ll(b); i++)
const double PI = acos(-1);
const int mod = 1e9+7;
const long long INF = (1LL << 60);
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}

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

  ll n;
  ll odd = 0;
  cin >> n;
  rep(i, n){
    ll a;
    cin >> a;
    if(a % 2 == 1) odd++;
  }
  if(odd % 2 == 1) cout << "NO" << endl;
  else cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
from sys import stdin


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


a, b, n = LI()
x = b - 1 if b - 1 <= n else n
print(int(a * x / b) - a * int(x / b))


Measured memory_bytes: 9124
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
#define ll long long
#define inf 1000000001
using namespace std;
#define N 2005
int n,k,Q,a[N],mi,top,b[N],ans;
int main(){
	scanf("%d%d%d",&n,&k,&Q);
	rep (i,1,n) scanf("%d",&a[i]);
	ans=inf;
	rep (i,1,n){
		mi=a[i];top=0;
		int st=1,ed=0;
		rep (j,1,n){
//			cerr<<st<<' '<<ed<<'\n';
			if (a[j]>=mi) ed++;
			if (a[j]<mi||j==n){
//				cerr<<st<<' '<<ed<<'\n';
				if (ed-st+1>=k){
//					cerr<<st<<' '<<ed<<'\n';
					int last=top;
					rep (l,st,ed) b[++top]=a[l];
					sort(&b[last+1],&b[top+1]);
					rep (x,1,k-1) top--;
				}
				st=j+1,ed=j;
			}
		}
//		rep (j,1,top) cerr<<b[j]<<' ';cerr<<'\n';
		if (top>=Q){
			sort(&b[1],&b[top+1]);
			int mx=b[Q];
			ans=min(ans,mx-mi);
		}
	}
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<unsigned char, unsigned char> pcc;
typedef pair<double, double> pdd;
typedef vector<vector<ll>> matrix;

// if x is a value and you have k, the next number is (kx)/(k-1) + 1

ll getNimber(ll n, ll k) {
  while(n%k && n > k) {
    // cout << n << " " << k << " " << n/k << endl;
    // want mid * k / (k-1) + 1 == n
    // want mid * k == (n-1) * (k-1)
    ll mid = (n-1) * (k-1) / k;
    if((mid * k) / (k-1) + 1 != n) mid++;
    ll decrement = n - mid;
    ll low = n / k * k;
    ll down = max(1LL, (n - low) / decrement);
    n -= down * decrement;
  }
  return n/k;
}

void solve() {
  int n;
  cin >> n;
  ll curr = 0;
  while(n--) {
    ll a, k;
    cin >> a >> k;
    curr ^= getNimber(a, k);
  }
  if(curr) cout << "Takahashi\n";
  else cout << "Aoki\n";
}

void casesolve() {
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ":" << "\n";
    solve();
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  // casesolve();
}


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

inline int read() {
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - 48; ch = getchar(); }
	return x * f;
}

const int N = 2020;
char s[N][N];
int dp[N][N][4];

int main() {
	int n = read(), m = read();
	for (int i = 0; i < n; i++) {
		scanf("%s", s[i]);
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (s[i][j] == '.') {
				dp[i][j][0] = dp[i][j][1] = 1;
				if (j > 0 && dp[i][j - 1][0] > 0) dp[i][j][0] = dp[i][j - 1][0] + 1;
				if (i > 0 && dp[i - 1][j][1] > 0) dp[i][j][1] = dp[i - 1][j][1] + 1;
			}
		}
	}
	for (int i = n - 1; i >= 0; i--) {
		for (int j = m - 1; j >= 0; j--) {
			if (s[i][j] == '.') {
				dp[i][j][2] = dp[i][j][3] = 1;
				if (j < m - 1 && dp[i][j + 1][2] > 0) dp[i][j][2] = dp[i][j + 1][2] + 1;
				if (i < n - 1 && dp[i + 1][j][3] > 0) dp[i][j][3] = dp[i + 1][j][3] + 1;
			}
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (s[i][j] == '#') continue;
			int temp = 1;
			for (int cnt = 0; cnt < 4; cnt++) temp += dp[i][j][cnt];
			ans = max(ans, temp - 4);
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 67968
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define RREP(i,a) for(int (i)=(a)-1;(i)>=0;(i)--)
#define FORR(i,a,b) for(int (i)=(a)-1;(i)>=(b);(i)--)
#define PI acos(-1.0)
#define DEBUG(C) cout<<C<<endl;
#define VI vector<int>
#define VII vector<VI>
#define VL vector<LL>
#define VLL vector<VL>
#define VD vector<double>
#define VDD vector<VD>
#define PII pair<int,int>
#define PDD pair<double,double>
#define PLL pair<LL,LL>
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort(ALL(a))
#define REVERSE(a) reverse(ALL(a))
#define MP make_pair
#define EP emplace_back
#define FORE(a,b) for(auto &&a:b)

using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int INF=1e9;
const int MOD=INF+7;

VI ans;
VL a;
LL N,L;
int p=-1;
int main (void){
    cin>>N>>L;
    a=VL(N+1,0);
    REP(i,N){
        cin>>a[i+1];
        if(i && p==-1){
            if(a[i]+a[i+1]>=L) p=i;
        }
    }
    if(p==-1){
        cout<<"Impossible"<<endl;
        return 0;
    }
    FOR(i,1,p) ans.emplace_back(i);
    FORR(i,N,p) ans.emplace_back(i);
    cout<<"Possible"<<endl;
    REP(i,ans.size()){
        cout<<ans[i]<<endl;
    }
}


Measured memory_bytes: 2168
from sys import stdin
# import sys
import math


def cmd(n, r):
    return math.factorial(n) // (math.factorial(n - r)*math.factorial(r))


def bts(cnt, A):
    if cnt == N:
        # K += 1
        # print(A)
        global ans
        temp = 0
        for i in range(Q):
            if A[b[i]-1]-A[a[i]-1] == c[i]:
                temp += d[i]
        if temp > ans:
            ans = temp
        # print(ans)
        return
    if len(A) == 0:
        x = 1
    else:
        x = A[-1]
    for i in range(x, M+1):
        # print(i)
        A.append(i)
        bts(cnt+1, A)
        for i in range(cnt, len(A)):
            A.pop()


N, M, Q = [int(x) for x in stdin.readline().rstrip().split()]
# N = [int(x) for x in stdin.readline().rstrip().split()]
# N = int(input())
# U = input().split()
# A, B = [str(x) for x in stdin.readline().rstrip().split()]
global a, b, c, d, ans
ans = 0
a = []
b = []
c = []
d = []
for i in range(Q):
    a1, b1, c1, d1 = [int(x) for x in stdin.readline().rstrip().split()]
    a.append(a1)
    b.append(b1)
    c.append(c1)
    d.append(d1)
global A
A = []
global K
K = 0
cnt = 0
# print(A[K][-1])
bts(cnt, A)
# print(A)
print(ans)


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

void main() {
  ulong[] NK = readln.chomp.split.to!(ulong[]);
  ulong N = NK[0],
        K = NK[1];
  
  writeln(K * (K-1)^^(N-1));
}


Measured memory_bytes: 256
from sys import stdin


def a(input_string):
    favorite_sound_fee ,my_money, count = [int(x) for x in input_string.split()]
    hear_count = 0
    while(hear_count < count and my_money >= favorite_sound_fee):
        my_money -= favorite_sound_fee
        hear_count += 1
    return hear_count


def main():
    input_line = stdin.readline().rstrip()
    answer = a(input_line)
    print(answer)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main(void){

    int a, b;
    cin >> a >> b;
    int n = b - a - 1;


    cout << ((n * (n + 1) ) / 2) - a << endl;

    return 0;
}

Measured memory_bytes: 256
s=input()
flag=True
n=len(s)
if s!=s[::-1]:
    flag=False
if s[:(n-1)//2]!="".join(list(reversed(s[:(n-1)//2]))):
    flag=False
if s[(n+3)//2-1:]!="".join(list(reversed(s[(n+3)//2-1:]))):
    flag=False
print("Yes" if flag else "No")

Measured memory_bytes: 3064
open Batteries
module EnumL = Enum.Labels
module ListL = List.Labels
module ArrayL = Array.Labels

let dbg0 x = Printf.eprintf "[debug]%s\n" @@ dump x
let dbg1 x = dbg0 x; x

let id = identity

let (++) n m = List.range n `To m
let (++-) n m = if n >= m then List.range n `Downto m else []
let (++^) n m = if n < m then List.range n `To (pred m) else []

module ModOp = struct
  let prime = 1_000_000_007
  let (-) a b = (a + prime - b) mod prime
  let (+) a b = (a + b) mod prime
  let ( * ) a b = (a * b) mod prime

  let rec pow x n =
    if n = 0 then 1
    else if n mod 2 = 0 then pow (x*x) (n/2)
    else x * pow (x*x) (n/2)
end

let scan fmt = Scanf.sscanf (read_line ()) fmt

let scan_lines n fmt f =
  if n = 0 then []
  else List.map (fun _ -> scan fmt f) (1 ++ n)

let scan_list ?sep cnv =
  let line = read_line () in
  (match sep with
   | None -> List.map String.of_char @@ String.to_list line
   | Some sep -> String.split_on_char sep line)
  |> List.map cnv

let scan_array ?sep cnv = Array.of_list @@ scan_list ?sep cnv

let scan_matrix n m e ?sep conv =
  let arr = Array.make_matrix n m e in
  ListL.iter (0 ++^ n)
    ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list ?sep conv);
  arr

let atoi c = Char.code c - Char.code '0'

let rec powerset = function
  | [] -> [[]]
  | hd::tl ->
    let pws =  powerset tl in
    pws @ ListL.map pws ~f:(fun pw -> hd::pw)

let permutations l =
  let rec interleave x = function
    | [] -> [[x]]
    | (hd::tl) as l ->
      (x::l) :: (interleave x tl |> ListL.map ~f:(fun l -> hd::l)) in
  let rec aux = function
    | [] -> [[]]
    | a::rest ->
      aux rest |> ListL.map ~f:(interleave a) |> List.concat in
  aux l

let intersection l =
  EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)

let zip l m =
  let n = min (List.length l) (List.length m) in
  List.combine (List.take n l) (List.take n m)

let lower_bound n f =
  let rec aux l u =
    if u - l > 1 then
      let m = (l + u) / 2 in
      if f m then aux l m
      else aux m u
    else u in aux (-1) n

let between n x m = n <= x && x < m

let n = scan "%d" id
let a = scan_array ~sep:' ' Int.of_string

let () =
  let h = Hashtbl.create n in
  ArrayL.iter a ~f:(fun i ->
      Hashtbl.modify_def 0 (pred i) succ h);
  ListL.iter (0++^n) ~f:(fun i ->
      Printf.printf "%d\n" @@ Hashtbl.find_default h i 0)


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

int main(){
  ll n,all=0;
  cin >> n;
  vector<ll>ans(1000005);
  for(int i=0; i<n; i++){
    ll a;
    cin >> a;
    ans[a]++;
    all+=a;
  }
  ll q;
  cin >> q;
  
  for(int i=0; i<q; i++){
    ll b,c;
    cin >> b >> c;
    all+=(c-b)*ans[b];
    ans[c]+=ans[b];
    ans[b]=0;
    
    cout << all << endl;
  }
  
  
  
  
    
    
  
  

}
  


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

struct edge{
  int s,t;
};

int N,sum=0;
string str;
vector<int> a[100];
vector<edge> A,B;

bool solve( vector<edge> &A ){
  int pos=0;
  vector<bool> used(A.size());
  for(int i=0;i<(int)A.size();i++){
    int id=-1;
    for(int j=0;j<(int)A.size();j++){
      if(used[j])continue;
      if(A[j].s<=pos){
        id=j;
        used[j]=true;
        pos+=A[j].t;
        break;
      }
    }
    if(id==-1)return false;
  }
  return true;
}

int main(){
  cin>>N;
  for(int i=0;i<N;i++){
    cin>>str;
    a[i].resize( str.size() + 1 );
    a[i][0]=0;
    int mini=0;
    for(int j=1;j<(int)a[i].size();j++){
      a[i][j]=a[i][j-1];
      if(str[j-1]=='(')a[i][j]++;
      else a[i][j]--;
      mini=min(mini,a[i][j]);
    }
    sum+=a[i].back();
    if(a[i].back()>0){
      A.push_back((edge){-mini,a[i].back()});
    }else{
      B.push_back((edge){-mini+a[i].back(),-a[i].back()});
    }
  }
  if(sum!=0){
    cout<<"No"<<endl;
    return 0;
  }
  if( solve(A) && solve(B) ){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}

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

using namespace std;

int main()
{
	int a, b;
    cin >> a >> b;
  if (a == b)
    cout << "Draw" << endl;
  else if (a == 1)
    cout << "Alice" << endl;
  else if (b == 1)
    cout << "Bob" << endl;
  else if(a > b)
    cout << "Alice" << endl;
  else if (a < b)
    cout << "Bob" << endl;
  
return 0;

}

Measured memory_bytes: 256
# from math import factorial,sqrt,ceil #,gcd
# from itertools import permutations,combinations,combinations_with_replacement
# from collections import deque,Counter
# from bisect import bisect_left
# from heapq import heappush,heappop
# from numba import njit
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from fractions import gcd

# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np    # numpy.lcm()
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb,perm #permはnPk
# import networkx as nx
# G = Graph()

# slist = "abcdefghijklmnopqrstuvwxyz"
X,Y = map(int,input().split())

for num in range(1,X+1):
    asi1 = num*4 + (X-num)*2
    asi2 = num*2 + (X-num)*4
    if asi1 == Y or asi2 == Y:
        print("Yes")
        exit()
    
print("No")
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


Measured memory_bytes: 9172
#include<stdio.h>
int main() {
  int a,b;
  //1≤a,b≤10000
  scanf("%d %d",&a,&b);
  if (!(1<=a && a<=10000) || !(1<=b && b<=10000)){
    printf("正しい数値を入力してください");
    return 0;
  }
  int goukei;
  goukei = a * b;
  int hantei;
  hantei = goukei % 2;
  if (hantei == 1){
    //奇数の場合
    printf("Odd");
    return 0;
  }else{
    //偶数の場合
    printf("Even");
  }
}

Measured memory_bytes: 128
#include<stdio.h>

int main(){
	int n, y, m, d, ans=0;
	int i, eto, mody, sho, modm;
	scanf("%d", &n);
	for(i=0;i<n;i++)
	{
		scanf("%d %d %d", &y, &m, &d);
		eto = (y - 1) / 3;
		mody = (y - 1) % 3;
		ans += eto * 590;
		ans += mody * 195;
		if(y%3 == 0)
		{
			ans += (m-1) * 20 + d;
		}
		else
		{
			sho = (m-1) / 2;
			modm = (m-1) % 2;
			ans += sho * 39;
			ans += modm * 20;
			ans += d;
		}
		printf("%d\n", 196471-ans);
		ans = 0;
	}
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define PP pair<P,P>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	random_device rnd;
	mt19937_64 mt64(rnd());
	uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt64);
}
/*--------Library Zone!--------*/


signed main() {
	int k, a, b; cin >> k >> a >> b;
	int ka = k - (a - 1);
	if (ka < 0)cout << 1 + k << endl;
	else if (ka % 2) {
		int ans = a;
		ans += max(0ll, (b - a) * (ka / 2)) + 1;
		cout << max(ans, 1 + k) << endl;
	}
	else {
		int ans = a;
		ans += max(0ll, (b - a) * (ka / 2));
		cout << max(ans, 1 + k) << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    
  int N = 5;
  vector<int> v(N);
  
  for(int i=0;i<N;i++){
    scanf("%d", &v[i]);
  }

  int S = accumulate(v.begin(), v.end(), 0);  
  printf("%d\n", 15-S);


  return 0;
}

Measured memory_bytes: 3716
#include<bits/stdc++.h>
using namespace std;
#define SZ(v) ((int)(v).size())
#define zero(v) memset(v,0,sizeof(v))
#define rep(i,n) for(int i=0;i<(n);i++)
#define foreach(it,c) for(__typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define all(v) (v).begin(),(v).end()
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
typedef long long ll;
typedef unsigned uint;
const int INF=0x3f3f3f3f;
const double EPS=1e-10;
typedef pair<int,int> pii;
int inline in(){int x=0,c;for(;(uint)((c=getchar())-'0')>=10;)
{if(c=='-')return -in();if(!~c)throw ~0;}do{x=(x<<3)+(x<<1)+(c-'0');}
while((uint)((c=getchar())-'0')<10);return x;}
int main(){
	char c;
	cin>>c;
	if(c>='a'&&c<='z')cout<<'a'<<endl;
	else cout<<'A'<<endl; 
	return 0;
}


Measured memory_bytes: 3628
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		Set<String> hinaSet = new HashSet<>();
		for(int i = 0; i< N; i++) {
			hinaSet.add(sc.next());
		}
		sc.close();

		if(hinaSet.size() == 3) {
			System.out.println("Three");
		}else {
			System.out.println("Four");
		}

	}

}


Measured memory_bytes: 21716
c11,c12,c13=map(int,input().split())
c21,c22,c23=map(int,input().split())
c31,c32,c33=map(int,input().split())
if c11+c22+c33 == c12+c23+c31 == c13+c21+c32:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 2940
use std::fs;
use std::io::{stdin, Read};
struct UnionFind {
    parents: Vec<usize>,
}
impl UnionFind {
    pub fn new(n: usize) -> Self {
        let par = (0..n).collect();
        UnionFind { parents: par }
    }
    pub fn root(&mut self, x: usize) -> usize {
        if self.parents[x] == x {
            return x;
        }
        let par = self.parents[x];
        self.parents[x] = self.root(par);
        self.parents[x]
    }
    pub fn union(&mut self, x: usize, y: usize) {
        let rx = self.root(x);
        let ry = self.root(y);
        if rx == ry {
            return;
        }
        self.parents[rx] = ry;
    }
    pub fn is_same(&mut self, x: usize, y: usize) -> bool {
        let rx = self.root(x);
        let ry = self.root(y);
        rx == ry
    }
}

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: expr) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    let (n, m) = parse!(it, 2);
    let x: Vec<usize> = parse!(it, n);
    let mut uf = UnionFind::new(n);
    let mut e: Vec<(usize, usize, usize)> = (0..m)
        .map(|_| {
            let (a, b, c): (usize, usize, usize) = parse!(it, 3);
            (a - 1, b - 1, c)
        })
        .collect::<Vec<_>>();
    e.sort_by_key(|&x| x.2);
    let mut weights = x.clone();
    let mut excludes = vec![0; n];
    for &(a, b, c) in e.iter() {
        let pa = uf.root(a);
        let pb = uf.root(b);
        if pa == pb {
            excludes[pa] += (weights[pa] < c) as usize
        } else {
            uf.union(pa, pb);
            let r = uf.root(pa);
            weights[r] = weights[pa] + weights[pb];
            excludes[r] = if weights[r] < c {
                excludes[pa] + excludes[pb] + 1
            } else {
                0
            };
        }
    }
    println!(
        "{}",
        (0..n)
            .filter(|&i| uf.root(i) == i)
            .map(|i| excludes[i])
            .sum::<usize>()
    );
}

fn test() {
    let mut f = fs::File::open("foo.txt").unwrap();
    let mut s = String::new();
    f.read_to_string(&mut s).unwrap();
    solve(&s);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_main() {
        test();
    }
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


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

using namespace std;


int main() {
    int n,m,X,Y;
    cin >> n >> m >> X >> Y;
    vector<int> x(n);
    vector<int> y(m);

    for(auto it = x.begin();it != x.end();it++){
        cin >> *it;
    }
    for(auto it = y.begin();it != y.end();it++){
        cin >> *it;
    }
    x.push_back(X);
    y.push_back(Y);
    sort(x.begin(),x.end());
    sort(y.begin(),y.end());
    
    if(x[x.size()-1] < y[0])  cout << "No War" << endl;
    else cout << "War" << endl;
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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; }



int n, k;
void solve(){
	cin >> n >> k;
	
	double ans = 0;
	for(int i = 1; i <= n; i++){
		int cnt = 0;
		for(int j = i; j < k; j*=2) cnt++;
		ans += pow(2, -cnt);
	}
	printf("%.10f\n", ans/n);
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

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

int main(){
    string n;
    cin >> n;
    int num=n.size();
    int sum=0;
    for(int i=0;i<num;i++){
        sum+=(n[i]-'0');
        sum%=9;
    }
    if(sum==0) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3752
#include <stdio.h>
#pragma warning (disable:4996)
//FILE *in = fopen("input.txt", "r"), *out = fopen("output.txt", "w");
FILE *in = stdin, *out = stdout;
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
#define INF 1e18
#define NM 20005
#define MOD 1000000000
#define FOR(i,n,m) for (int i=(n);i<=(m);i++)
#define si(n) fscanf(in,"%d",&n)
#define sd(n) fscanf(in,"%lf",&n)
typedef long long int ll;
int a[3][105], d[3][105];
int main(){
int n; si(n);
FOR (i,1,2) FOR (j,1,n){
si(a[i][j]);
d[i][j]=max(d[i-1][j],d[i][j-1])+a[i][j];
}
fprintf(out,"%d",d[2][n]);
return 0;
}

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

int N,A,B;
bool check(int n,vector<long long> h){
  long long zentai = (long long)B*n;
  vector<long long> nokori;
  for(int i=0;i<N;i++){
    h[i] -= zentai;
    if(h[i] > 0)
      nokori.push_back(h[i]);
  }
  if(nokori.size() == 0)return true;
  long long cnt = 0;
  for(int i=0;i<nokori.size();i++){
    cnt += (long long)ceil(1. * nokori[i] / (A-B));
  }
  if(cnt <= n)return true;
  return false;
}

int main(void) {
  cin >> N >> A >> B;
  vector<long long> h(N);
  for(int i=0;i<N;i++){
    cin >> h[i];
  }

  // 一番大きいのにAを打つ
  int low=0,hi=1e9,mid=0;
  while(hi > low+1) {
    mid = (low + hi)/2;
    if(check(mid,h)) {
      hi = mid;
    } else {
      low = mid;
    }
  }
  cout << low+1 << endl;

  return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	int t=a*100+b*10+c;
	if(t%4==0){
		cout<<"YES"<<endl;
	}
	else
	{
		cout<<"NO"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
# ContestName
# URL
import sys
#import numpy as np

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N = i2n()
    L = i2nn()
    L.sort()
    l1 = sum(L[:-1])
    l2 = L[-1]
    if l1 > l2:
        print('Yes')
    else:
        print('No')

main()


Measured memory_bytes: 38256
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		int ans = 0;
		if (a + w < b) {
			ans = b - (a + w);
		} else if (a >= b +w) {	
			ans = a - (b + w);
		} else {
			ans = 0;
		}
		
		System.out.println(ans);
		
	}
}

Measured memory_bytes: 21844
sx, sy, tx, ty = map(int, input().split())
dx = tx - sx
dy = ty - sy
print('U'*dy+'R'*dx+'U'+'L'*(dx+1)+'D'*(dy+1)+'R'*(dx+1)+'U'*dy+'R'+'D'*(dy+1)+'L'*(dx+1)+'U')

Measured memory_bytes: 3060
#include <iostream>
#include <ios>
#include <iomanip>
#include <vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <numeric>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

using namespace std;

int main(void){
  int x,y;
  cin >> x >> y;
  cout << (x + y/2);
  return 0;
}


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

//#define int long long
#define DBG 0
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

//?´???°????±??????? ????????????
vector<int> divisor(int x) {
	vector<int> ret;
	int i;
	for (i = 1; i*i < x; i++) {
		if (x%i)continue;
		ret.emplace_back(i);
		ret.emplace_back(x / i);
	}
	if (i*i == x)ret.emplace_back(i);
	return ret;
}

signed main() {
	int N; cin >> N;
	vector<int> S(N); rep(i, 0, N) { cin >> S[i]; }
	vector<int> d = divisor(N);
	sort(d.begin(), d.end());
	dumpc(d);
	rep(i, 0, d.size()) {
		bool f = true;
		int t = d[i];
		int k = N / d[i];
		rep(j, 0, t) {
			rep(l, 1, k) {
				dump(S[j])dump(S[j + l*t]);
				if (S[j] != S[j + l*t]) {
					j = INF;
					f = false;
					break;
				}
			}
		}
		if (f) {
			cout << N/d[i] << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>
int main()
{
    int a,i,n;
    scanf("%d%d",&n,&a);
    if(a==0)
        {
        if(n%500==0)
                {
                printf("Yes");
                }
        else
               {
                printf("No");
               }
        }
    else if(a>0 && a<=1000)
    {
        i=n%500;
        if(i<=a)
            {
            printf("Yes");
           }
        else
            {
            printf("No");
            }
    }
    return 0;
}


Measured memory_bytes: 1728
#include <iostream>
typedef long long ll;
using namespace std;

ll mod=1000000007;
const int SIZE=1000100;
ll fac[SIZE], finv[SIZE], inv[SIZE];
void COMinit(ll m){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2; i<SIZE; ++i){
        fac[i]=(fac[i-1]*i)%m;
        inv[i]=m-(inv[m%i]*(m/i))%m;
        finv[i]=(finv[i-1]*inv[i])%m;
    }
}
ll COM(int n, int k, ll m){
    if(n<k) return 0;
    if(n<0 || k<0) return 0;
    return (fac[n]*((finv[k]*finv[n-k])%m))%m;
}
ll modpow(ll a, ll b, ll m){
    ll res=1, p=0, now=a%m;
    b %= (m-1);
    for(int i=0; b>p; ++i){
        if(b&((ll) 1<<i)){
            res=(res*now)%m;
            p |= ((ll) 1<<i);
        }
        now=(now*now)%m;
    }
    return res;
}
ll modinv(ll a, ll m){
    return modpow(a, m-2, m);
}
ll moddiv(ll a, ll b, ll m){
    return (a*modinv(b, m))%m;
}


int main() {
	int N;
	cin >> N;
	COMinit(mod);
	ll ans=0;
	--N;
	for(int i=0; i<N; ++i){
		ll g=COM(N, i, mod), h=COM(i-1, N-i, mod);
		h=(g+mod-h)%mod;
		(ans += moddiv((fac[N]*h)%mod, g, mod)) %= mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 23680
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] a = new int[n];
        long max, min, sum = 0;
        ArrayList<Integer> z = new ArrayList<>();

        for (int i = 0; i < n; i++) {
            z.add(scan.nextInt());
            sum += z.get(i);
//            a[i] = scan.nextInt();
        }
        max = Collections.max(z);
        min = Collections.min(z);

//        max = a[0];
//        min = a[0];

        /*for (int num : a) {
            if (max < num) {
                max = num;
            } else if (min > num) {
                min = num;
            }
            sum += num;
        }*/
        System.out.println(min + " " + max + " " + sum);
    }
}

Measured memory_bytes: 42356
#include<stdio.h>

#define MAX 2000000

int H;
int A[MAX+1];
int i;

void maxHeapify(int i);
void swap(int *x,int *y);

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

  for(i=1;i<=H;i++)
    {
      scanf("%d",&A[i]);
    }

  for(i=H/2;i>=1;i--)
    {
      maxHeapify(i);
    }

  for(i=1;i<=H;i++)
    {
      printf(" %d",A[i]);
    }

  putchar('\n');

  return 0;
}

void swap(int *x,int *y)
{
  int tmp;

  tmp=*x;

  *x=*y;

  *y=tmp;
}
  

void maxHeapify(int i)
{
  int l,r,largest;
  
  l=2*i;
  
  r=2*i+1;

  if(A[l]>A[i]&&l<=H)
    {
      largest=l;
    }

  else
    {
      largest=i;
    }

  if(A[r]>A[largest]&&r<=H)
    {
      largest=r;
    }

  if(largest!=i)
    {
      swap(&A[i],&A[largest]);

      maxHeapify(largest);
    }

}



Measured memory_bytes: 3688
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
using namespace std;

int main() {

	string S;
	cin >> S;

	int Q;
	cin >> Q;

	int T, F;
	int jdgT = 0;
	string s_front = "";
	string s_back = "";
	string str;
	for (int i = 0; i < Q; i++) {
		cin >> T;
		if (T == 1) {
			jdgT = 1 + jdgT * (-1);
		}
		else {
			cin >> F >> str;
			F = F + jdgT * pow(-1, F / 2);
			if (F == 1) {
				s_front += str;
			}
			else {
				s_back += str;
			}
		}
	}

	if (jdgT == 1) {
		reverse(S.begin(), S.end());
		reverse(s_back.begin(), s_back.end());
		S = s_back + S + s_front;
	}
	else {
		reverse(s_front.begin(), s_front.end());
		S = s_front + S + s_back;
	}

	cout << S << endl;

	return 0;
}

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  while (cin >> n) {
    vector<int> a(n);
    each (i, a) cin >> i;

    int target = 0;
    map<int, int> m;
    each (i, a) {
      if (0) ;
      else if (i <=  399) ++m[0];
      else if (i <=  799) ++m[1];
      else if (i <= 1199) ++m[2];
      else if (i <= 1599) ++m[3];
      else if (i <= 1999) ++m[4];
      else if (i <= 2399) ++m[5];
      else if (i <= 2799) ++m[6];
      else if (i <= 3199) ++m[7];
      else ++target;
    }

    int mn = m.empty() ? 1 : m.size();
    int mx = m.size() + target;

    cout << mn << ' ' << mx << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256