akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		int c=scan.nextInt();
		int d=scan.nextInt();
		int count1=0;
		int count2=0;
		int count3=0;
		int count4=0;
		if(a==1||b==1||c==1||d==1) {
			count1=1;
		}
		if(a==9||b==9||c==9||d==9) {
			count2=1;
		}
		if(a==7||b==7||c==7||d==7) {
			count3=1;
		}
		if(a==4||b==4||c==4||d==4) {
			count4=1;
		}
		if(count1==1&&count2==1&&count3==1&&count4==1) {
			System.out.println("YES");
		}
		else {
			System.out.println("NO");
		}
}
	}

Measured memory_bytes: 22228
def b(M,x,y,n=1):
 M[x][y]=0;a=n
 if M[x-1][y]:a=max(a,b(M,x-1,y,n+1))
 if M[x][y-1]:a=max(a,b(M,x,y-1,n+1))
 if M[x+1][y]:a=max(a,b(M,x+1,y,n+1))
 if M[x][y+1]:a=max(a,b(M,x,y+1,n+1))
 M[x][y]=1
 return a
for e in iter(input,'0'):
 n,m=int(e),int(input())
 P=[[0]*(n+2)for _ in[0]*(m+2)]
 for i in range(m):P[i+1][1:-1]=map(int,input().split())
 print(max(b(P,i,j)for i in range(1,m+1)for j in range(1,n+1)if P[i][j]))


Measured memory_bytes: 5736
N, M, K = map(int, input().split())
desk_a = list(map(int, input().split()))
desk_b = list(map(int, input().split()))

sum_a = [0]
sum_b = [0]

for i in range(N):
    sum_a.append(sum_a[-1] + desk_a[i])
for i in range(M):
    sum_b.append(sum_b[-1] + desk_b[i])

ans = 0
j = M
for i in range(N+1): 
    a = sum_a[i]
    if K - a < 0:
        break
    while sum_b[j] > K - a: 
        j -= 1
    ans = max(ans, i+j)

print(ans)

Measured memory_bytes: 134020
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from functools import reduce



INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


a = S()[0]
if a == 'S':
    print('Cloudy')
elif a == 'C':
    print('Rainy')
else:
    print('Sunny')

Measured memory_bytes: 39664
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
	
	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner Scanner = new Scanner(System.in);
        List<Integer> list = new ArrayList<>();

        while (Scanner.hasNext()) {
            int input = Integer.parseInt(Scanner.next());
            if (input == 0) {
                break;
            }
            list.add(input);
        }

        IntStream.range(0, list.size())
                .forEach(i -> System.out.println("Case" + " " + (i + 1) + ": " + list.get(i)));
    }

}


Measured memory_bytes: 48244
#include <iostream>
using namespace std;
int main() {
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b)
        cout<<c<<endl;
    else if(a==c)
        cout<<b<<endl;
    else
        cout<<a<<endl;
    //std::cout << "Hello, World!" << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

vector<ll>inarr(ll N)
{
	ll t;
	vector<ll>r;
	for(ll i=0;i<N;i++)
	{
		cin>>t;
		r.push_back(t);
	}
	return r;
}

int main()
{
	ll N;
	ll T=0L;
	cin>>N;
	auto A=inarr(N);
	auto B=inarr(N);
	for(int i=0;i<N;i++)
	{
		if(A[i]>B[i])
		{
			T-=A[i]-B[i];
		}
		else if(A[i]<B[i])
		{
			T+=(B[i]-A[i])/2;
		}
	}
	cout<<(T>=0?"Yes":"No")<<endl;
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned long long int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


bool check_prime(long long n)
{
	int flag = 0;
	for (long long i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			flag = 1;
			break;
		}
	}
	if (n == 1)
		return false;
	else if (flag == 0 || n == 2 || n == 3)
	{
		return true;
	}
	else
	{
		return false;
	}

}

int BE(int x, int n, int m) //function to calculate x raise to power n modulo m
{
	int result = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			result = result * x % m;
		x = x * x % m;
		n = n / 2;
	}
	return result;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________

	cout << fixed << setprecision(17);
	ld a, b;
	cin >> a >> b;
	ld x = a * b;
	int ans = floor(x);
	cout << ans << en;



	return 0;
}



Measured memory_bytes: 3744
N = int(input())
S = input()

W = [0] * (N+2)
E = [0] * (N + 2)

s = 0
e = 0
for i in range(0, N):
    if S[i] == "W":
        s += 1
    else:
        e += 1
    W[i + 1] = s
    E[i + 1] = e

ret = 10**10
for leader in range(1, N+1):
    leftW = W[leader-1]
    rightE = E[N]-E[leader]
    # print("{}, {}".format(leftW, rightE))
    sum = leftW + rightE
    ret = min(ret, sum)

print(ret)


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

#define pb     push_back
#define mp     make_pair
#define all(v) v.begin() , v.end()
#define allr(v) v.rbegin(), v.rend()
const int MOD = 1e9+7;
const int MAX = 1e5+5;

int n, m;
ll ans;
ll fact[MAX];

