akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   " << endl;
		for(int j=0; j<v[i].size(); j++){
			cout << v[i][j] << "   ";
		}
		cout << endl;
	}
}




int main(){//
	int H, N;
	cin >> H >> N;
	vector<int> A(N), B(N);
	for(int i=0; i<N; i++) cin >> A[i] >> B[i];

	const int H_MAX = 10000;
	const int B_MAX = 10000;
	const int INF = H_MAX*B_MAX+1;
	//dp[n][h]: 0~n-1番目までの魔法を考慮して体力hを減らすのに必要な最小魔力
	vector<vector<int>> dp(N+1, vector<int>(H+1, INF));
	dp[0][0] = 0;//魔法使わないで体力0を減らすのに必要な魔力は0
	for(int n=0; n<=N; n++) dp[n][0] = 0;

	//解1 //dp[n][h]: 魔法0~n-1番目まで考慮した時，体力h以下の敵を倒すのに必要な最小魔力
	//解2に(★)の行を足しただけで，　解2の最後のansを探すforループがいらなくなる
	for(int h=0; h<=H; h++){
		for(int n=0; n<N; n++){
			if(h<A[n]) dp[n+1][h] = min(dp[n+1][h], dp[n][0]+B[n]);//........(★)
			dp[n+1][h] = min(dp[n+1][h], dp[n][h]+0*B[n]);//魔法n番を使わない
			if(h+A[n] < (int)dp[0].size()) dp[n+1][h+A[n]] = min(dp[n+1][h+A[n]], dp[n][h] + B[n]);//魔法nを使う(1回目)
			if(h+A[n] < (int)dp[0].size()) dp[n+1][h+A[n]] = min(dp[n+1][h+A[n]], dp[n+1][h]+B[n]);//魔法nを使う(2回目以降)(1回目の時のh+A[n]が今回のhと等しくなる時に影響)
		}
	}
	cout << dp[N][H] << endl;

	//解2
	// // for(int n=0; n<N; n++){
	// // 	for(int h=0; h<=H+H_MAX; h++){
	// for(int h=0; h<H+H_MAX; h++){
	// 	for(int n=0; n<N; n++){
	// 		dp[n+1][h] = min(dp[n+1][h], dp[n][h]+0*B[n]);//魔法n番を使わない
	// 		if(h+A[n] < (int)dp[0].size()) dp[n+1][h+A[n]] = min(dp[n+1][h+A[n]], dp[n][h] + B[n]);//魔法nを使う(1回目)
	// 		if(h+A[n] < (int)dp[0].size()) dp[n+1][h+A[n]] = min(dp[n+1][h+A[n]], dp[n+1][h]+B[n]);//魔法nを使う(2回目以降)(1回目の時のh+A[n]が今回のhと等しくなる時に影響)
	// 	}
	// }
	// //print_vec2(dp);
	// int ans = INF;
	// for(int h=H; h<=H+H_MAX; h++){//答えは体力H以上削った場合の最小消費体力
	// 	ans = min(ans, dp[N][h]);
	// }
	// cout << ans << endl;

}


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

//短縮
#define rep(i,n) for(int i=0;i<(n);++i)
//sort()用
#define all(v) v.begin(), v.end()

#define PB(N) push_back(N)

using namespace std;

using Graph = vector<vector<int>>;

