akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define Sheryang main
const int maxn=1e6+7;
typedef long long ll;
const int mod=1e9+7;
ll read(){ll c = getchar(),Nig = 1,x = 0;while(!isdigit(c))c = getchar();if(c == '-')Nig = -1,c = getchar();while(isdigit(c))x = ((x<<1) + (x<<3)) + (c^'0'),c = getchar();return Nig*x;}
#define read read()

ll a[maxn],b[maxn];
int cmp(pair<ll,int> a,pair<ll,int> b){
    return a.first>b.first;
}

int vis[maxn];
int Sheryang()
{
    ll n=read;

    for(int i=1;i<=n;i++){
        a[i]=read;
    }

    vector<pair<ll,int> >v;
    for(int i=1;i<=n;i++){
        b[i]=read;
        if(a[i]>b[i]) v.push_back({a[i]-b[i],i});
    }

    sort(v.begin(),v.end(),cmp);

    int ans=0,cot=0;
    for(int i=1;i<=n;i++){
        if(a[i]<b[i]){
            ans++;
            if(v.size()-cot==0){
                printf("-1\n");
                return 0;
            }
            ll t=b[i]-a[i];

            for(int i=cot;i<v.size();i++){
                if(v[i].first>=t){
                    if(v[i].first==t) cot++;
                    v[i].first-=t;t=0;
                    if(!vis[v[i].second]) ans++,vis[v[i].second]=1;
                    break;
                }else{
                    t-=v[i].first;cot++;
                    if(!vis[v[i].second]) ans++,vis[v[i].second]=1;
                }
            }

            if(t){
                printf("-1\n");
                return 0;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

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

  int64_t N, K;
  cin >> N >> K;
  int64_t A[N], F[N];
  rep(i, N){
    cin >> A[i];
  }
  sort(A, A+N);
  reverse(A, A+N);

  rep(i, N){
    cin >> F[i];
  }
  sort(F, F+N);

  pair<int64_t, int64_t> P[N];
  rep(i, N){
    P[i].first = A[i]*F[i];
    P[i].second = F[i];
  }
  sort(P, P+N);
  int64_t num = 0;
  int64_t left = -1, right = P[N-1].first, middle;
  while((right - left) >= (int64_t)2){
    middle = (left+right)/2;
    num = 0;
    for(int64_t i=0;i<N;i++){
      num += max((int64_t)0, ((P[i].first + P[i].second - 1)-middle)/P[i].second);
    }
    if(num > K) left = middle;
    else right = middle;
  }


  cout << right << endl;
}

Measured memory_bytes: 6528
import sys
from collections import deque
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    S=input()
    T=input()
    dp=[[0]*(len(T)+1) for _ in range(len(S)+1)]
    dp2=[[()]*(len(T)+1) for _ in range(len(S)+1)]
    for s in range(len(S)):
        for t in range(len(T)):
            if S[s]==T[t]:
                dp[s+1][t+1]=dp[s][t]+1
                dp2[s+1][t+1]=(s,t)
            else:
                if dp[s+1][t]>dp[s][t+1]:
                    dp[s+1][t+1]=dp[s+1][t]
                    dp2[s+1][t+1]=dp2[s+1][t]
                else:
                    dp[s+1][t+1]=dp[s][t+1]
                    dp2[s+1][t+1]=dp2[s][t+1]
    tmp=dp2[len(S)][len(T)]
    if tmp:
        ans=deque()
        ans.appendleft(S[tmp[0]])
        for _ in range(dp[len(S)][len(T)]-1):
            tmp=dp2[tmp[0]][tmp[1]]
            ans.appendleft(S[tmp[0]])
        print(''.join(ans))

if __name__ == '__main__':
    main()


Measured memory_bytes: 376712
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,n,cunt=0,m=0;
    cin>>a;
    while(a--)
    {
        cin>>n;
        if(n%2==0)
        {
            m++;
            if(n%3==0)
            {
                cunt++;
            }
            else if(n%5==0)
            {
                cunt++;
            }
        }
    }
    if(m==cunt)cout<<"APPROVED"<<endl;
    else cout<<"DENIED"<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public Main() {
    }

    private Scanner sc;

    public static void main(String[] args) {
        new Main().solve();
    }

    private void solve() {
        sc = new Scanner(System.in);
        int n = sc.nextInt();
        int q = sc.nextInt();
        MyQueue queue = new MyQueue();
        for (int i = 0; i < n; i++) {
            Query qry = new Query(sc.next(), sc.nextInt());
            queue.enqueue(qry);
        }
        int sum = 0;
        while (!queue.isEmpty()) {
            Query now = (Query) queue.dequeue();
            if (now.time <= q) {
                sum += now.time;
                System.out.println(now.name + " " + sum);
            } else {
                now.time -= q;
                sum += q;
                queue.enqueue(now);
            }
        }

    }
}

class MyQueue {
    private int top;
    private int tail;
    private Object[] arr;

    public MyQueue() {
        top = 0;
        tail = -1;
        arr = new Object[1000000];
    }

    public void enqueue(Object o) {
        tail++;
        arr[tail] = o;
    }

    public Object dequeue() {
        Object r = arr[top];
        top++;
        return r;
    }

    public boolean isEmpty() {
        return top > tail;
    }
}

class Query {
    String name;
    int time;

    public Query(String name, int time) {
        super();
        this.name = name;
        this.time = time;
    }
}

Measured memory_bytes: 80272
#include<stdio.h>
#include<algorithm>
using namespace std;
double dp[2100][2100];
double pe[2100];
double qe[2100];
double re[2100];
double sum[2100][2100];
int p[2100];int q[2100];
int r[2100];
double v[5];
double w[5];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++)scanf("%d%d%d",p+i,q+i,r+i);
	dp[0][0]=1;
	for(int i=0;i<=b;i++){
		for(int j=0;j<=b;j++){
			dp[i+1][j]+=dp[i][j]*2/3;
			dp[i+1][j+1]+=dp[i][j]/3;
		}
		for(int j=0;j<=b;j++)sum[i][j+1]=sum[i][j]+dp[i][j];
	}
	for(int i=0;i<=b;i++){
		int t=p[0]*i;
		for(int j=0;j<5;j++)v[j]=w[j]=0;
		v[0]=1;
		double dame=1;
		for(int j=1;j<a;j++){
			if(b*p[j]>=t)dame*=(1.0-sum[b][(t-1+p[j])/p[j]]);
			else dame=0;
			if(b*p[j]<t)continue;
			w[0]=v[0]*sum[b][(t-1+p[j])/p[j]];
			w[1]=v[1]*sum[b][(t-1+p[j])/p[j]]+v[0]*(1.0-sum[b][(t-1+p[j])/p[j]]);
			w[2]=v[2]*sum[b][(t-1+p[j])/p[j]]+v[1]*(1.0-sum[b][(t-1+p[j])/p[j]]);
			v[0]=w[0];v[1]=w[1];v[2]=w[2];
		}
	//	printf("%d: %f\n",i,dame);
		pe[i]=(v[0]+v[1]+v[2])*5-dame;
	}
	for(int i=0;i<=b;i++){
		int t=q[0]*i;
		for(int j=0;j<5;j++)v[j]=w[j]=0;
		v[0]=1;
		double dame=1;
		for(int j=1;j<a;j++){
			if(b*q[j]>=t)dame*=(1.0-sum[b][(t-1+q[j])/q[j]]);
			else dame=0;
			if(b*q[j]<t)continue;
			w[0]=v[0]*sum[b][(t-1+q[j])/q[j]];
			w[1]=v[1]*sum[b][(t-1+q[j])/q[j]]+v[0]*(1.0-sum[b][(t-1+q[j])/q[j]]);
			w[2]=v[2]*sum[b][(t-1+q[j])/q[j]]+v[1]*(1.0-sum[b][(t-1+q[j])/q[j]]);
			v[0]=w[0];v[1]=w[1];v[2]=w[2];
		}
		qe[i]=(v[0]+v[1]+v[2])*3-dame;
	}
	for(int i=0;i<=b;i++){
		int t=r[0]*i;
		for(int j=0;j<5;j++)v[j]=w[j]=0;
		v[0]=1;
		double dame=1;
		for(int j=1;j<a;j++){
			if(b*r[j]>=t)dame*=(1.0-sum[b][(t-1+r[j])/r[j]]);
			else dame=0;
			if(b*r[j]<t)continue;
			w[0]=v[0]*sum[b][(t-1+r[j])/r[j]];
			w[1]=v[1]*sum[b][(t-1+r[j])/r[j]]+v[0]*(1.0-sum[b][(t-1+r[j])/r[j]]);
			w[2]=v[2]*sum[b][(t-1+r[j])/r[j]]+v[1]*(1.0-sum[b][(t-1+r[j])/r[j]]);
			v[0]=w[0];v[1]=w[1];v[2]=w[2];
		}
		re[i]=(v[0]+v[1]+v[2])*2-dame;
	}
	double ret=-999999999;
	for(int i=0;i<=b;i++)for(int j=0;i+j<=b;j++){
		int k=b-i-j;
		ret=max(ret,pe[i]+qe[j]+re[k]);
	}
	printf("%.12f\n",ret);
}