int main(int argc, char const *argv[])
{
  ios_base::sync_with_stdio(false);
  
  // #ifndef ONLINE_JUDGE
  // freopen("in","r",stdin);
  // freopen("out","w",stdout);
  // #endif

  fact[0] = 1;
  for(int i = 1 ; i < MAX ; i++)
  	fact[i] = (i * fact[i-1]) % MOD;


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

  if(n == m){
  	ans = (2ll * (fact[n] * fact[m])%MOD) % MOD; 
  }
  else if(n == m + 1 || m == n + 1)
  	ans = (fact[n] * fact[m])%MOD;
  else
  	ans = 0;

  printf("%lld" , ans);

  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <array>
#include <cmath>
#include <iterator>
#include <utility>
#include <set>
#include <random>
#include <map>
#include <stack>
#include <queue>
#include <list>
 
using namespace std;
 
 
int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a == 5 && b == 5 && c == 7)
    {
        cout << "YES" << endl;
    }
    else if (a == 5 && b == 7 && c == 5)
    {
        cout << "YES" << endl;
    }
    else if (a == 7 && b == 5 && c == 5)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
module Main where

toInt :: String -> Int
toInt s = read s :: Int

strToIntList :: String -> [Int]
strToIntList = map toInt . words

getIntList :: IO [Int]
getIntList = getLine >>= return . strToIntList

main :: IO ()
main = do
  ab <- getIntList
  putStrLn $ if all odd ab then "Odd" else "Even"

Measured memory_bytes: 508
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cctype>
#include <locale>
#include <cmath>
#include <iomanip>
#include <numeric>

using namespace std;

int main() {
    string s;
    cin >> s;
    int flag = 0;
    string ans;
    string rs = s;
    reverse(rs.begin(), rs.end());
    // cout << "s: " << s << " rs: " << rs << endl;
    if(s != rs) {
        flag = 1;
    }

    string s1 = s.substr(0, (s.length() - 1)/2);
    // cout << "s1: " << s1 << endl;
    string rs1 = s1;
    reverse(rs1.begin(), rs1.end());
    // cout << "s1: " << s1 << " rs1: " << rs1 << endl;
    if(s1 != rs1) {
        flag = 1;
    }

    string s2 = s.substr((s.length()+3)/2-1, s.length()-1);
    // cout << "s1: " << s2 << endl;
    string rs2 = s2;
    reverse(rs2.begin(), rs2.end());
    // cout << "s2: " << s2 << " rs2: " << rs2 << endl;
    if(s2 != rs2) {
        flag = 1;
    }


    if(flag == 0) {
        ans = "Yes";
    } else {
        ans = "No";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int n;
int a[20][20];
ll dp[1<<17];
ll dp2[1<<17];
ll go(int msk){
    //cout<<msk<<endl;
    if(dp2[msk]>=-1e17) return dp2[msk];
    dp2[msk]=dp[msk];
    /*for(int i=1;i<(1<<n);i++){
        if((i|msk)!=msk) continue;
        int res=msk-i;
        dp2[msk]=max(dp2[msk],go(i)+go(res));
    }*/
    for(int i=msk;i!=0;i=(i-1)&msk){
        if(i==msk) continue;
        int res=msk^i;
        dp2[msk]=max(dp2[msk],go(i)+go(res));
    }
    return dp2[msk];
}
int main(){
    cin>>n;
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            cin>>a[i][j];
    memset(dp,-127,sizeof(dp));
    ll mx=0;
    for(int i=0;i<n;i++){
        dp[1<<i]=0;
        if(i==0) continue;
        for(int j=0;j<(1<<n);j++){
            if((j&(1<<i))==0) continue;
            if(j==(1<<i)) continue;
            int now=j^(1<<i);
            ll ha=0;
            for(int k=0;k<n;k++)
                if(now&(1<<k))
                    ha+=a[k][i];
            dp[j]=dp[now]+ha;
        }
    }
    memset(dp2,-127,sizeof(dp2));
    cout<<go((1<<n)-1)<<endl;
    return 0;
}


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

using namespace std;

int main() {
    int n; vector <int> v;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int x; cin >> x;
        v.push_back(x - 1);
    }
    vector <int> res;
    while (v.size() > 0) {
        int lst = -1;
        for (int i = 0; i < v.size(); i++) {
            if (v[i] == i) {
                lst = i;
            }
        }
        if (lst == -1) {
            cout << -1 << endl;
            return 0;
        }
        res.push_back(lst);
        v.erase(v.begin() + lst);
    }
    reverse(res.begin(), res.end());
    for (int i : res) {
        cout << i + 1 << endl;
    }
    cout << endl;
    return 0;
}


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

typedef pair<int,string> P;

int main(){
  int n;
  while(cin >> n && n){
    string str,str2;
    char c;
    map<string,int> m;
    vector<P> v;
    getline(cin,str);
    for(int i=0;i<n;i++){
      getline(cin,str);
      istringstream iss(str);
      while(iss >> str2) m[str2]++;
    }
    cin >> c;

    for(map<string,int>::iterator it=m.begin(); it!=m.end(); it++)
      if(it->first[0] == c)
	v.push_back(P(-1*it->second,it->first));
    sort(v.begin(),v.end());

    if(v.size() == 0) cout << "NA" << endl;
    else{
      cout << v[0].second;
      for(int i=1;i<v.size();i++){
	if(i >= 5) break;
	cout << ' ' << v[i].second;
      }
      cout << endl;
    }
  }
}

Measured memory_bytes: 1244
#include<bits/stdc++.h>
using namespace std;
long int gcd(long int a,long int b){ 
    if (a == 0) 
        return b;  
    return gcd(b % a, a);  
 } 
 int main()
 {
 	long long int a,b;
 	cin>>a>>b;
 	long long int g=gcd(a,b);
 	long long int ans=(a*b)/g;
 	cout<<ans<<"\n";
 }

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int h,w,d;
  cin>>h>>w>>d;
  vector<pair<int,pii> > p(h*w);
  rep(i,h)rep(j,w){
    cin>>p[i*w+j].first;
    p[i*w+j].second.first=i;
    p[i*w+j].second.second=j;
  }
  sort(all(p));
  vi a(h*w+5);

  rep(i,p.size()){
    if(i+d>=h*w)continue;
    int x=p[i].second.first-p[i+d].second.first;
    int y=p[i].second.second-p[i+d].second.second;
    a[1+i+d]=abs(x)+abs(y);
  }

  for(i=1;i+d<=h*w;i++)
    a[i+d]=a[i]+a[i+d];

  int q;
  cin>>q;
  rep(i,q){
    int l,r;
    cin>>l>>r;
    cout<<a[r]-a[l]<<endl;
  }

}


Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {

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

		char nextTurn = 'a';
		int N = sa.length() + sb.length() + sc.length();
		while(true){
			if (nextTurn == 'a') {
				if (sa.length() == 0) {
					System.out.println("A");
					break;
				}
				nextTurn = sa.charAt(0);
				sa.delete(0, 1);
			} else if (nextTurn == 'b') {
				if (sb.length() == 0) {
					System.out.println("B");
					break;
				}
				nextTurn = sb.charAt(0);
				sb.delete(0, 1);
			} else {
				if (sc.length() == 0) {
					System.out.println("C");
					break;
				}
				nextTurn = sc.charAt(0);
				sc.delete(0, 1);
			}
		}
		in.close();
	}
}