int main(){
  string S; cin >> S;
  cout << S.substr(0,3);
  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
//map<key,value>


int main(){
  int n,k;
  cin >> n;
  string s;
  cin >> s;
  cin >> k;
  for(int i=0;i<n;i++){
    if(s[i]!=s[k-1]){
      s[i]='*';
    }
  }
  cout << s;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
using ll = long long;
using vi = vector<int>;
using vl = vector<int>;
using Graph = vector<vector<int>>;  // int <=> ll
using P = pair<int, int>;  // int <=> ll
const int INFTY = 1e9+7;

int main() {
  // 1-indexed
  vector<bool> prime(1e5+1, true);
  vi like(1e5+1, 0);
  prime[1] = false;
  like[1] = 0;

  for (int i=2; i<=1e5; i++) {
    if (prime[i]) {
      for (int j=2*i; j<=1e5; j+=i) {
        prime[j] = false;
      }
    }
  }

  for (int i=3; i<=1e5; i+=2) {
    if (prime[i] && prime[(i+1)/2]) {
      like[i] = like[i-2] + 1;
    } else {
      like[i] = like[i-2];
    }
  }

  int Q;
  cin >> Q;
  rep(i,Q) {
    int l, r;
    cin >> l >> r;
    if (l != 1) l -= 2;
    cout << like[r] - like[l] << endl;
  }
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    string s;
    cin >> s;
    int ans = 0;
    int cur = 0;
    int u = 0;
    while (u < s.size()){
        if (s[u] == 'A'){
            cur++;
            u++;
            continue;
        }
        if (s[u] == 'C'){
            cur = 0;
            u++;
            continue;
        }
        if (u == s.size() - 1) break;
        if (s[u+1] != 'C'){
            cur = 0;
            u++;
            continue;
        }
        else{
            u += 2;
            ans += cur;
        }
    }
    cout << ans;
}


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

typedef long double ld;

const ld EPS = 1e-9;
const ld INF = 1e10;
const ld PI = M_PI;

struct Point{
  ld x, y;
  Point(ld x, ld y):x(x), y(y){}
  Point(){}
};

Point operator+(const Point &a, const Point &b){
  return Point(a.x + b.x, a.y + b.y);
}
Point operator-(const Point &a, const Point &b){
  return Point(a.x - b.x, a.y - b.y);
}
Point operator*(const Point &a, const ld b){
  return Point(a.x * b, a.y * b);
}
Point operator*(const Point &a, const Point &b){
  return Point(a.x*b.x-a.y*b.y, a.x*b.y+a.y*b.x);
}
Point operator/(const Point &a, const ld b){
  return Point(a.x / b, a.y / b);
}

ld cross(const Point &a, const Point &b){
  return a.x*b.y - a.y*b.x;
}

ld dot(const Point &a, const Point &b){
  return a.x*b.x + a.y*b.y;
}

ld norm(const Point &a){
  return dot(a, a);
}

struct Line:vector<Point>{
  Line(Point a = Point(0, 0), Point b = Point(0, 0)){
    this->push_back(a);
    this->push_back(b);
  }
};

typedef vector<Point> Polygon;

Point next(const Polygon &a, int x){
  return a[(x+1)%a.size()];
}

ld area(const Polygon &a){
  ld ret = 0.0;
  for(int i = 0 ; i < (int)a.size() ; i++){
    ret += cross(a[i], next(a, i));
  }
  return abs(ret) * .5;
}

int main(){  
  int q;
  cin >> q;
  Polygon poly;
  while(q--){
    Point p;
    cin >> p.x >> p.y;
    poly.push_back(p);
  }
  ld ans = area(poly);
  printf("%.1Lf\n", ans);
  
  return 0;
}

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

#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	int x;cin>>x;
	cout<<48-x;
	return 0;
}


Measured memory_bytes: 256
program main
implicit None
	integer(8)::n,p,q,i
	integer(8),allocatable::a(:)
	
	read*,n
	allocate(a(n))
	read*,a
	
	p = a(1)
	q = p
	
	do i = 1,n
		call euc(a(i),p,q)
		p = q
	enddo
	
	print"(i0)",p
	
end program main

subroutine euc(a1,b1,c)
implicit None
integer(8)::a1,b1,c,a,b
	! return GCD of a1 and b1 in c
	
	a = a1
	b = b1
	c = 1
	
	do while (a /=0 .and. b /= 0)
		if (a > b)then
			c = b
			a = mod(a,b)
			else
			c = a
			b = mod(b,a)
		endif
	enddo
end subroutine euc

Measured memory_bytes: 1536
#include <iostream>

using namespace std;

int main()
{
    char o,x;
    string s;
    cin >>s;
    if(s=="oxx" || s=="xox" || s=="xxo"){
        cout << 800;
    } else if (s=="xxx"){
    cout <<700;
    }else if(s=="oox" || s=="oxo" || s=="xoo"){
    cout <<900;
    }else {
    cout <<1000;}
    return 0;
}


Measured memory_bytes: 3596
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
using namespace std;
#define INF 100000000
#define MAXN 100010
typedef long long ll;

int n, q;
ll dat[MAXN*4];

void init(int n_) {
    n = 1;
    while (n < n_) n *= 2;
    for (int i = 0; i < 2*n-1; i++) dat[i] = 0;
}

void update(int k, int x) {
    k += n-1;
    dat[k] += x;
    while (k > 0) {
        k = (k-1)/2;
        dat[k] += x;
    }
}

ll getSum(int a, int b, int k, int l, int r) {
    if (r <= a || b <= l) return 0;
    if (a <= l && r <= b) return dat[k];
    ll sl = getSum(a, b, k*2+1, l, (l+r)/2);
    ll sr = getSum(a, b, k*2+2, (l+r)/2, r);
    return (sl+sr);
}

int main(void) {
    cin >> n >> q;
    init(n);
    for (int i = 0; i < q; i++) {
        int com, x, y;
        cin >> com >> x >> y;
        if (com == 0) {
            update(x-1, y);
        } else {
            cout << getSum(x-1, y, 0, 0, n) << endl;
        }
//        for (int i = 0; i < 2*n-1; i++) {
//            cout << dat[i] << endl;
//        }
    }
    return 0;
}

Measured memory_bytes: 3208
import operator

N, K = map(int, input().split())
A = list(map(int, input().split()))

k = [((K+1)&(1<<i))>>i for i in range(40)]

m = [0]*40
for i in range(40):
	c = sum([(a&(1<<i))>>i for a in A])
	m[i] = 0 if N<2*c else 1

f = 0
b = [1<<i for i in range(40)]
for i in range(40):
	if k[i]==1:
		x = sum(map(operator.mul, m[:i]+[0]+k[i+1:], b))
		f = max(f, sum([x^a for a in A]))

print(f)

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

const Int MOD = 1000000007;

Int modpow(Int a, Int n) {
    Int res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}


int main(){ 
  Int N, K;
  cin >> N >> K;

  vector<Int> cds(K+1,0), gcds(K+1,0);

  rep1(i,K) {
    Int q = K / i;
    cds[i] = modpow(q,N);
  }

  rep(i,K) {
    Int temp = cds[K-i];
    for (Int j = 2; j * (K-i) <= K; j++) {
      temp = (temp + MOD - gcds[j * (K-i)]) % MOD;
    }
    gcds[K-i] = temp;
  }

  Int ans = 0;

  rep1(i,K) {
    ans = (ans + (i * gcds[i] % MOD)) % MOD;
  }

  cout << ans << endl;

}

Measured memory_bytes: 4832
#include<stdio.h>
#include<string.h>
char s[101];
int main(void){
  	scanf("%s",s);
  int res = 0;
  int n = strlen(s);
  for(int i = 0; i < n; i++){
    if(s[i] != s[n - 1 - i]) res++;
  }
  printf("%d\n",res / 2);
  return 0;
}
      

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using namespace std;

int MOD = 1e9 + 7;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<long long> T(n),A(n);
	REP(i,n)cin >> T[i];
	REP(i,n)cin >> A[i];
	if(T[n-1] != A[0]){
		cout << 0 << endl;
		return 0;
	}
										
	long long ans = 1;
	REP(i,n){
		if((i && T[i] > T[i-1] && T[i] > A[i]) || (i != n-1 && A[i+1] > A[i] && A[i] > T[i])){
			ans = 0;
			break;
		}
		if(i && i != n-1){
			if(T[i] == T[i-1] && A[i] == A[i+1]){
				ans = (ans % MOD) * min(A[i],T[i]) % MOD;
			}
		}
	}
	cout << ans % MOD << endl;
  return 0;
}


Measured memory_bytes: 1792
"""
N rooms and M passages
"""

import sys

input = sys.stdin.readline

from collections import deque

