akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#define rep(i,a) for(int i=0;i<a;i++)
#define nrep(i,a,b) for(int i=a;i<b;i++)
#define INF 1145141919810
#define ll long long
using namespace std;

int main(){
    ll n; cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    ll sum=0;
    ll ans_1=0;
    ll ans_2=0;
    bool plus=true;
    rep(i,n){
        sum+=a[i];
        if(plus){
            if(sum>=0){
                ans_1+=abs(sum)+1;
                sum=-1;
            }
        }else{
            if(sum<=0){
                ans_1+=abs(sum)+1;
                sum=1;
            }
        }plus=!plus;
    }plus=false;
    sum=0;
    rep(i,n){
        sum+=a[i];
        if(plus){
            if(sum>=0){
                ans_2+=abs(sum)+1;
                sum=-1;
            }
        }else{
            if(sum<=0){
                ans_2+=abs(sum)+1;
                sum=1;
            }
        }plus=!plus;
    }
    cout<<min(ans_1,ans_2)<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>

using namespace std;

#define REP(i,n)	for(int i=0;i<(n);++i)
#define REPS(i,s,t)	for(int i=(s);i<(t);++i)
#define SUMV(v)		(accumulate(v.begin(),v.end(),0.0))

#define INF 		2000000007
#define MOD			998244353

#define MAX 		300005

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int ll;

//int dp[MAX];
int C[MAX];
int inv[MAX];

ull pow(ull x, int n) { //x^n 計算量O(logn)
	ull ans = 1;
	while (n > 0) {
		if ((n & 1) == 1) {
			ans = ans * x % MOD;
		}
		x = x * x % MOD; //一周する度にx, x^2, x^4, x^8となる
		n >>= 1; //桁をずらす n = n >> 1
	}
	return ans;
}

int main(){
	int N;cin>>N;
	int A,B;cin>>A>>B;
	ull K;cin>>K;
	ull ans = 0;
	
	inv[0]=inv[1]=1;
	REPS(i,2,N+1)	inv[i]=MOD-1LL*(MOD/i)*inv[MOD%i]%MOD;
	C[0]=1;
	REPS(i,1,N+1)	C[i]=1LL*C[i-1]*(N-i+1)%MOD*inv[i]%MOD;

	REP(y,N+1){
		if(K < 1LL*B*y) continue;
		ull x = K-1LL*B*y;
		if(x%A==0){
			x = x/A;
			if(x<=N)
				ans = (ans+(1LL*C[x]*C[y])%MOD)%MOD;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 2560
N, A, B = map(int, input().split())
V = list(map(int, input().split()))
V.sort(reverse = True)

total = sum(V[:A])

ave = total / A

tmp = V[A - 1]

count = V.count(tmp)

def combination(n, r): #nCrを求める
    if n - r > r:
        r = n - r
    tmp = 1
    for i in range(n - r + 1, n + 1):
        tmp *= i
    for i in range(1, r + 1):
        tmp //= i
    return tmp





if V[0] == V[A - 1]: #上からA個が同じ
    ans = 0
    for i in range(A, min(B, count) + 1):
        ans += combination(count, i)

else: #A個ちょうど取るのがいいとき
    count2 = V[:A].count(tmp)
    ans = combination(count, count2)

print (ave)
print (ans)


Measured memory_bytes: 3064
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long double ld;

using namespace std;


int main() {
	string s;
	string t = "CODEFESTIVAL2016";
	cin >> s;
	int cnt = 0;
	for (int i = 0; i < (int)s.size(); ++i)
		if (s[i] != t[i])
			++cnt;
	cout << cnt << "\n";
	return 0;
}




Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int x, y, z;
    cin >> x >> y >> z;
    
    int tmp = x;
    x = y;
    y = tmp;
    int temp = x;
    x = z;
    z = temp;
    
    printf("%d %d %d\n", x, y, z);
    
}


Measured memory_bytes: 3760
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>

int main() {
  size_t N, K;
  scanf("%zu %zu", &N, &K);

  std::vector<int> l(N);
  for (auto& li: l) scanf("%d", &li);

  std::sort(l.rbegin(), l.rend());
  printf("%d\n", std::accumulate(l.begin(), l.begin()+K, 0));
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) throws Exception {
    Scanner sc = new Scanner(System.in);
    Long N = sc.nextLong();
    
    String name = "";
    
    while(N>0){
      N = N-1;
      String x = String.valueOf(Character.toChars((int)(N%26)+97));
      name = x.concat(name);
      if(N >=26){
        N = (Long)N/26;
      } else {
        break;
      }
    }
    System.out.println(name);
  }
}

Measured memory_bytes: 35692
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int N=200005;
int n,V,x[N],lt[N][21],rt[N][21],f[1100000],g[1100000],num,i,j,k,w[N];
int main()
{
	scanf("%d%d",&n,&V);
	for(i=1;i<=n;++i)
		scanf("%d",x+i);
	for(i=0;;++i)
	{
		lt[0][i]=lt[1][i]=1;
		for(j=2;j<=n;++j)
			if(x[j]-x[j-1]<=(V>>i))
				lt[j][i]=lt[j-1][i];
			else
				lt[j][i]=j;
		rt[n+1][i]=rt[n][i]=n;
		for(j=n-1;j>=1;--j)
			if(x[j+1]-x[j]<=(V>>i))
				rt[j][i]=rt[j+1][i];
			else
				rt[j][i]=j;
		num=i;
		if(!(V>>i))
			break;
	}
	f[0]=0;
	for(i=1;i<(1<<num);++i)
		for(j=1;j<=num;++j)
			if(i>>(j-1)&1)
				f[i]=max(f[i],rt[f[i^(1<<(j-1))]+1][j]);
	g[0]=n+1;
	for(i=1;i<(1<<num);++i)
	{
		g[i]=n+1;
		for(j=1;j<=num;++j)
			if(i>>(j-1)&1)
				g[i]=min(g[i],lt[g[i^(1<<(j-1))]-1][j]);
	}
	for(i=0;i<=n+1;++i)
		w[i]=-1;
	for(i=0;i<(1<<num);++i)
		w[g[i]]=max(w[g[i]],f[((1<<num)-1)^i]);
	for(i=1;i<=n+1;++i)
		w[i]=max(w[i],w[i-1]);
	for(i=1;i<=n;++i)
		if(w[rt[i][0]+1]>=lt[i][0]-1)
			puts("Possible");
		else
			puts("Impossible");
	return 0;
}


Measured memory_bytes: 40960
#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 fi first
#define se second
#define mp make_pair
#define pb push_back
#define pf push_front;
#define fbo find_by_order
#define ook order_of_key
#define lb lower_bound
#define ub upper_bound
#define rep(i,n) for(int i=0;i<n;i++)
#define fo(j,a,b) for(int j=a;j<=b;j++)
#define mem(x,a) memset(x,a,sizeof(x))

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef long double ld;
typedef map<ll,ll> spt;
typedef set<ll> si;
typedef multiset<ll>::iterator sit;
typedef map<int,int>::iterator mi;
typedef vector<int>::iterator vit;
typedef vector<ii> vii;
typedef set<ii> sii;
typedef multiset<ll> msi;
typedef vector< vector<ll> > matrix;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ost;
typedef tree<ii,null_type,greater<ii>,rb_tree_tag,tree_order_statistics_node_update> ost1;
template<class T> T chmin(T& a, T& b) { if(a>b) return a; }
template<class T> T chmax(T& a, T& b) { if(a<b) return b; }
const ll INF = 1e18;
const int MOD = 1e9 + 7;
const int N = 1e6 +5 ;
int main()
{
    ll n;
    cin>>n;
    ll a[n+2];
    rep(i,n)
    cin>>a[i];
    ll l=0,r=n-1,id=n-1,b[n+2];
    while(l<r)
    {
        b[l]=a[id];
        b[r]=a[id-1];
        l++,r--;
        id-=2;
    }
    if(n%2)
    b[l]=a[id];
    rep(i,n)
    cout<<b[i]<<" ";
}


Measured memory_bytes: 5248
use std::io::stdin;
use std::collections::HashMap;

fn main () {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    let mut s: isize = s.trim().parse().unwrap();
    let mut m: HashMap<isize, usize> = HashMap::new();
    for i in 1.. {
        if m.contains_key(&s) {
            println!("{}", i);
            return;
        }
        m.insert(s, i);
        s = if s % 2 == 0 { s / 2 } else { s * 3 + 1 };
    }
}

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


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

int N,M;
vector<vector<int>>G;


ll dp[100100];
int rec(ll v){
    if(dp[v]!=-1)return dp[v];
    
    int res=0;
    for(auto nv:G[v]){
        chmax(res,rec(nv)+1);
    }
    return dp[v]=res;
}



int main(){
   cin>>N>>M;
   G.assign(N,vector<int>());
   for(int i=0;i<M;i++){
       int x,y; cin>>x>>y;
       --x; --y;
       G[x].push_back(y);
   }

   rep(i,100100)dp[i]=-1;

   int res=0;
   for(int v=0;v<N;v++)chmax(res,rec(v));

   cout<<res<<endl;
}

Measured memory_bytes: 11376
#include <cstdio>

int main()
{
  int a, n, max, min;
  long sum = 0;
  scanf("%d", &n);

  min = 1000000;
  max = -1000000;

  for(int i=0; i<n; i++)
  {
    scanf("%d", &a);
    if (min > a)
    {
      min = a;
    }
    if (max < a)
    {
      max = a;
    }
    sum += a;
  }

  printf("%d %d %ld\n", min, max, sum);
  return 0;

}


Measured memory_bytes: 2740
/* be name khoda */

// #define long_enable
#include <iostream>
#include <algorithm>
#include <cstring>
#include <numeric>
#include <vector>
#include <fstream>
#include <set>
#include <map>
using namespace std;

#ifdef long_enable
typedef long long int ll;
#else
typedef int ll;
#endif

typedef pair<ll, ll> pii;
typedef pair<pii, ll> ppi;
typedef pair<ll, pii> pip;
typedef vector<ll> vi;
typedef vector<pii> vpii;

#define forifrom(i, s, n) for (ll i = s; i < n; ++i)
#define forirto(i, n, e) for (ll i = (n) - 1; i >= e; --i)
#define fori(i, n) forifrom (i, 0, n)
#define forir(i, n) forirto (i, n, 0)

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define smin(a, b) a = min(a, (b))
#define smax(a, b) a = max(a, (b))

#define debug(x) cout << #x << " -> " << (x) << endl
#define debug2(x, y) cout << #x << ' ' << #y << " -> " << (x) << ' ' << (y) << endl
#define debug3(x, y, z) cout << #x << ' ' << #y << ' ' << #z << " -> " << (x) << ' ' << (y) << ' ' << (z) << endl
#define debug4(x, y, z, t) cout << #x << ' ' << #y << ' ' << #z << ' ' << #t << " -> " << (x) << ' ' << (y) << ' ' << (z) << ' ' << (t) << endl
#define debuga(x, n) cout << #x << " -> "; fori (i1_da, n) { cout << (x)[i1_da] << ' '; } cout << endl
#define debugaa(x, n, m) cout << #x << " ->\n"; fori (i1_daa, n) { fori (i2_daa, m) { cout << (x)[i1_daa][i2_daa] << ' '; } cout << '\n'; } cout << endl

const ll MOD = 1000000007;
const ll INF = 2000000000;
const long long BIG = 1446803456761533460LL;

#define XL (x << 1)
#define XR (XL | 1)
#define MD ((l + r) >> 1)
#define Add(a, b) a = ((a) + (b)) % MOD
#define Mul(a, b) a = (1LL * (a) * (b)) % MOD

// -----------------------------------------------------------------------

const ll maxn = 6;

ll h, w, k;
string A[maxn];

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    // ifstream cin(".in");

    cin >> h >> w >> k;
    fori (i, h) cin >> A[i];
    ll cnt = 0;
    fori (b, 1 << (h + w)) {
        ll c = 0;
        fori (i, h) fori (j, w) {
            if (A[i][j] == '#' && ((b >> i) & 1) == 0 && ((b >> (h + j)) & 1) == 0) ++c;
        }
        cnt += c == k;
    }
    cout << cnt << '\n';
    
}


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

int main() {
	int a, b;
	cin >> a >> b;
	int count = 0;
	for (int i = a;i <= b;i++) {
		if (i / 10000 == i % 10 && (i % 10000) / 1000 == (i % 100) / 10) {
			count++;
		}
	}
	cout << count;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int a,b,c,d;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	while(1) {
		c-=b;
		if(c<=0) {
			printf("Yes\n");
			break;
		}
		a-=d;
		if(a<=0) {
			printf("No\n");
			break;
		}
	}
	return 0;
}
	

Measured memory_bytes: 1604
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

int main()
{
	ll x,y; cin >> x >> y;
	ll ret = 1e18;
	if(y>=x) ret = y-x;
	
	x*=-1;
	if(y>=x) ret = min(ret,1+y-x);
	else ret = min(ret,1+x-y);
	
	x*=-1;
	if(y>=x) ret = min(ret,2+y-x);
	else ret = min(ret,2+x-y);
	
	cout << ret << endl;
}

Measured memory_bytes: 256
h, w, k = map(int, input().split())
C = [list(input()) for _ in range(h)]

ans = 0
for b1 in range(2 ** h):
  for b2 in range(2 ** w):
    CC = [c[:] for c in C]
    for i in range(h):
      if (b1 >> i) & 1:
        for ww in range(w):
          CC[i][ww] = "."
    for j in range(w):
      if (b2 >> j) & 1:
        for hh in range(h):
          CC[hh][j] = "."
    bl = 0
    for line in CC:
      bl += line.count("#")
    if bl == k:
      ans += 1
print(ans)


Measured memory_bytes: 9208
#include<iostream>
using namespace std;
int main()
{
	long long n,l1=1,l2=2,ans=0;
	cin>>n;
	if(n==0)
	    cout<<2;
	else
	if(n==1)
	    cout<<1;
	else
	{
			for(int i=0;i<=n-2;i++) 
		{
			ans=l1+l2;
			l2=l1;
			l1=ans;
		} 
		cout<<ans; 
	}		
	return 0;
}

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

int main(){
    int n, k;
    cin >> n >> k;
    int v[50];
    for(int i=0;i<n;i++) cin >> v[i];

    pair<int,int> vs[50];
    for(int i=0;i<n;i++) vs[i] = {v[i], i};
    sort(vs, vs+n);

    int sum_l[51], sum_r[51];
    sum_l[0] = 0;
    for(int i=0;i<n;i++) sum_l[i+1] = sum_l[i] + v[i];
    sum_r[0] = 0;
    for(int i=1;i<=n;i++) sum_r[i] = sum_r[i-1] + v[n-i];

    int ans = 0;
    for(int ret=0;ret<=k;ret++){
        for(int left=0;left<=k-ret;left++){
            for(int right=0;right<=k-ret-left;right++){
                if(left+right>n) continue;
                int sc = sum_l[left] + sum_r[right];
                int r = 0;
                for(int i=0;i<n;i++){
                    if(vs[i].first >= 0 || r>=ret) break;
                    if(vs[i].second < left || vs[i].second >= n-right){
                        r++;
                        sc -= vs[i].first;
                    }
                }
                ans = max(ans, sc);
            }
        }
    }

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

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import Counter
from operator import itemgetter
def main():
    n=int(input())
    V=[int(_) for _ in input().split()]
    even=V[0::2]
    odd=V[1::2]
    even_c=Counter(even)
    odd_c=Counter(odd)
    even_ci,odd_ci=list(even_c.items()),list(odd_c.items())
    even_ci.sort(key=itemgetter(1),reverse=True)
    odd_ci.sort(key=itemgetter(1),reverse=True)
    if even_ci[0][0]==odd_ci[0][0]:
        if len(even_ci)>1 and len(odd_ci)>1:
            print(min(sum(even_c.values())-even_ci[1][1]+sum(odd_c.values())-odd_ci[0][1],
                        sum(even_c.values())-even_ci[0][1]+sum(odd_c.values())-odd_ci[1][1]))
        elif len(even_ci)>1 and len(odd_ci)==1:
            print(sum(even_c.values())-even_ci[1][1])        
        elif len(even_ci)==1 and len(odd_ci)>1:
            print(sum(odd_c.values())-odd_ci[0][1])        
        else:
            print(n//2)   
    else:
        print(sum(even_c.values())-even_ci[0][1]+sum(odd_c.values())-odd_ci[0][1])

if __name__=='__main__':
    main()

Measured memory_bytes: 21944
N,K = map(int,input().split())

coef = 1
pp = 1

answer = 0
if N >= K:
  answer += N-K+1 # 最初から勝てるやつ

while pp <= K:
  coef /= 2
  cnt = min(N,(K-1)//pp) - min(N,(K-1)//(pp<<1)) # 勝率がcoefであるようなものの個数
#  print(coef,cnt)
  answer += coef * cnt
  pp <<= 1
  
answer /= N
print(answer)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
	string T;
	cin >> T;
	string S;
	cin >> S;
	
	int sum=0;
	for(int i=0;i<T.length();i++){
		if(T[i]!=S[i]){
			sum++;
		}
	}
	cout << sum <<endl;
	return 0;
}

Measured memory_bytes: 3860
#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int n, m, root, d[N], desc[N], fa[N];
vector <int> v[N];
queue <int> q;
int main() {
	cin >> n >> m;
	for (int i = 1; i < n + m; i ++) {
		int from, to;
		cin >> from >> to;
		v[from].push_back (to);
		desc[to] ++;
	}
	for (int j = 1; j <= n; j ++)
		if (desc[j] == 0) {
			root = j;
			break;
		}
	q.push(root);
	while (!q.empty()) {
		int x = q.front(), to;
		q.pop();
		for (int i = 0; i < v[x].size(); i ++) {
			to = v[x][i];
			desc[to] --;
			if (desc[to] == 0) {
				fa[to] = x;
				q.push(to);
			}
		}
	}
	fa[root] = 0;
	for (int i = 1; i <= n; i ++)
		cout << fa[i] << endl;
	return 0;
}


Measured memory_bytes: 7040
#include <iostream>
//#include <iomanip>
#include <string>
//#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}
//ld dis(ll a,ll b,ll c,ll d){return sqrt((a-c)*(a-c)+(b-d)*(b-d)) ;}

int main(){
	string s,t ;
	cin >> s >> t ;
	for(int i=0;i<s.size();i++){
		if(s.at(i)!=t.at(i)){
			yorn(0) ;
			return 0 ;
		}
	}
	yorn(1) ;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  string S= "APPROVED";
  cin >> N;
  vector<int> A(N);
  for ( int i=0; i < N; i++){
    cin >> A.at(i);
  }
  for (int i=0; i < N; i++){
    if (A.at(i) % 2 ==0){
      if( A.at(i) % 3 != 0 && A.at(i) % 5 != 0){
        S = "DENIED";
        break;
      }
      else
        continue;
    }
  }
  cout << S << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
using namespace std;
const int MaxN = 1e3 + 5;
int n,m;
int a[MaxN];
int main(){
	while(~scanf("%d%d",&n,&m)){
		int a1,a2,a3;
		a1 = n%10;
		a2 = (n%100)/10;
		a3 = n/100;
		m = a1*100+a2*10+a3;
		if(n==m)
			printf("Yes\n");
		else
			printf("No\n");
	}
}

Measured memory_bytes: 128
<?php
 $n1 = trim(fgets(STDIN));
$n2 = trim(fgets(STDIN));
  $array = [1,2,3];
  foreach($array as $i => $val) {
    if($val==$n1 || $val==$n2){
        unset($array[$i]);
    }
  }
  foreach($array as $val) {
      echo $val;
  }

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

typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define MP make_pair
#define MT make_tuple
#define F first
#define S second
#define PB push_back
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((ll)(x).size())
#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 ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define pvd(v) cout << setprecision(16) << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, start_index, num)  (a).begin()+(start_index),(a).begin()+(num)

int main() {
	int x, y;
	cin >> x >> y;
	bool flag = false;
	FOR(k, 0, x) {
		int t = x - k;
		if (k * 4 + t * 2 == y) {
			flag = true;
		}
	}
	if (flag) {
		ps(Yes);
	}
	else {
		ps(No)
	}
	return 0;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <string.h>
#include <vector>

int makeXY(int x, int y)
{
    return y * 100 + x;
};

int check(int H, int W, const int mazeb[22][22], int startX, int startY)
{
    std::vector<int> open;

    int maze[22][22];
    memcpy(maze, mazeb, sizeof(int) * 22 * 22);

    // スタート
    open.push_back(makeXY(startX, startY));
    maze[startY][startX] = 0;

    auto update = [&maze](int x, int y, int length)
    {
        if (maze[y][x] == 200000000)
        {
            // 入れない
        }
        else if (maze[y][x] > length) {
            // 遠いので上書き
            maze[y][x] = length;
            return true;
        }
        return false;
    };

    // 距離
    int maxLength = 0;
    while (open.size() > 0)
    {
        std::vector<int> nextOpen;

        for (auto it : open)
        {
            int x = it % 100;
            int y = it / 100;
            int length = maze[y][x] + 1;

            if (update(x, y - 1, length)) nextOpen.push_back(makeXY(x, y - 1)); if (maxLength < maze[y][x]) maxLength = maze[y][x];
            if (update(x, y + 1, length)) nextOpen.push_back(makeXY(x, y + 1)); if (maxLength < maze[y][x]) maxLength = maze[y][x];
            if (update(x - 1, y, length)) nextOpen.push_back(makeXY(x - 1, y)); if (maxLength < maze[y][x]) maxLength = maze[y][x];
            if (update(x + 1, y, length)) nextOpen.push_back(makeXY(x + 1, y)); if (maxLength < maze[y][x]) maxLength = maze[y][x];
        }

        open = std::move(nextOpen);
    }

    return maxLength;
}

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

    char maze[22][22] = { 0 };

    memset(maze, '#', 22);
    memset(maze[H + 1], '#', 22);

    for (int i = 0; i < H; ++i)
    {
        maze[i + 1][0] = '#';
        scanf("%s", &maze[i + 1][1]);
        maze[i + 1][W + 1] = '#';
    }

    int maze2[22][22];
    for (int y = 0; y <= H + 1; ++y)
    {
        for (int x = 0; x <= W + 1; ++x)
        {
            if (maze[y][x] == '#')
            {
                maze2[y][x] = 200000000;
            }
            else
            {
                maze2[y][x] = 100000000;
            }
        }
    }

    int maxLenght = 0;
    for (int y = 1; y <= H; ++y)
    {
        for (int x = 1; x <= W; ++x)
        {
            if (maze[y][x] == '#')
            {
                // 入れない場所
                continue;
            }

            int length = check(H, W, maze2, x, y);
            if (maxLenght < length)
            {
                // 遠い
                maxLenght = length;
            }
        }
    }

    printf("%d", maxLenght);
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
using System.IO;

class Solve
{
	const int mod = 1000000007;
	static void Main(string[] args)
	{
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
		Console.SetOut(sw);

		int N = int.Parse(Console.ReadLine());
		var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
		long snuke = a[0];
		long arai = 0;
        for(int i = 1; i < N; i++)
		{
			arai += a[i];
		}
		long ans = Math.Abs(snuke - arai);
		for (int i = 0; i < N - 1; i++) 
		{
			if (i == 0) { continue; }
			snuke += a[i];
			arai -= a[i];
			if (Math.Abs(snuke - arai) < ans)
			{
				ans = Math.Abs(snuke - arai);
			}
		}

		Console.WriteLine(ans);
		
		Console.Out.Flush();
	}
}

Measured memory_bytes: 31580
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;


unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

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

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    ll n,m;
    cin >> n >> m;
    vector<pair<pair<ll,ll>,ll>> z(m);
    for (int i = 0; i < m; i++) {
        cin >> z[i].first.first >> z[i].first.second >> z[i].second;
        z[i].first.first--;
        z[i].first.second--;
    }
    vector<ll> point(n, -100000000000000000);
    point[0] = 0;
    for (int iii = 0; iii < n; iii++) {
        for (int i = 0; i < m; i++) {
            point[z[i].first.second] = max(point[z[i].first.second], point[z[i].first.first] + z[i].second);
        }
    }
    ll a = 0;
    for (int iii = 0; iii < n+5; iii++) {
        for (int i = 0; i < m; i++) {
            if (point[z[i].first.second] < point[z[i].first.first] + z[i].second && z[i].first.second == n - 1) {
                a = -1000000000000000000;

            }
            point[z[i].first.second] = max(point[z[i].first.second], point[z[i].first.first] + z[i].second);
        }
    }
    if (a == -1000000000000000000)cout << "inf" << endl;
    else cout << point[n - 1] << endl;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[222222];
struct edge{int to,cost;};
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){//線分の交差判定
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
void init_fact(int n){
	kaijo[0]=1;
	for(int i=1;i<=n;i++){
		kaijo[i]=kaijo[i-1]*i;
		kaijo[i]%=MOD;
	}
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	int memo=modpow(a,b/2);
	return memo*memo%MOD;
}
int comb(int a,int b){
	return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int g(int x){
	x=modpow(x,MOD-2);
	return x;
}
int n,q;
string s;
signed main(){
	cin>>n>>s>>q;
	rep(i,q){
		int k,cntd=0,cntm=0,cnt=0,ans=0;
		cin>>k;
		rep(i,n){
			if(i>=k){
				if(s[i-k]=='D')cntd--,cnt-=cntm;
				else if(s[i-k]=='M')cntm--;
			}
			if(s[i]=='D')cntd++;
			else if(s[i]=='M')cntm++,cnt+=cntd;
			else if(s[i]=='C')ans+=cnt;
		}
		cout<<ans<<endl;
	}
	return 0;
}


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

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

vector<string> a;
int n;

set<char> boin = { 'a', 'i', 'u', 'e', 'o' };

bool ok(int k) {
        set<string> s;
        for (int i = 0; i < n; i ++) {
                string res = "";
                res += a[i][0];
                for (int j = 1; j < a[i].size(); j ++) {
                        if (boin.count(a[i][j - 1])) res += a[i][j];
                }
                if (res.size() >= k) res = res.substr(0, k);
                if (s.count(res)) return false;
                s.insert(res);
        }
        return true;
}

int main() {
        while (cin >> n && n) {
                a.clear();
                a.resize(n);
                for (int i = 0; i < n; i ++) cin >> a[i];
                int lb = 0, ub = 51;
                while (ub - lb > 1) {
                        int mid = (lb + ub) / 2;
                        if (ok(mid)) ub = mid;
                        else lb = mid;
                }
                if (ub == 51) cout << -1 << endl;
                else cout << ub << endl;
        }
        return 0;
}

Measured memory_bytes: 3096
#include <stdio.h>

int main(){
  int h, w, i, j;
  while(scanf("%d%d", &h, &w) && h && w){
    for(i = 0;i < h;i++){
      for(j = 0;j < w;j++) putchar((i + j) % 2 == 0 ? '#' : '.');
      puts("");
    }
    puts("");
  }
  return 0;
}

Measured memory_bytes: 588
#include <iostream>
#include <iosfwd>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cassert>
#include <cctype>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <sstream>
#include <complex>
#include <fstream>
#include <functional>
#include <numeric>
#include <utility>
#include <algorithm>
#include <assert.h>
#include <unordered_map>
#include <random>
#include <ctime>
#include <chrono>

using namespace std;

long long t, n, m, u, v, q, k, p;
const int N = 1e6 + 1e5 + 500;
const long long mod = 1e9 + 7;
const long long INF = 1LL << 57;



int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  for (int i = 1; i <= 5; ++i) {
    cin >> u;
    if (u == 0) cout << i << endl;
  }
}





















Measured memory_bytes: 3652
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++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(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

const ll mod = 1000000007;
const int N = 201000;
ll fact[N], invf[N];

ll add(ll x, ll y){
    return (x+y)%mod;
}

ll mul(ll x, ll y){
    return (x%mod)*(y%mod)%mod;
}

ll powll(ll x, ll y){
    ll res = 1LL;
    while(y){
        if (y & 1LL)
            res *= x;
        res %= mod;
        x = (x*x) % mod;
        y >>= 1LL;
    }
    return res;
}

ll divll(ll x, ll y){
    return (x * powll(y,mod-2)) % mod;
}

ll nCr(ll n, ll r){
    if (n < r || r < 0) return 0;
    return mul(mul(fact[n], invf[r]), invf[n-r]);
}

int main() {
    ll x, y;
    cin >> x >> y;

    fact[0] = invf[0] = 1;
    FOR(i,1,N-1){
        fact[i] = (fact[i-1] * i) % mod;
        invf[i] = divll(invf[i-1], i);
    }

    ll px = 0, py = 0;
    FOR(t,0,x+y-1){
        // cout << "t " << t << endl;
        if (t >= y){
            ll p = divll(nCr(t - 1, y - 1), powll(2, t - 1));
            p = divll(p, 2);
            py = (py + p) % mod;
            // cout << "y " << p << endl;
        }
        if (t >= x){
            ll p = divll(nCr(t - 1, x - 1), powll(2, t - 1));
            p = divll(p, 2);
            px = (px + p) % mod;
            // cout << "x " << p << endl;
        }
        ll ans = (1 + py - px + mod) % mod;
        ans = divll(ans, 2);
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 5376
//in the name of god
//if you read this code please search about imam hussain
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

#define pb push_back
#define endl "\n"
#define X first
#define Y second
#define pii pair<int,int>
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define read freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout)

const int maxn=1e5+5;
const int mod=1e9+7;
const int inf=1e9;
const int del=728729;

ll poww(ll a, ll b, ll md) {return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));}
ll n ;
ll l ;
ll arr[maxn];
ll tol[maxn];
ll mx=-1;
ll ind;
int main(){
	migmig;
	cin >> n >> l;
	for(int i = 1 ; i <= n ; i++){
		cin >> arr[i];
	}
	for(int i = 1; i <= n-1 ; i ++){
		tol[i]=arr[i]+arr[i+1];
	}
	for(int i = 1 ; i <= n - 1 ; i++){
		if(tol[i]>mx){
			mx=tol[i];
			ind=i;
		}
	}
	if(mx >= l){
		cout<<"Possible"<<endl;
		for(int i = 1 ; i <= ind-1;i++){
			cout<<i<<endl;
		}
		for(int i = n - 1   ; i >= ind+1 ;i--){
			cout<<i<<endl;
		}
		cout<<ind;
	}else cout<<"Impossible";
	return 0;
}



Measured memory_bytes: 2432
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
 
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;
}
using namespace std;

void solve(){
    ll n;
    cin>>n;
    ll minv=1e12;
    for(int i=1;i<=sqrt(n);++i){
        if(n%i==0){
            minv=min(minv,i+n/i);
        }
    }
    cout<<minv-2<<"\n";
}
 
signed main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
	//cout<<fixed<<setprecision(15);
	solve();
	return 0;
}

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

  int main()
  {
    ios::sync_with_stdio(0);
      cin.tie(0);
      cout.tie(0);
    
    int n;
    string s;
    cin >> n >> s;
    int c=0;
    for(int i=0;i<n;i++) {
      if(s[i]=='.') c++;
    }
    int ans = c;
    for(int i=0;i<n;i++) {
      if(s[i]=='#') c++;
      else c--;
      ans = min(ans, c);
    } 
    cout << ans << "\n";

    return 0;
  }

Measured memory_bytes: 3668
#include<bits/stdc++.h>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iostream>
#define ios   ios_base::sync_with_stdio(false);  cin.tie(0);    cout.tie(0);
typedef   long long int ll;
using namespace std;
const int N=3e3+5;
#define fi first
#define se second
#define pb push_back
#define endl "\n"
ll ans[N][N];
int main()
{
    string s,t;cin>>s>>t;
    ll n=s.length(),m=t.length();
    for(ll i=1;i<=n;++i)
    {
        for(ll j=1;j<=m;++j)
        {
           if(s[i-1]==t[j-1])
           {
               ans[i][j]=ans[i-1][j-1]+1;
           }
           else
           ans[i][j]=max(ans[i][j-1],ans[i-1][j]);
        }
    }
    string  res="";
    ll i=n,j=m;
    while(i && j)
    {
        if(ans[i][j]!=ans[i][j-1] && ans[i][j]!=ans[i-1][j])
        {
            res+=t[j-1];
            --i;
            --j;
        }
        else
       if(ans[i][j]==ans[i][j-1])
       {
        //res+=t[j-1];
       --j;
       }
       else
       if(ans[i][j]==ans[i-1][j])
       {
         --i;
       }

    }
    ll u=res.size();
    for(ll i=u-1;i>=0;--i)
    cout<<res[i];
   /* for(ll i=0;i<=n;++i)
    {
        for(ll j=0;j<=m;++j)
        {
            cout<<ans[i][j]<<" ";
        }
        cout<<endl;
    }*/

}

Measured memory_bytes: 74044
#include <bits/stdc++.h>
using namespace std;
#include<algorithm>
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
ll gcd(ll a,ll b){
	if(b==0){
		return a;
	}
	return gcd(b,a%b);
}
int main() {
	ll n,m;
	cin>>n>>m;
	ll ch[100010];
	for(ll i=0;i<n;i++){
		cin>>ch[i];
		ch[i]/=2;
	}
	ll cnt=0;
	for(ll i=0;i<n;i++){
		ll now=0;
		while(ch[i]%2==0){
			now++;
			ch[i]/=2;
		}
		if(i==0){
			cnt=now;
			continue;
		}
		if(now!=cnt){
			cout << 0;
			return 0;
		}
	}
	while(cnt!=0){
		cnt--;
		m/=2;
	}
	ll lcm=ch[0];
	for(ll i=1;i<n;i++){
		ll now=gcd(max(lcm,ch[i]),min(lcm,ch[i]));
		//cout << now<<endl;
		//cout << lcm<<endl;
		//cout << ch[i]<<endl;
		now=lcm/now*ch[i];
		if(now>m){
			cout << 0;
			return 0;
		}
		lcm=now;
	}
	cout << (m+lcm)/(2*lcm);
	// your code goes here
	return 0;
}


Measured memory_bytes: 4328
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, M = mapint()
edges = [[10**18]*N for _ in range(N)]
used = [[False]*N for _ in range(N)]

ab = []
for _ in range(M):
    a, b, c = mapint()
    edges[a-1][b-1] = c
    edges[b-1][a-1] = c
    ab.append((a-1, b-1))

from heapq import heappop, heappush

def dijkstra(start):
    dist = [10**18]*N
    Q = [(0, start, start)]
    cnt = 0
    while Q:
        d, v, e = heappop(Q)
        if d>dist[v]:
            continue
        else:
            dist[v] = d
        cnt += 1
        used[v][e] = True
        used[e][v] = True
        for nx in range(N):
            if edges[v][nx]==10**18:
                continue
            if dist[nx] > d + edges[v][nx]:
                heappush(Q, (d + edges[v][nx], nx, v))
        if cnt==N:
            break

for i in range(N):
    dijkstra(i)
ans = 0
for a, b in ab:
    if not used[a][b]:
        ans += 1
print(ans)
        

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

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

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

	return false;
}

const int MAX_N = 1e2 + 10;
const int MAX_V = 1e5 + 10;
const long long INF = 1LL << 60;

int N, W, w[MAX_N], v[MAX_N];
long long dp[MAX_N][MAX_V];

int main()
{
	cin >> N >> W;
	for (int i = 0; i < N; ++i)
	{
		cin >> w[i] >> v[i];
	}

	for (int i = 0; i < MAX_N; ++i)
	{
		for (int j = 0; j < MAX_V; ++j)
		{
			dp[i][j] = INF;
		}
	}

	dp[0][0] = 0;

	for (int i = 0; i < N; ++i)
	{
		for (int j = 0; j < MAX_V; ++j)
		{
			if (j - v[i] >= 0)
				chmin(dp[i + 1][j], dp[i][j - v[i]] + w[i]);
			chmin(dp[i + 1][j], dp[i][j]);
		}
	}

	int res = 0;
	for (int i = 0; i < MAX_V; ++i)
	{
		if (dp[N][i] <= W)
		{
			res = i;
		}
	}

	cout << res << endl;
}

Measured memory_bytes: 86272
#include<stdio.h>
int main(void){
	int m,f,r;
	while(1){
	scanf("%d %d %d",&m,&f,&r);
		if(m==-1&&f==-1&&r==-1){
			break;
		}else if(m==-1||f==-1){
			printf("F\n");
		}else if(80<=m+f){
			printf("A\n");
		}else if(65<=m+f&&m+f<80){
			printf("B\n");
		}else if(50<=m+f&&m+f<65){
			printf("C\n");
		}else if(30<=m+f&&m+f<50&&50<=r){
			printf("C\n");
		}else if(30<=m+f&&m+f<50&&r<50){
			printf("D\n");
		}else if(m+f<30){
			printf("F\n");
		}
	}
	return 0;
}

Measured memory_bytes: 584
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <math.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 1000000007
#define F first
#define S second
#define INF 200000000000000
#define PB push_back
struct e{
  ll a,b,c;  
};
ll n,m,s,t,ans,r;
P sd[100005],td[100005];
vector<P>g[100005];
e eg[200005];
int main(void){
    cin>>n>>m>>s>>t;
    s--;
    t--;
    for(int i=0;i<m;i++){
        cin>>eg[i].a>>eg[i].b>>eg[i].c;
        g[--eg[i].a].PB(P(--eg[i].b,eg[i].c));
        g[eg[i].b].PB(P(eg[i].a,eg[i].c));
    }
    for(int i=0;i<n;i++){
        sd[i]=P(INF,0);
        td[i]=P(INF,0);
    }
    priority_queue<P,vector<P>,greater<P> >dik;
    dik.push(P(0,s));
    sd[s]=P(0,1);
    while(!dik.empty()){
        ll v=dik.top().S,c=dik.top().F;
        dik.pop();
        if(sd[v].F<c)continue;
        for(int i=0;i<g[v].size();i++){
            ll u=g[v][i].F,d=g[v][i].S;
            if(sd[u].F>c+d){
                sd[u]=P(c+d,sd[v].S);
                dik.push(P(c+d,u));
            }else if(sd[u].F==c+d){
                sd[u].S=(sd[u].S+sd[v].S)%M;
            }
        }
    }
    dik.push(P(0,t));
    td[t]=P(0,1);
    while(!dik.empty()){
        ll v=dik.top().S,c=dik.top().F;
        dik.pop();
        if(td[v].F<c)continue;
        for(int i=0;i<g[v].size();i++){
            ll u=g[v][i].F,d=g[v][i].S;
            if(td[u].F>c+d){
                td[u]=P(c+d,td[v].S);
                dik.push(P(c+d,u));
            }else if(td[u].F==c+d){
                td[u].S=(td[u].S+td[v].S)%M;
            }
        }
    }
    ans=sd[t].S*sd[t].S%M;
    r=sd[t].F;
    for(int i=0;i<n;i++){
        if(sd[i].F+td[i].F==r&&sd[i].F==td[i].F){
            ans=(ans+M-sd[i].S*td[i].S%M*sd[i].S%M*td[i].S)%M;
        }
    }
    for(int i=0;i<m;i++){
        ll a=eg[i].a,b=eg[i].b,c=eg[i].c;
        if(sd[a].F+td[b].F+c==r&&abs(sd[a].F-td[b].F)<c){
            ans=(ans+M-sd[a].S*td[b].S%M*sd[a].S%M*td[b].S%M)%M;
        }
        if(sd[b].F+td[a].F+c==r&&abs(sd[b].F-td[a].F)<c){
            ans=(ans+M-sd[b].S*td[a].S%M*sd[b].S%M*td[a].S%M)%M;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 22896
#include <bits/stdc++.h>
//#include "local_debug.h"
using namespace std;
#define endl endl
#define debug(x) cout << #x << " = " << (x) << endl
typedef long long ll;
const int MOD = (int)1e9 + 7;
const int MAXN = (int)1e2 + 5;
ll n, a[MAXN], b[MAXN];
int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	while (cin >> n)
	{
		for (ll i = 2; i <= n; ++i) cin >> b[i];
		for (ll i = 2; i < n; ++i)
			a[i] = min(b[i], b[i + 1]);
		a[n] = b[n];
		a[1] = max(a[2], b[2]);
		ll ans = 0;
		for (ll i = 1; i <= n; ++i)
			ans += a[i];
		cout << ans << endl;
	}
}
/*
3
2 5

2
3

6
0 153 10 10 23
*/

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

using ll = long long int;
using ull = unsigned long long int;
using P = pair<int, int>;
using P3 = pair<P,int>;
using PP = pair<P, P>;
constexpr int INF = 1 << 30;
constexpr ll MOD = ll(1e6)+3;
constexpr int di[] = {0, 1, 0, -1};
constexpr int dj[] = {1, 0, -1, 0};
constexpr int di8[] = {0, 1, 1, 1, 0, -1, -1, -1};
constexpr int dj8[] = {1, 1, 0, -1, -1, -1, 0, 1};
constexpr double EPS = 1e-9;


int main(){
    ll n, k = 0;
    cin >> n;
    vector<ll> d(n+1);
    for(int i=0;i<n+1;i++){
        cin >> d[i];
        k += d[i];
    }
    bool ok = true;
    ll w = 1, ans = 0;
    for(int i=0;i<n+1;i++){
        // cout << w << " " << d[i] << endl;
        if(d[i] > w){
            ok = false;
            break;
        }
        ans += w;
        w -= d[i];
        k -= d[i];
        w = min(k, w*2);
    }
    if(ok){
        cout << ans << endl;
    }else{
        cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 4056
#include <iostream>
#include <cstdio>                                               //scanf,printf
#include <algorithm>                                            //max,min
#include <string>                                               //string
#include <cstring>                                              //strlen,strcat
#include <cctype>                                               //isalpha,tolower
#include <cmath>                                                //sqrt,sin
#include <stack>                                                //top,push
#include <queue>                                                //front,push
#include <vector>                                               //push_back,sort
#include <set>                                                  //insert,begin
#include <map>                                                  //insert,find
#include <list>                                                 //push_front,begin
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>                                               //pow,powf
#define INF (1<<30)
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
#define ll long long
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl;
#define WHITE 0
#define BLACK 2
#define GRAY 1


int main(){
  ll a,b;
  ll n;
  cin>>n;
  ll ans=0;
  bool c=true;
  ll minb=INF;
  for(int i=0; i<n; i++){
    cin>>a>>b;
    if(a<b){
      ans+=a;
      c=false;
    }else if(b<a){
      ans+=a;
      c=false;
      minb=min(minb,b);
    }else{
      ans+=a;
    }
  }
  if(c==false) {
    cout<<ans-minb<<en
    return 0;
  }else{
    cout<<0<<en
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const ll Mod = 998244353;
const int MAX = 510000;

int main() {
  int N;
  cin >> N;
  int Y = 1;
  while (true) {
    if (Y*(Y+1)/2>=N) break;
    Y++;
  }
  // 取り除く数
  int num = Y*(Y+1)/2-N;
  for (int i=1; i<=Y; i++) {
    if (i!=num) cout << i << endl;
  }
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace   std;
#define ff        first
#define ss        second
#define ll        long long
#define int       long long
#define inf       ((ll)1e18)
#define double    long double
#define ull       unsigned long long
#define mod       1000000007
#define vi        vector<ll>
#define extreme   inline
#define ppi       pair<ll,pair<ll,ll>>
#define pb        push_back
#define mp        make_pair
#define str       string
#define pi        2*acos(0.0)
#define pr(a,x,n) for(int i=x;i<n;i++){cout<<a[i]<<" ";}
#define p(a)      cout<<a;
#define sp(x,y)   fixed<<setprecision(y)<<x
#define w(x)      ll x; cin>>x; while(x--)
#define all(v)    v.begin(), v.end()
#define test      cout<<"THIS_AND_THIS"<<endl;
void kehsihba(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	/*#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif*/
}
void solve(){
	ll n,k,sum=0;cin>>n>>k;
	ll arr[n];
	for(int i=0;i<n;i++){
		cin>>arr[i];
	}
	sort(arr,arr+n);
	ll ans=0;
	ll m=n-k;
	for(int i=0;i<m;i++){
		sum+=arr[i];
	}
	cout<<sum;
}
int32_t main(){
	kehsihba();
	ll t=1;
	//cin>>t;
	while(t--){
		solve();
	}
}

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

int main(){
  string S;cin>>S;
  bool MM=false,YY=false;
  if(S.at(0)=='0' && S.at(1)!='0') MM=true;
  else if(S.at(0)=='1' && S.at(1)-'0'<=2) MM=true;
  if(S.at(2)=='0' && S.at(3)!='0') YY=true;
  else if(S.at(2)=='1' && S.at(3)-'0'<=2) YY=true;
  if(MM && YY) cout<<"AMBIGUOUS"<<endl;
  else if(MM) cout<<"MMYY"<<endl;
  else if(YY) cout<<"YYMM"<<endl;
  else cout<<"NA"<<endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1000000000;

int main()
{
   int k,s;
   cin >> k >> s;
   int ans = 0;
   rep(i,k+1)
   {
      rep(j,k+1)
      {
         if(s-i-j<=k&&s-i-j>=0)ans++;
      }
   }
   cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

int main(){
	int n;
	while(cin >> n){
		bool bin[1000000] = {};
		int m = 0;
		FOR(i,2,n+1)if(!bin[i]){
			REP(j,n/i+1)bin[i*j] = true;
			m++;
		}
		cout << m << endl;
	}
	return 0;
}

Measured memory_bytes: 1840
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  (n : r : _) <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  print $ if n < 10 then r + 100 * (10 - n) else r

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 508