Measured memory_bytes: 23124
#include <iostream>
#define MOD 1000000007
using namespace std;

int N, M;

long long dp[100001];

long long factorial(long long n) {
    if (dp[n] != -1)
        return dp[n];

    if (n == 0)
        return dp[n] = 1;

    return dp[n] = (n % MOD) * (factorial(n - 1) % MOD);
}

int solve() {
    if (abs(N - M) > 1) {
        cout << 0 << endl;
        return 0;
    }

    if(N == M){
        cout << 2 * (((factorial(N) % MOD) * (factorial(M) % MOD)) % MOD) % MOD << endl;
    }else{
        cout << ((factorial(N) % MOD) * (factorial(M) % MOD)) % MOD << endl;
    }

}

int main() {
    cin >> M >> N;
    for (int i = 0; i <= 100000; ++i) {
        dp[i] = -1;
    }

    solve();
}


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

int main(){
	int n;
	scanf("%d", &n);
	
	vector <int> cnt(n, 0), cntb(n, 0), a(n), b(n);
	
	for(int i = 0; i < n; i++){
		scanf("%d", &a[i]);
		a[i]--;
		
		cnt[a[i]]++;
	}
	
	for(int i = 0; i < n; i++){
		scanf("%d", &b[i]);
		b[i]--;
		
		cnt[b[i]]++;
		cntb[b[i]]++;
	}
	
	set < pair <int, int> > s;
	for(int i = 0; i < n; i++){
		if(cnt[i] > n){
			printf("No\n");
			return 0;
		}
		if(cntb[i] > 0)s.insert(make_pair(cnt[i], i));
	}
	
	printf("Yes\n");
	for(int i = 0; i < n; i++){
		if(i > 0)printf(" ");
		
		if(s.size() == 1){
			printf("%d", s.begin()->second + 1);
			continue;
		}
		
		int x = prev(s.end())->second, y = prev(prev(s.end()))->second;
		
		if(x != a[i]){
			printf("%d", x + 1);
			
			if(cntb[a[i]] > 0)s.erase(make_pair(cnt[a[i]], a[i]));
			s.erase(make_pair(cnt[x], x));
			
			cnt[a[i]]--;
			cnt[x]--;
			cntb[x]--;
			
			if(cntb[a[i]] > 0)s.insert(make_pair(cnt[a[i]], a[i]));
			if(cntb[x] > 0)s.insert(make_pair(cnt[x], x));
		}else{
			printf("%d", y + 1);
			
			if(cntb[a[i]] > 0)s.erase(make_pair(cnt[a[i]], a[i]));
			s.erase(make_pair(cnt[y], y));
			
			cnt[a[i]]--;
			cnt[y]--;
			cntb[y]--;
			
			if(cntb[a[i]] > 0)s.insert(make_pair(cnt[a[i]], a[i]));
			if(cntb[y] > 0)s.insert(make_pair(cnt[y], y));
		}
	}
	printf("\n");
	
	return 0;
}


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