def solve(n, m, g):
    visited = [0] * (n+1)
    prev = [0] * (n+1)

    deq = deque([0])
    visited[0] = 1
    visited_count = 1

    while deq:
        node = deq.popleft()

        for nb in g[node]:
            if not visited[nb]:
                visited[nb] = 1
                deq.append(nb)
                visited_count += 1
                prev[nb] = node + 1
    
    if visited_count == n:
        print("Yes")
        for node in range(1, n):
            print(prev[node])
    else:
        print("No")
            


n, m = map(int, input().split())
g = [[] for _ in range(n+1)]

for _ in range(m):
    a, b = map(lambda x: int(x) - 1, input().split())
    g[a].append(b)
    g[b].append(a)

solve(n, m, g)
    


Measured memory_bytes: 92652
import os
from io import BytesIO, IOBase
import sys
def main():
    n = int(input())
    a = []
    for i in range(n):
        a.append(list(map(int, input().split())))
    b=max(a,key=lambda x:x[0]+x[1])
    c=min(a,key=lambda x:x[0]+x[1])
    ma=abs(b[0]+b[1]-(c[0]+c[1]))
    b=max(a,key=lambda x:x[0]-x[1])
    c=max(a,key=lambda x:x[1]-x[0])
    ma=max(ma,abs(b[0]+c[1]-(c[0]+b[1])))
    print(ma)
# region fastio
BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == "__main__":
    main()

Measured memory_bytes: 49500
#include <bits/stdc++.h>
#define LL long long
using namespace std;

const int maxn = 2e5 + 10;
int n, a[maxn], c[maxn];

int main()
{
    scanf("%d", &n);
    for(int i = 1; i <= n; i ++)
        scanf("%d", &a[i]), c[i] = a[i];
    sort(c + 1, c + 1 + n);
    for(int i = 1; i <= n; i ++)
        if(a[i] <= c[n / 2])
            printf("%d\n", c[n / 2 + 1]);
        else
            printf("%d\n", c[n / 2]);

    return 0;
}