Measured memory_bytes: 68640
//============================================================================
// Name        :
// Author      : John Purcell
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
    int A, B;
    cin>>A>>B;
    int x1, x2;

    for(int i=1; i<=1009; i++){
        if(floor(i*0.08)==A and floor(i*0.1)==B){
            cout<<i<<endl;
            return 0;
        }
    }

    cout<<"-1"<<endl;
    return 0;
}

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

set<int> dfs(const vector<ll>& ss, int index, int N)
{
    static array<set<int>, 100> memo;

    if (!memo[index].empty()) {
        return memo[index];
    }

    auto score = ss[index];

    set<int> result;
    if (index == N - 1) {
        result.insert(0);
        result.insert(score);
    } else {
        auto r1 = dfs(ss, index + 1, N);
        for (auto&& r : r1) {
            result.insert(r + score);
            result.insert(r);
        }
    }
    memo[index] = result;
    return result;
}

void solve_by_dfs(const vector<ll>& ss, int N)
{
    auto score_pattern = dfs(ss, 0, N);

    vector<ll> notx10_scores;
    copy_if(begin(score_pattern), end(score_pattern), back_inserter(notx10_scores), [](ll a) { return a % 10 != 0; });

    if (notx10_scores.empty()) {
        cout << "0" << endl;
    } else {
        cout << *max_element(begin(notx10_scores), end(notx10_scores)) << endl;
    }
}

void main_()
{
    ll N;
    vector<ll> ss;
    cin >> N;
    copy_n(istream_iterator<ll>(cin), N, back_inserter(ss));

    solve_by_dfs(ss, N);
    return;

    auto total = accumulate(begin(ss), end(ss), 0LL);

    // 総計が10の倍数でないならそれが最大値
    if (total % 10 != 0) {
        cout << total << endl;
        return;
    }

    // 総計が10の倍数なら、10の倍数ではないスコアのうち最小のものを引いたのが最大値
    auto notx10_end = partition(begin(ss), end(ss), [](ll a) { return a % 10 != 0; });

    if (notx10_end == ss.begin()) {
        // 10の倍数のスコアしか無いので0
        cout << 0 << endl;
        return;
    }

    auto notx10_min = *min_element(begin(ss), notx10_end);
    cout << total - notx10_min << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 17792
#include<bits/stdc++.h>
using namespace std;
int main() {
	int a,b;
	cin>>a>>b;
	if(a>=1)
		cout<<"Positive";
	else if(b>=0)
		cout<<"Zero";
	else if((abs(b)-abs(a)*1+1)%2-0==1-1)
		cout<<"Positive";
	else
		cout<<"Negative";
	return 0;
}//、、っています

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

#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); 

#define int  long long int
#define pb push_back
#define fe first
#define lb lower_bound 
#define ub upper_bound
#define pii pair<pair<int,int>,pair<int,int> >
#define se second
#define endl "\n"
#define pi pair<int, int>
#define vi vector<int> 
#define vvi vector<vi>
#define bs   binary_search
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,a,b) for(int i=a;i<=b;i++)	
#define all(c) (c).begin(),(c).end()
#define sz(x)       (int)x.size() 
#define PI 3.14159265358979323846