using namespace std;

const long long MOD = (long long)1e9 + 7;
long long fact[100001];

void init_fact(){
    fact[1] = 1;
    for(int i = 2; i <= 100000; i++){
        fact[i] = (fact[i - 1] * i) % MOD;
    }
}

int main(){
	int n, m, ans = 0;
	cin >> n >> m;
    int diff = abs(n - m);
    if(diff > 1){
        cout << 0 << endl;
        return 0;
    }
    init_fact();
    if(diff == 0){
        cout << (2 * fact[n] * fact[m]) % MOD << endl;
    }else{
        cout << (fact[n] * fact[m]) % MOD << endl;
    }
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>

using namespace std;

#define rep1(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rep2(i, n, m) for (long long i = (long long)(n); i <= (long long)(m); i++)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

int main() {
    long long n;
    cin >> n;
    vector<long long> vec(n);
    long long max = 0;
    long long min = 1000000000;
    rep1(i, n) {
        cin >> vec.at(i);
        chmax(max, vec.at(i));
        chmin(min, vec.at(i));
    }
    long long result = 1000000000;
    rep2(i, min, max) {
        long long tmp = 0;
        rep1(j, n) tmp += (i - vec.at(j)) * (i - vec.at(j));
        result = std::min(result, tmp);
    }
    cout << result << endl;
}

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

//Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

//Type / Class / Struct Definitions:
using ll = long long;
using ull = unsigned long long;

//Constants:
const int INF = (1ll << 30) - 1;  //nearly 1.07e9
const ll INFLL = 1ll << 60;       //nearly 1.15e18
const int MOD = 1e9 + 7;
const long double EPS = 1.0e-14;

//Global Variables:

//Prototype Declarations:
int gcd(int, int);
template <class T>
inline bool chmin(T&, T);
template <class T>
inline bool chmax(T&, T);

//================ Main Loop ================
int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    vector<ll> count(n, 0);
    rep(i, n) {
        cin >> a[i];
        a[i]--;
        count[a[i]]++;
    }

    ll ans = 0;
    rep(i, n) {
        ans += count[i] * (count[i] - 1) / 2;
    }

    rep(i, n) {
        cout << ans - count[a[i]] * (count[a[i]] - 1) / 2 + (count[a[i]] - 1) * (count[a[i]] - 2) / 2 << endl;
    }
    return 0;
}
//===========================================

//Functions:
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

template <class T>
inline bool chmin(T& a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

template <class T>
inline bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    vector<int>a(n);
    vector<int>b(n);
    int i;
    for(i=0;i<n;i++)
    {
        cin>>a[i]>>b[i];
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    if(n&1)
    {
        cout<<(b[n/2]-a[n/2]+1)<<"\n";
    }
    else
    {
        cout<<(b[n/2]-a[n/2]+b[n/2-1]-a[n/2-1]+1)<<"\n";
    }
    return 0;
}

Measured memory_bytes: 4836
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#include <time.h>
#include <iostream>
#include <vector>
#include <string>

using namespace std;
int main(void)
{

  int n, a, b, c, d, count = 0;

  cin >> a >> b >> c >> d;

  if (a >= d)
    cout << d << endl;
  else if (a + b >= d)
    cout << a << endl;
  else
    cout << a - (d - a - b) << endl;
}


Measured memory_bytes: 3588
#include<iostream>
#include<algorithm>
#include<string>
#include<stdio.h>
using namespace std;
int main(){

	int x,a,b;
	cin >> x >> a >> b;
	if((max(x,a)-min(x,a))<(max(x,b)-min(x,b)))
		puts("A");
	else
		puts("B");
	return 0;
}

Measured memory_bytes: 256
k = int(input())
a = [49 for _ in range(50)]
for i in range(50):
  a[i] += k // 50
for i in range(k % 50):
  a[i] += 51
  a = list(map(lambda x:x-1, a))
print(50)
print(" ".join(map(str, a)))

Measured memory_bytes: 3060
use std::io::{stdin, Read};

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

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    let mut iter = s.split_whitespace();
    let n = parse!(iter);
    for _ in 0..n {
        let a: usize = parse!(iter);
        if a % 2 == 0 {
            if a % 3 != 0 && a % 5 != 0 {
                println!("DENIED");
                return;
            }
        }
    }
    println!("APPROVED")
}


Measured memory_bytes: 4352
#include <iostream>
using namespace std;
 