Measured memory_bytes: 3712
#include "bits/stdc++.h"
using namespace std;
int main() {
	long long X; cin >> X;
	for (int i = -130; i <= 130; i++) {
		for (int j = -130; j <= 130; j++) {
			long long num = i - j;
			long long num2 = (i * i * i * i) + (i * i * i * j) + (i * i * j * j) + (i * j * j * j) + (j * j * j * j);
			if (num * num2 == X) {
				cout << i << ' ' << j << endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 3624
#include <iostream>
#define rep(i, n) for(int i=0; i<n; i++)
using namespace std;

int main(){
  int N;
  long long x;
  cin >> N >> x;
  long long a[N];
  rep(i, N)
    cin >> a[i];
  //ここまで入力

  long long ans = 0;

  //まずはxまですべて値を下げる
  rep(i, N)
    if(a[i] > x){
      ans += (a[i]-x);
      a[i] = x;
    }

  long long sum;
  for(int i=1; i<N; i++){
    sum = a[i-1]+a[i];
    //二項間の和の超過分を計算していく
    //二項のうち，右側を書き換えていく
    if(sum > x){
      ans += (sum-x);
      a[i] -= (sum-x);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
constexpr int inf=1e9+7;
constexpr ll longinf=1LL<<60 ;
constexpr ll mod=998244353 ;


vector<ll> inv,fact,invfact;
void mod_build(int n=101010){
    fact.resize(n+1);
    inv.resize(n+1);
    invfact.resize(n+1);
    fact[0]=inv[0]=invfact[0]=1;
    inv[1]=1;
    rep(i,n){
        fact[i+1]=fact[i]*(i+1)%mod;
        if(i>0)inv[i+1]=mod-inv[mod%(i+1)]*(mod/(i+1))%mod;
        invfact[i+1]=invfact[i]*inv[i+1]%mod;
    }
}
ll perm(int n,int k){
    if(n<0||k<0||k>n)return 0;
    return fact[n]*invfact[n-k]%mod;
}
ll comb(int n,int k){
    if(n<0||k<0||k>n)return 0;
    return (fact[n]*invfact[n-k]%mod)*invfact[k]%mod;
}
ll powmod(ll n,ll k){
    k%=mod-1;
    if(k<0)k+=mod-1;
    ll ret=1;
    while(k){
        if(k&1)ret=ret*n%mod;
        n=n*n%mod;
        k>>=1;
    }
    return ret;
}

ll dp[555][555][2];
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    mod_build();
    int n,x;
    cin>>n>>x;
    dp[0][0][0]=1;
    rep(i,x+1){
       rep(j,512)rep(k,512)dp[j][k][(i+1)%2]=0;
       rep(j,512)rep(k,512){
           dp[j][k][(i+1)%2]+=dp[j][k][i%2];
           if(dp[j][k][(i+1)%2]>=mod)dp[j][k][(i+1)%2]-=mod;
           dp[j+1][k^i][(i+1)%2]+=dp[j][k][i%2];
           if(dp[j+1][k^i][(i+1)%2]>=mod)dp[j][k][(i+1)%2]-=mod;
       }
    }
    ll ans = 0;
    rep(i,n+1){
        int res = n-i;
        if(res%2)continue;
        res/=2;
        ans += comb(x+res,res)*dp[i][x][(x+1)%2]%mod;
    }
    cout<<ans%mod<<endl;
    return 0;
}


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

int main()
{
    int s,w;
    cin >> s >> w;
    if( s <= w )
    {
        cout << "unsafe" << endl;
    }
    else{
        cout << "safe" << endl;
    }
    return 0;
}



Measured memory_bytes: 3640
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

long gcd(long a, long b){
	long t;
	if(a<b){t=b; b=a; a=t;}
	t=a%b;
	while(t!=0){
		a=b;
		b=t;
		t=a%b;
	}
	return b;
}

long lcm(long a, long b){
	return a/gcd(a, b)*b;
}

int main(void){
	int n, i;
	scanf("%d", &n);
	long a=1;
	for(i=0; i<n; i++){
		long t;
		scanf("%ld", &t);
		a=lcm(a, t);
	}
	printf("%ld\n", a);
}


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

using namespace std;

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

int paper_u[500][500],paper_n[500][500];
int n2c_u[1000000],n2c_n[1000000],n2r_u[1000000],n2r_n[1000000];
int cscore_u[500],cscore_n[500],rscore_u[500],rscore_n[500];
int d1score_u=0,d1score_n=0,d2score_u=0,d2score_n=0;
int sum_u=0,sum_n=0;

int main(){

  int n,u,v,m;
  cin >> n >> u >> v >> m;
  rep(i,1000000){
    n2c_u[i]=-1;
    n2c_n[i]=-1;
    n2r_u[i]=-1;
    n2r_n[i]=-1;
  }
  rep(i,n)rep(j,n){
    cin >> paper_u[i][j];
    paper_u[i][j]--;
    n2c_u[paper_u[i][j]] = i;
    n2r_u[paper_u[i][j]] = j;
  }
  rep(i,n)rep(j,n){
    cin>>paper_n[i][j];
    paper_n[i][j]--;
    n2c_n[paper_n[i][j]] = i;
    n2r_n[paper_n[i][j]] = j;
  }
  int flag=0;
  rep(i,m){
    if(flag)break;
    int card;
    cin >> card;
    card--;
    if (n2c_u[card]>=0){
      cscore_u[n2c_u[card]]++;
      if (cscore_u[n2c_u[card]]==n)sum_u++;
      if (n2c_u[card]==n2r_u[card]&&n>=2){
        d1score_u++;
        if (d1score_u==n)sum_u++;
      }
      if (n2c_u[card]+n2r_u[card]==n-1&&n>=2){
        d2score_u++;
        if (d2score_u==n)sum_u++;
      }
    }
    if (n2c_n[card]>=0){
      cscore_n[n2c_n[card]]++;
      if (cscore_n[n2c_n[card]]==n)sum_n++;
      if (n2c_n[card]==n2r_n[card]&&n>=2){
        d1score_n++;
        if (d1score_n==n)sum_n++;
      }
      if (n2c_n[card]+n2r_n[card]==n-1&&n>=2){
        d2score_n++;
        if (d2score_n==n)sum_n++;
      }
    }
    if (n2r_u[card]>=0&&n>=2){
      rscore_u[n2r_u[card]]++;
      if (rscore_u[n2r_u[card]]==n)sum_u++;
    }
    if (n2r_n[card]>=0&&n>=2){
      rscore_n[n2r_n[card]]++;
      if (rscore_n[n2r_n[card]]==n)sum_n++;
    }
    if (sum_u>=u){
      if (sum_n>=v){
        cout << "DRAW" << endl;
        flag = 1;
      } else {
        cout << "USAGI" << endl;
        flag = 1;
      }
    } else if (sum_n>=v){
      cout << "NEKO" << endl;
      flag = 1;
    }
  }
  if (!flag)cout << "DRAW" << endl;


  return 0;
}



Measured memory_bytes: 20176
#include<iostream>
#include<algorithm>
#define int long long
using namespace std;

int N, M, ans, X[100010], Y[100010];

signed main()
{
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		cin >> X[i];
	}
	sort(X, X + M);
	for (int i = 0; i < M-1; i++) {
		Y[i] = X[i + 1] - X[i];
	}
	sort(Y, Y + M - 1);
	if (N >= M) {
		cout << 0 << endl;
		return 0;
	}
	for (int i = 0; i < M - N; i++) {
		ans += Y[i];
	}
	cout << ans << endl;
	//system("pause");

    return 0;
}


Measured memory_bytes: 1792
////////////////////////////////////////////
///                                      ///
///         Template ver. 1 rapel        ///
/// Fear is Temporary, Regret is Forever ///
///          Must Try and Get AC         ///
///                                      ///
////////////////////////////////////////////
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <iomanip>

#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>

#include <math.h>
#include <complex>

#include <assert.h>
#include <time.h>
//#include <chrono>
//#include <random>

#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <bitset>

#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define endl '\n'
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

void desperate_optimization(int precision){
  	ios_base::sync_with_stdio(false);
  	cin.tie(0);
  	cout.tie(0);
  	cout.setf(ios::fixed);
  	cout.setf(ios::showpoint);
  	cout.precision(precision);
}

const LL MOD = 1e9 + 7;
const int N = 50;

struct matrix {
	LL arr[N + 5][N + 5];
};

LL n,k;

matrix mulmat(matrix A, matrix B) {
	matrix C;
	for(int i = 0;i < n;i++) {
		for(int j = 0;j < n;j++) {
			C.arr[i][j] = 0;
			for(int k = 0;k < n;k++) {
				C.arr[i][j] = (C.arr[i][j] + A.arr[i][k] * B.arr[k][j]) % MOD;
			}
		}
	}
	return C;
}

void hora(int tc) {
	matrix base, ans;
	cin>>n>>k;
	for(int i = 0;i < n;i++) {
		for(int j = 0;j < n;j++) {
			cin>>base.arr[i][j];
			ans.arr[i][j] = (i == j);
		}
	}
	while(k) {
		if(k & 1) ans = mulmat(ans,base);
		base = mulmat(base, base);
		k /= 2;
	}
	LL tot = 0;
	for(int i = 0;i < n;i++) {
		for(int j = 0;j < n;j++) {
			tot = (tot + ans.arr[i][j]) % MOD;
		}
	}
	cout<<tot<<endl;
}

int main(){
	desperate_optimization(10);
	int ntc = 1;
	//cin>>ntc;
	for(int tc = 1;tc <= ntc;tc++) hora(tc);
	return 0;
}



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

int AdjM[51]={0};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    int s,t;
    while(cin>>s>>t){
        if(s!=0){
            AdjM[s-1]+=1;
            AdjM[t-1]+=1;
        }
        else{
            AdjM[0]+=1;
            AdjM[1]+=1;
            
            string output="OK";
            
            for(int i=0;i<51;++i){
                if(AdjM[i]%2!=0){
                    output="NG";
                    break;    
                }
            }

            cout<<output<<"\n";
            
            Fill(AdjM,0);
        }
    }
}

Measured memory_bytes: 2948
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a), i##_max = (b); i < i##_max; ++i)
#define RFOR(i, a, b) for (int i = (b)-1, i##_min = (a); i >= i##_min; --i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define RREP(i, n) for (int i = (n)-1; i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()

using namespace std;
using vi = vector<int>;
using vd = vector<double>;
using i64 = int64_t;

constexpr int INF = 1 << 30;
constexpr int MOD = 1000000007;

template <typename T>
void print(vector<T> &v) {
  REP(i, v.size()) {
    if (i) cout << " ";
    cout << v[i];
  }
  cout << endl;
}

template <typename T>
std::vector<T> enum_div(T n) {
  std::vector<T> ret;
  for (T i = 1; i * i <= n; ++i) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i != 1 && i * i != n) {
        ret.push_back(n / i);
      }
    }
  }
  return ret;
}

