akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;

int main(){
   string S;
   cin >> S;
   if(S=="SUN") cout << 7 << endl;
   if(S=="MON") cout << 6 << endl;
   if(S=="TUE") cout << 5 << endl;
   if(S=="WED") cout << 4 << endl;
   if(S=="THU") cout << 3 << endl;
   if(S=="FRI") cout << 2 << endl;
   if(S=="SAT") cout << 1 << endl;
}

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

int main(){
	int n;
	cin >> n;
	for(int i = 0; i < n; i++) {
		int a;
		cin >> a;
		if (a % 2 == 0 && a % 3 != 0 && a % 5 != 0) {
			cout << "DENIED" << endl;
			return 0;
		}
	}
	cout << "APPROVED" << endl;
}


Measured memory_bytes: 256
//10
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>

using namespace std;

int main(){
  for(int n;cin>>n,n;){
    vector<int> c(n),r(n);
    for(int i=0;i<n;i++){
      cin>>c[i];
    }
    sort(c.begin(),c.end());
    for(int i=0;i<n;i++){
      cin>>r[i];
    }
    sort(r.begin(),r.end(),greater<int>());
    for(;;){
      bool u=false;
      for(;;){
	if(c.empty())goto end;
	if(c.back()!=r.size())break;
	c.pop_back();
	u=true;
	for(int i=0;i<r.size();i++){
	  r[i]--;
	}
      }
      for(;;){
	if(r.empty())goto end;
	if(r.back())break;
	r.pop_back();
	u=true;
      }
      if(!u)break;
    }
  end:
    cout<<((c.empty()||r.empty())?"Yes":"No")<<endl;
  }
  return 0;
}

Measured memory_bytes: 1288
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    ll N;
    cin >> N;

    ll ct = 10;
    ll ans = 0;
    while (N >= ct) {
        ans += N / ct;
        ct *= 5;
    }

    if (N % 2) ans = 0;

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

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    string s;
    cin >> s;
    s[3] = '8';
    
    
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1LL << 30;
int MOD = 1e9+7;
main(){
    string S;
    cin >> S;
    if(S.size() != 26){
        int num[26] = {};
        for(auto c:S)num[c-'a']++;
        for(int i = 0;i < 26;i++){
            if(!num[i]){
                cout << S << (char)(i+'a') << endl;
                return 0;
            }
        }
    }else{
        string str = "zyxwvutsrqponmlkjihgfedcba",ans;
        if(S == str){
            cout << -1 << endl;
            return 0;
        }
        str = S;
        next_permutation(S.begin(),S.end());
        for(int i = 0;i < S.size();i++){
            if(S[i] == str[i])ans += S[i];
            else {
                ans += S[i];
                break;
            }
        }
        cout << ans << endl;
    }
}

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

int main()
{
	char s[20],c[20];
	int n,f=0; 
	cin>>s;
	cin>>c;
	n=strlen(s);
	for(int i=0;i<n;++i)
	  if(s[i]!=c[i]) f=1;
	if(f) cout<<"No"<<endl;
	  else cout<<"Yes"<<endl;  
}


Measured memory_bytes: 3636
s = input()
l = len(s)

def DFS(i, f):
    n = []
    if i == l - 1:
        n.append(sum(list(map(int, f.split("+")))))
        return n

    return DFS(i + 1, f + s[i + 1]) + DFS(i + 1, f + "+" + s[i + 1])

print(sum(DFS(0, s[0])))


Measured memory_bytes: 3060
N, K = map(int, input().split())
*H, = map(int, input().split())
INF = 10**12
dp = [INF]*N
dp[0] = 0
dp[1] = abs(H[1] - H[0])
for i in range(2, N):
    beg = min(i, K)
    h_now = H[i]
    dp[i] = min([d + abs(h_now - h) for d, h in zip(dp[i-beg:i], H[i-beg:i])])
print(dp[N-1])

Measured memory_bytes: 13980
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[fastout]
fn main() {
    input!{
        n: usize,
        a: [usize;n],
    }
    let mut col: Vec<usize> = vec![0;8];
    let mut sup = 0;
    for i in 0..n {
        if 1<=a[i] && a[i]<=399 {
            col[0] += 1;
        } else if 400<=a[i] && a[i]<=799 {
            col[1] += 1;
        } else if 800<=a[i] && a[i]<=1199 {
            col[2] += 1;
        } else if 1200<=a[i] && a[i]<=1599 {
            col[3] += 1;
        } else if 1600<=a[i] && a[i]<=1999 {
            col[4] += 1;
        } else if 2000<=a[i] && a[i]<=2399 {
            col[5] += 1;
        } else if 2400<=a[i] && a[i]<=2799 {
            col[6] += 1;
        } else if 2800<=a[i] && a[i]<=3199 {
            col[7] += 1;
        } else {
            sup += 1;
        }
    }

    let mut ans = 0;
    for i in 0..col.len() {
        if col[i]!=0 {
            ans += 1;
        }
    }
    let mut min_col = 0;
    let mut max_col = 0;
    if ans==0 {
        min_col = 1;
        // max_col = min(col.len(), sup);
        max_col = sup;
    } else {
        min_col = ans;
        // max_col = min(col.len(), ans+sup);
        max_col = ans + sup;
    }  
    // debug!(col.len());
    // debug!(ans);
    // debug!(sup);
    println!("{} {}", min_col,max_col);

}


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