int main(){
  int n; cin >> n;
  int ans=0;
  
  for(int i = 1; i < n + 1; i++){
    string str = to_string(i);
    if((int)(str.length()) % 2 != 0) ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b) {
		cout << c << endl;
	}
	if (a == c) {
		cout << b << endl;
	}
	if (b == c) {
		cout << a << endl;
	}
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

const int MOD = 1e9 + 7;
ll modfact(int n) {
    ll res = 1;
    while (n >= 1) {
        res = res * n % MOD;
        n--;
    }
    return res;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;

    if (abs(N - M) >= 2) {
        cout << 0 << "\n";
    } else {
        ll res = modfact(N);
        res = res * modfact(M) % MOD;
        if (N == M) {
            res = res * 2 % MOD;
        }
        cout << res << "\n";
    }
    return 0;
}


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

int main() {
  int n;
  int x = 100000;
  double ans = 100000;
  cin >> n;
  for (int i=0;i<n;i++) {
    ans *= 1.05;
    x = ans;
    if (x % 1000 > 0) x = (x / 1000 + 1) * 1000;
    ans = x;
  }
  cout << x << endl;
  return 0;
}

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

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

using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> P;
 
constexpr int INF = 1e9;
constexpr int MOD = 1e9+7;

int main() {
    string n;
    cin >> n;
    int sum = 0;
    rep(i,n.size()) sum += n[i]-'0';
    cout << (sum%9==0?"Yes":"No") << endl;
	return 0;
}

Measured memory_bytes: 3580
import sys
import math
from collections import deque
import heapq
import itertools
MAX_INT = int(10e25)
MIN_INT = -MAX_INT
mod = 1000000000+7
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
a = IL()

ans = 1
cnt = a.count(0)
if cnt:
  print(0)
else:
  for i in range(N):
    ans *= a[i]
    if ans > int(1e18):
      print(-1)
      break
  else:
    print(ans)

Measured memory_bytes: 84028
from collections import Counter
n = int(input())
a = list(map(int, input().split()))

a_cs = [0] * (n + 1)
for i in range(n):
    a_cs[i + 1] = a_cs[i] + a[i]

cnt = Counter(a_cs)
ans = sum(v * (v - 1) // 2 for v in cnt.values())
print(ans)


Measured memory_bytes: 44352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main()
{
  int n, h, w;
  cin >> n >> h >> w;

  cout << (n - h + 1) * (n - w + 1) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define pb push_back
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

int main(){
  int n;
  db p[3000],dp[3000][3000],ans=0;
  cin>>n;
  Fr(i,n) cin>>p[i];
  dp[0][0]=1;
  Fr(i,n){
    dp[i][0]=dp[i-1][0]*p[i];
    Fr(j,i-1) dp[i][j]=dp[i-1][j]*p[i]+dp[i-1][j-1]*(1-p[i]);
    dp[i][i]=dp[i-1][i-1]*(1-p[i]);
  }
  fr(i,n/2.0) ans+=dp[n][i];
   printf("%.12f\n",ans);
}

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

int main(){
    string s;
    cin >> s;
    int N = s.size();
    int cnt = 0;
    for (int i = 0; i < N/2; i++) {
        if (s[i] != s[N-1-i]) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
# row = [int(x) for x in input().rstrip().split(" ")]
# n = int(input().rstrip())
# s = input().rstrip()

def resolve():
    import sys
    input = sys.stdin.readline

    n = int(input().rstrip())
    a_list = [int(x) for x in input().rstrip().split(" ")]

    ans = 0
    for a in a_list:
        while a % 2 == 0:
            ans += 1
            a = a // 2

    print(ans)

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 69628
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x ,n) for(int i = x; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main(){
    int n;
        ll a[210];
    cin >> n;
    rep(i,n)cin >> a[i];
    
    int ans = 0;
    int i = 0;
    while(1){
        if(a[i]%2==0)a[i] /= 2;
        else break;
        i++;
        if(i==n){
            i=0;
            ans++;
        }
    }
    
    cout << ans;
    
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <iostream>
#include <functional>
#include <vector>
#include <stdio.h>
#include <queue>
#include <string.h>
#include <math.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define rep1(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=a;i>=n;i--)
#define per1(i,a,n) for (int i=a;i>n;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define endl "\n"
#define pi 3.14159265358979323846264338327950288419716939937510
#define IOS cin.sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll mod=1000000007;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
ll qpow(ll a,ll b){ll s=1;while(b>0){if(b%2==1){s=s*a;}a=a*a;b=b>>1;}return s;}
ll qpowmod(ll a, ll b, ll c){ll res, t;res=1;t=a%c;while(b){if(b & 1){res=res*t%c;}t=t*t%c;b>>=1;}return res;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline long long read(){long long k=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){k=k*10+ch-'0';ch=getchar();}return k*f;}
inline void write(long long x){if(x<0)x=-x,putchar('-');if(x>9)write(x/10);putchar(x%10+'0');}
// head
ll n,a,b;
int main()
{
    //IOS;
    cin>>n>>a>>b;
    if(n>=(a+b))
    {
        cout<<min(a,n%(a+b))+n/(a+b)*a<<endl;
    }
    else
    {
        cout<<min(a,n)<<endl;
    }
    return 0;
}
/*

*/


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
//var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve
{
    class Solve
    {
        const int mod = 1000000007;
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            long N = long.Parse(Console.ReadLine());
            Console.WriteLine(N * (N + 1) / 2);

            Console.Out.Flush();
        }
    }
    


    public class Calculation
    {
        
    }

    public class Graph
    {

    }
}
    

Measured memory_bytes: 11092
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>
#include <cstring>
#include <iomanip>
#include<queue>
#include<set>
#include<stack>

using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
 
#define INF 1000000000
typedef unsigned long long  ll;

#define MOD 1000000007



int main()
{
	string S,T;
	cin>>S>>T;
	string g=T+S;
	cout<<g<<endl;
	return 0;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
//mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
//int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head
unsigned long long a,b,c;
char s[6];
int main() {
	scanf("%lld%s",&a,s);
	b = (s[0]-'0')*100 + (s[2]-'0')*10 + (s[3]-'0'); 
	c=a*b/100;
	printf("%llu",c);
} 

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



int main(){
    int N, M; cin >> N >> M;

    if(N<=M){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#2パターンでのfail
#①→偶奇がstepと位置で違う
#単純に遠すぎる
n = int(input())

t_pre =0
x_pre =0
y_pre =0
for i in range(n):
    t,x,y = list(map(int,input().split()))
    if (t-t_pre)<abs(x-x_pre)+abs(y-y_pre):
        print('No')
        break
    if t%2 != (x+y)%2:
        print('No')
        break
    t_pre = t
    x_pre =x
    y_pre = y
    
    if i ==n-1:
        print('Yes')

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

int main(void)
{
    ll N, K;
    cin >> N >> K;
    vector<ll> a(N), b(N);
    for (int i = 0; i < N; i++)
    {
        cin >> a[i] >> b[i];
    }
    
    vector<ll> hist(1e5+1, 0);
    for (int i = 0; i < N; i++)
    {
        hist[a[i]] += b[i];
    }

    ll count = 0;
    int ans = 0;
    for (int n = 1; n <= 1e5; n++)
    {
        count += hist[n];
        if(count >= K) {
            ans = n;
            break;
        }
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 5608
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int X = sc.nextInt();
		int Y = sc.nextInt();
		int price;

		if (A+B < 2*C){
			price = A*X + B*Y;
		} else {
			int ACnt=0;
			int BCnt=0;
			int CCnt=0;
			CCnt = 2 * Math.min(X, Y);
			int remainA = X - CCnt/2;
			int remainB = Y - CCnt/2;
			if (remainA > 0){
				if (A >= 2*C){
					CCnt += remainA * 2;
				} else {
					ACnt += remainA;
				}
			} else {
				if (B >= 2*C){
					CCnt += remainB * 2;
				} else {
					BCnt += remainB;
				}
			}
			price = A * ACnt + B * BCnt + C*CCnt;
		}
		System.out.println(price);
	}

}


Measured memory_bytes: 23764
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    TA = [list(map(int, input().split())) for _ in range(n)]

    t_pev, a_prev = TA[0]
    for i in range(1, n):
        t_now, a_now = TA[i]
        if t_pev <= t_now and a_prev <= a_now:
            t_pev, a_prev = t_now, a_now
        else:
            d = max((t_pev + (t_now - 1)) // t_now, (a_prev + (a_now - 1)) // a_now)
            t_pev, a_prev = t_now * d, a_now * d
    print(t_pev + a_prev)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3188
using System;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] ArrayS = Console.ReadLine().Split(' ');
            try
            {
                ulong sum = 1;
                ulong A = 1000000000000000000;

                ulong[] Array1 = new ulong[N];
                for(int i = 0;i < N; i++)
                {
                    if(ArrayS[i] == "0")
                    {
                        Console.WriteLine(0);
                        return;
                    }
                    Array1[i] = ulong.Parse(ArrayS[i]);
                }
                Array.Sort(Array1);
                for (int i = 0; i < N; i++)
                {
                    if(A / sum < Array1[i])
                    {
                        Console.WriteLine("-1");
                        return;
                    }
                    sum = (sum * Array1[i]);
                    if (sum > A)
                    {
                        Console.WriteLine("-1");
                        return;
                    }
                }
                Console.WriteLine(sum);
            }
            catch
            {
                Console.WriteLine("-1");
                return;
            }
        }
    }
}


//long n = long.Parse(Console.ReadLine());
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

//Console.WriteLine(cnt);
//Console.ReadKey();


Measured memory_bytes: 40600
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
using namespace std;


int main() {
	long long int n, a[234567], s[200005] = {},two=1;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		s[a[i]]++;
		if (s[a[i]] >= 3||a[i]%2==n%2) { cout << 0; return 0; }
	}
	if (s[0]!=1&&n%2==1) { cout << 0; return 0; }
	for (int i = 1+n%2; i < n; i+=2) {
		if (s[i] != 2) { cout << 0; return 0; }
	}
	for (int i = 0; i  < n/2; i ++) {
		two *= 2;
		two %= 1000000007;
	}
	cout << two;
}


Measured memory_bytes: 3328
#include "bits/stdc++.h"

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i,n) for(ll i=1;i<=(ll)(n);i++)
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(ll)(n);i>0;i--)
#define REP(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
#define mp make_pair


int main () {
  string s;
  cin >> s;
  long long k;
  cin >> k;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '1') {
      k--;
      if (k == 0) {
        cout << 1 << endl;
        return 0;
      }
    }
    else {
      cout << s[i] << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include <stdio.h>

static const int N = 100;

void trace(int a[], int n) {
  for (int i = 0; i < n; i++) {
    if (i != 0) printf(" ");
    printf("%d", a[i]);
  }
  printf("\n");
}

int main() {
  int n;
  int a[N];
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  trace(a, n);
  
  for (int i = 1; i < n; i++) {
    int key = a[i];
    int j = i - 1;
    while (j >= 0 & a[j] > key) {
      a[j + 1] = a[j];
      j--;
    }
    a[j + 1] = key;
    trace(a, n);
  }
  return 0;
}

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

ll p = 1e9 + 7;
ll n, k, a, ans;
ll fac[2005];

ll mul(ll x, ll y) {
	ll k = (x * y) % p;
	if (k >= 0) return k;
	else return k + p;
}
ll power(ll a, ll b) {
	if (!b) return 1;
	ll k = power(a, b >> 1);
	k = mul(k, k);
	if (b & 1) return mul(k, a);
	else return k;
}

int main() {
	cin >> n >> k;
	fac[0] = 1;
	for (ll i = 1; i <= n + 2; ++i) {
		fac[i] = mul(i, fac[i - 1]);
	}
	for (ll b = mul(fac[n - k + 1], fac[k - 1]), i = 1; i <= k; ++i) {
		if (n - k - i + 1 < 0) {
			cout << 0 << endl;
			continue;
		}
		a = 1;
		a = mul(a, fac[n - k - i + 1]);
		a = mul(a, fac[i]);
		a = mul(a, fac[k - i]);
		a = mul(a, fac[i - 1]);
		cout << mul(b, power(a, p - 2)) << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

ll N, M, D[200000], T[200000];

int main(void) {
  cin >> N;
  REP(i, 0, N) cin >> D[i];
  cin >> M;
  REP(i, 0, M) cin >> T[i];

  sort(D, D + N);
  sort(T, T + M);

  bool ans = true;
  ll j = 0;
  REP(i, 0, M) {
    while(j < N && T[i] != D[j]) j++;
    if(j < N) {
      j++;
    } else {
      ans = false;
    }
  }

  cout << (ans ? "YES" : "NO") << endl;
}


Measured memory_bytes: 3328
#include <iostream>
#include <unordered_map>
#include <string>
#include <algorithm>
using namespace std;
int solve(void){
    int N;
    int V[100],C[100];
    cin >> N;
    for(int i=1;i<=N;i++){
        cin >> V[i];
    }
    for(int i=1;i<=N;i++){
        cin >> C[i];
    }
    int ans = 0;
    for(int i=1;i<=N;i++){
        if(V[i] - C[i] > 0){
            ans += V[i] - C[i];
        }
    }
    
    return ans;
    
}
int main(void){
    int ans = solve();
    cout << ans << endl;
}


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


int main() {
  int a, b;
  cin >> a >> b;
  int ans = (a + b + 1) / 2;
  cout << ans << endl;
  return 0;
  
}

Measured memory_bytes: 256
var n,s,flag,i,left,right:longint;
  tot:int64;
   x,p:array[1..100000]of int64;
begin
 readln(n,s);
 for i:=1 to n do
   begin
   readln(x[i],p[i]);
  end;
  if s<=x[1] then
    begin
    tot:=x[n]-s;
    write(tot);
    exit;
    end;
  if s>x[n] then
    begin
    tot:=s-x[1];
    write(tot);
    exit;
    end;
    left:=1;
    right:=n;
    if p[1]<p[n] then flag:=2
    else flag:=1;
    if p[1]<p[n] then begin p[n]:=p[n]+p[1]; tot:=tot+x[right]-x[left]; inc(left);  end
                  else begin p[1]:=p[1]+p[n]; tot:=tot+x[right]-x[left];dec(right); end;
  while(x[left]<s)and(x[right]>s)do begin
  if p[left]>=p[right] then
   begin
     p[left]:=p[left]+p[right];
     if flag=2 then tot:=tot+x[right]-x[left];
     dec(right);
     if flag=2 then flag:=1;
   end
   else begin
     p[right]:=p[right]+p[left];
    if flag=1 then tot:=tot+x[right]-x[left];
     inc(left);
     if flag=1 then flag:=2;
       end;
    end;
  if x[left]>s then write(tot+x[right]-s)
               else write(tot+s-x[left])
end.


Measured memory_bytes: 1664
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const double inf=1e8;
int main(){
	int a,b,c,d,e;
	while(cin>>a>>b>>c>>d>>e,a+b+c+d+e){
		int na,nb,nc;
		cin>>na>>nb>>nc;
		int out=na*a+nb*b+nc*c;
		int t=d;
		if(t<=nc)out=na*a+nb*b+nc*e;
		else{
			out=min(out,na*a+nb*b+d*e);
			t=d-nc;
			if(t<=nb){
				out=min(out,na*a+(nb-t)*b+d*e);
			}else{
				t=d-nc-nb;
				if(t<=na)out=min(out,(na-t)*a+d*e);
			}
		}
		cout<<out<<endl;
	}
}

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

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(N: int, W: "Tuple[int, int]"):
    W = sorted(sorted(W, key=lambda work: work[0], reverse=True), key=lambda work: work[1])
    t = 0
    for i in range(N):
        t += W[i][0]
        if t > W[i][1]:
            return NO
    return YES


# Generated by 1.1.4 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()
    N = int(next(tokens))  # type: int
    W = [(int(), int())] * (N)  # type: "Tuple[int, int]"
    for i in range(N):
        a = int(next(tokens))
        b = int(next(tokens))
        W[i] = (a, b)
    print(solve(N, W))

if __name__ == '__main__':
    main()


Measured memory_bytes: 34776
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>
#include<stdio.h>
#include<stdlib.h>



using namespace std;
typedef long long ll;
int gcd( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	// ユークリッドの方法
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}//gcd
int lcm( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
int input(){
  int x;
  cin>>x;
  return x;
}
int abs(int x){
  if(x>=0){
    return x;
  }else{
    return -x;
  }
}

int moji(char in)
{
    int ans = (int)in-(int)'a'+1;
    if((in < 1) || (in > 26)){
        ans = 100;
    }
    return ans;
}
const int VV=10;//場合に応じてVVの値のみ変更する必要あり
//dijkstra(s)sがスタート地点でそこからの最短距離を配列dで表す。正の重みのみ使用可能
int cost[VV][VV];
int d[VV];
bool used[VV];
void dijkstra(int s){
  fill(d,d+VV,100000);
  fill(used,used+VV,false);
  d[s]=0;
  while(true){
    int v=-1;
    for(int u=0;u<VV;u++){
      if(!used[u]&&(v==-1||d[u]<d[v]))v=u;
    }
    if(v==-1)break;
    used[v]=true;
    for(int u=0;u<VV;u++){
      d[u]=min(d[u],d[v]+cost[v][u]);
    }
  }

}

int compare_int(const void *a, const void *b)//qsort(quick sort利用時に使用)
{
    return *(int*)a - *(int*)b;
}









int main() {
  int N;
  cin>>N;
  int a[N];
  for(int i=0;i<N;i++){
    cin>>a[i];
  }
  sort(a,a+N);
  int sum=0;
  int summ=1;
  for(int i=0;i<N-1;i++){
    if(a[i]==a[i+1]){
      summ++;
    }else{
      if(a[i]>summ){
        sum+=summ;
        summ=1;
      }else if(summ>a[i]){
        sum+=summ-a[i];
        summ=1;
      }else{
        summ=1;
      }
    }
    if(i==N-2&&summ==1&&a[i+1]!=1){
      sum++;


    }else if(i==N-2){
      if(a[i]>summ){
        sum+=summ;
        summ=1;
      }else if(summ>a[i]){
        sum+=summ-a[i];
        summ=1;
      }

    }

  }
  if(N==1&&a[0]!=1){
    cout<<1<<endl;
    return 0;
  }else{
    cout<<sum<<endl;

  }
  

  





    




  

  


  

    


  

  
  
  
  
}


  

Measured memory_bytes: 640
import numpy as np
import sys
readline = sys.stdin.readline
read = sys.stdin.read

import bisect
n, q = map(int, readline().split())
s = readline().rstrip()
a = []
for i in range(len(s) - 1):
	if s[i] == 'A' and s[i + 1] == 'C':
		a.append(i)
for _ in range(q):
	l, r = map(int, readline().split())
	l -= 1
	r -= 2
	print(bisect.bisect_right(a, r) - bisect.bisect_left(a, l))


Measured memory_bytes: 15196
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
int arr[maxn];
int main()
{
	int n;
	scanf("%d", &n);
	for(int i = 1; i <= n; i ++) scanf("%d", &arr[i]);
	sort(arr + 1, arr + 1 + n);
	long long ans = 0LL + arr[n];
	int cnt = n - 2;
	for(int i = n - 1; i >= 1; i --)
	{
		if(cnt <= 2){
			ans += cnt * arr[i];
			break;
		}
		ans += 2LL * arr[i];
		cnt -= 2;
	}
	printf("%lld\n", ans);
	return 0;
} 

Measured memory_bytes: 4612
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
int n, c;
int dp[31][100010];
int main()
{
    cin >> n >> c;
    rep(i, n)
    {
        int s, t, x;
        cin >> s >> t >> x;
        dp[x][s] += 1;
        dp[x][t + 1] -= 1;
    }
    rep(j, 31)
    {
        for (int i = 1; i < 100010; i++)
        {
            dp[j][i] += dp[j][i - 1];
            dp[j][i - 1] = min(dp[j][i - 1], 1);
        }
    }
    int ans = 0;
    for (int j = 1; j < 31; j++)
    {
        rep(i, 100010)
        {
            dp[j][i] += dp[j - 1][i];
            ans = max(ans, dp[j][i]);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 12416
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    ll a,b,k;
    cin>>a>>b>>k;
    if(a>=k) cout<<a-k<<" "<<b;
    else if(a<k&&k<=a+b) cout<<0<<" "<<b+a-k;
    else cout<<0<<" "<<0;
}

Measured memory_bytes: 3640
def get_nums
  gets.split.map(&:to_i)
end

def init_matrix(row_num, row_length, default = nil)
  Array.new(row_num).map { Array.new(row_length, default) }
end

n = gets.to_i
nums = get_nums

current_min = 10**6
res = 0
nums.each do |i|
  if current_min >= i
    res += 1 
    current_min = i
  end
end

puts res


Measured memory_bytes: 15236