int main() {
  i64 n, ans = 0;
  cin >> n;
  vector<i64> v = enum_div(n);
  for (auto a : v) {
    auto m = n / a - 1;
    if (a < m) {
      ans += m;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <map>
#include <queue>

using namespace std;

int main() {
  map<int, int> m;
  priority_queue<pair<int, int> > que;
  int n;
  while (cin >> n) {
    m[n]++;
  }
  for (map<int, int>::iterator it = m.begin(); it != m.end(); it++) {
    que.push(pair<int, int>(it->second, it->first));
  }
  priority_queue<int, vector<int>, greater<int> > result;
  pair<int, int> maxi = que.top(); que.pop();
  result.push(maxi.second);
  while (!que.empty()) {
    pair<int, int> n = que.top(); que.pop();
    if (maxi.first == n.first) {
      result.push(n.second);
    } else {
      break;
    }
  }
  while (!result.empty()) {
    cout << result.top() << endl;
    result.pop();
  }

  return 0;
}

Measured memory_bytes: 0
use proconio::input;

fn calc(start: usize, end: usize, v: &Vec<(i64, i64)>) -> Vec<(i64, i64)> {
    let mut res = Vec::new();
    let mut val = Vec::new();
    let mut idx = start;
    while idx > end {
        val.push(v[idx-1]);
        idx /= 2;
    }
    for i in 0..1<<val.len() {
        let mut sv = 0;
        let mut sw = 0;
        for j in 0..val.len() {
            if i&(1<<j) != 0 {
                sv += val[j].0;
                sw += val[j].1;
            }
        }
        res.push((sw, sv));
    }
    res.sort();
    for i in 1..res.len() {
        res[i].1 = std::cmp::max(res[i].1, res[i-1].1);
    }
    res
}

fn main() {
    input! {
        n : usize,
        v : [(i64, i64); n],
        q : usize,
        query : [(usize, i64); q]
    };
    let thr = 2048;
    let mut first = Vec::new();
    for i in 0..std::cmp::min(thr, n) {
        first.push(calc(i+1, 0, &v));
    }
    for &t in &query {
        let mut res = 0;
        if t.0 <= thr {
            for &r in &first[t.0-1] {
                if r.0 > t.1 { continue }
                res = std::cmp::max(res, r.1);
            }
        } else {
            let second = calc(t.0, thr, &v);
            let mut par = t.0;
            while par > thr { par /= 2; }
            par -= 1;
            let mut idx0 = 0;
            let mut idx1 = second.len() - 1;
            while idx0 < first[par].len() && idx1 < second.len() {
                if first[par][idx0].0 + second[idx1].0 <= t.1 {
                    res = std::cmp::max(res, first[par][idx0].1 + second[idx1].1);
                    idx0 += 1;
                } else {
                    idx1 = idx1.wrapping_add(!0);
                }
            }
        }
        println!("{}", res);
    }
}


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

int main() {
  
  string N;
  cin >> N;
  
  bool flag=false;
  
  for(int i; i<N.size()-1; i++){
  	if(N.at(i)==N.at(i+1)){
    	flag=true;
    }
  }
  
  if( flag ){ cout << "Bad" << endl; }
  else{ cout << "Good" << endl; }
  

}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  ll a,b;cin>>a>>b;
  ll ans;
  if(a>=13)ans=b;
  else if(a>=6)ans=b/2;
  else ans=0;
  cout<<ans<<endl;
}

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

#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

const long long int MOD = 1000000007LL;

long long int kansu( long long int x, long long int n ) {
    long long int cnt = x;
    long long int ans = 1;
    while( n > 0 ) {
        if ( ( n % 2 ) == 1 ) {
            ans *= cnt;
            ans %= MOD;
        }
        n /= 2;
        cnt *= cnt;
        cnt %= MOD;
    }
    return ans;
}

int main() {

    long long int n, k;
    cin >> n >> k;

    long long int ans = 0;
    long long int cnt[114514] = {};
    for ( long long int p = k; p >= 1; p-- ) {
        long long int x = k / p;
        cnt[p] = kansu( x, n );
//        cout << " " << x << "^" << n << " = " << cnt[p] << endl;
        for ( long long int i = 2; i <= x; i++ ) {
            cnt[p] -= cnt[p*i];
            if ( cnt[p] < 0 ) cnt[p] += MOD;
        }
        long long int c = ( cnt[p] * p ) % MOD;
//        cout << c << endl;
        ans += c;
        ans %= MOD;
    }

    cout << ans << endl;

    return 0;

}


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

typedef long long ll;

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

int main() {
  int n, x;
  cin >> n >> x;
  vector<ll> a(n);
  vector<ll> b(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = abs(a[i] - x);
  }
  if (n == 1) {
    cout << b[0] << endl;
    return 0;
  }
  sort(b.rbegin(), b.rend());
  ll g = gcd(b[0], b[1]);
  for (int i = 0; i < n; i++) {
    g = gcd(g, b[i]);
  }
  cout << g << endl;
  return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
using namespace std;
#define rep(i,x) for(int i=0;i<x;i++)
#define rrep1(i,x) for(int i=x;i>0;i--)

const int INF=1000000000;

int main(){
	int n;
	int t[10010];
	
	scanf("%d",&n);
	rep(i,n-1){
		scanf("%d",&t[i]);
	}
	
	int dp[2][5010];
	rep(i,2)rep(j,5010)dp[i][j] = INF;
	dp[0][1] = 0;
	
	rep(i,n-1){
		rrep1(j,n/2){
			dp[1][j] = min ( dp[0][j] + t[i] , dp[1][j] );
			dp[0][j] = min ( dp[0][j-1] , dp[1][j-1] + t[i] );
		}
	}
	
	printf("%d\n",min ( dp[0][n/2] , dp[1][n/2] ) );
}

Measured memory_bytes: 1252
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>

using namespace std;

int main(int argc, char const *argv[]) {
	int N,C,tempi;
	std::cin >> N >> C;
	int stc[N][3];
	for (size_t i = 0; i < N; i++) {
		std::cin >> stc[i][0] >> stc[i][1] >> stc[i][2];
	}
	// 終了時刻の検索
	int finish = -1;
	for (size_t i = 0; i < N; i++) {
		finish = max(finish, stc[i][1]);
	}
	// チャンネルの録画時間
	int channel[C][finish+1];
	// 初期化
	for (size_t i = 0; i < C; i++) {
		for (size_t j = 0; j < finish + 1; j++) {
			channel[i][j] = 0;
		}
	}

	// 加算
	for (size_t i = 0; i < N; i++) {
		for (size_t j = stc[i][0]; j < stc[i][1]+1; j++) {
			channel[stc[i][2]-1][j] = 1;
		}
	}

	// 合計
	int sum[finish+1];
	// 初期化
	for (size_t i = 0; i < finish+1; i++) {
		sum[i] = 0;
	}
	// 合計
	for (size_t i = 0; i < finish+1; i++) {
		for (size_t j = 0; j < C; j++) {
			sum[i] += channel[j][i];
		}
	}

	int ans = 0;
	for (size_t i = 0; i < finish+1; i++) {
		ans = max(ans, sum[i]);
	}
	std::cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 13568
import java.util.*;

public class Main{
    static final long bairitsu = 100000000L;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long result = 0;
        for(int i=0; i<N; i++) {
            String val = sc.next();
            String type = sc.next();
            switch(type) {
                case "JPY":
                    long l_tmp = Long.parseLong(val);
                    result += l_tmp * bairitsu;
                    break;
                case "BTC":
                    double d_tmp = Double.parseDouble(val);
                    long hoge = (long)(d_tmp * bairitsu * 380000L);
                    result += hoge;
                    break;
            }
        }
        double f_result = ((double)result) / bairitsu;
        System.out.println(f_result);
    }
}

Measured memory_bytes: 21460
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) *b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////



int main() {
	ll N;
	cin >> N;

	ll ans = 0;

	for (ll x = 1; x*(x + 2) <= N; x++) {
		if (N%x == 0) {
			ans += N / x - 1;
		}
	}

	cout << ans;

	system("PAUSE");
}


Measured memory_bytes: 504
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int n, s[], ave;
		int i;
		int max, min;
		Scanner sc = new Scanner(System.in);
		while (true) {
			n = sc.nextInt();
			if (n == 0) {
				break;
			}
			s = new int[n];
			max = 0;
			min = 0;
			ave = 0;
			for (i = 0; i < n; ++i) {
				s[i] = sc.nextInt();
				if (s[max] < s[i]) {
					max = i;
				}
				if (s[min] > s[i]) {
					min = i;
				}
				ave += s[i];
			}
			ave -= s[max] + s[min];
			ave /= (n - 2);
			System.out.println(ave);
		}
		sc.close();
	}

}


