akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 998244353;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
 
signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	string S;
	cin >> N >> S;
	int R{}, G{}, B{};
	int ans = 1;
	for(int i=2;i<=N;i++){
		ans *= i;
		ans %= MOD;
	}
	int num = 2;
	int tmp = INF;
	if(S[0] == 'B') ++B;
	if(S[0] == 'R') ++R;
	if(S[0] == 'G') ++G;
	for(int i=1;i<N*3;i++){
		if(S[i] == 'B'){
			++B;
			if(B > R && B > G){
				ans *= B - max(R, G);
			}
			else if(B <= R && B <= G) B += 0;
			else{
				ans *= B - min(R, G);
			}
		}
		if(S[i] == 'R'){
			++R;
			if(R > B && R > G){
				ans *= R - max(B, G);
			}
			else if(R <= B && R <= G) B += 0;
			else{
				ans *= R - min(B, G);
			}
		}
		if(S[i] == 'G'){
			++G;
			if(G > R && G > B){
				ans *= G - max(R, B);
			}
			else if(G <= R && G <= B) B += 0;
			else{
				ans *= G - min(R, B);
			}
		}
		ans %= MOD;
	}
	cout << ans << endl;
}

Measured memory_bytes: 720
#include <cmath>
#include <iostream>
#include <vector>

using namespace std;

void eratosthenes(vector<bool> &num, long long n) {
  num[0] = false;
  num[1] = false;
  for (int i = 2; i <= n; i++) {
    num[i] = true;
  }

  long long p = 2;
  while (p < sqrt(n)) {
    num[p] = true;
    for (int i = p + 1; i <= n; i++) {
      if (i % p == 0) {
        num[i] = false;
      }
    }

    p++;
    while (num[p] == false) {
      p++;
    }
  }
}

int main(int argc, char const *argv[]) {
  int Q;
  cin >> Q;

  vector<int> l(Q);
  vector<int> r(Q);
  int r_max = 0;

  for (int i = 0; i < Q; i++) {
    cin >> l[i] >> r[i];
    r_max = r_max > r[i] ? r_max : r[i];
  }

  vector<bool> prime(r_max + 1);
  vector<long long> sim(r_max + 1);
  eratosthenes(prime, r_max);

  sim[0] = 0;
  for (int i = 1; i < r_max + 1; i++) {
    sim[i] = sim[i - 1] + (prime[i] && prime[(i + 1) / 2] ? 1 : 0);
  }

  for (int i = 0; i < Q; i++) {
    cout << sim[r[i]] - sim[l[i] - 1] << "\n";
  }

  return 0;
}


Measured memory_bytes: 2176
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


signed main(){
    int n;
    string s;
	cin >> n;
	cin >> s;
	ll a = 0;
	ll b = s.length()-1;
	ll cnt = 0;
    
	while(a <= b){
        
		if(s[a] == 'W' && s[b] == 'R'){
            cnt++;
            swap(s[a], s[b]);
        } else if(s[a] == 'W') {
            b--;
        } else if(s[b] == 'R') {
            a++;
        } else {
			a++;
            b--;
		}
        
	}
	mes(cnt);
}


Measured memory_bytes: 3760
#include <bits/stdc++.h>
#define INF 10000000
using namespace std;
int main()
{
  int n, m;
  while(cin >> n >> m, n | m) {
    vector<int> A(n + 1, 0);
    vector<int> B(n + 1, 0);
    int x, k, p;
    for(int i = 0; i < m; i++) {
      cin >> x >> k;
      for(int j = 0; j < k; j++) {
	cin >> p;
	p--;
	if(k == 1) A[p] += x;
	B[p] += x;
      }
    }
    int max_p = -1;
    int min_p = INF;
    for(int i = 0; i < n; i++) {
      if(B[i] > max_p && A[i] < min_p && min_p != INF){
	max_p = max(max_p, B[i]);
	continue;
      }
      max_p = max(max_p, B[i]);
      min_p = min(min_p, A[i]);
    }
    //cout << max_p << " " << min_p << endl;
    int ans = max_p - min_p + 1;
    cout << ans << endl;
    //for(int i = 0; i < n; i++)
    //  cout << B[i] << " ";
    //cout << endl;
  }
  return 0;
}



Measured memory_bytes: 3140
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

const int MAXN = 1024 * 512;

bool p[MAXN] = {1,1};