int main(){
    ll S, x1,x2,x3,y1,y2,y3;
    cin >> S;
    if(S%(ll(1e9)) == 0){
        y3 = S/1e9;
        x3 = 0;
    }else{
        ll r = S % (ll(1e9));
        x3 = 1e9 - r;
        y3 = (S+x3) / ll(1e9);
    }

    cout << "0 0 1000000000 1 "<< x3 <<" "<<y3<<endl;
    /*
    ll L = 0;
    ll R = S+1;
    while(L + 1 < R){
        ll X = (L+R)/2;
        if(X > 1e10){
            L = X;
        }else{
            if(S/X > 1e10){
                R 
            }
        }
    }
    */    
}


Measured memory_bytes: 256
include3 :: Int -> Bool
include3 0 = False
include3 n
  | n `mod` 10 == 3 = True
  | otherwise = include3 $ n `div` 10

main :: IO ()
main = do
  n <- readLn
  putStrLn $ " " ++ unwords [show i | i <- [1..n], i `mod` 3 == 0 || include3 i]

Measured memory_bytes: 4032
#include<bits/stdc++.h>  
using namespace std;
typedef long long ll;
const ll M=998244353;
int m,d,i,j,ans;
int main()
{
	scanf("%d %d",&m,&d);
	for(i=1;i<=m;i++)
		for(j=1;j<=d;j++)
			if(j%10>=2&&j/10>=2&&(j%10)*(j/10)==i)
				ans++;
	cout<<ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <math.h>
#include <map>
#include <stack>
using namespace std;
static const int INF = 1e9+7;
// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, a, b) for (int i =a; i < b; i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define PI 3.14159265359

int main(){
    int n, m, x, y; cin >> n >> m;
    vector<int>xi(n+1);
    vector<int>yi(m+1);
    cin >> xi[0];
    cin >> yi[0];
    repr(i, 1, n+1) cin >> xi[i];
    repr(i, 1, m+1) cin >> yi[i];

    sort(all(xi));
    sort(all(yi));

    if(xi[n] >= yi[0]){
        cout << "War" << endl;
    }else{
        cout << "No War" << endl;
    }
    
    return 0;
}


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

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n; cin >> n;
  long long ans = 0;
  for(int i = 1; i <= n; i++){
    if(i%3 != 0 && i%5 != 0){
      ans += i;
    }
  }
  cout << ans << endl;
  return 0;
}


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










int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n;
  cin>>n;
  int d=n%10;
  if(d==2 || d==4 || d==5 || d==7 || d==9){
    cout<<"hon";
  }else if(d==3){
    cout<<"bon";
  }else{
    cout<<"pon";
  }

  
  

}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
using namespace std;
int main()
{
  int N, M; cin >> N >> M;
  vector<int> a(M*2);
  rep(i,M) cin >> a[2*i] >> a[2*i+1];
  rep(i, N) cout << count(a.begin(), a.end(), i+1) << endl;
  return 0;
}

Measured memory_bytes: 256
// C++ program to compute LCM of array elements modulo M 
#include <bits/stdc++.h> 
#define F first 
#define S second 
#define MAX 10000003 
using namespace std; 
#define int long long
typedef long long ll; 
const int mod = 1000000007; 

int prime[MAX]; 
unordered_map<int, int> max_map; 

// Function to return a^n 
int power(int a, int n) 
{ 
    if (n == 0) 
        return 1; 
    int p = power(a, n / 2) % mod; 
    p = (p * p) % mod; 
    if (n & 1) 
        p = (p * a) % mod; 
    return p; 
} 

// Function to find the smallest prime factors 
// of numbers upto MAX 
void sieve() 
{ 
    prime[0] = prime[1] = 1; 
    for (int i = 2; i < MAX; i++) { 
        if (prime[i] == 0) { 
            for (int j = i * 2; j < MAX; j += i) { 
                if (prime[j] == 0) { 
                    prime[j] = i; 
                } 
            } 
            prime[i] = i; 
        } 
    } 
} 

// Function to return the LCM modulo M 
ll lcmModuloM(const int* ar, int n) 
{ 

    for (int i = 0; i < n; i++) { 
        int num = ar[i]; 
        unordered_map<int, int> temp; 

        // Temp stores mapping of prime factor to 
        // its power for the current element 
        while (num > 1) { 

            // Factor is the smallest prime factor of num 
            int factor = prime[num]; 

            // Increase count of factor in temp 
            temp[factor]++; 

            // Reduce num by its prime factor 
            num /= factor; 
        } 

        for (auto it : temp) { 

            // Store the highest power of every prime 
            // found till now in a new map max_map 
            max_map[it.first] = max(max_map[it.first], it.second); 
        } 
    } 

    ll ans = 1; 

    for (auto it : max_map) { 

        // LCM is product of primes to their highest powers modulo M 
        ans = (ans * power(it.F, it.S)) % mod; 
    } 

    return ans; 
} 

// Driver code 
signed main() 
{ 
    sieve(); 
    
    int n;cin>>n;
    int a[n];
    // inputarr(a,n);
    for(int i=0;i<n;i++) cin>>a[i];

    int k=lcmModuloM(a, n); 
    int ans=0;
    for(int i=0;i<n;i++){
        int z=k*power(a[i],mod-2);
        z%=mod;
        ans+=z;
        ans%=mod;
    }
    cout<<ans<<endl;
    return 0; 
} 


Measured memory_bytes: 78848
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

a=n3(3)
n=n0()
b=n2(n)

c=[[0,0,0] for _ in range(3)]
for i in range(3):
    for j in range(3):
        if a[i][j] in b:
            c[i][j]=1