Measured memory_bytes: 28292
#include <stdio.h>
#include <stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))

ll coef[100010];
ll cons[100010];

int a[100010];
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
 
	rep(i,1,n+1)scanf("%d",a+i);
		
	rep(i,1,n){
		//a[i],a[i+1]に操作
		int l=a[i],r=a[i+1];
		if(r<l)r+=m;
		if(r-l<=1)continue;
		if(r>m){
			ll con=-a[i]-1;
			coef[l+2]++;
			coef[m+1]--;
			cons[l+2]+=con;
			cons[m+1]-=con;
			con+=m;
			coef[1]++;
			coef[r-m+1]--;
			cons[1]+=con;
			cons[r-m+1]-=con;			
		}else{
			ll con=-a[i]-1;
			coef[l+2]++;
			coef[r+1]--;
			cons[l+2]+=con;
			cons[r+1]-=con;
		}
	}
	rep(i,1,m+1){
		coef[i]+=coef[i-1];
		cons[i]+=cons[i-1];
	}

	ll otoku=0;
	rep(i,1,m+1){
		ll t=coef[i]*i+cons[i];
		otoku=max(otoku,t);
	}
	
	ll sum=0;
	rep(i,1,n)sum+=(a[i+1]-a[i]+m)%m;
	
	printf("%lld\n",sum-otoku);
	return 0;
}

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

int n, m;
int x[100][100] = {0}, a[100][2] = {0};
int v[100] = {1};

void dfs(int p) {
  v[p] = 0;
  for (int i = 1; i <= n; i++) {
    if (v[i] == 1 && x[p][i] == 1) {
      dfs(i);
    }
  }
}

bool check() {
  bool flag = false;
  for (int i = 1; i <= n; i++) {
    if (v[i] == 1) {
      flag = true;
    }
  }
  return flag;
}

int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int p, q;
    cin >> p >> q;
    x[p][q] = 1;
    x[q][p] = 1;
    a[i][0] = p;
    a[i][1] = q;
  }
  int ans = 0;
  for (int i = 0; i < m; i++) {
    x[a[i][0]][a[i][1]] = 0;
    x[a[i][1]][a[i][0]] = 0;
    for (int i = 1; i <= n; i++) {
      v[i] = 1;
    }
    dfs(1);
    if (check()) {
      ans++;
    }
    x[a[i][0]][a[i][1]] = 1;
    x[a[i][1]][a[i][0]] = 1;
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
    string s,t;
    cin >> t;
    s = t;
    int cnt1=0;
    for(int i=0; i<s.size()-1; i++){
        if(s[i] == s[i+1]) {
            cnt1++;
          if(cnt1 == 1) {
            if(s[i] == '1') {
                s[i] = '0';
            }else{
                s[i] = '1';
            }
            if(cnt1 == 1) cnt1 += i;         
          }else{
            if(s[i+1] == '1') {
                s[i+1] = '0';
            }else{
                s[i+1] = '1';
            }          
          }
        }
    }
    
    s = t;
    int cnt2=0;
    for(int i=0; i<s.size()-1; i++){
        if(s[i] == s[i+1]) {
            cnt2++;
            if(s[i+1] == '1') {
                s[i+1] = '0';
            }else{
                s[i+1] = '1';
            }
        } 
    }
    cout <<min(cnt1, cnt2)<<endl;
}