int main()
{
	REP(MAXN)if(!p[i])for(int j=i*2;j<MAXN;j+=i)p[j] = 1;

	int n;
	while(cin >> n && n)
	{
		int ans = 0;
		REP(n / 2 + 1) ans += !p[i] & !p[n - i];
		cout << ans << endl;

	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

struct Node{
	int location;
	int p,left,right;
};

struct Point{
	Point(){
		id = x = y = 0;
	}

	Point(int arg_id,int arg_x,int arg_y){
		id = arg_id;
		x = arg_x;
		y = arg_y;
	}
	bool operator < (const Point & arg)const{
		return id < arg.id;
	}
	void print(){
		printf("%d\n",id);
	}
	int id,x,y;
};

static const int MAX = 1000000;
static const int NIL = -1;

int N;
Point P[MAX];
Node T[MAX];
int number;

bool lessX(const Point &p1, const Point &p2) {return p1.x < p2.x; }
bool lessY(const Point &p1, const Point &p2) {return p1.y < p2.y; }

int makeKDTree(int left,int right, int depth){

	if(!(left < right))return NIL;

	int mid = (left+right)/2;

	int node_id = number++;

	if(depth%2 == 0){
		sort(P+left,P+right,lessX);
	}else{
		sort(P+left,P+right,lessY);
	}

	T[node_id].location = mid;
	T[node_id].left = makeKDTree(left,mid,depth+1);
	T[node_id].right = makeKDTree(mid+1,right,depth+1);

	return node_id;
}

void find(int node_id,int sx,int tx,int sy,int ty, int depth, vector<Point> &ans){

	int x = P[T[node_id].location].x;
	int y = P[T[node_id].location].y;

	if(sx <= x && x <= tx && sy <= y && y <= ty){
		ans.push_back(P[T[node_id].location]);
	}

	if(depth%2 == 0){
		if(T[node_id].left != NIL){
			if(sx <= x)find(T[node_id].left,sx,tx,sy,ty,depth+1,ans);
		}
		if(T[node_id].right != NIL){
			if( x <= tx)find(T[node_id].right,sx,tx,sy,ty,depth+1,ans);
		}
	}else{
		if(T[node_id].left != NIL){
			if(sy <= y)find(T[node_id].left,sx,tx,sy,ty,depth+1,ans);
		}
		if(T[node_id].right != NIL){
			if(y <= ty)find(T[node_id].right,sx,tx,sy,ty,depth+1,ans);
		}
	}
}


int main(){

	int x,y;
	scanf("%d",&N);
	for(int i = 0; i < N; i++){
		scanf("%d %d",&x,&y);
		P[i] = Point(i,x,y);
		T[i].left = T[i].right = T[i].p = NIL;
	}

	number = 0;

	int root = makeKDTree(0,N,0);

	int q;
	scanf("%d",&q);
	int sx,tx,sy,ty;
	vector<Point> ans;
	for(int i = 0; i < q; i++){
		scanf("%d %d %d %d",&sx,&tx,&sy,&ty);
		ans.clear();
		find(root,sx,tx,sy,ty,0,ans);
		sort(ans.begin(),ans.end());
		for(int j = 0; j < ans.size(); j++){
			ans[j].print();
		}
		printf("\n");
	}
	return 0;
}



Measured memory_bytes: 22468
import sys

input=sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()


def II(): return int(input())


def MI(): return map(int,input().split())


def MF(): return map(float,input().split())


def LI(): return list(map(int,input().split()))


def LF(): return list(map(float,input().split()))


def TI(): return tuple(map(int,input().split()))


# rstrip().decode('utf-8')

def main():
	n,m,k=MI()
	mod=998244353
	
	f=[1]
	for i in range(1,2*10**5+100):
		f.append((f[-1]*i)%mod)
	finv=[]
	for i in f:
		finv.append(pow(i,mod-2,mod))
	
	mp=[1]
	for i in range(1,2*10**5+100):
		mp.append((mp[-1]*(m-1))%mod)
		
	
	ans=0
	for kk in range(k+1):
		cnt=f[n-1]*finv[kk]*finv[n-1-kk]
		cnt%mod
		cnt*=m*mp[n-kk-1]
		ans+=cnt
		ans%mod
	print(ans%mod)













if __name__=="__main__":
	main()


Measured memory_bytes: 32864
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, n) for (int i = 0; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;

struct edge {
    int to;
    int id;
};

int N;
vector<vector<edge>> G;
vector<int> ans;

void dfs(int n, int p = 0, int bc = 0) {
    int nowColor = 1;
    rep(i, G[n].size()) {
        if(G[n][i].to == p) continue;
        if (nowColor == bc) nowColor++;
	    ans[G[n][i].id] = nowColor;
        dfs(G[n][i].to, n, nowColor);
        nowColor++;
    }
}

int main() {
    cin >> N;
    G.resize(N);
    ans.resize(N);

    rep(i, N - 1) {
        int from, to;
        cin >> from >> to;
        from--;
        to--;
        G[from].push_back({to, i});
    }
    dfs(0);

    int mx =0;
    rep(i,N-1) mx = max(mx,ans[i]);
    cout << mx << endl;
    rep(i,N-1){
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 8320
fun main(args: Array<String>) {
  val (A, B, M) = readInts()
  val AA = readInts()
  val BB = readInts()

  var min = AA.min()!! + BB.min()!!
  repeat(M) {
    val (X, Y, C) = readInts()
    val v = AA[X - 1] + BB[Y - 1] - C
    min = Math.min(min, v)
  }
  println(min)
}

fun readString() = readLine()!!
fun readStrings() = readString().split(" ")
fun readInt() = readString().toInt()
fun readInts() = readStrings().map(Integer::parseInt)
fun readLong() = readString().toLong()
fun readLongs() = readStrings().map { it.toLong() }


Measured memory_bytes: 87984
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};




int main(){
    double l;cin >> l;
    cout << setprecision(30) << fixed << l * l * l / 27 << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(raw_input())
a = map(int,raw_input().split(' '))

nswap=0
for i in range(n):
    min_v = a[i]
    min_p = i
    for j in range(i,n):
        if min_v > a[j]:
            min_v = a[j]
            min_p = j
    if min_p != i:
        a[i],a[min_p]=a[min_p],a[i]
        nswap+=1

print ' '.join([str(v) for v in a])
print nswap

Measured memory_bytes: 6356
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <deque>
using ll = long long;
using namespace std;

int main(){
    char a, b;
    cin >> a >> b;
    if((a=='H' && b=='H')||(a=='D' && b=='D')) cout << 'H' << endl;
    else cout << 'D' << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))
num = 0


def calc(l, r):
    mi = float('inf')
    i = -1
    if l + 1 == r:
        return H[l]
    if l == r:
        return 0
    for j in range(l, r):
        if mi > H[j]:
            mi = H[j]
            i = j

    for j in range(l, r):
        H[j] -= mi

    return calc(l, i) + calc(i + 1, r) + mi


print(calc(0, N))

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

int main()
{
    int x,n,i,d=0,ans=1;
    cin>>n>>x;
    int a[n];
    for(i=0;i<n;i++)
     {
         cin>>a[i];
         d+=a[i];
         if(d<=x)
            ans++;
     }
     cout<<ans;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int x = sc.nextInt();
        long ans = 0;
        Integer A[] = new Integer[N];
        for (int j=0; j<N; j++) {
            A[j] = sc.nextInt();
        }
      
        for (int i=0;i<N-1;i++){
         if (A[i]+ A[i+1] > x){
           ans += A[i]+A[i+1]-x;
           A[i+1] =Math.max(0,x-A[i]);
        }
        }   
          
       System.out.println(ans);
    }
}


Measured memory_bytes: 61412
n, m, k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

total = 0
count = 0
flag = n-1
for i in range(n):
    total += a[i]
    if total > k:
        total -= a[i]
        flag = i-1
        break
    count += 1
ans = count
for i in range(m):
    if b[i] > k:
        break
    total += b[i]
    count += 1
    while total > k:
        if flag == -1:
            break
        else:
            total -= a[flag]
            flag -= 1
            count -= 1
    if total > k: 
        break
    ans = max(ans, count)

total = 0
count = 0
flag = m-1
for i in range(m):
    total += b[i]
    if total > k:
        total -= b[i]
        flag = i-1
        break
    count += 1
for i in range(n):
    if a[i] > k:
        break
    total += a[i]
    count += 1
    while total > k:
        if flag == -1:
            break
        else:
            total -= b[flag]
            flag -= 1
            count -= 1
    if total > k: 
        break
    ans = max(ans, count)


print(ans)

Measured memory_bytes: 40804
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <deque>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const int MOD = 1000000007;
int main(){
	int n,z,w;
	cin >> n >> z >> w;
	vector<int> a(n);
	for(int i = 0;i < n;i++)cin >> a[i];

	if(n == 1){
		cout << abs(a[0] - w) << endl;
	}
	else{
		cout << max(abs(w-a[n-1]),abs(a[n-1] - a[n-2])) << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
typedef long long ll;
typedef pair<int,int> pii;
#define Rep(i,a,b) for(register int i=(a);i<=int(b);++i)
#define Dep(i,a,b) for(register int i=(a);i>=int(b);--i)
#define rep(i,a,b) for(register int i=(a);i<int(b);++i)
#define mem(x,v) memset(x,v,sizeof(x))
/*inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}*/
#define gc getchar
#define pc putchar
#define fi first
#define se second
#define debug(x) cout << #x" = " << x << endl;
#define pp(x,y) cout << "pp: " << x << " " << y << endl;
#define rank __RANK
inline ll read(){
	register ll x=0,f=1;register char c=gc();
	for(;!isdigit(c);c=gc())if(c=='-')f=-1;
	for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
	return x*f;
}

#define rd read
void write(ll x){if(x<0)x=-x,pc('-');if(x>=10)write(x/10);putchar(x%10+'0');}
void writeln(ll x){write(x);puts("");}
int n,cnt;
vector<int> V;
int main(){
    n=rd();
    rep(i,0,n){
    	int x = rd();
    	V.push_back(x);
    	if(V.size()>0 && V[i-1]==x) cnt++,V[i]=0;
	}
	writeln(cnt);
    return 0;
}


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

#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

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

const int N = 2e5 + 5;

int A[N];

int main() {

	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int n, ans = 0; cin >> n;
	for (int i = 0; i < n; i++) cin >> A[i], A[i] = (A[i] == i + 1);
	for (int i = 0; i < n; i = i += 1 + A[i]) ans += A[i], A[i + 1] *= !A[i];
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 640
import math
N=int(input())
def F(a,b):
  return(max(len(str(a)),len(str(b))))
d=int(math.sqrt(N))
m=1000000007
for i in range(1,d+1):
  if N%i!=0: continue
  m=min(m,F(i,N//i))
print(m)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
const int MAX = 22;
int n, ans = 0;
struct node {
	int x, y;
}point[MAX];
node line[MAX];
int vis[MAX] = { 0 };
int getNum() {
	int cnt = 0;
	int u = n / 2;
	for (int i = 0; i < u - 1; i++) {
		for (int j = i + 1; j < u; j++) {
			if (line[i].x * line[j].y == line[i].y * line[j].x) cnt++;
		}
	}
	return cnt;
}
void dfs(int num, int sum) {
	if (sum == n / 2) {
		ans = max(ans, getNum());
		return;
	}
	if (vis[num]) dfs(num + 1, sum);
	else {
		for (int i = 0; i < n; i++) {
			if (vis[i] == 1 || i == num) continue;
			vis[i] = 1;
			vis[num] = 1;
			line[sum].x = point[i].x - point[num].x;
			line[sum].y = point[i].y - point[num].y;
			dfs(num + 1, sum + 1);
			vis[i] = 0;
			vis[num] = 0;
		}
	}
}
int main()
{
	cin >> n;
	for (int i = 0; i < n; i++) cin >> point[i].x >> point[i].y;
	dfs(0, 0);
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
int main(){
  int r;
  cin>>r;
  if(r<1200){
    cout<<"ABC"<<'\n';
  }
  if(r>=1200 && r<2800){
    cout<<"ARC"<<'\n';
  }
  if(r>=2800){
    cout<<"AGC"<<'\n';
  }
  return 0;
}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Data.List

main = do
  [a, b, c, d] <- map (read::String -> Integer) . words <$> getLine
  let gcd = calcGcd c d
      lcm = (c * d) `div` gcd
      a_num = (a - 1) `div` c + (a - 1) `div` d - (a - 1) `div` lcm
      b_num = b `div` c + b `div` d - b `div` lcm
  print $ b - a + 1 - b_num + a_num

calcGcd::Integer -> Integer -> Integer
calcGcd x y
 | x < y = calcGcd y x
 | x `mod` y == 0 = y
 | otherwise = calcGcd y (x `mod` y)

Measured memory_bytes: 508
function main(input) {
  input = input.trim();
  const a = input.split(' ');
  
  if(a[0]=='H' && a[1]=='H'){
    console.log('H');
  }else if(a[0]=='H' && a[1]=='D'){
     console.log('D');
  }else if(a[0]=='D' && a[1]=='H'){
     console.log('D');
  }else if(a[0]=='D' && a[1]=='D'){
     console.log('H');
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 29564
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			double d = sc.nextDouble();
			if(d<0) break;
			if(d>=256){
				System.out.println("NA");
			}else{
				StringBuffer sb = new StringBuffer();
				String s = Integer.toBinaryString((int)d);
				for(int i=0;i<8-s.length();i++) sb.append("0");
				sb.append(s);
				sb.append(".");
				
				double e = d-(int)d;
				double f = 1.0;
				for(int i=0;i<4;i++){
					f/=2;
					if(e>=f){
						sb.append("1");
						e-=f;
					}else{
						sb.append("0");
					}
				}
				if(e==0) System.out.println(sb);
				else System.out.println("NA");
			}
	
		}
	}	
}

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

int main()
{
	int a[100];
	int n;
	int count=1;
	int flag;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(int i=1;i<n;i++)
	{
		flag=1;
		for(int j=0;j<i;j++)
		{
			if(a[j]>a[i]) flag=0;
		}
		if(flag==1) count++;
	}
	cout<<count;
	return 0;
}

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

int main() {
	int n,a,o=0;
	cin >> n;
	set<int> b;
	for(int i = 0;i < n;i++)
	{
		cin >> a;
		if(a / 400 > 7)
		{
			o++;
		}
		else
		{
			b.insert(a / 400);
		}
	}
	int c = b.size();
	int mn = max(1,c);
    cout << mn << ' ' << c + o << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;



int main() {

  int n;
  cin >> n;

  vi a(n);

  int sum = 0;

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

  int m;
  cin >> m;

  vi d(m);

  int b, c;

  for (int i = 0; i < m; ++i) {
    scanf("%d%d", &b, &c);
    d[i] = sum - a[b - 1] + c;
  }

  for (int i = 0; i < m; ++i) {
    cout << d[i] << endl;
  }

  return 0;
}




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

using namespace std;

int main()
{
	string s,t;
	cin >> s >> t;
	set<string> ans;

	for(int i=0;i<s.size()-t.size()+1;i++)
	{
		bool flag=true;
		for(int j=0;j<t.size();j++)
		{
			if(s[i+j]!=t[j] and s[i+j]!='?')flag=false;
		}
		if(flag)
		{
			string tmp="";
			for(int j=0;j<s.size();j++)
			{
				if(s[j]!='?')
					tmp+=s[j];
				else
				{
					if(j>=i and i+t.size()>j)tmp+=t[j-i];
					else tmp+='a';
				}
			}
			ans.insert(tmp);
		}
	}


	if(ans.size()==0)cout << "UNRESTORABLE" << endl;
	else cout << *ans.begin() << endl;


	
}

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

using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    
    int X[M];
    for(int i=0; i<M; i++) {
        cin >> X[i];
    }
    
    sort(X, X+M);
    
    int dist[M-1];
    long long int sum=0;
    for(int i=0; i<M-1; i++) {
        dist[i] = X[i+1] - X[i];
        sum += dist[i];
    }
    
    sort(dist, dist+M-1, greater<int>());
    for(int i=0; i<min(N-1, M-1); i++) {
        sum -= dist[i];
    }
    
    cout << sum << endl;

    return 0;
    
}

Measured memory_bytes: 1024
import java.util.*;

public class Main{

    static class Pair {
        long a,b;
        public Pair(long a,long b) {
            this.a = a;
            this.b = b;
        }
    }

    public static void main(String args[]){

        Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
        Pair[] tasks = new Pair[n];

        for(int i = 0; i < n; i++){
            tasks[i] = new Pair(sc.nextLong(), sc.nextLong());
        }

        Arrays.sort(tasks, new Comparator<Pair>(){
            public int compare(Pair o1, Pair o2){
                return (int) (o1.b - o2.b);
            }
        });

        boolean flag = true;
        long sum = 0;

        for(int i = 0; i < n; i++){
            sum += tasks[i].a;
            if(sum > tasks[i].b){
                flag = false;
                break;
            }
        }

        if(flag) System.out.println("Yes");
        else System.out.println("No");

    }

}


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


int main(){
	ll A,B,V,W,T;
	cin >> A >> V >> B >> W >> T;
	if(abs(A-B) <= (V-W)*T) cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair <ll, ll > pll;

bool comp(const pll &a, const pll &b) {
	return a.first < b.first;
}
std::vector<int> enum_div(int n)//nの約数を列挙
{
	std::vector<int> ret;
	for (int 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;
}


template<int N>
int factorial() {
	return factorial<N - 1>() * N;
}

template<>  /// 特殊化：factorial<N=”1”>だったら，値を返す
int factorial<1>() {
	return 1;
}
int main()
{
	//priority_queue<int> q;
	string s = {};
	string s1 = {};
	ll h = 0, w = 0, k = 0, a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, ans = 0;
	//ll x[300005] = {};
	ll y[300005] = {};
	ll z[302][302] = {};
	cin >> a;
	for (int i = 0; i < a; i++)
	{
		cin >> y[i];
	}
	sort(y, y + a);
	for (int i = 0; i < a-1; i++)
	{
		if (y[i]==y[i+1])
		{
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;

	//cout << ans << endl;



	//return 0;

	/*cout << c << endl;
	cout << b << endl;*/
	//cout << fixed << setprecision(10) <<tmp << endl;
	//cout<<factorial<10><<endl;
	return 0;
}
//2つの組の数をソートしたりするやつ
//vector<pair<ll, ll> > hoges(a);
//for (int i = 1; i <= a; i++)
//{
//	cin >> h;
//	hoges[i - 1] = make_pair(h, i);
//}
//sort(hoges.begin(), hoges.end(), comp);
//for (int i = 0; i < a; i++)
//{
//	cout << hoges[i].second << endl;
//}


Measured memory_bytes: 2560
#include <iostream>
#include <cmath>

int main(){
    long long n;
    std::cin >> n;

    long long ans = 0, val = 10;
    if(0 == n % 2){
        while(val <= n){
            ans += n / val;
            val *= 5;
        }
    }

    std::cout << ans << std::endl;
    
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
import time
import re
import math
import fractions

def main():
    global N,A,B,C,D,memo,mx,mn,temp
    s=input()
    f=False
    if len(set(list(s)))==2:
        num1=0
        num2=0
        for a in range(4):
            if list(set(list(s)))[0]==s[a]:
                num1+=1
            else:
                num2+=1
        if num1==num2:
            f=True
    if f:
       print("Yes")
    else:
        print("No")

start=time.time()
main()
#print("処理速度 {}sec".format(time.time()-start))
#"YNeos"[True::2]
#A=list(map(int,input().split()))
#A,B,C=map(int,input().split())
#n=int(input())
# global N,A,B,C,D,memo,mx,mn,temp



Measured memory_bytes: 5716
import sys
input = sys.stdin.readline
N,C = map(int, input().split())

X = []

for i in range(N):
  x,c = map(int, input().split())
  X.append((x,c))
  
PS1 = [[0,0,0]]
PS2 = [[0,0,0]]
QS1 = [[0,0,0]]
QS2 = [[0,0,0]]

# PS[i] = c,i,c0
# PS1:右回りで得られるコスト（行きのxのロス組み込み
# PS2:右回り＋Oに帰るまでで得られるコスト
# i:Xのindex。

for i in range(N):
  c1, xx, c0 = PS1[i]
  c2, _,  _  = PS2[i]
  x,c = X[i]
  PS1.append([c0+c-x, i+1, c0+c])
  PS2.append([c0+c-x*2, i+1, c0+c])

for i in range(N):
  c1, xx, c0 = QS1[i]
  c2, _,  _  = QS2[i]
  x,c = X[N-i-1]
  x = C-x
  QS1.append([c0+c-x, i+1, c0+c])
  QS2.append([c0+c-x*2, i+1, c0+c])

PS1.sort(reverse=True)
PS2.sort(reverse=True)

"""
print(PS1)
print(PS2)
print(QS1)
print(QS2)
"""

# 左回りのINDEXをqとする。ただし原点=0とする
# するとQSindex + PSindex <= N であればOKで
# かつPSがソート済単調減少なので、貪欲に取れるはず
ans = 0
ps1index, ps2index = 0,0
for q in range(N+1):
  while PS1[ps1index][1] + q > N:
    ps1index += 1
  while PS2[ps2index][1] + q > N:
    ps2index += 1
  a1 = PS1[ps1index][0] + QS2[q][0]
  a2 = PS2[ps2index][0] + QS1[q][0]
  ans = max(ans, a1,a2)
  
print(ans)

Measured memory_bytes: 108308
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
#define INF (int)1e9+1
#define INFLL (int)1e18+1
#define sz(bb) (int)bb.size()
#define all(qq) qq.begin(), qq.end() 
#define Max(a, b, c) max(a, max(b, c))
#define Min(a, b, c) min(a, min(b, c))
const double PI=acos(-1);
// #define int unsigned long long int//used when x<=2^64-1 && x>0
#define int long long//used when x<=2^63-1
//bool cmp if returns true it keeps 1st as first else swaps
typedef long long  ll;

const int N=100005;
vector<int> gr[N];
int white[N], black[N];
void fun(int x, int par)
{
    black[x]=1;
    white[x]=1;
    for(auto it: gr[x])
    {
        if(it==par)
            continue;
        fun(it, x);
        white[x]*=white[it]+black[it];
        black[x]*=white[it];
        white[x]%=mod;
        black[x]%=mod;
    }
}
void solve()
{
    int n;
    cin>>n;
    for(int i=0;i<n-1;i++)
    {
        int a, b;
        cin>>a>>b;
        gr[a].pb(b);
        gr[b].pb(a);
    }
    memset(white, 0, sizeof(white));
    memset(black, 0, sizeof(black));
    fun(1, -1);
    cout<<(white[1]+black[1])%mod<<"\n";
}
int32_t main()
{
    IOS;
    int t;
    // cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
    return 0;
}

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

struct Node {
  int key;
  Node *right, *left, *parent;
};

Node *root, *NIL;

Node * treeMinimum(Node *x) {
  while( x->left != NIL ) x = x->left;
  return x;
}

Node * find(Node *u, int k) {
  while( u != NIL && k != u->key ) {
    if ( k < u->key ) u = u->left;
    else u = u->right;
  }
  return u;
}

Node * treeSuccessor(Node *x) {
  if ( x->right != NIL ) return treeMinimum(x->right);
  Node *y = x->parent;
  while( y != NIL && x == y->right ) {
    x = y;
    y = y->parent;
  }
  return y;
}

//Delete
void treeDelete(Node *z) {
  Node *y;
  Node *x;
  
  if ( z->left == NIL || z -> right == NIL ) y = z;
  else y = treeSuccessor(z);
  
  if ( y->left != NIL ) {
    x = y->left;
  } else {
    x = y->right;
  }
  
  if ( x != NIL ) {
    x->parent = y->parent;
  }

  if ( y->parent == NIL ) {
    root = x;
  } else {
    if ( y == y->parent->left ) {
      y->parent->left = x;
    } else {
      y->parent->right = x;

    }
  }

  if ( y != z ) {
    z->key = y->key;
  }

  free(y);
}

//insert
void insert(int k) {
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while ( x != NIL ) {
    y = x;
    if ( z->key < x->key ) {
      x = x->left;
    } else {
      x = x->right;
    }
  }

  z->parent = y;
  if ( y == NIL ) {
    root = z;
  } else {
    if ( z->key < y->key ) {
      y->left = z;
    } else {
      y->right = z;
    }
  }
}

void inorder(Node *u) {
  if ( u == NIL ) return;
  inorder(u->left);
  cout << " " << u->key;
  inorder(u->right);
  
}

void preorder(Node *u) {
  if ( u == NIL ) return;
  cout << " " << u->key;
  preorder(u->left);
  preorder(u->right);
}

int main() {
  int n, x;
  string com;

  //入力
  cin >> n;
  for ( int i = 0; i < n; i++ ) {
    cin >> com;
    if ( com == "find" ) {
      cin >> x;
      Node *t = find(root, x);
      if ( t != NIL ) cout << "yes" << endl;
      else cout << "no" << endl;
    } else if ( com == "insert" ) {
      cin >> x;
      insert(x);
    } else if ( com == "print" ) {
      inorder(root);
      cout << endl;
      preorder(root);
      cout << endl;
    } else if ( com == "delete" ) {
      cin >> x;
      treeDelete(find(root, x));
    }
  }
  
}

Measured memory_bytes: 19964
s = list(input())
n = len(s)
ans = [0 for i in range(n)]
cnt = 0
even_r =0
odd_r = 0
for i in range(n):
    if s[i] == 'R':
        cnt += 1
    else:#'L'が出てきたら
        even_r = cnt//2
        odd_r = cnt-even_r
        ans[i] += even_r
        ans[i-1] += odd_r
        cnt = 0

even_l = 0
odd_l = 0
cnt = 0
for i in range(n-1,-1,-1):
    if s[i] == 'L':
        cnt += 1
    else:
        even_l = cnt//2
        odd_l = cnt-even_l
        ans[i] += even_l
        ans[i+1] += odd_l
        cnt = 0
print(*ans)

Measured memory_bytes: 7092
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok;
ll dx[9] = { 0,1,-1,0,0,1,1,-1,-1 }, dy[9] = { 0,0,0,1,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222






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


  ll a, b;
  cin >> a >> b;
  if (b%a) cout << b - a << endl;
  else cout << b + a << endl;



  return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	fsc := NewFastScanner()
	c := fsc.Next()
	if c == "a" || c == "i" || c == "u" || c == "e" || c == "o" {
		fmt.Println("vowel")
	} else {
		fmt.Println("consonant")
	}
}

//template
type FastScanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewFastScanner() *FastScanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1024)
	return &FastScanner{r: rdr}
}
func (s *FastScanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *FastScanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *FastScanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *FastScanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *FastScanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *FastScanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

func IntMax(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func Int64Max(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
func Float64Max(a, b float64) float64 {
	if a < b {
		return b
	}
	return a
}

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

func Int64Min(a, b int64) int64 {
	if a > b {
		return b
	}
	return a
}
func Float64Min(a, b float64) float64 {
	if a > b {
		return b
	}
	return a
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;
int n;
int A[110][110];
int P[10010] = {0};
void init(int N){
	for(int i=0;i<=N;++i) P[i] = i;
}

int root(int a){
	if(P[a] == a) return a;
	return (P[a] = root(P[a]));
}

bool is_same_set(int a,int b){
	return root(a) == root(b);
}

void unite(int a, int b){
	P[root(a)] = root(b);
}


int main(){
	while(cin >> n && n>0){
		init(n);
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				cin >> A[i][j];
			}
		}
		int M = 0;
		int cost[10000],src[10000],dst[10000];
		vector< pair<int,int> > edges;
		for(int r=0;r<n;r++){
			for(int c=r+1;c<n;c++){
				if(A[r][c] > -1){
					cost[M] = A[r][c];
					src[M] = r;
					dst[M] = c;
					//cout << cost[M] << endl;
					pair<int,int> edge = make_pair(cost[M],M);
					edges.push_back(edge);
					M++;
				}
			}
		}
		sort(edges.begin(),edges.end());
		long long  sum = 0;
		for(int i=0;i<M;i++){
			int n1 = src[edges[i].second],n2 = dst[edges[i].second];
			if(!is_same_set(n1,n2)){
				unite(n1,n2);
				sum += edges[i].first;
			}
		}
		cout << sum << endl;
	}
}

#if 0
所要時間は45分程度。クラスカル法を回す部分の実装に少し苦戦した。
#endif 


Measured memory_bytes: 3256
#include <iostream>
#include <cstring>
#include <string>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <ctime>
#include <cmath>
#include <stack>
#include <set>
#include <map>

#define INF 0x3f3f3f3f
#define ll long long
#define rep(i, n) for(ll i=0;i<n;i++)
#define per(i, n) for(int i=n;i>=0;i--)
#define rep2(i, n) for(ll i=1;i<=n;i++)
#define pb(x) push_back(x)
#define clint(x, n) memset(x,n,sizeof(x))
#define mp make_pair
#define fi first
#define se second
#define IO std::ios::sync_with_stdio(false)
#define ull unsigned long long
#define ud long double
#define pii pair<int,int>
#define random(x) (rand()%x)
using namespace std;
const ll inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const int MAX = 123123;
const int N = 555;
const double eps = 1e-6;

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 - '0';
        ch = getchar();
    }
    return x * f;
}

inline ll read1() {
    ll 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 - '0';
        ch = getchar();
    }
    return x * f;
}

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

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

ll multi(ll a, ll b, ll p) {
    ll ans = 0;
    while (b) {
        if (b & 1ll) ans = (ans + a) % p;
        a = (a + a) % p;
        b >>= 1;
    }
    return ans;
}

ll pow_mod(ll a, ll b, ll p) {
    ll ans = 1;
    while (b) {
        if (b & 1ll) ans = multi(ans, a, p);
        a = multi(a, a, p);
        b >>= 1;
    }
    return ans;
}

int qpow(int a, int b) {
    int ans = 1, base = a;
    while (b != 0) {
        if ((b & 1) != 0)
            ans *= base;
        base *= base;
        b >>= 1;
    }
    return ans;
}

int lowbit(ll x) {
    return x & (-x);
}

int gcd(int a, int b) {
    return b > 0 ? gcd(b, a % b) : a;
}

bool cmp(int &a, int &b) {
    return a > b;
}

const int maxn = 1e5 + 10;

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

int main() {
    int a;
    cin>>a;
    rep2(i,9){
        if(a%i==0&&a/i<=9&&a/i>=1) {
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
from itertools import product as prod

s = list(input())
n = len(s)

ans = 0
for sym in prod(["", "+"], repeat=n-1):
    form = []
    for i, c in enumerate(s[:-1]):
        form.append(c)
        form.append(sym[i])
    form.append(s[-1])
    ans += eval("".join(form))

print(ans)


Measured memory_bytes: 3060
import math
n = int(input())
s = int(math.sqrt(n))
a = 0
for i in range(s, 0, -1):
    if n % i == 0:
        a = i
        break
if a == 0:
    print(n - 1)
else:
    print(int((a - 1) + (n / a - 1)))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,sum=0;
  cin>>N;
  vector<int> v(N);
  vector<int> c(N);
  for(int i=0;i<N;i++){
    cin>>v[i];
  }
  for(int i=0;i<N;i++){
    cin>>c[i];
  }
  for(int i=0;i<N;i++){
    if(v[i]>c[i])sum+=(v[i]-c[i]);
  }
  cout<<sum<<endl;
}
  

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

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define fcin ios::sync_with_stdio(false); cin.tie(nullptr);
#define INF 0x3f3f3f3f
#define all(x) x.begin(), x.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

int main(){
    fcin;

    string s;
    cin >> s;

    int q;
    cin >> q;

    int side = 0;
    deque<char> d;
    for(char c : s) d.pb(c);
    while(q--){
        int type;
        cin >> type;

        if(type == 1){
            side ^= 1;
        } else {
            int f;
            cin >> f;

            char c; cin >> c;
            if(f == 1){
                // begin
                if(!side){
                    d.push_front(c);
                // end
                } else {
                    d.pb(c);
                }
            }

            else {
                // end
                if(!side){
                    d.pb(c);
                // begin
                } else {
                    d.push_front(c);
                }
            }
        }

    }
    if(side) reverse(all(d));
    for(auto i : d) cout << i;
    
    return 0;
}



Measured memory_bytes: 976
#Volume5-0521
while True:
  nedan = input()
  if nedan == str(0):
    break
  o = str(1000 - int(nedan))
  m = int(0)
  if int(nedan) > 990:
    n = int(1)
  elif int(nedan) > 900:
    n = int(2)
  else:
    n = int(3)
  for a in range(n):
    if int(o[a]) < 5:
      m = m+int(o[a])
    else:
      m = m+int(o[a])-4
  print(m)



Measured memory_bytes: 5592
#include <iostream>
#define ll long long
using namespace std;

int main() {
	ll n;
	cin >> n;
	string s = "";
	while (n > 0) {
		s = (char)((n - 1) % 26LL + 'a') + s;
		n -= 1;
		n /= 26;
	}
	cout << s;
}

Measured memory_bytes: 3628
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000007


using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))



int main(){
    ll ans=0,n;
    cin>>n;
    //for(n=0;n<100;n++){
        if (n%2==0){
                ans=0;
                ll tmp=10;
                while(n/tmp>0){
                    ans+=n/tmp;
                    tmp*=5;
                }
        }else{
            ans=0;
        }

        cout <<ans<<endl;
    //}


    return 0;

}

Measured memory_bytes: 256
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
  int N =sc.nextInt();
  double p = 1.0;
  for(int i = 0;i < N;i++){
    p *= i+1;
    p %= Math.pow(10,9)+7;
  }
  System.out.println((int)p);
}}


Measured memory_bytes: 21460
#include <iostream>
#include <string>

using namespace std;

class Dice
{
public:
	Dice(unsigned int *in)
	{
		for (int i = 0; i < 6; i++)
		{
			label[i] = in[i];
			//cout << "label[" << i << "]=" << label[i];
		}
		//cout << endl;
		N = 5;
		E = 3;
		S = 2;
		W = 4;
		F = 1;
		B = 6;
		
	}
	~Dice()
	{
	}
	void Run(string &cmd)
	{
		for (int i = 0; i < cmd.size(); i++)
		{
			char c = cmd[i];
			if (c == 'S')
			{
				// 3, 4?????????????????????
				int tmpF = F;
				F = N;
				N = B;
				B = S;
				S = tmpF;
			}
			else if (c == 'N')
			{
				// 3, 4?????????????????????
				int tmpN = N;
				N = F;
				F = S;
				S = B;
				B = tmpN;
			}
			else if (c == 'E')
			{
				// 2,5?????????????????????
				int tmpB = B;
				B = E;
				E = F;
				F = W;
				W = tmpB;
			}
			else if (c == 'W')
			{
				int tmpW = W;
				W = F;
				F = E;
				E = B;
				B = tmpW;
			}
		}
	}
	int GetFront()
	{
		return F;
	}
	int GetLabel()
	{
		return label[F-1];
	}
private:
	unsigned int label[6];
	int N;
	int E;
	int S;
	int W;
	int F;
	int B;
};

int main()
{
	unsigned int in[6] = {0};
	unsigned int n;
	string cmd;
	for (int i = 0; i < 6; i++)
	{
		cin >> n;
		in[i] = n;
	}
	cin >> cmd;
	
	Dice d1(in);
	d1.Run(cmd);
	cout << d1.GetLabel() << endl;;
	
	return 0;
}

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

int main() {
  int a,b,c,d,e,aa,bb,cc,dd,ee,A,B,C,D,E;
  cin >> a >> b >> c >> d >> e;
  if(a%10 != 0){
    aa = a%10;
  }
  else{
    aa = 10;
  }
  if(b%10 != 0){
    bb = b%10;
  }
  else{
    bb = 10;
  }
  if(c%10 != 0){
    cc = c%10;
  }
  else{
    cc = 10;
  }
  if(d%10 != 0){
    dd = d%10;
  }
  else{
    dd = 10;
  }
  if(e%10 != 0){
    ee = e%10;
  }
  else{
    ee = 10;
  }
  if(a%10 == 0){
    A = a;
  }
  else{
    A = (a/10)*10+10;
  }
  if(b%10 == 0){
    B = b;
  }
  else{
    B = (b/10)*10+10;
  }
 if(c%10 == 0){
    C = c;
  }
  else{
    C = (c/10)*10+10;
  }
  if(d%10 == 0){
    D = d;
  }
  else{
    D = (d/10)*10+10;
  }
  if(e%10 == 0){
    E = e;
  }
  else{
    E = (e/10)*10+10;
  }
  if(aa < bb && aa < cc && aa < dd && aa < ee){
    cout << a+B+C+D+E << endl;
  }
  else if(bb < aa && bb < cc && bb < dd && bb < ee){
    cout << A+b+C+D+E << endl;
  }
  else if(cc < aa && cc < bb && cc < dd && cc < ee){
    cout << A+B+c+D+E << endl;
  }
  else if(dd < aa && dd < bb && dd < cc && dd < ee){
    cout << A+B+C+d+E << endl;
  }
  else{
    cout << A+B+C+D+e << endl;
  }
}


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

#define Online 1
// #define multitest 1
#define Debug 1
typedef long long ll;
typedef long double ld;
#define f first
#define s second
#define pb push_back
#define mp make_pair
const long long mod = 1000000007;
void ControlIO();
void TimerStart();
void TimerStop();
#ifdef Debug
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void ZZ(const char *name, Arg1 &&arg1)
{
	std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char *names, Arg1 &&arg1, Args &&... args)
{
	const char *comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
#else
#define db(...)
#endif

void solve()
{
	int q, a, b, t;
	cin >> q;
	ll answer = 0;
	priority_queue<int> Left;
	priority_queue<int, vector<int>, greater<int>> Right;
	while (q--)
	{
		cin >> t;
		if (t == 1)
		{
			cin >> a >> b;
			answer += b;
			if (Left.empty() or (Left.top() <= a && Right.top() >= a))
			{
				Left.push(a);
				Right.push(a);
			}
			else if(a < Left.top())
			{
				int m = Left.top();
				Left.pop();
				answer += abs(m-a);
				Right.push(m);
				Left.push(a);
				Left.push(a);
			}
			else
			{
				int m = Right.top();
				Right.pop();
				answer += abs(m-a);
				Left.push(m);
				Right.push(a);
				Right.push(a);
			}
		}
		else
		{
			if(Left.size()==0)
				cout << 0 << ' ' << 0 << '\n';
			else cout << Left.top() << ' ' << answer << '\n';
		}
	}
}

int main()
{
	ControlIO();
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
	TimerStart();
	while (t--)
		solve();
	TimerStop();
	return 0;
}

void ControlIO()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#ifndef Online
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

auto TimeStart = chrono::steady_clock::now();
auto TimeEnd = chrono::steady_clock::now();

void TimerStart()
{
#ifndef Online
	TimeStart = chrono::steady_clock::now();
#endif
}

void TimerStop()
{
#ifndef Online
	TimeEnd = chrono::steady_clock::now();
	auto ElapsedTime = TimeEnd - TimeStart;
	cout << "\n\nTime elapsed: " << chrono::duration<double>(ElapsedTime).count() << " seconds.\n";
#endif
}

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

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

    if(a*b > c*d)
        cout<<a*b;
    else if(a*b < c*d)
        cout<<c*d;
    else
        cout<<a*b;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i, x, n) for(int i = x; i < (int)(n); ++i)
#define speed ios::sync_with_stdio(0); cin.tie(0);
int const N = 1e5 + 2;
int n;
int a[N], b[N], c[N], dp[N][3];

int calc(int index, int place){
	if (index > n - 1)return 0;
	if (dp[index][place] != -1)return dp[index][place];
	if (place == 0)return dp[index][place] = (max(calc(index + 1, 1), calc(index + 1, 2)) + a[index]);
	else if (place == 1)return dp[index][place] = (max(calc(index + 1, 0), calc(index + 1, 2)) + b[index]);
	return dp[index][place] = (max(calc(index + 1, 0), calc(index + 1, 1)) + c[index]);
}

int main(){
	speed
	cin >> n;
	f(i, 0, n)cin >> a[i] >> b[i] >> c[i];
	memset(dp, -1, sizeof(dp));
	cout << max(calc(0, 0), max(calc(0, 1), calc(0, 2))) << endl;
}

Measured memory_bytes: 7296