const int N =2e5+5;

int mod= 1e9+7;
int dx[4]={0,0,+1,-1};
int dy[4]={+1,-1,0,0};

vi v[N];
int vis[N],lv[N],cv[N],gv[N];


void  dfs(int u,int val){   
	
	vis[u]=1;

	 for(auto to:v[u]){        
		 if(!vis[to])           
			  dfs(to,val+gv[to]);		 	
		}

	 cv[u]+=val;

}

void solve() {
  
   int n,m;
   cin>>n>>m;

   rep(i,0,n-1){
     int x,y;
	 cin>>x>>y;
	 v[x].pb(y);
	 v[y].pb(x);
  }



   while(m--){
       int x,y;
	   cin>>x>>y;
	   
   	  gv[x]+=y;
	
   }


    dfs(1,gv[1]);


  rep(i,1,n+1)
	   cout<<cv[i]<<" ";
  


}


int32_t main() {
	cool;
	int t=1;
	//cin>>t;
	while(t--)
		solve();


	return 0;	  
}



Measured memory_bytes: 28800
import sys
input=sys.stdin.readline
from random import seed, randint

def calc(d,C,S,T):
    Last=[0]*26
    score=0
    for day,t in enumerate(T):
        t-=1
        Last[t]=day+1
        score+=S[day][t]
        for i,c in enumerate(C):
            score-=c*(day+1-Last[i])
    return score

def main():
    d=int(input())
    C=tuple(map(int,input().split()))
    S=[tuple(map(int,input().split())) for _ in range(d)]
    Ans=[0]*d
    Last=[0]*26
    
    #貪欲法
    for day in range(d):
        ans=0
        score=-float('inf')
        for t in range(26):
            TmpList=Last[:]
            tmp_score=S[day][t]
            TmpList[t]=day+1
            for i,c in enumerate(C):
                tmp_score-=c*(day+1-TmpList[i])
            if tmp_score>score:
                score=tmp_score
                ans=t+1
        Ans[day]=ans
        Last[ans-1]=day
    
    score=calc(d,C,S,Ans)
    #print(Ans)
    #print(score)
    
    #局所探索法
    m=12000
    for i in range(m):
        T=Ans[:]
        seed(i)
        d_idx=randint(0,d-1)
        q=randint(1,26)
        #print(d_idx,q)
        T[d_idx]=q
        tmp=calc(d,C,S,T)
        if tmp>score:
            score=tmp
            Ans=T[:]
    #print(Ans)
    #print(score)
    
    print(*Ans,sep='\n')
    
if __name__=='__main__':
    main()

Measured memory_bytes: 84072
import java.util.*;
import java.lang.*;

class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] weight = new int[N];
        int sum =0;
        int sum2 = 0;
        int[] g = new int[N];
        for(int j =0; j < N ; j++){
            weight[j] = sc.nextInt();

        }
        for(int t =1; t <= N; t ++) {
            for (int i = 1; i <= N; i++) {
                if (i <= t) {
                    sum += weight[i-1];
                } else if(i > t){
                    sum2 += weight[i-1];
                }
            }
            g[t-1] = Math.abs(sum - sum2);
            sum =0;
            sum2 =0;
        }
        Arrays.sort(g);
        System.out.println(g[0]);
    }
}


Measured memory_bytes: 22996
#pragma GCC optimize("O3", "unroll-loops")

#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <bitset>
#include <sstream>
#include <deque>
#include <queue>
#include <random>
#include <complex>

using namespace std;

#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FIXED cout << fixed << setprecision(12);
#define RANDOM srand(94385)
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define graph vector<vector<int>>
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define f first
#define s second
#define hashmap unordered_map
#define hashset unordered_set
#define eps 1e-9
#define mod 1000000007
#define inf 3000000000000000007ll
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define shuffle(a) \
    for (int i = 0; i < sz(a); ++i) \
        swap(a[i], a[rand() % sz(a)])

template<class T, class U> inline void checkmin(T &x, U y) { if (y < x) x = y; }
template<class T, class U> inline void checkmax(T &x, U y) { if (y > x) x = y; }
template<class T, class U> inline bool ifmax(T &x, U y) { if (y > x) return x = y, true; return false; }
template<class T, class U> inline bool ifmin(T &x, U y) { if (y < x) return x = y, true; return false; }
template<class T> inline void sort(T &a) { sort(all(a)); }
template<class T> inline void rsort(T &a) { sort(rall(a)); }
template<class T> inline void reverse(T &a) { reverse(all(a)); }
template<class T, class U> inline istream& operator>>(istream& str, pair<T, U> &p) { return str >> p.f >> p.s; }
template<class T> inline istream& operator>>(istream& str, vector<T> &a) { for (auto &i : a) str >> i; return str; }


#define int long long

signed main() {
    FAST; FIXED; RANDOM;
    int n;
    cin >> n;
    vector<ll> v(n);
    cin >> v;
    vector<vector<int>> div(n);
    for (int i = 1; i < n; ++i)
        for (int j = i; j < n; j += i)
            div[j].pb(i);
    vector<vector<int>> sum(n, vector<int>(1, 0));
    for (int d = 1; d < n; ++d)
        for (int i = d; i < n; i += d)
            sum[d].pb(sum[d].back() + v[i]);
    vector<vector<int>> revsum(n, vector<int>(1, 0));
    for (int d = 1; d < n; ++d)
        for (int i = n - 1 - d; i >= 0; i -= d)
            revsum[d].pb(revsum[d].back() + v[i]);
    ll ans = 0;
    vector<bool> used(n);
    for (int a = 1; a < n; ++a)
        for (auto d : div[n - a - 1]) 
            if (a > d && !(a % d == 0 && 2 * a < n)) {
                int b = a - d;
                int x = n - a - 1;
                ll check = sum[d][x / d] + revsum[d][x / d];
                //cout << check << '\n';
                checkmax(ans, check);
            }
    cout << ans;
    return 0;
}   