ans="No"
for i in range(3):
    if sum(c[i])==3:
        ans="Yes"
    if c[0][i]+c[1][i]+c[2][i]==3:
        ans="Yes"
if c[0][0]+c[1][1]+c[2][2]==3 or c[0][2]+c[1][1]+c[2][0]==3:
    ans="Yes"
print(ans)

Measured memory_bytes: 3064
while True:
    a, op, b = input().split()
    a, b = int(a), int(b)
    if op == '+':
        print(a + b)
    elif op == '-':
        print(a - b)
    elif op == '*':
        print(a * b)
    elif op == '/':
        print(a // b)
    elif op == '?':
        break



Measured memory_bytes: 5600
n = int(input())
a, b = map(int, input().split())
p = list(map(int, input().split()))

c1 = 0
c2 = 0
c3 = 0

for pi in p:
    if pi <= a:
        c1 += 1
    elif pi <= b:
        c2 += 1
    else:
        c3 += 1

print(min(c1, c2, c3))


Measured memory_bytes: 38256
#include <stdio.h>

int main(){
    int N, buf;
    scanf("%d", &N);
    int A[300000] = {};
    for(int i=0; i<N-1; i++){
        scanf("%d", &buf);
        A[buf]++;
    }
    for(int i=1; i<=N; i++){
        printf("%d\n", A[i]);
    }
    return 0;
}

Measured memory_bytes: 2896
use proconio::{input};

fn main() {
    input! {
        n: i32,
        m: usize,
        a: [i32; m]
    }

    let sum: i32 = a.iter().sum();
    if n - sum >= 0 {
        println!("{}", n - sum);
    } else {
        println!("{}", -1);
    }
}



Measured memory_bytes: 2200
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>


using namespace std;
using namespace __gnu_pbds;


#define LL long long
#define N 100005
#define MOD 1000000007
#define dd double
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

int main() {

ios_base::sync_with_stdio(false);
cin.tie(NULL);
	
	int t=1;
	//cin>>t;
	while(t--){
		int a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
		int k;cin>>k;
		cout<<a[k-1]<<'\n';
	}



return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    ll x;
    cin >> x;
    ll tmp = 100;
    int ans = 0;
    while(true){
        tmp *= 1.01;
        ans++;
        if(tmp >= x){
            cout << ans << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;

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

__attribute__ ((constructor))
void init() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(10);
}

signed main(){
  int n;
  cin >> n;
  vector<pair<int,int>> v;
  rep(i, n){
    int x;
    cin >> x;
    v.push_back({x, i});
  }
  sort(v.rbegin(), v.rend());
  int max_index = v[0].second;
  rep(i,n){
    if(i!=max_index)
      cout << v[0].first << endl;
    else
      cout << v[1].first << endl;
  }
  return 0;
}

Measured memory_bytes: 5332
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int number_k, number_x, i;
    number_k = Integer.parseInt(sc.next());
    number_x = Integer.parseInt(sc.next());
    System.out.print(number_x - number_k + 1);
    for(i = 1; i <= 2 * number_k - 2; i++) {
      System.out.print(" " + (number_x - number_k + 1 + i));
    }
    System.out.println();
  }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    string st;
    cin>>st;
    ll len=st.length();
    ll ok=0;
    ll cnt=0;
    sort(st.begin(),st.end());
    for(int i=0;i<len;i++)
    {
        if(st[i]==st[i+1])
            cnt++;
    }
    if(4-cnt==2)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

        return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

// x^n
ll mod_pow(ll x, ll n) {
  if (n == 0) return 1;
  ll res = mod_pow(x * x % MOD, n / 2);
  if (n & 1) res = res * x % MOD;
  return res;
}

// x^{-1}
ll mod_inv(ll x) { return mod_pow(x, MOD - 2); }

vector<ll> fact;
vector<ll> fact_inv;

void init_fact(int n) {
  fact.resize(n + 1);
  fact_inv.resize(n + 1);
  fact[0] = fact_inv[0] = 1;
  for (int i = 0; i < n; ++i) {
    fact[i + 1] = fact[i] * (i + 1) % MOD;
    fact_inv[i + 1] = fact_inv[i] * mod_inv(i + 1) % MOD;
  }
}

ll nCr(ll n, ll r) {
  if (n < r || n < 0 || r < 0) return 0;
  return fact[n] * fact_inv[r] % MOD * fact_inv[n - r] % MOD;
}

ll nPr(ll n, ll r) { return nCr(n, r) * fact[r] % MOD; }

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  ll ans = mod_pow(2, n);
  init_fact(2 * 100001);
  ll ans1 = 1, ans2 = 1;
  for (int i = 1; i <= a; ++i) {
    ans1 = (ans1 * (n - i + 1)) % MOD;
    ans1 = (ans1 * mod_inv(i)) % MOD;
  }
  for (int i = 1; i <= b; ++i) {
    ans2 = (ans2 * (n - i + 1)) % MOD;
    ans2 = (ans2 * mod_inv(i)) % MOD;
  }
  ans = (ans + MOD - ans1) % MOD;
  ans = (ans + MOD - ans2) % MOD;
  ans = (ans + MOD - 1) % MOD;
  cout << ans << endl;
  return 0;
}

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

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

const int INF = 1000000007;
const ll INFLL = 1000000000000000007;

#define st first
#define nd second
#define pb push_back
#define _boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

// ***************************** CODE ***************************** //

const int MAX = 57;
const ll mod = 1e9 + 7;

int n;

void add(ll& a, ll b)
{
    a += b;
    if(a >= mod)
        a -= mod;
}

ll mult(ll a, ll b)
{
    return a * b % mod;
}

struct M
{
    vector <vector<ll>> T;
    M()
    {
        T.resize(n, vector<ll>(n));
    }
    M operator* (const M& b) const
    {
        M c = M();
        for(int i = 0; i < n; i++)
            for(int j = 0; j < n; j++)
                for(int k = 0; k < n; k++)
                    add(c.T[i][k], mult(T[i][j], b.T[j][k]));
        return c;
    }
};


int main() {
    _boost;

    ll k;
    cin >> n >> k;

    vector <vector<ll>> can(n, vector<ll>(n));
    for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++)
            cin >> can[i][j];

    M ans = M();
    for(int i = 0; i < n; i++)
        ans.T[i][i] = 1;

    M m = M();
    m.T = can;

    while(k)
    {
        if(k % 2 == 1)
            ans = ans * m;
        m = m * m;
        k /= 2;
    }

    ll total = 0;
    for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++)
            add(total, ans.T[i][j]);

    cout << total;

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    
    int a1,a2,a3;
    cin>>a1>>a2>>a3;
    
    cout<<max({a1,a2,a3})-min({a1,a2,a3})<<endl;
    
    return 0;
}

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

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES puts("YES\n")
#define Yes puts("Yes\n")
#define NO  puts("NO\n")
#define No  puts("No\n")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }




signed main() {

	int N;
	cin >> N;
	vector<int> A(N), B(N), C(N);
	rep(i, N) cin >> A[i];
	rep(i, N) cin >> B[i];
	rep(i, N - 1) cin >> C[i];

	int ans = 0;
	rep(i, N) {
		ans += B[i];
		if (i != N - 1 && A[i]+1==A[i+1])
			ans += C[A[i] - 1];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#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 = 1LL << 61;
const ll mod = 1000000007LL;
//const ll mod = 998244353LL;

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


ll a[33];



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



  cin >> s;
  rep(i, 4) {
    tmp = s[i] - 'A';
    a[tmp]++;
  }
  rep(i, 33) if (a[i] == 2) ans++;
  if (ans == 2) cout << "Yes" << endl;
  else cout << "No" << endl;




  return 0;
}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N, K, C;
	string S;
	cin >> N >> K >> C >> S;
	vector<int> DP(N, 0);
	vector<int> DP2(N, 0);

	rep(i, 0, N)
	{
		if (S[i] == 'o')
		{
			if (i - (C + 1) >= 0)DP[i] = DP[i - (C + 1)] + 1;
			else DP[i] = 1;
		}
		else
		{
			if (i - 1 >= 0)DP[i] = DP[i - 1];
			else DP[i] = 0;
		}
	}
	rrep(i, 0, N)
	{
		if (S[i] == 'o')
		{
			if (i + (C + 1) < N)DP2[i] = DP2[i + (C + 1)] + 1;
			else DP2[i] = 1;
		}
		else
		{
			if (i + 1 < N)DP2[i] = DP2[i + 1];
			else DP2[i] = 0;
		}
	}

	rep(i, 0, N)
	{
		if (S[i] == 'o')
		{
			int res = 0;
			if (i - 1 >= 0)res += DP[i - 1];
			if (i + 1 < N)res += DP2[i + 1];
			if (res < K)
			{
				cout << i + 1 << endl;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 5012
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    string s, t;
    cin >> s >> t;
    vector<vector<int>> v(26);
    int len = s.size();
    rep(i, 0, len) v[s[i] - 'a'].push_back(i);
    rep(i, 0, len) v[s[i] - 'a'].push_back(i + len);
    ll ans = 0;
    int p = 0;
    rep(i, 0, t.size()) {
        int c = t[i] - 'a';
        if ((int)v[c].size() == 0) {
            cout << -1 << endl;
            return 0;
        }
        p = *lower_bound(all(v[c]), p) + 1;
        if (p >= len) {
            ans += len;
            p -= len;
        }
    }
    ans += p;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1724
#include <stdio.h>

int main(){
    int n,k;
    scanf("%d %d", &n,&k);

    int d[k];
    int a[n];
    int i,j,tmp, cnt = 0;

    for(i = 0; i < n; i++){
        a[i] = 0;
    }

    for(i = 0; i < k; i++){
        scanf("%d", &d[i]);
        for(j = 0; j < d[i]; j++){
            scanf("%d", &tmp);
            a[tmp-1] = 1;
        }
    }
    for(i = 0; i < n; i++){
        if(a[i] == 0){
            cnt++;
        }
    }
    printf("%d", cnt);
}


Measured memory_bytes: 1708
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
#define F(i,a,n) for(int i=a;i<n;i++)
#define mod 1000000007 
#define pb push_back

int main(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	int w=1;
	// cin>>w;
	while(w--){
	string s;
	cin>>s;
	if(s[s.size()-1]=='s')s+="es";
	else s+='s';
	cout<<s;
	
	}

	return 0;
}

Measured memory_bytes: 3624
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <vector>
using namespace std;

const int INF = 1000000001;

inline int query(const vector<vector<int> >& mat, int a, int b, int c, int d) {
	return mat[d][c] - mat[d][a] - mat[b][c] + mat[b][a];
}

int main() {
	int n, m;
	scanf("%d %d", &n, &m);

	vector<int> x_pos, y_pos;
	x_pos.reserve(n + 1);
	y_pos.reserve(n + 1);

	x_pos.push_back(-INF);
	y_pos.push_back(-INF);

	vector<int> x(n), y(n);
	for(int i = 0; i < n; ++i) {
		scanf("%d %d", &x[i], &y[i]);
		x_pos.push_back(x[i]);
		y_pos.push_back(y[i]);
	}

	sort(x_pos.begin(), x_pos.end());
	sort(y_pos.begin(), y_pos.end());
	x_pos.erase(unique(x_pos.begin(), x_pos.end()), x_pos.end());
	y_pos.erase(unique(y_pos.begin(), y_pos.end()), y_pos.end());

	const int w = (int)x_pos.size(), h = (int)y_pos.size();
	vector<vector<int> > treasure(h, vector<int>(w, 0));

	for(int i = 0; i < n; ++i) {
		const int x1 = lower_bound(x_pos.begin(), x_pos.end(), x[i]) - x_pos.begin();
		const int y1 = lower_bound(y_pos.begin(), y_pos.end(), y[i]) - y_pos.begin();
		++treasure[y1][x1];
	}

	for(int i = 0; i < h; ++i)
		for(int j = 0; j < w - 1; ++j)
			treasure[i][j + 1] += treasure[i][j];

	for(int j = 0; j < w; ++j)
		for(int i = 0; i < h - 1; ++i)
			treasure[i + 1][j] += treasure[i][j];

	for(int i = 0; i < m; ++i) {
		int x1, y1, x2, y2;
		scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
		x1 = lower_bound(x_pos.begin(), x_pos.end(), x1) - x_pos.begin();
		y1 = lower_bound(y_pos.begin(), y_pos.end(), y1) - y_pos.begin();
		x2 = upper_bound(x_pos.begin(), x_pos.end(), x2) - x_pos.begin();
		y2 = upper_bound(y_pos.begin(), y_pos.end(), y2) - y_pos.begin();
		printf("%d\n", query(treasure, x1 - 1, y1 - 1, x2 - 1, y2 - 1));
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 98948
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int R, G, B, N;
  cin>>R>>G>>B>>N;
  int ans = 0;
  for(int r=0;r<=3000;++r) {
    for(int g=0;g<=3000;++g) {
      if((N-R*r-G*g)>=0 && (N-R*r-G*g)%B==0) {
        ans++;
      }
    }
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3596
while True:
    x = raw_input().split()
    a,op,b = int(x[0]),x[1],int(x[2])
    if op == "+":
        print a+b
    elif op == "-":
        print a-b
    elif op == "*":
        print a*b
    elif op == "/":
        print a/b
    else:
        break
    
    
    
    

Measured memory_bytes: 6336
#include<stdio.h>
#define N 1000

int main(void){
int a,b,c;
int i,n=0;

scanf("%d %d %d",&a,&b,&c);

for(i=a;i<=b;i++){
  if( (c%i) == 0 )n++;
}
printf("%d\n",n);
return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  if (N == 1) {
    cout << M << endl;
    return 0;
  }
  int ans = 1, tmp;
  for (int i = 2; i <= M/N; i++) {
    tmp = M - i * (N-1);
    if (tmp % i == 0) ans = i;
  }
  cout << ans << endl;
}

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

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> ans(n);
    vector<vector<int>> A(n,vector<int>(m));
    vector<int> B(m);
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            cin >> A[i][j];
        }
    }
    for(int i = 0; i < m; i++){
        cin >> B[i];
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            ans[i] += A[i][j] * B[j];
        }
    }
    for(int i = 0; i < n; i++){
        cout << ans[i] << endl;
    }
    return 0;
}


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

using namespace std;
#define inf             0x3f3f3f3f
#define INF             2e18
#define eps             1e-9

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen("output.txt","w",stdout)

#define LL              long long
#define ull            unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define SQR(a)          ((a)*(a))
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define vi              vector <int>
#define vL              vector <LL>
#define LB(a,x)         (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x)         (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define prec(n)         fixed << setprecision(n)

#define MEM(a,x)        memset(a,x,sizeof(a))
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())

#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define IT(it,x)	    for(it=x.begin();it!=x.end();it++)
int main()
{
  LL x,y;
  cin>>x>>y;
  if(2*x<=y and y<=4*x and y%2==0)
        cout<<"Yes";
  else
    cout<<"No";
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main(){
int N, sum = 0;
cin >>N;
vector<int> vec(N);
for (int i = 0; i < N; i++){
cin >> vec.at(i);
sum += vec.at(i);
}
sort(vec.begin(), vec.end());
if(vec.at(N-1) < sum - vec.at(N-1)){
cout << "Yes" <<endl;
}
else{
cout << "No" <<endl;
}
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = j;i <= k;++i)
#define repp(i,j,k) for(int i = j;i >= k;--i)
#define rept(i,x) for(int i = linkk[x];i;i = e[i].n)
#define P pair<int,int>
#define Pil pair<int,ll>
#define Pli pair<ll,int>
#define Pll pair<ll,ll>
#define pb push_back 
#define pc putchar
#define mp make_pair
#define file(k) memset(k,0,sizeof(k))
#define ll long long
int rd()
{
	int num = 0;char c = getchar();bool flag = true;
	while(c < '0'||c > '9') {if(c == '-') flag = false;c = getchar();}
	while(c >= '0' && c <= '9') num = num*10+c-48,c = getchar();
	if(flag) return num;else return -num;
}
int n;
int a[201000];
bool flag[201000];
int mi[100],tot; 
multiset<int>h;
multiset<int>::iterator it;
int main()
{
	n = rd(); rep(i,1,n) a[i] = rd();
	sort(a+1,a+n+1);
	reverse(a+1,a+n+1);
	for(ll i = 2;i <= 2e9;i <<= 1) mi[++tot] = i;
	rep(i,1,n) h.insert(-a[i]);
	
	int ans = 0;
	
	while(h.begin() != h.end())
	{
		int x = -(*h.begin());
		bool ck = false;
		rep(i,1,tot)
		{
			int y = x - mi[i];
		    if(y >= 0) continue;
			if(y == -x)
			{
		    	if(h.find(y) != h.end())
		    	{
		    		it = h.lower_bound(y);
		    	    it++;
		    	    if(it != h.end() && (*it) == y)
		    	    {
		    	    	h.erase(it);
		    	    	h.erase(h.begin());
		    	    	ans++;
		    	    	ck = true;
		    	    	break;
		    	    }
				}
		    }
			else
			if(h.find(y) != h.end())
			{
				h.erase(h.lower_bound(y));
				h.erase(h.begin());
				ans++;
				ck = true;
				break;
			}
		}
		if(!ck) h.erase(h.begin());
	}
	
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 10368
#include <iostream>
#include <float.h>
#include <cfloat>
#include <string>
#include <ctype.h>
#include <algorithm>
#include <errno.h>
#include <cerrno>
#include <assert.h>
#include <cassert> 
#include <map>
#include <memory.h>
#include <cctype>
#include <ctype.h>
#include <math.h>
#include <vector> 
#include <cstdio> 
#include <set>
#include <string.h>
#include <stdio.h>
#include <new>
#include <memory>
#include <cmath>
#include <queue>
#include <cstring>
#define ll long long
#define fo(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define br break
#define ct continue
#define pb push_back
#define mp make_pair 
#define pi 3.141592653589793238462643383279502884197169
#define F first
#define S second
#define pii pair<int,int>  
#define em empty()
#define vei vector<int>
#define ves vector<string>
#define qui queue<int> 
#define qu queue
using namespace std;
int main()
{int n;
 cin>>n;
 if(n<1200){
 cout<<"ABC"<<endl;
 return 0;
 }
 else if(n<2800 && n>=1200){
 cout<<"ARC"<<endl;
 return 0;
 }
 else{
 cout<<"AGC"<<endl;
 }
 return 0;
}

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

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<string>vst;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0)
#define all(ct) ct.begin() , ct.end()
#define endl "\n"
#define fr(i,a) for(auto i:a)
#define f(i,a,b) for(int i=a;i<b;++i)
#define fd(i,a,b) for(int i=a;i>=b;--i)
#define pb push_back
#define in(d,v) d.find(v)!=d.end()
#define mp make_pair
#define size(a) int(a.size())

const int mod = 1e9 + 7;
const ll inf = ll(1e15);
const double PI = acos(-1);

ll modexp(ll x,ll n,int md){
    if(n==0)return 1;
    if(n%2==0)return modexp((x*x)%md,n/2,md);
    return (x*modexp((x*x)%md,n/2,md))%md;
}


int main(){
    fastio;
    //clock_t tm = clock();
    string s;
    cin>>s;
    if(s[2]==s[3] and s[4]==s[5]){
        cout<<"Yes"<<endl;
    } else
        cout<<"No"<<endl;
    //cout<<((clock()-tm)*1.0)/CLOCKS_PER_SEC<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)

int bitCount(int x){
	int res = 0;
	while (x > 0) {
		if (x & 1) res++;
		x >>= 1;
	}
	return res;
}

int main() {
	int n;
	cin >> n;
	while (n--) {
		int s,d;
		scanf("%d %d", &s, &d);
		
		int ans = 0;
		if (s < 0 && d < 0) { s = -s; d = -d; swap(s, d);}
		
		if (s < 0) {
			ans += bitCount(-s);
			s = 0;
		}
		
		if (s != d) {
			if (s == 0) {
				ans += bitCount(d);
			}
			else {
				while (s + (s & -s) < d) {
					s += s & -s;
					ans++;
				}
				ans += bitCount(d - s);
			}
		}
		cout << ans << endl;
	}
	return 0;
}

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

int main()
{
    int h,w;
    while (1)
    {
        cin>>h>>w;

        if (h==0 && w==0)
            return 0;
        else
        {
            for (int i=0; i<h; i++)
            {
                for (int j=0; j<w; j++)
                {
                    if (i%2==0)
                    {
                        if (j%2 != 0)
                            cout<<".";

                        else if (j%2 == 0)
                            cout<<"#";
                    }
                    else if (i%2 != 0)
                    {
                        if (j%2 == 0)
                            cout<<".";

                        else if (j%2 != 0)
                            cout<<"#";
                    }
                }
                cout<<endl;
            }
            cout<<endl;
        }
    }
}



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

const double rad = 180 / M_PI;

int main() {
    cout<< fixed << setprecision(10);
    double a, b, x;
    cin >> a >> b >> x;
    if (x <= a * a * b / 2) {
        double p = x * 2 / a / b;
        cout << atan(b / p) * rad << endl;
    } else {
        double p = (a * b - x / a) * 2 / a;
        cout << 90 - atan(a / p) * rad << endl;
    }
}


Measured memory_bytes: 4056
import sys
input = sys.stdin.readline
def print_ans(input_line,input_arr):
    """Test Case
    >>> print_ans("4 150","150 140 100 200")
    2
    >>> print_ans("1 500","499")
    0
    >>> print_ans("5 1","100 200 300 400 500")
    5
    """
    N, K = list(map(int,input_line.split()))
    arr = list(map(int,input_arr.split()))
    ans = filter(lambda x:x >= K, arr)
    print(len(list(ans)))

if __name__ == '__main__':
    N = input()
    arr = input()
    print_ans(N,arr)

Measured memory_bytes: 12000
#include<iostream>
#include<vector>
#include<stack>
#include<algorithm>
#include<limits.h>
#include<string>
#include<math.h>
#include<map>
#include<deque>
#include<unordered_map>
using namespace std;

int main(){
    string a,b;
    cin>>a>>b;
    int m = a.length();
    int n = b.length();
    string matrix[m+1][n+1];
    int dp[m+1][n+1];
    for(int i=0;i<=m;i++)
        dp[i][0]=0;
    for(int i=0;i<=n;i++)
        dp[0][i]=0;
    for(int i=1;i<=m;i++){
        for(int j=1;j<=n;j++){
            if(a[i-1]==b[j-1]){
                dp[i][j] = 1+dp[i-1][j-1];
            }else{
                dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
    // for(int i=0;i<=m;i++){
    //     for(int j=0;j<=n;j++){
    //         cout<<dp[i][j]<<" ";
    //     }cout<<endl;
    // }
    string result = "";
    int i = m,j=n;
    while(i>0 && j>0){
        if(a[i-1]==b[j-1]){
            result.push_back(a[i-1]);
            i--;j--;
        }
        
        else if(dp[i-1][j]>dp[i][j-1]){
            i--;
        }else{
            j--;
        }
    }
    reverse(result.begin(),result.end());
    cout<<result;
}









Measured memory_bytes: 105856
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
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;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 

vll dp(100100);

ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll a,b,c;
  	ci(a>>b>>c);
  ll n=a-b;
  ll z=0;
  co(M(c-n,z))
}

Measured memory_bytes: 1024
#include<iostream>
 #include<vector>
 #include<algorithm>
 #include<string>
 #define REP(i,a) for (int i = 0;i < (a);++i)
 #define FOR(i,a,b) for (int i = (a);i < (b); ++i)
 #define FORR(i,a,b) for (int i = (a);i >= (b); --i)
 #define ALL(obj) (obj).begin,(obj).end()
 #define SORT(list) sort(ALL((list)));
 using namespace std;
 using ll = long long;
 int main(){
     string s;
     cin >> s;
     REP(i,s.length()){
         if(s.at(i)=='1')cout<<"9";
         else if(s.at(i)=='9')cout<<"1";
         else cout << s.at(i);
     }
     cout << endl;
     return 0;
 }

Measured memory_bytes: 256
import functools  # Python3 
N,M = map(int,input().split())
x, y, z = [0] * N, [0] * N, [0] * N
for i in range(N):
	x[i], y[i], z[i] = map(int,input().split())

if M==0:
	print(0)
	exit()

ppp = functools.reduce(lambda x,y: x+y,sorted([ x[i]+y[i]+z[i] for i in range(N)])[-M:])
pmp = functools.reduce(lambda x,y: x+y,sorted([ x[i]-y[i]+z[i] for i in range(N)])[-M:])
ppm = functools.reduce(lambda x,y: x+y,sorted([ x[i]+y[i]-z[i] for i in range(N)])[-M:])
pmm = functools.reduce(lambda x,y: x+y,sorted([ x[i]-y[i]-z[i] for i in range(N)])[-M:])
mpp = functools.reduce(lambda x,y: x+y,sorted([-x[i]+y[i]+z[i] for i in range(N)])[-M:])
mpm = functools.reduce(lambda x,y: x+y,sorted([-x[i]+y[i]-z[i] for i in range(N)])[-M:])
mmp = functools.reduce(lambda x,y: x+y,sorted([-x[i]-y[i]+z[i] for i in range(N)])[-M:])
mmm = functools.reduce(lambda x,y: x+y,sorted([-x[i]-y[i]-z[i] for i in range(N)])[-M:])

MAX = 0
for lis in [ppp,pmp,ppm,pmm,mpp,mpm,mmp,mmm]:
	if lis  > MAX:
		MAX = lis
print(MAX)


Measured memory_bytes: 3700
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
#define print(n) cout<<n<<endl
const int M=100111;
const int inf=1000000007;
const long long INF=1e18;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};

ll n,m,k,a,b,c,x;
vector<P> to[M];
ll dist[M];
priority_queue<P,vector<P>,greater<P>> que;
void dijkstra(int start){
//	rep(i,0,M)dist[i]=INF;
	dist[start]=0;
	que.push(P(0,start));
	while(que.size()){
		P p=que.top();que.pop();
		ll cost=p.first,now=p.second;
		if(dist[now]<cost)continue;
		for(auto e:to[now]){
			ll cost=e.first,next=e.second;
			if(dist[next]>dist[now]+cost){
				dist[next]=dist[now]+cost;
				que.push(P(dist[next],next));
			}
		}
	}
}


int main(){
	cin>>n>>m>>k;
	rep(i,0,m){
		cin>>a>>b>>c;
		to[a].push_back(P(c,b));
		to[b].push_back(P(c,a));
	}
	rep(i,0,M)dist[i]=INF;
	rep(i,0,k){
		cin>>x;
		dijkstra(x);
	}
	ll ans=0;
	rep(i,0,n+1){
		for(auto e:to[i]){
			ans=max(ans,(dist[i]+dist[e.second]+e.first+1)/2);
		}
	}
	print(ans);
		
}


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

int a[100010];

int main()
{
    cin.sync_with_stdio(0);
    cin.tie(0);

    int n, x; cin>>n>>x;
    for(int i=0; i<n; ++i) cin>>a[i+1];

    long res=0;
    for(int i=1; i<=n; ++i) {
        int t=(a[i]+a[i+1])-x;
        if (t>0) {
            a[i+1]-=t;
            if (a[i+1]<0) { a[i]+=a[i+1]; a[i+1]=0; }
            res+=t;
        }
    }
    cout<<res<<endl;
}


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

using namespace std;

int l[10];
int a, b;

int main()
{
    while (~scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",&l[0],&l[1],&l[2],&l[3],&l[4],&l[5],&l[6],&l[7],&l[8],&l[9],&a,&b)) {
        for (int i = 1; i < 10; ++i) l[i] += l[i - 1];
        double c = (double)l[9] / (a + b) * a;
        for (int i = 9; i >= 0; --i) if (c >= l[i]) { printf("%d\n", i + 2 - (c == l[i])); break; }
    }
}

Measured memory_bytes: 1188
#include<cstdio>
using namespace std;

int visited[160001],used[160001];
long cnt,cnt2;
int h,w;
char s[410][410];
void dfs(int x,int y){
    visited[x*w+y]=1;
    used[x*w+y]=1;
    if(s[x][y]=='#'){
        cnt2++;
    }
    cnt++;
    if(x>0&&s[x][y]!=s[x-1][y]&&used[(x-1)*w+y]==0){
        dfs(x-1,y);
    }
    if(x<h-1&&s[x][y]!=s[x+1][y]&&used[(x+1)*w+y]==0){
        dfs(x+1,y);
    }
    if(y>0&&s[x][y]!=s[x][y-1]&&used[(x)*w+y-1]==0){
        dfs(x,y-1);
    }
    if(y<w-1&&s[x][y]!=s[x][y+1]&&used[(x)*w+y+1]==0){
        dfs(x,y+1);
    }
}

int main(){
    long ans=0;
    scanf("%d %d",&h,&w);
    for(int i=0;i<h;i++){
        scanf("%s",s[i]);
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cnt=0;
            cnt2=0;
            if(used[i*w+j]==0){
                dfs(i,j);
                ans+=(cnt-cnt2)*cnt2;
            }
        }
    }
    printf("%ld\n",ans);
}

Measured memory_bytes: 19072
#include<cstdio>
#include<cstring>
#include<algorithm>

using int64=long long;

namespace IOManager{
	constexpr int FILESZ(131072);
	unsigned char buf[FILESZ];
	const unsigned char*ibuf=buf,*tbuf=buf;

	struct IOManager{

		IOManager(){}
		~IOManager(){}

		inline unsigned char gc()
			{return(ibuf==tbuf)&&(tbuf=(ibuf=buf)+fread(buf,1,FILESZ,stdin),ibuf==tbuf)?EOF:*ibuf++;}

		template<class _Tp>
			inline operator _Tp(){
				_Tp s=0u;unsigned char c=gc();
				for(;c<48;c=gc());
				for(;c>47;c=gc())
					s=(_Tp)(s*10u+c-48u);
				return s;
			}
	};
}IOManager::IOManager io;

int a[100001];
int lis[100001];
int bit[200001];

const int n=io;
const int64 total=(int64)n*(n+1)/2;

inline void update(const int&idx){
	for(int i=idx;i<=200000;i+=i&-i)
		++bit[i];
}
inline int sum(const int&idx){
	int ans=0;
	for(int i=idx;i;i-=i&-i)
		ans+=bit[i];
	return ans;
}

inline bool check(const int&v){
	memset(bit,0,sizeof bit);
	int64 s=0,ss=0;update(100000);
	for(int i=1;i<=n;++i){
		(a[i]<v)?--s:++s;
		ss+=sum(s+100000);
		update(s+100000);
	}return((total>>1)+(total&1ll))<=ss;
}

int main(){
	for(int i=1;i<=n;++i)
		a[i]=io;
	std::copy(a+1,a+n+1,lis+1);
	std::sort(lis+1,lis+n+1);
	int l=1,r=n;
	for(int mid;l<r;)
		check(lis[mid=((l+r)>>1)+1])?l=mid:(r=mid-1);
	printf("%u",lis[l]);
}


Measured memory_bytes: 1792
input_line = raw_input().split()
n = int(input_line[0])
m = int(input_line[1])
a = []
b = []
for i in range(0,n):
    line = raw_input().split()
    a.append([])
    for c in line:
        a[i].append(int(c))
for i in range(0,m):
    line = int(raw_input())
    b.append(line)
for i in range(0,n):
    out_sum = 0
    for j in range(0,m):
        out_sum += a[i][j]*b[j]
    print out_sum

Measured memory_bytes: 6584
#include<iostream>
#include<bits/stdc++.h>
#include<string>
using namespace std;
int main()
{
  int n,m,x,y ;
  cin >>  n >> m >> x >> y ;
  vector<int> xx(n) ;
  vector<int> yy(m) ;
  
  for(int i=0;i<n;i++)
   cin >>  xx[i] ;

  for(int i=0;i<m;i++)
    cin >>  yy[i] ;
  
  bool cond = 1 ;
  
  sort(xx.begin(), xx.end(), greater<int>());
  int z = xx[0]+1 ;
  
  if(!(x<z && z<=y))
    cond = 0 ;
  
  if(cond){
    for(int i=0;i<m;i++){
     if(yy[i]<z){
       cond = 0 ;
       break ;
     } 
    }
  }

  if(cond)
    cout << "No War" << endl ;
  else
    cout << "War" << endl ;
  
  return 0 ;
}


Measured memory_bytes: 256