Measured memory_bytes: 512
import sys
input = sys.stdin.readline

import heapq

def main(): 

    X,Y,Z,K = map(int,input().split())
    
    A=list(map(int,input().split()))
    B=list(map(int,input().split()))
    C=list(map(int,input().split()))
    
    AB = []
    for i in range(X):
        for j in range(Y):
            AB.append(A[i]+B[j])
    AB.sort(reverse=True)
    ABC=[]
    for i in range(min(K,len(AB))):
        for j in range(Z):
            ABC.append(AB[i]+C[j])
    ABC.sort(reverse=True)
    for i in range(K):
        print(ABC[i])


        


if __name__ == "__main__":
    main()
    

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

int main()
{
	int N;
	cin >> N;
	vector<int> A(N), C(N-1);
	int ans = 0;
	
	for (int i = 0; i < N; ++i) cin >> A[i];
	for (int i = 0; i < N; ++i)
	{
		int b;
		cin >> b;
		ans += b;
	}
	for (int i = 0; i < N-1; ++i) cin >> C[i];
	
	int last = A[0];
	for (int i = 1; i < N; ++i)
	{
		if (A[i] - last == 1)
			ans += C[last - 1];
		last = A[i];
	}
	
	cout << ans << '\n';
}


Measured memory_bytes: 256
tmp = list(map(int, input().split()))
h = tmp[0]
w = tmp[1] 

s = ['None'] * (h + 1)
for i in range(h):
  s[i] = input()
  s[i] = s[i] + '#'
s[h] = '#' * w

ans = 0

sta = -1
cnt = 0
pt = [[0] * w for i in range(h)]
for i in range(h):
  for j in range(w+1):
    if s[i][j] == '#':
      if sta != -1:
        for k in range(sta, j):
          pt[i][k] = cnt
      cnt = 0
      sta = -1
    else:
      if sta == -1:
        sta = j
      cnt += 1

for i in range(w):
  for j in range(h+1):
    if s[j][i] == '#':
      if sta != -1:
        for k in range(sta, j):
          pt[k][i] += cnt - 1
          if pt[k][i] > ans:
            ans = pt[k][i]
      cnt = 0
      sta = -1
    else:
      if sta == -1:
        sta = j
      cnt += 1

print(ans)

Measured memory_bytes: 98264
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author toshibablack
 */

#include <algorithm>
#include <cctype>
#include <cmath>
#include <fstream>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define ll long long int
#define REP(i, n) for(int i=0;i<n;++i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) out << (x) << endl;

using namespace std;


class BAcCepted {
public:
    string S;
    string ans = "AC";

    void solve(std::istream& in, std::ostream& out) {
        in >> S;
        if (S[0] != 'A') ans = "WA";
        ll cnt = 0;
        for (int i = 2; i <= S.length() - 2; i++) if (S[i] == 'C') cnt++;
        if (cnt != 1) ans = "WA";
        REP(i, S.length()) {
            if (isupper(S[i]) && i != 0 && S[i] != 'C') ans = "WA";
        }
        DUMP(ans);
    }
};


int main() {
    BAcCepted solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int xa,ya,xb,yb,xc,yc,wx,wy,r;

int crosscheck(int tx,int ty,int sx,int sy,int wx,int wy,int rr,int type){

	int abx=sx-tx,aby=sy-ty;
	int awx=wx-tx,awy=wy-ty;
	int bwx=wx-sx,bwy=wy-sy;

	int rr2=rr*rr;
	int aw2=awx*awx+awy*awy;
	int bw2=bwx*bwx+bwy*bwy;
	int ab2=abx*abx+aby*aby;

	int tim=abx*awy-aby*awx;
	int abw=abx*awx+aby*awy;

	if(aw2<rr2 && bw2<rr2)return 0;
	if(aw2<rr2 || bw2<rr2)return 1;
	if(type==0 && tim*tim/ab2 >= (double)rr2)return 0;
	if(type==1 && tim*tim/ab2 != (double)rr2)return 0;
	if(abw<0)return 0;
	if(abw>ab2)return 0;
	return 1;
}

int main(){
	while(scanf("%d %d",&xa,&ya)*xa){
		scanf("%d %d %d %d %d %d %d",&xb,&yb,&xc,&yc,&wx,&wy,&r);

		int ttt=0;

		int d1=(xa-wx)*(xa-wx)+(ya-wy)*(ya-wy)-r*r;
		int d2=(xb-wx)*(xb-wx)+(yb-wy)*(yb-wy)-r*r;
		int d3=(xc-wx)*(xc-wx)+(yc-wy)*(yc-wy)-r*r;
		int tim1=(wx-xa)*(yb-ya)-(wy-ya)*(xb-xa);
		int tim2=(wx-xb)*(yc-yb)-(wy-yb)*(xc-xb);
		int tim3=(wx-xc)*(ya-yc)-(wy-yc)*(xa-xc);

		if (tim1*tim2>0 && tim2*tim3>0) ttt=1;

		if(d1<=0 && d2<=0 && d3<=0){printf("b\n");continue;}
		if(d1==0 || d2==0 || d3==0){printf("c\n");continue;}

		if(crosscheck(xa,ya,xb,yb,wx,wy,r,0)){printf("c\n");continue;}
		else if(crosscheck(xb,yb,xc,yc,wx,wy,r,0)){printf("c\n");continue;}
		else if(crosscheck(xc,yc,xa,ya,wx,wy,r,0)){printf("c\n");continue;}

		if(ttt==1){printf("a\n");continue;}

		if(crosscheck(xa,ya,xb,yb,wx,wy,r,1)){printf("c\n");continue;}
		else if(crosscheck(xb,yb,xc,yc,wx,wy,r,1)){printf("c\n");continue;}
		else if(crosscheck(xc,yc,xa,ya,wx,wy,r,1)){printf("c\n");continue;}
		
		printf("d\n");

	}
	return 0;
}

Measured memory_bytes: 584
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        int n = sc.nextInt();
        
        int big = 0;
        int small = 0;
        if (h > w) {
            big = h;
            small = w;
        } else {
            big = w;
            small = h;
        }
        
        for (int i = 0; i <= small; i++) {
            int num = big * i;
            if (num >= n) {
                System.out.println(i);
                return;
            }
        }
        
    }
}