Measured memory_bytes: 48888
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int lose = 0;
		for(int i = 0; i < S.length(); i++) {
			if(S.charAt(i) == 'x')
				lose ++;
		}
		System.out.println(lose >= 8 ? "NO" : "YES");

	}

}


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

#define froop1(a,n) for(int i = a;i < n;i++)
#define froop2(a,n) for(int i = a;i > n;i--)
int main(){
	long long N,M;
  cin >> N >> M;
  long long sum = 1;
  froop1(0,N) sum *= 100;
  long long sum2 = sum * M;
  if(M == 100){
   sum2 += sum; 
  }
    
  cout << sum2 << endl;

return 0;
}

Measured memory_bytes: 3584
#include<cstdio>
#include<iostream>
#include<cstring>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#define fs first
#define se second
using namespace std;

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

const int maxn=1e3+5;
const ll inf=0x3f3f3f3f;
const ll mod=1e9+7;

char s[maxn];

int main(){
	double n;
	scanf("%lf",&n);
	printf("%.6lf",n*n*n/27);
	return 0;
}

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

#define rep(i, n) for(int i = 0; i < n; i++)
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define all(v) (v).begin(), (v).end()

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> P;

void p(vi v){
	rep(i, v.size()){
		cout << v[i] << ' ';
	}
	cout << endl;
}

int num[200];

int decode(string s){
	int ret = 0;
	int co = 1;
	rep(i, s.size()){
		if( s[i] >= '2' && s[i] <= '9'){
			co = s[i] - '0';
		}else{
			ret += co*num[s[i]];
			co = 1;
		}
	}
	return ret;
}

string snum = "mcxi";
string encode(int n){
	string ret;
	rep(i, 4){
		int rest = n%1000;
		int co = n/1000;

		if(co >= 1){
			if(co >= 2){
				ret += ('0' + n/1000);
			}
			ret += snum[i];
		}
		n = rest*10;
	}
	return ret;
}

void test(){
	cout << encode(decode("mcxi")) << endl;
	cout << encode(decode("2m3c4x5i")) << endl;
	cout << encode(decode("3cx5i")) << endl;
}

int main(){
	num['m'] = 1000;
	num['c'] = 100;
	num['x'] = 10;
	num['i'] = 1;

	int n;
	cin >> n;
	while(n--){
		string x, y;
		cin >> x >> y;
		//cout << "***";
		cout << encode(decode(x)+decode(y)) << endl;
	}

	return 0;
}

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

int main(){
  int N;cin>>N;
  long long int A[N+10];for(int i=0;i<=N;i++)cin>>A[i];
  long long int B[N+10];for(int i=0;i<N;i++)cin>>B[i];
  long long int res=0;
  for(int i=0;i<N;i++){
    int h=min(A[i],B[i]);
    res+=h,A[i]-=h,B[i]-=h;
    int e=min(A[i+1],B[i]);
    res+=e,A[i+1]-=e,B[i]-=e;
  }
  cout<<res<<endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <unordered_map>

using namespace std;

unordered_map<string, bool> memo;

inline string Sum(int i, string s)
{
    int sum = (s[i] - '0') + (s[i + 1] - '0');
    string res = s.substr(0, i);

    if (sum / 10 == 0)
        res += (char)(sum + '0');
    else {
        res += (char)((sum / 10) + '0');
        res += (char)((sum % 10) + '0');
    }

    if (s.size() == i + 1)
        return res;
    else
        return res + s.substr(i + 2, s.size() - (i + 2));
}

int main()
{
    int t;

    cin >> t;
    while (t--) {
        string s;
        int ft = 0;

        cin >> s;
        while (1 < s.size()) {
            s = Sum(0, s);
            ft = 1 - ft;
        }

        if (ft == 1)
            cout << "Fabre wins.\n";
        else
            cout << "Audrey wins.\n";
    }

    return 0;
}

Measured memory_bytes: 1208
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
#include <complex>
typedef complex<double> Point;
struct Line : public vector<Point> {
  Line(Point a, Point b){
    push_back(a); push_back(b);
  }
  Point vector() const {
    return back() - front();
  }
};
double dot(Point a, Point b){
  return real(conj(a) * b);
}
double cross(Point a, Point b){
  return imag(conj(a) * b);
}
int ccw(Point a, Point b, Point c){
  b -= a; c -= a;
  if(cross(b, c) > EPS) return +1;
  if(cross(b, c) < -EPS) return -1;
  if(dot(b, c) < 0) return 2;
  if(norm(b) < norm(c)) return -2;
  return 0;
}
bool intersectSS(const Line& s, const Line& t){
  return ccw(s[0], s[1], t[0]) * ccw(s[0], s[1], t[1]) <= 0 && 
         ccw(t[0], t[1], s[0]) * ccw(t[0], t[1], s[1]) <= 0;
}
bool intersectSP(const Line& s, const Point& p){
  return ccw(s[0], s[1], p) == 0;
}
Point projection(const Line& l, const Point& p){
  double t = dot(p - l[0], l.vector()) / norm(l.vector());
  return l[0] + t * l.vector();
}
double distanceSP(const Line& s, const Point& p){
  const Point r = projection(s, p);
  if(intersectSP(s, r)) return abs(r - p);
  return min(abs(s[0] - p), abs(s[1] - p));
}
int main(){
  double R;
  int N;
  while(cin >> R >> N && N){
    vector<Point> c(N);
    vector<double> r(N);
    vector<double> v(N);
    REP(i, N) cin >> c[i].real() >> c[i].imag() >> r[i] >> v[i];
    vector<bool> over(N);
    for(int t = 1; ; t++){
      vector<Point> curr(N);
      vector<double> dist(N);
      REP(i, N) dist[i] = max(0.0, abs(c[i]) - v[i] * t);
      REP(i, N) curr[i] = (dist[i] / abs(c[i])) * c[i];
      int n_idx = -1;
      REP(i, N) if(!over[i] && dist[i] > R + EPS && (n_idx == -1 || dist[n_idx] > dist[i])) n_idx = i;
      if(n_idx == -1) break;
      Line laser(c[n_idx] / abs(c[n_idx]) * R, c[n_idx] / abs(c[n_idx]) * 2000.0);
      REP(i, N) if(!over[i] && dist[i] > R + EPS && distanceSP(laser, curr[i]) < r[i] + EPS) over[i] = true;
    }
    int ans = 0;
    REP(i, N) if(!over[i]) ans ++;
    cout << ans << endl;
  }
  return 0;
}

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

int main() {
	string s; cin >> s;
	int c0 = 0, c1 = 0;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] == '0') c0++;
		else c1++;
	}
	cout << 2 * min(c0, c1) << endl;

	return 0;
}

