akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MOD	1000000007
#define int	long long
#define pii pair<int,int> 
#define vi vector<int>
using namespace std;

int32_t main(){
	 int n;
	 cin >> n;
	 cout << n*n << endl;

	return 0;
}



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

int main()
{
  int N;
  cin >> N;
  int L[N];
  for (int i = 0; i < N; ++i)
    cin >> L[i];
  int max_index = -1;
  int max = 0;
  for (int i = 0; i < N; ++i)
  {
    if (max < L[i])
    {
      max = L[i];
      max_index = i;
    }
  }
  int others = 0;
  for (int i = 0; i < N; ++i)
  {
    if (i == max_index)
    {
      continue;
    }
    others += L[i];
  }
  if (max < others)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
use std::io::*;
    use std::str::FromStr;
     
    fn read<T: FromStr>() -> T {
        let stdin = stdin();
        let stdin = stdin.lock();
        let token: String = stdin
            .bytes()
            .map(|c| c.expect("failed to read char") as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        token.parse().ok().expect("failed to parse token")
    }
     
    fn judge_contest(n: u32, m: u32) -> String {
        if n == m {
            return "Yes".to_string();
        } else {
            return "No".to_string();
        }
    }
     
    fn main() {
        let n: u32 = read();
        let m: u32 = read();
   		let result = judge_contest(n, m);
        println!("{}", result);
    }

Measured memory_bytes: 4352
#include<stdio.h>
int s[3005][3005],c[3005][3005];
int main()
{
	int n,p;
	scanf("%d%d",&n,&p);
	for(int i=0;i<=n;i++)
	{
		s[i][0]=1;
		c[i][0]=1;
		for(int j=1;j<=i;j++)
		{
			s[i][j]=s[i-1][j-1]+(long long)s[i-1][j]*(j+1)%p;
			if(s[i][j]>=p)
			{
				s[i][j]-=p;
			}
			c[i][j]=c[i-1][j-1]+c[i-1][j];
			if(c[i][j]>=p)
			{
				c[i][j]-=p;
			}
		}
	}
	int ans=0;
	for(int i=0;i<=n;i++)
	{
		int mt1=1,mt2=2;
		for(int j=0;j<n-i;j++)
		{
			mt1<<=1;
			if(mt1>=p)
			{
				mt1-=p;
			}
			mt2=(long long)mt2*mt2%p;
		}
		int val=0;
		for(int j=i;j>=0;j--)
		{
			val=(long long)val*mt1%p;
			val+=s[i][j];
			if(val>=p)
			{
				val-=p;
			}
		}
		val=(long long)val*mt2%p;
		if(i&1)
		{
			ans-=(long long)val*c[n][i]%p;
			if(ans<0)
			{
				ans+=p;
			}
		}
		else
		{
			ans+=(long long)val*c[n][i]%p;
			if(ans>=p)
			{
				ans-=p;
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 69376
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
typedef pair<string, int> P;
#define mod 1e9 + 7;
ll gcd(ll x, ll y)
{
	ll r;
	while ((r = x % y) != 0)
	{
		x = y;
		y = r;
	}
	return y;
}
ll lcm(ll x, ll y)
{
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x * y);
}

int ab[100010];

int main()
{
	ios_base::sync_with_stdio(false);
	ll h, w;
	cin >> h >> w;
	char s[110][110];
	rep(i, h) rep(j,w)cin >> s[i][j];
	vi v,q;
	rep(i, h) {
		bool x = true;
		rep(j, w) {
			if (s[i][j] == '.') continue;
			else {
				x = false;
				break;
			}
		}
		if (x) v.pb(i);
	}
	rep(i, w) {
		bool x = true;
		rep(j, h) {
			if (s[j][i] == '.') continue;
			else{
				x = false;
				break;
			}
		}
		if (x) q.pb(i);
	}
	rep(i, h) {
		bool x = true;
		rep(a, v.size()) if (v[a] == i) x = false;
		if (x) {
			rep(j, w) {
				x = true;
				rep(a, q.size()) if (q[a] == j) x = false;
				if (x) {
					cout << s[i][j];
				}
			}
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {

    int N;
    cin >> N;
    cout << (N < 1000 ? "ABC" : "ABD") << endl;
    
    return 0;
}

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

int main() {
  int n,m; cin >> n >> m;
  vector<pair<ll,ll>> mazai(n);
  rep(i,n) cin >> mazai[i].first >> mazai[i].second;

  //rep(i,n) cout << mazai[i].first << mazai[i].second;

  sort(mazai.begin() , mazai.end());
  ll count=0;
  bool flag = false;
  ll ans = 0;
  rep(i,n){
    rep(j,mazai[i].second){
        ans += mazai[i].first;
        count++;
        if(count == m){
          flag = true;
          break;
        }
    }
    if(flag) break;
  }

  cout << ans << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <random>

using namespace std;

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

	int n;
	cin >> n;
	vector<int> a(n);
	for (auto &t : a) {
		cin >> t;
	}
	sort(a.begin(), a.end());
	double cur = ((double)a[0] + a[1]) / 2;
	for (int i = 2; i < n; i++) {
		cur = (cur + a[i]) / 2;
	}
	cout << fixed << setprecision(15);
	cout << cur << endl;
} 


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
    int n; cin >> n;
    double ans = 0;
    for(int i = 0; i < n; i++){
        double x;
        string u;
        cin >> x >> u;
        if(u == "BTC") ans += 380000*x;
        else ans += x;
    }
    printf("%.10f\n", ans);
    return 0;
}

Measured memory_bytes: 256
import collections

n, k = map(int, input().split())
mod = 10 ** 9 + 7
graph = [[] for i in range(n + 1)]
for i in range(n - 1):
    a, b = map(int, input().split())
    graph[a].append(b)
    graph[b].append(a)
flag = [False for i in range(n + 1)]
flag[1] = True
queue = collections.deque([1])
ans = k
while queue:
    test = queue.popleft()
    temp = [flag[graph[test][i]] for i in range(len(graph[test]))].count(True)
    num = 0
    for i in range(len(graph[test])):
        if flag[graph[test][i]] == True:
            continue
        ans *= (k - temp - num - 1)
        ans %= mod
        num += 1
        queue.append(graph[test][i])
        flag[graph[test][i]] = True
print(ans)

Measured memory_bytes: 28192
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
//change null_type here for map/set
typedef tree<int,null_type,less<int>,rb_tree_tag,
            tree_order_statistics_node_update> indexed_set;
typedef long long int  ll;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mem(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define F first
#define S second

template<class T>inline bool read(T &x){
    int c=getchar();int sgn=1;
    while(~c&&c<'0'||c>'9'){if(c=='-')sgn=-1;c=getchar();}
    for(x=0;~c&&'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
    x*=sgn; return ~c;
}
///START HERE
///indexed_set pbd;
//pbd.insert()
//auto x = pbd.find_by_order(2);
//int od=pbd.order_of_key(7)
///rope<int> rp;
//rp.push_back()
//RandomAccess like vector
//mutable_begin, mutable_end()

int main(){
    ///read()+printf
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //fast;
    int a;
    cin>>a;
    cout<<a+a*a+a*a*a;


    return 0;
}


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

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

    int a, b;
    string s;
    cin >> a >> b >> s;
    bool flg = true;

    for(int i = 0; i < s.length(); ++i){
        if(i<a && s[i]=='-') flg = false;
        if(i==a && s[i]!='-') flg = false;
        if(i>a && s[i]=='-') flg = false;
    }
    // if(flg) puts("Yes");
    // else puts("No");

    cout << (flg? "Yes": "No") << endl;
}

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

int main(){
    int n;cin>>n;
    vi v(n+1), w(n+1);
    rep(i,n)cin>>v[i+1]>>w[i+1];
    
    int q;cin>>q;
    vi s(q),tot(q);
    int mtot=0;
    rep(i,q){
        cin>>s[i]>>tot[i];
        mtot = max(mtot, tot[i]);
    }
    
    int size = min(n+1, 512);
    vv dp(size, vi(mtot+2, 0));
    
    for(int i=1; i<size; i++){
        for(int j=1; j<=mtot; j++){
            dp[i][j] = max(dp[i][j-1], dp[i/2][j]);
            if(j-w[i]>=0)
                dp[i][j] = max(dp[i][j], dp[i/2][j-w[i]]+v[i]);
        }
    }//dp[1~511][0~100000]のvが求まった
    
    rep(i,q){
        if(s[i]<size){
            cout << dp[s[i]][tot[i]] << endl;
            continue;
        }
        
        int len=0, b=s[i];
        while(b>511){
            b /= 2;
            len ++;
        }
        
        int ans = 0;
        
        rep(k,1<<len){
            int vsum = 0, wsum = 0;
            b = s[i];
            rep(j,len){
                if(k>>j & 1){
                    vsum += v[b];
                    wsum += w[b];
                }
                b /= 2;
            }
            
            if(wsum>tot[i])continue;
            ans = max(ans, vsum + dp[b][tot[i]-wsum]);
        }
        
        cout << ans << endl;
    }
    
    return 0;
}

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

using namespace std;

typedef long long int ll;
#define pb push_back
#define ALL(a) (a).begin() , a.end()

int mod = 1e9 + 7;
int add(int a, int b){
	if(a + b >= mod)return a+ b - mod;
	return a + b;
}
int mul(int a, int b){
	return 1LL * a * b  % mod;
}
int sub(int a, int b){
  if(a >= b)return a-b;
  return a - b + mod;
}
int power(int a, int b){
	int re = 1;
	while(b){
		if(b&1)re= mul(re, a);
		a = mul(a, a);
		b>>=1;
	}
	return re;
}
int const N = 100 *1001;

/********************i**********************************/
vector<int> vec[10];
void dfs(int a, int p){
  cout << a << " ";
  for(int b : vec[a]){
    if(b == p)continue;
    dfs(b, a);
  }
  cout << a << " ";
}
void solve(){
  int h, n; cin >> h >> n;
  vector<int> dp(h+ 1, 1e9);
  dp[0] = 0;
  for(int x = 1; x<=n; x++){
      vector<int> dp1 (h+1, 1e9);
      dp1[0] = 0;
      int a, b;
      cin >> a >> b;
      for(int y =1; y<= h; y++){
          if(y >= a) dp1[y] = min(dp[y], dp1[y-a] + b), dp1[y] = min(dp[y-a] + b , dp1[y]);
          else dp1[y] = min(dp[y], b);
      }
      swap(dp, dp1);
  }
  cout << dp[h];

}
/******************************************************/
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(nullptr);
	int t;
	t = 1;
	// cin >> t;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 384
S = input()

former = S[0:2]
latter = S[2:4]

is_former_month = False
is_latter_month = False
if 1 <= int(former) <= 12:
    is_former_month = True
if 1 <= int(latter) <= 12:
    is_latter_month = True

if is_former_month and is_latter_month:
    print("AMBIGUOUS")
elif is_former_month:
    print("MMYY")
elif is_latter_month:
    print("YYMM")
else:
    print("NA")


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

int main(){
  while(1){
    int a,n,m;
    vector<int> t;
    map<int,int> x,y;
    cin>>n>>m;
    if(n==0&&m==0)break;
    for(int i=0;i<n+m;i++){
      cin>>a;
      t.push_back(a);
      if(i<n)x[a]++;
      else y[a]++;
    }
    sort(t.begin(),t.end());
    int ans=0;
    for(int i=0;i<(int)t.size();i++){
      if(i&&t[i]==t[i-1])continue;
      ans+=max(x[t[i]],y[t[i]])*t[i];
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1220
#include <iostream>
#include <math.h>
#include <bits/stdc++.h>

using namespace std;

int main()
{
    char a[20]={0},b[20]={0},c[20]={0};
    int la,lb,flag=0;
    scanf(" %s",a);
    scanf(" %s",b);
    scanf(" %s",c);
    la=strlen(a);
    lb=strlen(b);
    if(a[la-1]==b[0]&&b[lb-1]==c[0]) flag=1;
    if(flag==1) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
bool isPrime[1000001];
ll power(ll a,ll b)
{
    ll result = 1;
    while(b>0)
    {
        if(b%2)
        {
            result = (a*result)%mod;
        }
        a = (a*a)%mod;
        b = b/2;
    }
    return result;
}
int gcd(int a,int b)
{
    if(b==0)
    {
        return a;
    }
    return gcd(b,a%b);
}
void sieve()
{
    memset(isPrime,1,sizeof(isPrime));
    isPrime[0] = isPrime[1] = 0;
    for(int i=2;i*i<=1000000;i++)
    {
        if(isPrime[i])
        {
            for(int j=i*i;j<=1000000;j+=i)
            {
                isPrime[j] = 0;
            }
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL),cout.tie(NULL);
    int t;
    t = 1;
    for(int i=0;i<t;i++)
    {
        int n;
        cin>>n;
        ll arr[n];
        unordered_map <ll,int> mp;
        ll sum = 0;
        for(int i=0;i<n;i++)
        {
            cin>>arr[i];
            mp[arr[i]]++;
            sum+=arr[i];
        }
        int q;
        cin>>q;
        for(int i=0;i<q;i++)
        {
            int a,b;
            cin>>a>>b;
            sum+=(b-a)*mp[a];
            cout<<sum<<"\n";
            int l = mp[a];
            mp.erase(a);
            mp[b] += l;
        }
    }
    return 0;
}

Measured memory_bytes: 7460
import sys

input = sys.stdin.readline

a = list(map((int), input().split(' ')))
N, M = a[0], a[1]
 
first = []
second = []
 
for i in range(M):
    
    b = list(map((int),input().split(' ')))
    start, end = b[0], b[1]
    
    if start == 1:
        first.append(end)
    if end == N:
        second.append(start)
        
first_set = set(first)
second_set = set(second)
 
matched_l = list(first_set & second_set)
 
if matched_l is None or len(matched_l) == 0:
    print('IMPOSSIBLE')
else:
    print('POSSIBLE')

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

int main() {
  int num;
  while(cin >> num && num) {
    string res = "";
    while(num) {
      int t = ( num % 10 + 10 ) % 10;
      res += '0' + t;
      num = (num-t)/-10;
    }
    reverse(res.begin(), res.end());
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
vector<vector<char>> mass;
vector<vector<ll>> dp;
int H, W;

int main(){
  cin >> H >> W;
  mass.resize(H, vector<char>(W));
  dp.resize(H, vector<ll>(W, 1));  //すべてのマスに1を代入

  char c;
  for(int i = 0; i < H; i++){ for(int j = 0; j < W; j++){ cin >> c; mass[i][j] = c; } }
  for(int i = 0; i < H; i++){ 
    for(int j = 0; j < W; j++){
    if(mass[i][j] == '#') dp[i][j] = 0; //そもそも行けないよ
    else if(i == 0 && j == 0) continue; //始点は何もしないよ
    else if(i == 0) dp[i][j] = dp[i][j-1];  //一行目は左からしか行けないよ
    else if(j == 0) dp[i][j] = dp[i-1][j];  //一列目は上からしか行けないよ
    else dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % MOD;  //それ以外は上・右から来れるよ
    }
  }
  /*確認用*/
  //for(int i = 0; i < H; i++){ for(int j = 0; j < W; j++){ cout << dp[i][j] << " "; } cout << endl; }
  
  cout << dp[H-1][W-1] << endl;
  return 0;
}







Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, m, n) for (int i = m; i < n; ++i)
#define rem(i, m, n) for (int i = m; i > n; --i)
const int MOD = 1000000007;

int main() {
  int x, a;
  cin >> x >> a;
  cout << (x < a ? 0 : 10) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
   int N, M, A, B, i, sum_money = 0, max_money = 0;
   scanf("%d %d", &N, &M);
   while ( M ) {
      scanf("%d %d", &A, &B);
      if ( A < N ) {
         sum_money += N - A;
         if (max_money < N - A ) max_money = N - A;
      }
      M--;
   }
   printf("%d\n", sum_money - max_money);
   return 0;
}

Measured memory_bytes: 1860
#include <iostream>
#include<vector>
#include<algorithm>
#define rep(i,n) for(int i = 0;i <n;i++)
using namespace std;
int main(){
	int n, q; cin >> n;
	vector<int> a(n),b(n);
	rep(i, n) cin >> a[i];
	b = a;
	sort(b.begin(), b.end()); int cnt = 0;
	rep(i, n) if (a[i] == b[i]) cnt++;
	if (cnt == n) {
		cout << 0 << endl;
		return 0;
	}cin >> q;
	rep(i, q) {
		int l, r; cin >> l >> r; l--; r--;
		if (a[l] == b[l]) cnt--;
		if (a[r] == b[r])cnt--;
		if (a[l] == b[r])cnt++;
		if (a[r] == b[l])cnt++;
		swap(a[r], a[l]);
		if (cnt == n) {
			cout << i + 1 << endl;
			return 0;
		}
	}cout << -1 << endl;
}


Measured memory_bytes: 5180
import collections
N,M = map(int, input().split())
A = list(map(int,input().split()))
D = collections.Counter(A)

A.sort()
max = 0 

for i in range(M):
    B,C = map(int, input().split())
    D[C] += B  

D = sorted(D.items(), key=lambda x:x[0],reverse=True)

sum = 0 
count = 0 
for k,v in D:
    if N > v : 
        sum += k * v
        N -= v 
    else : 
        sum += k * N 
        break 
print(sum)

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

int main() {
	string S;
	cin >> S;
	int x = 0;
	int y = 0;
	for (int n = 0;n<S.size();++n) {
		if ('0' == S[n]) {
			++x;
		}
		else {
			++y;
		}
	}
	cout << 2*min(x,y) <<  endl;
}


Measured memory_bytes: 3728
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
//#pragma GCC optimize("Ofast")
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
//#define int ll
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX / 2;
const ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  int N, K;
  cin >> N >> K;
  vll H(N);
  rep(i, N) cin >> H[i];
  
  if(K >= N) {
    fin(0);
    return 0;
  }
  
  sort(all(H));
  reverse(all(H));
  
  rep(i, K) H[i] = 0;
  ll sum = 0;
  for(int i=K; i<N; i++) sum += H[i];
  
  fin(sum);
}

Measured memory_bytes: 1792
import sys

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))  # applies to only numbers
rs = lambda: stdin.readline().rstrip()  # ignores trailing space

A, B, C = rl()
cookie = min(A+B, C)
C -= cookie
cookie += B
if C > 0:
    cookie += 1

print(cookie)
# 13

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define vi vector<int>
#define vll vector<long long>
#define FOR(n) for(int i=0;i<n;i++)
#define till(n) for(int i=1;i<=n;i++)
#define mod 1000000007
using namespace std;

ll a[3000];

pair<ll, ll> dp[3000][3000];

pair<ll, ll> solve(ll i, ll j){
    if(i==j) return make_pair(a[i], 0);
    pair<ll, ll> tmp1, tmp2, ans;

    if(dp[i][j].first != -1 && dp[i][j].second != -1) return dp[i][j];

    tmp1 = solve(i+1, j); tmp1 = make_pair(tmp1.first, tmp1.second + a[i]);
    tmp2 = solve(i, j-1); tmp2 = make_pair(tmp2.first, tmp2.second + a[j]);


    if(tmp1.second> tmp2.second)
        ans = make_pair(tmp1.second, tmp1.first);
    else ans = make_pair(tmp2.second, tmp2.first);

    return dp[i][j] = ans;
}

int main(){
    //ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n;cin >> n;

    for(int i=0;i<3000;i++){
        for(int j=0;j<3000;j++){
            dp[i][j] = make_pair(-1, -1);
        }
    }

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

    pair<ll, ll> ans = solve(0, n-1);

    cout << ans.first - ans.second;

	return 0;
}


Measured memory_bytes: 141056
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
 
int main() {
  int n;
  string s;
  cin >> n >> s;
  
  rep(i, n) {
    rep(j, s.size()) {
      if (s[j] == 'Z') {
        s[j] = 'A';
      } else {
        s[j] = char(s[j] + 1);
      }
    }
  }
  
  cout << s << endl;
}


Measured memory_bytes: 256
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
#define endl "\n"
using namespace std;

constexpr int inf = 2147483647;
constexpr int64_t inf64 = 9223372036854775807;
constexpr int mod = 1e9+7;

set<int64_t> lunluns;

bool is_lunlun(int64_t n) {
  string s = to_string(n);
  rep(i,s.size()-1) if(abs(s[i]-s[i+1]) > 1) {return false;}
  return true;
}

void lunlun_generator(int64_t n) {
  lunluns.insert(n);
  if(n > 3234566667LL) return;
  if(n % 10LL == 0LL) {lunlun_generator(n*10+(n%10)); lunlun_generator(n*10+1);}
  else if(n % 10LL == 9LL) {lunlun_generator(n*10+(n%10)); lunlun_generator(n*10+8);}
  else {
    lunlun_generator(n*10+(n%10));
    lunlun_generator(n*10+(n%10+1));
    lunlun_generator(n*10+(n%10-1));
  }
}

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

  int k;
  cin >> k;

  lunlun_generator(1LL);
  lunlun_generator(2LL);
  lunlun_generator(3LL);
  lunlun_generator(4LL);
  lunlun_generator(5LL);
  lunlun_generator(6LL);
  lunlun_generator(7LL);
  lunlun_generator(8LL);
  lunlun_generator(9LL);

  for(int64_t res : lunluns) {
    if(k == 1) { cout << res << endl; return 0;}
    //if(!is_lunlun(res)) cout << res << endl;
    k--;
  }
  return 0;
}

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

int main(){
  int n;
  cin >> n;
  vi l(n);
  rep(i,n) cin >> l[i];
  sort(l.rbegin(),l.rend());
  int sum=0;
  rep(i,n-1) sum += l[i+1];
  if(l[0] < sum) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3600
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
struct japan{
    char s[100];
    int st,e;
}j[2000];


int main(){
    int n,m,h;
    while(scanf("%d%d",&n,&m)){
        if(n==0&&m==0) break;
        int a,b;
        for(int i=0;i<n;i++){
            scanf("%s%d%d",j[i].s,&a,&b);
            j[i].st=b-a+1;
            j[i].e=b;
        }
        for(int i=0;i<m;i++){
            scanf("%d",&h);
            int flag=0;
            for(int k=0;k<n;k++){
                if(h>=j[k].st && h<=j[k].e){
                    printf("%s %d\n",j[k].s,h-j[k].st+1);
                    flag=1;
                    break;
                }
            }
            if(flag==0){
                printf("Unknown\n");
            }
        }
    }
    return 0;
}
/*
4 3
taisho 6 1917
heisei 22 2010
meiji 10 1877
showa 62 1987
*/

Measured memory_bytes: 1304
#include <stdio.h>

int main(){

	int N,K,X,Y;

	scanf("%d",&N);
	scanf("%d",&K);
	scanf("%d",&X);
	scanf("%d",&Y);

	int i;

	int ans=0;

	for(i=1;i<=N;i++){
		if(i<=K){ans+=X;}
		else{ans+=Y;}
	}
	printf("%d\n",ans);

	return 0;
}

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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<long> a(n);
    long mark[n+1];
    memset(mark, 0, sizeof(mark));
    for(long i=0; i<n; i++) {
        cin >> a[i];
        mark[a[i]]++;
    }
 
    long long sum = 0;
    for(long j=1; j<=n; j++) {
        long mk = mark[j];
        sum = sum + (mk*(mk-1))/2;
    }
    for(long i=0; i<n; i++) {
        long long ans = sum;
        ans = ans - mark[a[i]] +1;
        cout << ans << "\n";
    }
    return 0;
}


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

int main()
{
    double a , b ;
    cin >> a >> b ;
    double f = a/b ;
    int r = (int)a%(int)b ;
    int d = (int)f ;
    printf("%d %d %.5lf\n" , d , r , f) ;
}


Measured memory_bytes: 3204
#include <stdio.h>
#include <stdlib.h>


int main(){
    
    char s[10];//入力用変数
    int A[102];//数値入力用配列
    int point=0;

    while(scanf("%s",s)!=EOF){
        if(s[0]=='+'){
            A[point-1]+=A[point];
            point--;
        }else if(s[0]=='-'){
            A[point-1]-=A[point];
            point--;
        }else if(s[0]=='*'){
            A[point-1]*=A[point];
            point--;
        }else{
            point++;
            A[point]=atoi(s);
        }
    }

    printf("%d\n",A[1]);
}


Measured memory_bytes: 2084
N, K, A, B = list(map(int, input().split()))
A_max = max(list(map(int, input().split())))
B_min = min(list(map(int, input().split())))

if A_max > A and B_min <= B and A_max < B_min:
  print("No War")
else:
  print("War")

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<string>
#include<set>
using namespace std;
set<string>r;
set<string>::iterator it;
string s;
int main()
{
	int k;
	cin>>s>>k;
	for(int i=0;i<s.size();i++)
	{
		for(int j=1;j<=5;j++)
		{
			r.insert(s.substr(i,j));
		}
	 } 
	 int cnt=1;
	 for(it=r.begin();it!=r.end();it++)
	 {
	 	if(cnt==k)
		 {
		 	cout<<*it<<endl;break;
		 }
	 	cnt++;
	 }
	 return 0;
}

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

void sort(vector<int>& a);

int main()
{
	int sum = 0;
	vector<int> a;
	
	int N = 0;
	cin >> N;
	
	int temp;
	for (int i = 0; i < N; i++)
	{
		cin >> temp;
		a.push_back(temp);
	}
	
	sort(a);
	
	for (int i = a.size()-1; i > 0; i--)
	{
		sum += (a[i] - a[i-1]);
	}
		
	cout << sum;
	
	return 0;
}


void sort(vector<int>& a)
{
	bool sorted = true;
	
	for (int i = 0; i < a.size(); i++)
	{
		sorted = true;
		for (int j = 0; j < a.size()-1-i; j++)
		{
			if (a[j] > a[j+1])
			{
				int temp = a[j];
				a[j] = a[j+1];
				a[j+1] = temp;
				sorted = false;
			}
			
		}
		if (sorted)
			break;
	}
}



Measured memory_bytes: 256
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<string>
#include<algorithm>
#include<iostream>
#include<bitset>
#include<functional>
#include<numeric>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cassert>
#include<cmath>
#include<random>
#include<ctime>
#include<complex>
using namespace std;
typedef long long LL;
mt19937 gene(233);
typedef complex<double> Complex;
#define fi first
#define se second
#define ins insert
#define pb push_back
inline char GET_CHAR(){
	const int maxn = 131072;
	static char buf[maxn],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,maxn,stdin),p1==p2)?EOF:*p1++;
}
inline int getInt() {
	int res(0);
	char c = getchar();
	while(c < '0') c = getchar();
	while(c >= '0') {
		res = res * 10 + (c - '0');
		c = getchar();
	}
	return res;
}

inline LL fastpo(LL x, LL n, LL mod) {
	LL res(1);
	while(n) {
		if(n & 1) {
			res = res * (LL)x % mod;
		}
		x = x * (LL) x % mod;
		n /= 2;
	}
	return res;
}

inline string itoa(int x, int width = 0) {
  string res;
  if(x == 0) res.push_back('0');
  while(x) {
    res.push_back('0' + x % 10);
    x /= 10;
  }
  while((int)res.size() < width) res.push_back('0');
  reverse(res.begin(), res.end());
  return res;
}
const int _B = 131072;
char buf[_B];
int _bl = 0;
inline void flush() {
	fwrite(buf, 1, _bl, stdout);
	_bl = 0;
}
__inline void _putchar(char c) {
	if(_bl == _B) flush();
	buf[_bl++] = c;
}
inline void print(LL x, char c) {
	static char tmp[20];
	int l = 0;
	if(!x) tmp[l++] = '0';
	else {
		while(x) {
			tmp[l++] = x % 10 + '0';
			x /= 10;
		}
	}
	for(int i = l - 1; i >= 0; i--) _putchar(tmp[i]);
	_putchar(c);
}
const int N = 300033;
const int LOG = 20;
const int mod = 1e9 + 7;
const int inf = 1e9 + 7;
int n, m;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main() {
	LL k;
	cin >> k;
	LL pw = 26;
	for(int len = 1;; len++) {
		if(k <= pw) {
			k = k - 1;
			string ans;
			for(int i = 1; i <= len; i++) {
				ans.pb(k % 26 + 'a');
				k /= 26;
			}
			reverse(ans.begin(), ans.end());
			cout << ans << endl;
			return 0;
		}else {
			k -= pw;
		}
		pw *= 26;
	}
}






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

using namespace std;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
#ifdef sweety_candy
	freopen("input.txt","rt",stdin);
	freopen("ouput.txt","w",stdout);
#endif	
	int x1, x2, y1, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	cout << y1 + x2 - y2 << " " << x2 + y2 - x1 <<" " <<x1 + y1 - y2 << " " << y1 + x2 - x1;	
#ifdef sweety_candy
	cout << " Time elapsed: " << 1.0*clock() / LOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 896
<?php
$s = trim(fgets(STDIN));
$abc = range('a', 'z');
$ans = $abc;

for($i = 0; $i < 26; $i++) {
  if(strpos($s, $abc[$i]) !== false) unset($ans[$i]);
}
if(empty($ans)) {
  echo 'None'."\n";
} else {
  echo min($ans)."\n";
}

Measured memory_bytes: 4728
#include<bits/stdc++.h>
main(){int n,x,a[101],A=0;std::cin>>n>>x;for(int i=0;i<n;std::cin>>a[i++]);std::sort(a,a+n);for(int i=0;i<n-1;i++){if(a[i]>x)break;x-=a[i];A++;}std::cout<<(x-a[n-1]?A:A+1);}

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

typedef long long ll;

ll solve(ll a) {
  ll count = (a + 1) / 2;
  ll ans = count % 2; 
  if(a % 2 == 0) ans ^= a; 

  return ans;
}

int main() {
  ll a, b;

  std::cin >> a >> b;

  std::cout << (solve(a - 1) ^ solve(b)) << std::endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b;
  cin>>a>>b;
 int m=min(a,b);
  int ma=max(a,b);
  string s="";
  for(int i=0;i<ma;i++)
    cout<<m;
  return 0;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
write = sys.stdout.write
def solve():
    N = int(readline())
    A = [list(map(int, readline().split())) for i in range(N)]
    B = [[0]*(N+1) for i in range(N+1)]
    for i in range(N):
        c = 0
        Ai = A[i]
        Bi = B[i]
        Bj = B[i+1]
        for j in range(N):
            Bj[j+1] = Bi[j+1] + Ai[j]
    def gen():
        for i0 in range(N):
            Ba = B[i0]
            for i1 in range(i0+1, N+1):
                Bb = B[i1]
                mi = su = 0
                for j in range(N):
                    su += Bb[j+1] - Ba[j+1]
                    yield su - mi
                    mi = min(mi, su)
    write("%d\n" % max(gen()))
solve()



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

using namespace std;
int main(){
	string s, t;
  cin >> s >> t;
  int s1, t1;
  cin >> s1 >> t1;
  string u;
  cin >> u;
  if(u == s){
    cout << s1 - 1 << ' ' << t1;
  }else{
  	cout << s1 << ' ' << t1 - 1;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define FOR(i,p,n) for(int i = p;i < (int)(n);i++)
#define REP(i,n) FOR(i,0,n)

	
using namespace std;

struct rect 
{
	int min_w,max_w;
	int min_h,max_h;
	void update(int w,int h)
	{
		min_w = min(min_w,w);max_w = max(max_w,w);
		min_h = min(min_h,h);max_h = max(max_h,h);
	}
};

int h,w;
vector<vector<char> > bag;
vector<vector<char> > tmp;
vector<char> layer;
map<char,rect> rects;

void fill_rect(char type)
{
	rect rt = rects[type];
	for(int y = rt.min_h;y <= rt.max_h ; y++)
	{
		for(int x = rt.min_w; x <= rt.max_w;x++)
		{
			tmp[y][x] = type;
		}
	}

	return ;
}


bool is_safe()
{
	REP(y,h)REP(x,w)
	{
		if(tmp[y][x] != bag[y][x])return false;
	}
	
	return true;
}


int main()
{
	int T;
	cin >> T;
	REP(i,T)
	{
		cin >> h >> w;
		bag.assign(h,vector<char>(w, '.'));
		rects.clear();layer.clear();
		REP(y,h)REP(x,w)
		{
			cin >> bag[y][x];
			if(bag[y][x] == '.')continue;
			if(rects.count(bag[y][x]) == 0)
			{
				rects[bag[y][x]] = {x,x,y,y};
				layer.push_back(bag[y][x]);
			}
			else
			{
				rects[bag[y][x]].update(x,y);
			}
		}

	
		bool ok = false;
		sort(ALL(layer));
		do
		{
			tmp = bag;
			REP(i,layer.size())
			{
				fill_rect(layer[i]);
			}
			if(is_safe()) { ok = true;break;}
		}while(next_permutation(ALL(layer)));
		
		cout <<  ((ok) ? "SAFE":"SUSPICIOUS") << endl;
	}
	
	return 0;
	
}

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main() {
    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    double x = (double)(x2 - x1) * (double)(x2 - x1);
    double y = (double)(y2 - y1) * (double)(y2 - y1);
    cout << fixed << setprecision(6) << (double)sqrt(x+y) << endl;
    return 0;
}


Measured memory_bytes: 3288
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) {
        cin >> A[i];
    }
    cout << *max_element(A.begin(), A.end()) - *min_element(A.begin(), A.end()) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef vector<int>         vi;
const int mod = 1000000007;


int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m;
    cin>>n>>m;
    set <pair<int,int> > data;
    multiset<pair<int,int>> inp;

    for(int i =0;i < m;i++){
        int c1,c2;
        cin>>c1>>c2;
        data.insert(mp(c1,c2));
        inp.insert(mp(c1,c2));
    }
    int arr[n+1]={0};
    tr(it,inp){
        arr[it->first]++;
        arr[it->second]++;
    }
    for(int i=1;i<=n;i++){
        cout<<arr[i]<<endl;
    }














}




















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

typedef long long ll;

const ll inf = 1ll << 60;

int n, A, B, p[5005], q[5005], cnt[5005][5005];
ll f[5005];

int main() {
	scanf("%d%d%d", &n, &A, &B);
	for (int i = 1; i <= n; ++i)
		scanf("%d", p + i), q[p[i]] = i;
	cnt[0][0] = 1;
	for (int i = 1; i <= n; ++i) {
		copy(cnt[i - 1], cnt[i - 1] + 1 + n, cnt[i]);
		++cnt[i][q[i]];
	}
	for (int i = 0; i <= n; ++i)
		partial_sum(cnt[i], cnt[i] + 1 + n, cnt[i]);
	p[n + 1] = n + 1;
	for (int i = 1; i <= n + 1; ++i) {
		f[i] = inf;
		for (int j = 0; j < i; ++j)
			if (p[j] < p[i])
				f[i] = min(f[i], f[j] + 1ll * (j == 0 ? 0 : cnt[p[i] - 1][j - 1] - cnt[p[j]][j - 1]) * A + 1ll * ((cnt[p[i] - 1][n] - cnt[p[i] - 1][j]) - (cnt[p[j]][n] - cnt[p[j]][j])) * B);
	}
	printf("%lld\n", f[n + 1]);
	return 0;
}


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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

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

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    int h, w;
    int board[50][50];
    string s[50];
    cin >> h >> w;
    for (int i = 0; i < h; i++)
        cin >> s[i];

    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            board[i][j] = (s[i])[j];
        }
    }

    int ret[50][50] = {};
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            for (int m = -1; m <= 1; m++)
            {
                for (int n = -1; n <= 1; n++)
                {
                    int tmp_x = j + n;
                    int tmp_y = i + m;
                    if (tmp_x < 0 || tmp_y < 0 || tmp_x >= w || tmp_y >= h)
                        continue;
                    if (board[tmp_y][tmp_x] == '#')
                        ret[i][j]++;
                }
            }
        }
    }

    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if (board[i][j] == '#')
                cout << "#";
            else
                cout << ret[i][j];
        }
        cout << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long n,m,ans=0;
int main(){
  cin >> n;
  for(int i=1;i<=n;i++){
    int cnt=0;
    for(int j=1;j<=i;j++){
      if(i%j==0){
        cnt++;
      }
    }
    if(cnt==8 and i%2==1){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}  

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <bitset>
#include <iomanip>
#include <deque>
#include <tuple>
#include <algorithm>

using namespace std;

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

    if ((a*100 + b*10 + c) % 4) {
        cout << "NO" << endl;
    }
    else {
        cout << "YES" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int n;
    cin>>n;
    if(n<4){
            cout<< "No" <<endl;
            return 0;
    }
    for(int i=0; i<100; i++){
            for(int j=0; j<100; j++){
                    if(n == i*7 + j*4){
                            cout<< "Yes" <<endl;
                            return 0;
                    }
            }
    }
    cout<< "No" <<endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(long long i=(long long)(a);i<(long long)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	ll r;

	cin>>r;

	if(r<1200){
		cout<<"ABC"<<endl;
	} else if(r<2800){
		cout<<"ARC"<<endl;
	} else{
		cout<<"AGC"<<endl;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<string>
#define rep(i,a,b) for(long long int i=(a);i<(b);i++)
#define se(a) a.begin(),a.end()
#define ll unsigned long long int
#define mll map<ll,ll>
#define pll pair<ll, ll>
#define pii pair<int,int>
#define pb push_back
#define mk make_pair
#define F first
#define S second
#define mod 1000000007
#define maxn 100005
#define inf 1e18
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
int main()
{
	ll n,W;
	cin>>n>>W;
	ll w[n],v[n];
	rep(i,0,n)
	cin>>w[i]>>v[i];
	ll sum=0;
	rep(i,0,n)
	sum+=v[i];
	ll dp[n+1][sum+1];
	for(int i=0;i<=n;i++)
	for(int j=0;j<=sum;j++)
	dp[i][j]=INT_MAX;
	for(int i=0;i<=n;i++)
	dp[i][0]=0;
	for(int i=1;i<=n;i++)
	for(int j=1;j<=sum;j++)
	{
		if(j>=v[i-1])
		dp[i][j]=min(w[i-1]+dp[i-1][j-v[i-1]],dp[i-1][j]);
		else
		dp[i][j]=dp[i-1][j];
	}
	ll ans=0;
	for(int i=0;i<=n;i++)
	for(int j=0;j<=sum;j++)
	if(dp[i][j]<=W)
	{
		ans=max(ans,(ll)j);
	}
//	for(int i=1;i<=n;i++)
//	{
//		for(int j=1;j<=sum;j++)
//		cout<<dp[i][j]<<" ";
//		cout<<endl;
//	}
	cout<<ans<<endl;
}

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

using namespace std;

#define ll long long

#define mod 1000000007

ll gcd(ll aa,ll bb) { if(aa==0) return bb; return(bb%aa,aa); }

    
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll n,l;
    cin>>n>>l;
    
    vector < ll > a(n);
    
    for(int i=0;i<n;i++)
        cin>>a[i];
    
    ll cur=-1;
    for(int i=0;i<n-1;i++)
    {
        if((a[i]+a[i+1]) >= l)
        {
            cur=i;
            break;
        }
    }
    if(cur==-1)
    {
        cout<<"Impossible"<<endl;
    }
    else
    {
        cout<<"Possible"<<endl;
        for(int i=0;i<cur;i++)
        {
            cout<<i+1<<endl;
        }
        
        for(int i=n-1;i>cur;i--)
        {
            cout<<i<<endl;
        }
        

    }
    
    return 0;
}


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

int main() {
  int r, D, x;
  cin >> r >> D >> x;

  rep(i, 10) {
    x = r * x - D;
    cout << x << endl;
  }

  return 0;
}

Measured memory_bytes: 3616
#include <stdio.h>
int main() {
	int a, ans=0;
	scanf("%d", &a);
	if (a % 10 == 1)ans++;
	if ((a / 10) % 10 == 1)ans++;
	if (a / 100 == 1)ans++;
	printf("%d", ans);
	return 0;
}

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

#define READ                freopen("in.txt", "r", stdin)
#define WRITE               freopen("out.txt", "w", stdout)

#define si(a)               scanf("%d", &a)
#define sii(a,b)            scanf("%d %d", &a, &b)
#define siii(a,b,c)         scanf("%d %d %d", &a, &b, &c)

#define CLR(a)              memset(a, 0, sizeof(a))
#define SET(a)              memset(a, -1, sizeof(a))

#define PI                  acos(-1.0)

#define pb                  push_back
#define mp                  make_pair
#define SORT(v)             sort(v.begin(), v.end())
#define REV(v)              reverse(v.begin(), v.end())
#define FOR(i, n)           for(int i=0; i<n; i++)
#define FOR1(i, n)          for(int i=1; i<=n; i++)
#define ROF(i, n)           for(int i=n-1; i>=0; i--)
#define ROF1(i, n)          for(int i=n; i>=1; i--)
#define LOOP(i, x, y)       for(int i=x; i<=y; i++)
#define fastIO()            ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);


typedef long long              LL;
typedef unsigned long long     ULL;
typedef vector<int>            VI;
typedef pair<int, int>         PII;
typedef pair<string, int>      PSI;
typedef pair<char, int>        PCI;

const int MAX = 100005;
const LL LMAX = 12158598925;
const double eps = 1e-9;
const int INF = 0x3f3f3f3f;

int dx[] = {-1, 0, 1, 0};
int dy[] = {0, 1, 0, -1};
int kx[] = {1, 1, 2, 2, -1, -1, -2, -2};
int ky[] = {2, -2, 1, -1, 2, -2, 1, -1};

LL dp[MAX], arr[MAX];


int main()
{
//    READ;
//    WRITE;

    int n, k; sii(n, k);
    FOR1(i, n) scanf("%lld", &arr[i]);

    dp[1] = 0;

    for(int i=2; i<=n; i++){
        LL p = INT_MAX;
        for(int j=1; j<=min(k, i-1); j++)
            p = min(p, abs(arr[i] - arr[i-j]) + dp[i-j]);

        dp[i] = p;
    }

    cout << dp[n] << endl;
    return 0;
}


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

int kai(int i){

  vector<int> a(5);
  for ( int j = 0; j < 5; j++){
    a[j] = i % 10;
    i /= 10;
  }
  
  int hantei = 1;
  
  if ( a[0] != a[4] ){
    hantei = 0;
  }
  
  if ( a[1] != a[3]){
    hantei =  0;
  }
  
  return hantei;  
  
}


int main() {
  
  int a,b;
  cin >> a >> b;
  
  int count = 0;
  
  for ( int i = a; i <= b; i++){
    if ( kai(i) ){
      count++;
    }
  }
  
  cout << count << endl;
  
}

Measured memory_bytes: 256
# include <iostream>
# include <vector>
# include <algorithm>
# include <functional>
//using namespace std;

int main() {
	long long n, k;
	std::cin >> n >> k;
	std::vector<std::pair<long long, long long>> v;
	int a, b;
	for (int i = 0; i < n; ++i) {
		std::cin >> a >> b;
		v.emplace_back(a, b);
	}
	sort(v.begin(), v.end());
	long long pos = 0;
	while (k > 0) {
		k -= v[pos].second;
		pos++;
	}
	std::cout << v[pos - 1].first << std::endl;
	return 0;
}

Measured memory_bytes: 2420
#include <iostream>

using namespace std;

int n,m,x;
int c[12],a[12][12],s[12];
int res = 1000000000;

void se(int ac, int ct){
	if(ac==n){
		for(int i=0;i<m;i++)if(s[i]<x)return;
		if(ct<res)res=ct;
		return;
	}
	se(ac+1,ct);
	for(int i=0;i<m;i++)s[i]+=a[ac][i];
	se(ac+1,ct+c[ac]);
	for(int i=0;i<m;i++)s[i]-=a[ac][i];
}

int main(){
	
	cin.tie(0); ios_base::sync_with_stdio(0);
	cin>>n>>m>>x;
	for(int i=0;i<n;i++){
		cin>>c[i];
		for(int j=0;j<m;j++)cin>>a[i][j];
	}
	se(0,0);
	if(res==1000000000){
		cout<<-1<<endl;
		return 0;
	}
	cout<<res<<endl;
	
	return 0;
}

Measured memory_bytes: 3172