Measured memory_bytes: 21972
S = input()

dic = {}

for i in S:

    dic[i] = 1

if len(dic) == 4:
    print ("Yes")

elif len(dic) == 2 and (("N" in dic and "S" in dic) or ("W" in dic and "E" in dic)) :
    print ("Yes")

else:
    print ("No")


Measured memory_bytes: 2940
inputs = [input() for i in range(2)]
n = int(inputs[0])
a = map(lambda x: int(x), inputs[1].split(" "))

b = {}
for i in a:
  if i not in b:
    b[i] = 1
  else:
    b[i] += 1
count = 0
for k in b.keys():
  tmp = k - b[k]
  if tmp > 0:
    count += b[k]
  else:
    count += -tmp


print(count)

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

typedef long long ll;
const int dx[]={1,-1,0,0};
const int dy[]={0,0,1,-1};
const int MAXN=7e6+10;
const int MAXM=505;
const int INF=10000000;
const int mod=1e9+7;

int n;

int main(){
    scanf("%d",&n);
    int t=0,px=0,py=0;
    int tag=1;
    for(int i=1;i<=n;i++){
        int a,b,c; scanf("%d%d%d",&a,&b,&c);
        int tmp=abs(b-px)+abs(c-py);
        if (tmp>a-t) tag=0;
        else{
            if ((a-t-tmp)%2==1) tag=0;
        }
        px=b; py=c; t=a;
    }
    if (tag==1) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <algorithm>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
#define rep(i,n)	for(int i=0;i<n;i++)
#define srep(i,a,n)	for(int i=a;i<n;i++)
#define REP(i,n)	for(int i=0;i<=n;i++)
#define rrep(i,n)	for(int i=n-1;i>=0;i--)
#define mp(a,b)	make_pair(a,b)
#define fst	first
#define scn second

const ll mod = 1e9 + 7;
const ld eps = 1e-9;

ll dp[100010];

int main() {
	int n, t;	cin >> n >> t;
	int ret = 0, s = 0, e = 0;
	rep(i, n) {
		int c;	cin >> c;
		if (c <= e)	e = c + t;
		else {
			ret += e - s;
			s = c;
			e = c + t;
		}
	}
	ret += e - s;
	cout << ret << endl;
	return 0;
}

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

NO = "IMPOSSIBLE"  # type: str


def solve(A: int, B: int):
    small = min(A,B)
    big = max(A,B)
    diff = big - small
    if diff % 2 == 0:
        print(int(small+diff/2))
    else:
        print(NO)


# 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():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }


int main() {
	IOS;
	int n;
	cin >> n;
	string s;
	cin >> s;
	if (n % 2 == 1) {
		put("No");
		return 0;
	}
	REP(i, n / 2) {
		if (s[i] != s[i + n / 2]) {
			put("No");
			return 0;
		}
	}
	put("Yes");
	return 0;
}


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

typedef long long int ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;

#define endl '\n'
#define ff first
#define ss second
#define int long long
#define pb push_back
#define f(i,l,r) for(ll i=l;i<=r;i++)
#define rf(i,r,l) for(ll i=r;i>=l;i--)
#define Max 5000001
#define inf 2147483647
#define llinf 9223372036854775807
#define all(v) v.begin(),v.end()
#define bp(n) __builtin_popcountll(n)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

#define d0(a) cout<<a<<' ';
#define d1(a) cout<<a<<endl;
#define d2(a,b) cout<<a<<' '<<b<<endl;
#define d3(a,b,c) cout<<a<<' '<<b<<' '<<c<<endl;
#define d4(a,b,c,d) cout<<a<<' '<<b<<' '<<c<<' '<<d<<endl;
#define d5(a,b,c,d,e) cout<<a<<' '<<b<<' '<<c<<' '<<d<<' '<<e<<endl;
#define d6(a,b,c,d,e,f) cout<<a<<' '<<b<<' '<<c<<' '<<d<<' '<<e<<' '<<f<<endl;

const ll N=2e5+5,mod=1e9+7,bit=61;



signed main()
{
    fast;

    ll t=1;
    //cin>>t;
    while(t--)
    {
        ll n,m;
        cin>>n>>m;
        ll s=0;
        f(i,1,m)
        {
            ll x;
            cin>>x;
            s+=x;
        }
        if(s>n)
        {
            cout<<-1<<endl;
        }
        else
        {
            cout<<n-s<<endl;
        }
    }
    return 0;
}


















Measured memory_bytes: 3652
# -*- coding: utf-8 -*-

n, k = map(int, input().split())
P = [int(i) for i in input().split()]

if k == 1:
    m = max(P)
    print((m+1)/2)

else:
    Pa = [(1+h)/2 for h in P]
    if n == k:
        print(sum(Pa))
    else:
        sm = sum(Pa[:k])
        r_ind = k-1
        r_res = k-1
        l_ind = 0
        l_res = 0
        s = sm
        while r_ind < n - 1:
            right = Pa[r_ind + 1]
            left = Pa[l_ind]
            s += right
            s -= left
            if sm < s:
                sm = s
                l_res = l_ind
                r_res = r_ind
            r_ind += 1
            l_ind += 1

        m = 0
        for f in Pa[l_res+1:r_res+2]:
            m += f

        print(m)

Measured memory_bytes: 75912