Measured memory_bytes: 512
N = int(input())

mylist = list(map(int, input().split()))


myans = 0
mynum = 1

i = 0 
while i < N:
    
    if mylist[i] == mynum:
        mynum += 1
        
    else:
        myans += 1
        
    i += 1

if myans != N:
    print(myans)
else:
    print(-1)

Measured memory_bytes: 24872
#include <bits/stdc++.h>
using namespace std;
int main (){
    int N,ans=0,count=1,j;
    cin >> N;
    vector<int> v(N);
    
    for(int i=0;i<N;i++){
        cin >> v.at(i);
    }
    sort(v.begin(),v.end());
    //入力して昇順ソート


    if(v.size() != 1){
        for(j=0;j<v.size()-1;j++){//それぞれの要素について
        
         while(j+1 < v.size() && v.at(j)==v.at(j+1)){//隣と同じだったら片方消す
            v.erase(v.begin()+j);//v.eraseの書き方注意
            count++;//countは登場回数
         }
         if(j == v.size()-2 && v.at(j)!=v.at(j+1)){
             ans++;
         }
        
         if(count%2 == 1){//countは登場回数、奇数だったらその数は最後書かれてる
            ans++;
         }
        count=1;//countリセット
        }//同じ数がいくつ続いてるか見る
        cout << ans << endl;
    }
    else{cout << 1 << endl;}//数が１つだけの時は１つ
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod=1e9+7;

ll bigmod(ll b,ll p)
{
    if(!p)return 1;
    ll x=bigmod(b,p/2);
    x=(x*x)%mod;
    if(p&1)x=(x*b)%mod;
    return x;
}
int main()
{
    ll n,k;cin>>n>>k;
    vector<ll>vc;
    for(int i=1;i<=n;i++)
    {
        ll x;cin>>x;
        vc.push_back(x);
    }
    sort(vc.begin(),vc.end());

    ll fact[n+3],cal[n+3];
    fact[0]=1;
    for(ll i=1;i<=n+1;i++)fact[i]=(fact[i-1]*i)%mod;
    for(ll i=k-1;i<=n;i++)
    {
        ll ret=(fact[k-1]*fact[i-k+1])%mod;
        cal[i]=(fact[i]*bigmod(ret,mod-2))%mod;
    }
    ll sum=0;

    for(ll i=n-1;i>=k-1;i--)
    {
       ll ret=(vc[i]*cal[i])%mod;
       sum=(sum+ret)%mod;
    }
   // cout<<sum<<"\n";

    for(ll i=0;i<=n-k;i++)
    {
         ll ret=(vc[i]*cal[n-i-1])%mod;
       sum=((sum-ret)%mod+mod)%mod;
    }
    cout<<sum<<"\n";
}

Measured memory_bytes: 2292
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main()
{
   int n,d,c=0,i,x,y;
    scanf("%d %d",&n,&d);
    for(i=0;i<n;i++){
        scanf("%d %d",&x,&y);
        if(sqrt(pow(x,2)+(pow(y,2)))<=d)
        c++;
    }
    printf("%d\n",c);
    return 0;
  }

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

using namespace std;

int main() {
    int n, q;
    cin >> n;
    vector<int> s(n);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    cin >> q;
    vector<int> t(q);
    for (int i = 0; i < q; i++) {
        cin >> t[i];
    }
    int cnt = 0;
    for (int i = 0; i < q; i++) {
        for (int j = 0; j < n; j++) {
            if (s[j] == t[i]) {
                cnt++;
                break;
            }
        }
    }

    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3116
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7


int main() {

	int H, W;
	int h, w;
	scanf("%d%d%d%d", &H, &W,&h,&w);

	printf("%d", (H - h)*(W - w));




}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/hash_map>
#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcountll(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int OO = (int) 2e9;
const double eps = 1e-9;

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	int x;
	cin >> x;
	if (x >= 30)
		puts("Yes");
	else
		puts("No");
	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define ll int
#define INF 100000000000
#define mod 1000000007
#define pll pair<long,long>
#define se second
#define fi first
#define pb push_back
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef tree<pll,null_type,less<pll>,rb_tree_tag,tree_order_statistics_node_update>pllordered_set;


ll vis[100050][3];
vector<ll> g1[100050];

int main()
{
			ios_base::sync_with_stdio(false);
			cin.tie(NULL);
			ll n,m;
			cin>>n>>m;
			for(ll i=0;i<m;i++)
			{
				ll u,v;
				cin>>u>>v;
				g1[u].pb(v);
			}
			ll s,t;
			cin>>s>>t;
			queue<pll> q;
			q.push({s,0});
			memset(vis,-1,sizeof(vis));
			vis[s][0]=0;
			
			
			while(!q.empty())
			{
				pll node=q.front();
				q.pop();
				//cout<<node.fi<<" "<<vis[node.fi][node.se]<<endl;
				for(auto i:g1[node.fi])
				{
					
					if(vis[i][(node.se+1)%3]==-1)
						{
							vis[i][(node.se+1)%3]=vis[node.fi][node.se]+1;
							q.push({i,(node.se+1)%3});
						
						}
				}
			}
			//cout<<vis[t][0]<<endl;
			if(vis[t][0]!=-1)
				cout<<vis[t][0]/3;
			else
				cout<<-1;
			
}


Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    ll A, B, C, K;
    cin >> A >> B >> C >> K;
    if(K <= A) cout << K << endl;
    elif(K <= A+B) cout << A << endl;
    else cout << A-(K-A-B) << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  int count=0;
  cin>>a>>b;
  for(int i=a;i<=b;i++){
    if(i/10000 == i-(i/10)*10 && i/1000-(i/10000)*10 == (i-((i/100)*100)-i%10)/10) count++;
  }
  cout<<count<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf (long long)1e9
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(n,a) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define int ll


int n,ma,mb;
int a[50],b[50],c[50];
int dp[510][510];

signed main(){
  cin>>n>>ma>>mb;
  rep(i,n){
    cin>>a[i]>>b[i]>>c[i];
  }

  rep(i,510){
    rep(j,510){
        dp[i][j]=inf;
    }
  }

  dp[0][0]=0;

  rep(i,n){
    rrep(j,500){
      rrep(k,500){
        if(j-a[i]<0||k-b[i]<0) continue;
        if(dp[j][k]>dp[j-a[i]][k-b[i]]+c[i]){
          dp[j][k] = dp[j-a[i]][k-b[i]]+c[i];
        }
      }
    }
  }

  int ans=inf;
  rep(i,500){
    rep(j,500){
      if(i==0||j==0) continue;
      if(i*mb==j*ma)
        ans = min(dp[i][j],ans);
    }
  }

  if(ans==inf){
    cout<<-1<<endl;
  }
  else{
    cout<<ans<<endl;
  }
}

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

int main() {
    ll a;
    long double b;
    cin >> a >> b;

    ll ans = floor(a * b);

    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 3792
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <tuple>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <random>
#include <cstdlib>
#define INT_MAX 2147483647
#define INT_MIN -2147483646
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

static const int N = 105;

struct vertex {
	int id;
	int p;
	int d;
	bool operator<(const vertex & another) const {
		return (d != another.d ? d>another.d : id>another.id);
	}
};

int main() {
	vvi mx(N, vi(N, -1));
	int n;
	cin >> n;
	Loop(i, n) {
		Loop(j, n) {
			int a;
			cin >> a;
			mx[i][j] = a;
		}
	}
	
	vector<bool> color(N, 0);
	priority_queue<vertex> q;
	q.push({ 0,-1,0});
	int ret = 0;
	while(q.size() > 0) {
		vertex v = q.top();
		q.pop();
		if (color[v.id] == 1) continue;
		color[v.id] = 1;
		ret += v.d;
		Loop(j, n) {
			if (mx[v.id][j] != -1 && color[j] != 1){
				q.push({ j, v.id,mx[v.id][j] });
			}
		}
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 3208
// #include <bits/stdc++.h>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <map>
#include <math.h>
#include <algorithm> // std::sort, std::min, std::next_permutation, std::lower_bound
#include <iomanip> // std::setprecision
#include <cmath> // std::ceil
#include <numeric> // std::gcd, std::lcm
#include <limits> // std::numeric_limits<long int>::max()
#include <unordered_map>
#include <map>
#include <cmath> // std::atan2
#include <deque>
#include <queue>

using namespace std;
typedef long long ll;
#define INF 1999999999
#define MODA 1000000007 
#define rep(i,n) for (long long i = 0; i < (n); ++i)

int main() {
  ll N, M, Q;
  cin >> N >> M >> Q;
  vector<ll> L(M), R(M);
  rep (i, M) {
    cin >> L[i] >> R[i];
    L[i]--;
    R[i]--;
  }
  vector<ll> p(Q), q(Q);
  rep (i, Q) {
    cin >> p[i] >> q[i];
    p[i]--;
    q[i]--;
  }

  vector<vector<ll>> LRbin(N);
  rep (i, N) LRbin[i].resize(N,0);
  rep (i, M) {
    LRbin[L[i]][R[i]]++;
  }
  vector<vector<ll>> pqbin(N);
  rep (i, N) pqbin[i].resize(N,0);
  ll icount = M;
  for (ll i=0; i<N; ++i) {
    if (i > 0) {
      for (ll k=i-1; k<N; ++k) {
        icount -= LRbin[i-1][k];
      }
    }
    ll jcount = icount;
    ll count = 0;
    for (ll j=N-1; i<=j; --j) {
      if (j < N-1) {
        for (ll k=i; k<=j+1; ++k) {
          jcount -= LRbin[k][j+1];
        }
      }
      pqbin[i][j] = jcount;
    }
  }
  rep (i, Q) {
    cout << pqbin[p[i]][q[i]] << endl;
  }
  return 0;
}


Measured memory_bytes: 11908
n = int(input())
a = [int(_) for _ in input().split()]
count_four = 0
count_even = 0
count_odd = 0

for ai in a:
    if ai % 4 == 0:
        count_four += 1
    elif ai % 2 == 0:
        count_even += 1
    else:
        count_odd += 1

if count_odd <= 0:
    print('Yes')
elif count_odd == 1:
    if count_four >= 1:
        print('Yes')
    else:
        print('No')
elif count_odd == 2:
    if count_four >= 2:
        print('Yes')
    elif count_four == 1 and count_even == 0:
        print('Yes')
    else:
        print('No')
else:
    if count_even == 0:
        if count_four + 1 >= count_odd:
            print('Yes')
        else:
            print('No')
    else:
        if count_four >= count_odd:
            print('Yes')
        else:
            print('No')

Measured memory_bytes: 14252
#from numpy import*
#from scipy import*
from collections import* #defaultdict Counter deque appendleft
from fractions import gcd
from functools import* #reduce
from itertools import* #permutations("AB",repeat=2) combinations("AB",2) product("AB",2) groupby
from operator import mul
from bisect import* #bisect_left bisect_right
from heapq import* #heapify heappop heappushpop
from math import*  #factorial
from copy import deepcopy
import sys
#input=sys.stdin.readline  #危険！基本オフにしろ！
sys.setrecursionlimit(10**6)


def main():
    n=float(input())
    print(n**2*pi,n*2*pi)
    
    
    
if __name__ == '__main__':
    main()


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

int main() {
  int a,b,q;
  long inf=1e18;
  cin>>a>>b>>q;
  vector<long>s(a+2),t(b+2),x(q);
  s.at(0)=t.at(0)=-inf;
  s.at(a+1)=t.at(b+1)=inf;
  rep(i,a){
    cin>>s.at(i+1);
  }
  rep(i,b){
    cin>>t.at(i+1);
  }
  rep(i,q){
    cin>>x.at(i);
  }
  rep(i,q){
    long ans=inf;
    long d=x.at(i);
    
    int A=lower_bound(s.begin(),s.end(),d)-s.begin();
    
    int B=lower_bound(t.begin(),t.end(),d)-t.begin();
    rep2(i,A-1,A+1){
      rep2(j,B-1,B+1){
        long now=min(abs(s.at(i)-d)+abs(t.at(j)-s.at(i)),abs(t.at(j)-d)+abs(t.at(j)-s.at(i)));
        ans=min(ans,now);
      }
    }
    cout<<ans<<endl;
  }
}

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; ++i) cin >> A[i];

    int k = A[0], l = k + 1;
    for(int i=1; i<N; ++i) {
        if(A[i] == k - 1) {
            l = k;
        } else if(A[i] == k) {

        } else if(A[i] == l) {
            k = l;
        } else {
            cout << "No" << endl;
            return 0;
        }
    }

    if(k != l) {
        if(N - 1 == A[0] || N >= 2 * k) {
            cout << "Yes" << endl;
            return 0;
        } else {
            cout << "No" << endl;
            return 0;
        }
    } else {
        int cnt = 0;
        for(int i=0; i<N; ++i) {
            if(A[i] != k) ++cnt;
        }
        if(k > cnt && N - cnt >= 2 * (k - cnt)) {
            cout << "Yes" << endl;
            return 0;
        } else {
            cout << "No" << endl;
            return 0;
        }
    }
}

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

int N;
ll A[200010];

int main(){
  cin >> N;
  rep(i, N) cin >> A[i];

  ll ans = 0;
  ll max_value = A[0];
  rep(i, N-1){
    if (max_value > A[i+1]){
      ans += max_value - A[i+1];
    }
    else{
      max_value = A[i+1];
    }
  }
  cout << ans << endl;
}


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

int main(){
  vector<int> a(5);
  int j, r = 10;
  for (int i = 0; i < 5; i++){
    cin >> a.at(i);
    if (r > a.at(i)%10 && a.at(i)%10 > 0){
      j = i; r = a.at(i)%10;
    }
  }
  int ans = 0;
  for (int i = 0; i < 5; i++){
    if (i == j) ans += a.at(i);
    else{
      int s = a.at(i)%10;
      if (s == 0) ans += a.at(i);
      else ans += a.at(i) + (10 - a.at(i)%10);
    }
  }
  cout << ans << endl;
  return 0;
} 

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

int main(void) {
  long long H, N;
  cin >> H >> N;
  vector<long long> A(N);
  vector<long long> B(N);
  vector<long long> dp(H + 1, 100000000);
  for (int i = 0; i < N; i++) {
    cin >> A[i] >> B[i];
  }

  dp[0] = 0;
  for (long long j = 1; j <= H; j++) {
    for (long long i = 0; i < N; i++) {
      if (j - A[i] < 0)
        dp[j] = min(dp[j], B[i]);
      else
        dp[j] = min(dp[j], dp[j - A[i]] + B[i]);
    }
  }

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

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <string> 
#include <vector>
#include <iomanip>
using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;
	if (a % 2 == 1 && b % 2 == 1) {
		cout << "Odd" << endl;
	}
	else {
		cout << "Even" << endl;
	} 
}

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

int main()
{
  int n;
  cin >> n;
  vector<int> d(n);
  int i;
  for(i = 0; i < n; i++)
  {
    cin >> d.at(i);
  }
  int ans = 1;
  sort(d.begin(), d.end());
  for(i = 0; i < n-1; i++)
  {
    if(d.at(i)<d.at(i+1)) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

from fractions import gcd

N = int(input())
A = list(map(int, input().split()))

L, R = [0], [0]
for i in range(N):
    L.append(gcd(L[-1], A[i]))
    R.append(gcd(R[-1], A[-(i + 1)]))
R.reverse()

print(max([gcd(L[i], R[i + 1]) for i in range(N)]))


Measured memory_bytes: 16060
#include <bits/stdc++.h>
 
#define loop(n, i) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()

using namespace std;

int C[100][100] = {};
int vis[100][100] = {};

int dfs(int i, int j)
{
    int d[] = {1, 0, -1};
    if (!vis[i][j] && C[i][j]) {
        vis[i][j] = 1;
        loop (3, x) loop (3, y) dfs(i + d[x], j + d[y]);
    }
}

int main()
{
    while (1) {
        fill(C[0], C[99]+100, 0);
        fill(vis[0], vis[99]+100, 0);

        int w, h; cin >> w >> h;
        if (!w && !h) break;
        loop (h, i) loop (w, j) cin >> C[i+1][j+1];

        int ans = 0;
        loop (h, i) loop (w, j) {
            if (vis[i+1][j+1] || !C[i+1][j+1]) continue;
            ans++;
            dfs(i+1, j+1);
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1380
#include <iostream>
#include <algorithm>
#include <vector>
#include <list>
#include <map>
#include <string>
#include <functional>
#include <math.h>
#include <utility>
using namespace std;
int main()
{
	bool pre[30];
	fill(pre,pre+30,false);
	for(int i=0;i<28;i++){
		int t;cin>>t;
		pre[--t]=true;
	}
	for(int i=0;i<30;i++){
		if(!pre[i])cout<<i+1<<endl;
	}
}

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

int main() {
	string N;
	
	while (cin >> N) {
		if (N == "0000") break;
		int ok = 1, ans = 0;
		set< string > strs;
		
		while (ok) {
			if (N == "6174") break;
			strs.insert(N);
			
			string L = N, S = N;
			sort(L.begin(), L.end(), greater< char >());
			sort(S.begin(), S.end());
			
			stringstream ss;
			ss << L << " " << S;
			int l, s;
			ss >> l >> s;
			
			int n = l - s;
			stringstream sss;
			sss << n;
			N = sss.str();
			
			while (N.size() < 4) N = "0" + N;
			
			++ans;
			
			if (strs.count(N)) ok = 0;
		}
		
		if (ok) cout << ans << endl;
		else cout << "NA" << endl;
	}
}

Measured memory_bytes: 1260
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#define SIZE 1005
 
using namespace std;
typedef pair <int,int> P;
 
char mp[SIZE][SIZE];
int dist[SIZE][SIZE];
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
 
int main()
{
	int H,W;
	scanf("%d %d",&H,&W);
	for(int i=0;i<H;i++) scanf("%s",&mp[i]);
	queue <P> que;
	for(int i=0;i<H;i++)
	{
		for(int j=0;j<W;j++)
		{
			if(mp[i][j]=='#')
			{
				dist[i][j]=0;
				que.push(P(i,j));
			}
			else
			{
				dist[i][j]=-1;
			}
		}
	}
	while(!que.empty())
	{
		P p=que.front();que.pop();
		for(int t=0;t<4;t++)
		{
			int x=p.first+dx[t],y=p.second+dy[t];
			if(0<=x&&x<H&&0<=y&&y<W&&dist[x][y]==-1)
			{
				dist[x][y]=dist[p.first][p.second]+1;
				que.push(P(x,y));
			}
		}
	}
	int ret=0;
	for(int i=0;i<H;i++)
	{
		for(int j=0;j<W;j++)
		{
			ret=max(ret,dist[i][j]);
		}
	}
	printf("%d\n",ret);
	return 0;
}


Measured memory_bytes: 13328
#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);

    string s;
    ll k;
    cin >> s >> k;

    char res = '1';
    int one_idx = 0;
    rep(i, s.length()){
        if(s[i] != '1') {
            res = s[i];
            one_idx = i;
            break;
        }
    }

    if(k<=one_idx) cout << 1 << endl;
    else cout << res << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int n,m,s,c,a[100];
int main(){
    cin >> n >> m;
    fill(a+1,a+n+1,-1);
    for(int i = 1; i <= m; i++){
        cin >> s >> c;
        if(a[s] == -1) a[s] = c;
        if(a[s] != c){printf("-1"); return 0;}
    }
    if(a[1] == -1) a[1] = 1;
    if(n == 1 and m == 0){cout << 0; return 0;}
    if(a[1] == 0 and n > 1){printf("-1"); return 0;}
    for(int i = 1; i <= n; i++){
        if(a[i] == -1) cout << 0;
        else cout << a[i];
    }
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)


############ ---- Input Functions ---- ############
def in_int():
    return (int(input()))


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


def in_str():
    s = input()
    return (list(s[:len(s) - 1]))


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


n,m  = in_ints()
ans  = 0
if n >=2 : 
    ans  +=  (n)*(n-1)//2
if m >=2:
    ans += (m) * (m - 1) // 2
    
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
    #define N 200100
    using namespace std;
    double pb[N];
    int main(){
    	int n,d,x;
    	double ans=0;
    	scanf("%d%d%d",&n,&d,&x);
    	for(int i=1;i<n;i++) pb[i]=pb[i-1]+0.5/(i+1);
    	for(int i=0;i<n;i++){
    		ans+=0.5*(d+i*2*x);
    		ans+=0.5*(d+i*2*x+x);
    		ans+=0.5*(pb[i]+pb[n-1-i])*(d+d+i*4*x+x);
    	}
    	printf("%.12f\n",ans);
    	return 0;
    }

Measured memory_bytes: 1792
#include <atcoder/fenwicktree>
#include <iostream>
#include <vector>
using namespace std;
using namespace atcoder;
typedef long long ll;

int main()
{
    int n, q;
    cin >> n >> q;
    fenwick_tree<ll> bit(n);
    for(int i = 0; i < n; i++){
        ll a;
        cin >> a;
        bit.add(i, a);
    }
    while(q--){
        int t;
        cin >> t;
        if(t){
            int l, r;
            cin >> l >> r;
            cout << bit.sum(l, r) << endl;;
        }
        else{
            int p;
            ll x;
            cin >> p >> x;
            bit.add(p, x);
        }
    }
}


Measured memory_bytes: 8212
import java.io.*;
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;

public class Main
{
	public static void main(String []args)throws IOException
	{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String []s=br.readLine().split(" ");
		long A = Long.parseLong(s[0]);
		long B = Long.parseLong(s[1]);
		long K = Long.parseLong(s[2]);
		long aoki=B,taka=A;
		
		if(K<=A)
			taka=A-K;
		else if(K>A && K-A<=B)
		{
			taka=0;
			aoki=B-(K-A);
		}
		else
		{
			aoki=0;
			taka=0;
		}
		
		out.println(taka+" "+aoki);
	
	}
}




Measured memory_bytes: 21204
#include <iostream>
    #include <stdio.h>
    #include <string>
    #include <math.h>
    #include<algorithm>
    #include <numeric>
    using namespace std;
     
    int main(){
      int N ,A;
      cin >> N >>A;
      int x[N];
      for(int i=1;i<N+1;i++){
       cin >> x[i]; 
      }
      int K=2600;
      long long dp[N+1][K][N+1]={};
      dp[0][0][0]=1;
      for(int i=1;i<N+1;i++){
       for(int j=0;j<K;j++){
         for(int k=0;k<N+1;k++){
           if(k<1 || j<x[i]){
            dp[i][j][k]=dp[i-1][j][k]; 
           }else{
             dp[i][j][k]=dp[i-1][j][k]+dp[i-1][j-x[i]][k-1];
           }
         }
       }
      }
      long long ans=0;
      for(int i=1; i<=N; i++){
    ans+=dp[N][i*A][i];
  }
      cout << ans << endl;
      return 0;}

Measured memory_bytes: 53120