akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc,char* argv[]){
        char S[10];
        int i,max = 0,count=0;
        scanf("%s",S);
        for(i=0;i<strlen(S);i++){
                switch(S[i]){
                        case 'A':
                        case 'C':
                        case 'T':
                        case 'G':
                        count++;
                        break;
                        default:
                        count = 0;
                        break;
                }
                
                if(max<count) max = count;
        }
        printf("%d\n",max);

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
  long int n,a;
  cin >> n;
  a = 0;
  for (int i=1; i<=n; i++) {
    if(i%3 == 0 || i%5 == 0) {
      continue;
    }
    a += i;
  }
  cout << a << endl;
}

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

int n;

int main () {
  std::cin >> n;
  std::vector<int> a(n);
  for (int i = 0; i < n; ++i) {
	std::cin >> a[i];
  }
  int min = 1001, max = 0;
  for(int i = 0; i < n; ++i){
	if (min > a[i]){
	  min = a[i];
    }
	if(max < a[i]){
	  max = a[i];
	}
  }
  std::cout << max - min << std::endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

int main()
{
    string s;
    cin >> s;
    int len = s.size();
    if (s[len - 1] != 's')
        cout << s + 's' << endl;
    else
        cout << s + "es" << endl;
    
    return 0;
}

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

using namespace std;

int main() {
    
    
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    cin>>a[i];
    int ans=0;
    
    sort(a,a+n);
    
    
    for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			for(int k=j+1;k<n;k++){
				if((a[i]<a[j]+a[k]) && (a[j]<a[i]+a[k]) && (a[k]<a[j]+a[i]) && a[i]!=a[j] && a[j]!=a[k]){
					ans++;
//					cout<<" df "<<a[i]<<" "<<a[j]<<"  "<<a[k]<<endl;
				}
			}
		}
	}
    cout<<ans<<endl;
    return 0;

    
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
void solve()
{
    long long int n,k;cin>>n>>k;
    if(k>1)
    {
        cout<<n-k<<endl;
    }
    else
    {
        cout<<0<<endl;
    }
}
int main()
{
    solve();
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

int main(){
    ll n,m;
    cin >> n >> m;

    Graph G(n);
    REP(i,m){
        ll a,b;
        cin >> a >> b;
        --a;
        --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    vector<ll> dist(n, -1); // 全頂点を「未訪問」に初期化
    vector<ll> answer(n,-1);
    queue<ll> que;

    dist[0] = 0;
    que.push(0); // 0 を橙色頂点にする

    while (!que.empty()) {
        ll v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (ll nv : G[v]) {
            if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[nv] = dist[v] + 1;
            que.push(nv);
            answer[nv]=v+1;
        }
    }

    // 結果出力 (各頂点の頂点 0 からの距離を見る)
    //for (int v = 0; v < n; ++v) cout << v << ": " << dist[v] << endl;
    cout << "Yes" << endl;
    FOR(i,1,n)cout << answer[i] << endl;
    return 0;
}

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

int main(){
	int n,m;cin >> n >> m;
	n--;
	while(m--){
		int a,b; cin >> a >> b;
		a--,b--;
		int r = min(n-a,a);
		r = min(r,min(n-b,b));
		cout << (r%3)+1 << endl;
	}
}

Measured memory_bytes: 0
import java.io.*;
public class Main{
    public static void main(String [] args) throws NumberFormatException, IOException{
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        String[] st=br.readLine().split(" ");
        int a=Integer.parseInt(st[0]);
        int b=Integer.parseInt(st[1]);
        int c=Integer.parseInt(st[2]);
        System.out.println(a<b&&b<c?"Yes":"No");
    }}

Measured memory_bytes: 24180
#include<iostream>
#include<cstdio>
#include<string>
const int N=50+5;
using namespace std;
int main()
{
    int n,m,a[N];
    while(cin>>n>>m)
    {
        int x,sum=0;
       for(int i=0;i<n;i++)
       {
           scanf("%d",&a[i]);
       }
        for(int i=0;i<n-1;i++)
            for(int j=0;j<n-1-i;j++)
        {
            if(a[j]<a[j+1])
            {
                int t;
                t=a[j];
                a[j]=a[j+1];
                a[j+1]=t;
            }
        }
        for(int i=0;i<m;i++)
        {
            sum+=a[i];
        }
        printf("%d\n",sum);
    }

}


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

int main() {
        int m, nmin, nmax;
        while( cin >> m >> nmin >> nmax, m || nmin || nmax ) {
                vector<int>P( m );
                for( size_t i = 0; i < m; i++ ) {
                        cin >> P[i];
                }
                int ans = 0;
                int sub = 0;
                for( size_t i = nmin; i <= nmax; i++ ) {
                        if( sub <= P[i - 1] - P[i] ) {
                                sub = P[i - 1] - P[i];
                                ans = i;
                        }
                }
                cout << ans << endl;
        }
}

Measured memory_bytes: 3076
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

import java.util.*;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        int N = in.nextInt();
        int H = in.nextInt();
        Integer[] a = new Integer[N];
        Integer[] b = new Integer[N];
        for (int i=0;i<N;i++) {
            a[i] = in.nextInt();
            b[i] = in.nextInt();
        }
        Arrays.sort(a, (x, y) -> Integer.compare(y, x));
        Arrays.sort(b, (x, y) -> Integer.compare(y, x));

        int ans = 0;
        for (int i=0;i<N;i++) {
            if (a[0]>b[i]) {
                break;
            }
            H -= b[i];
            ans++;
            if (H<=0) {
                break;
            }
        }
        if (H>0) {
            ans += Math.ceil((double)H/a[0]);
        }
        out.println(ans);

        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}


Measured memory_bytes: 47252
//#pragma GCC optimize("O3")
//#pragma GCC target("sse4,avx2,abm,fma")
#include <bits/stdc++.h>
using namespace std;
#define _USE_MATH_DEFINES

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef complex<ld> pt;

const char nl = '\n';
const ll INF = 0x3f3f3f3f;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const ll MOD = 1e9+7;
const ld EPS = 1e-11;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

const int M = 1e4 + 1;
int cnt[M];

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cout << fixed << setprecision(10);

	int n, p;
	cin >> n >> p;
	string s;
	cin >> s;

	if(p == 2) {
		ll ans = 0;
		for(int i=0; i<n; i++) {
			if((s[i]-'0') % 2 == 0) {
				ans += i+1;
			}
		}
		cout << ans << nl;
	}

	else if(p == 5) {
		ll ans = 0;
		for(int i=0; i<n; i++) {
			if((s[i]-'0') % 5 == 0) {
				ans += i+1;
			}
		}
		cout << ans << nl;
	}

	else {
		reverse(s.begin(), s.end());

		ll cur = 0;
		ll mp = 1;
		cnt[0] = 1;
		for(char c : s) {
			cur = (cur + (c-'0') * mp) % p;
			mp = mp * 10 % p;
			cnt[cur]++;
		}

		ll ans = 0;
		for(int i=0; i<p; i++) {
			ans += (ll) cnt[i] * (cnt[i]-1) / 2;
		}
		cout << ans << nl;
	}

	return 0;
}


Measured memory_bytes: 720
import fractions
from math import sqrt

A, B = map(int, input().split())

G = fractions.gcd(A, B)
N = int(sqrt(max(A,B)))+1
g = G
ans = 1

for i in range(2, N+3):
    if(g % i == 0):
        ans += 1
        while(g % i == 0):
            g = g/i
            
if g != 1:
    ans += 1

print(ans)


Measured memory_bytes: 5172
import sys
sys.setrecursionlimit(10**8)
N,U,V = map(int,input().split())
U,V = U-1,V-1
AB = [tuple(map(int,input().split())) for i in range(N-1)]
es = [[] for _ in range(N)]
for a,b in AB:
    a,b = a-1,b-1
    es[a].append(b)
    es[b].append(a)

dist1 = [N] * N
dist1[V] = 0
def dfs1(v,p=-1):
    for to in es[v]:
        if to==p: continue
        dist1[to] = dist1[v] + 1
        dfs1(to,v)
dfs1(V)

D = dist1[U]

dist2 = [N] * N
dist2[U] = 0
def dfs2(v,p=-1):
    for to in es[v]:
        if to==p: continue
        if (D+1)//2 > dist1[to]: continue
        dist2[to] = dist2[v] + 1
        dfs2(to,v)
dfs2(U)

ans = 0
for a,b in zip(dist1,dist2):
    if b==N: continue
    ans = max(ans, a-1)
print(ans)

Measured memory_bytes: 133064
#include <iostream>
#include <vector>
using namespace std;
constexpr int MOD = 1000000007;

int main()
{
	int N; cin >> N;
	vector<int> A(N), B(N+1);
	for (int i = 0; i < N; ++i) cin >> A[i];
	B[0] = 3;
	long long ans = 1;
	for (int i = 0; i < N; ++i) {
		ans = ans * B[A[i]] % MOD;
		++B[-~A[i]];
		--B[A[i]];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;

signed main(){
    cin.tie(0); 
    ios::sync_with_stdio(false);
    
    int n;
    string s,t;
    cin >> n;
    cin >> s >> t;

    for(int i=0;i<n;i++){
        cout << s[i] << t[i];
    }
    cout << "\n";
    return 0;
}



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

using namespace std;

#define ll long long
#define dd double

int main()
{
	ll n,w;
	cin>>n>>w;
	vector<ll> we(n),val(n);
	for(ll i = 0;i<n;i++)
	{
		cin>>we[i]>>val[i];
	}
	ll sumval  = 0;
	for(ll i =0;i<n;i++)
	{
		sumval+=val[i];
	}
	ll dp[sumval+1];
	memset(dp,(int)1e9+7,sizeof(dp));
	dp[0] = 0;
	for(ll i = 0;i<n;i++)
	{
		for(ll j = sumval-val[i];j>=0;--j)
		{
			dp[j+val[i]] = min(dp[j]+we[i],dp[j+val[i]]);
		}
	}
	for(ll i = sumval;i>=0;--i)
	{
		if(dp[i]<=w)
		{
			cout<<i;
			break;
		}
	}
}

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

typedef long long int LL;

int main(){
	int n;	cin>>n;
	LL d,a;	cin>>d>>a;

	vector<pair<LL,LL>> enemy;
	for(int i=0;i<n;i++){
		int x,h;	cin>>x>>h;
		enemy.push_back({x,h});
	}
	sort(enemy.begin(), enemy.end());


	queue<pair<LL,LL>> Q;
	// 爆撃の座標、回数を入れる（詳しくは下）

	LL cnt=0,ans=0;
	for(int i=0;i<n;i++){
		while(Q.size()){
			auto prev=Q.front();
			if(prev.first < enemy[i].first){
				Q.pop();
				cnt-=prev.second;
			}else break;
		}

		if(cnt*a >= enemy[i].second){
			// 爆風巻き込まれて死んでる
			// -> ここを左端とする爆撃はない
			continue;
		}

		// 爆風ダメージ引いておく
		enemy[i].second -= cnt*a;

		LL tmp=(enemy[i].second+a-1)/a;
		cnt+=tmp;
		ans+=tmp;

		Q.push({enemy[i].first+2*d, tmp});
		// {爆撃の右端, 爆撃回数}
	}

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


Measured memory_bytes: 6512
N = int(input())
A = N*(N+1)//2
P = N//3
B = 3*P*(P+1)//2
Q = N//5
C = 5*Q*(Q+1)//2
R = N//15
D = 15*R*(R+1)//2

ans = A - B - C + D
print(ans)


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

int main() {
    std::string S;
    std::cin >> S;

    if (S[0] != S[1] && S[1] != S[2] && S[2] != S[0]) {
        std::cout << "Yes\n";
    } else {
        std::cout << "No\n";
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int n;
  cin>>n;
  while(n--){
    int a[10],b[2][11]={0},b1=1,b2=1,k=0;
    r(i,10)cin>>a[i];
    r(i,10){
      if(a[i]>b[1][b1-1])b[1][b1++]=a[i];
      else b[0][b2++]=a[i];
    }
    r(i,b1-1){if(b[1][i]>b[1][i+1])k++;}
    r(i,b2-1){if(b[0][i]>b[0][i+1])k++;}
    if(k)cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
  }
}

Measured memory_bytes: 3076
// /*
// power code taken from geeks for geeks
// */
// cout << setprecision (2) << fixed << 1.2;

#include <bits/stdc++.h>
#define MODD 1000000007LL
#define MAX_SIZE 100000000
#define MAX_N 200001
#define INF 1000000000
using namespace std;
typedef long long ll;
typedef long double ld;

ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
double max(double a,double b){return a>b?a:b;}
double min(double a,double b){return a<b?a:b;}

ll modd(ll a){if(a<0LL) return a*-1LL;return a;}
double modd(double a){if(a<0.0) return a*-1.0;return a;}

ll modulo(ll a){return a % MODD; }

ll power(ll k, ll p){
    if (p == 0)
        return 1LL;
 
    ll P = power(k, p/2LL);
    P = (P * P) % MODD;
 
    if (p % 2 == 1)
        P = (P * k) % MODD;
 
    return P;
}

ll power(ll k, ll p, bool f){
    if (p == 0)
        return 1LL;
 
    ll P = power(k, p/2LL);
    P = (P * P);
 
    if (p % 2 == 1)
        P = (P * k) ;
 
    return P;
}


struct p_str{
    ll a, b;
};


void solve(){
    char c;
    cin>>c;

    

    if('A' <= c  && c <= 'Z') {
        cout << 'A';
    }
    else{
        cout << 'a';
    }
}



int main(){




    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    



    ll t=1;


    // cin>>t;
    


    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <queue>

using ll = long long;

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

int main() {
  int k;
  std::cin >> k;

  std::queue<ll> q;

  for (int i = 1; i <= 9; ++i) q.push(i);

  ll x = 1;
  for (int i = 0; i < k; ++i) {
    x = q.front();
    q.pop();

    if (x % 10 != 0) q.push(10 * x + (x % 10) - 1);
    q.push(10 * x + x % 10);
    if (x % 10 != 9) q.push(10 * x + (x % 10) + 1);
  }

  std::cout << x << '\n';

  return 0;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define INF 1e9
#define PI acos(-1)
typedef long long ll;
typedef pair<int, int> p_ii;



int main() {
	int n, m, r, i, j, k;
	cin >> n >> m >> r;
	vector<int> rnum(r);
	for (i = 0; i < r; i++) {
		int tr; cin >> tr;
		tr--;
		rnum[i] = tr;
	}

	vector<int>a(m), b(m), c(m);
	for (i = 0; i < m; i++) {
		int aa, bb, cc;
		cin >> aa >> bb >> cc;
		aa--; bb--;
		a[i] = aa; b[i] = bb; c[i] = cc;
	}

	vector<vector<int>> dis(n, vector<int>(n, INF));
	for (i = 0; i < m; i++) {
		dis[a[i]][b[i]] = c[i];
		dis[b[i]][a[i]] = c[i];
	}

	for (k = 0; k < n; k++) {
		for (i = 0; i < n; i++) {
			for (j = 0; j < n; j++) {
				dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
			}
		}
	}

	int ans = INF;
	sort(rnum.begin(), rnum.end());
	do {
		int tmp = 0;
		for (i = 0; i < r-1; i++) {
			tmp += dis[rnum[i]][rnum[i + 1]];
		}
		ans = min(ans, tmp);
	} while (next_permutation(rnum.begin(), rnum.end()));

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

Measured memory_bytes: 640
use scanner::Scanner;

fn main() {
    let mut sc = Scanner::new();
    let _:String = sc.read();
    let s:String = sc.read();
    println!("A{}C", s.chars().nth(0).unwrap());
}

mod scanner {
    pub struct Scanner<'a> {
        s: String,
        words: ::std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new() -> Scanner<'a> {
            let s = String::new();
            let words = unsafe { ::std::mem::transmute(s.split_whitespace()) };
            Scanner { s: s, words: words }
        }

        pub fn read<T: ::std::str::FromStr>(&mut self) -> T {
            match self.words.next() {
                Some(x) => x.parse().ok().unwrap(),
                None => {
                    self.load();
                    self.read()
                }
            }
        }

        fn load(&mut self) {
            self.s.clear();
            ::std::io::stdin().read_line(&mut self.s).unwrap();
            self.words = unsafe { ::std::mem::transmute(self.s.split_whitespace()) };
        }
    }
}

Measured memory_bytes: 4352
n=int(input())
mod=998244353

ans=pow(3,n,mod)
rmv=0
f = [1, 1]  
inv = [1, 1]  
finv=[1,1]
for i in range(2, n+1):
    f.append((f[-1] * i) % mod)
    inv.append((-inv[mod % i] * (mod // i)) % mod)
    finv.append(finv[-1]*inv[-1]%mod)

k=n//2
if k*2<=n:
    k+=1
tmp=pow(2,n-k+1,mod)
inv2=pow(2,mod-2,mod)
for i in range(k,n+1):
    ans -= f[n]*finv[n-i]*finv[i]*tmp
    tmp*=inv2
    tmp%=mod
print(ans%mod)
    



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

const int max_n = 8;
map<array<int, max_n> , int> vis;
array<int, 4> dt = {1, -1, 4, -4};
array<int, max_n> init, final; 


int bfs(array<int, max_n> A){
	queue<array<int, max_n>> que;
	que.push(A);
	while(!que.empty()){
		array <int, max_n> B = que.front();
		que.pop();
		int p;
		for(p = 0; B[p]; ++p);
		for(int i = 0; i < 4; ++i){
			array<int, max_n> C = B;
			int dp = p + dt[i];
			if(dp >= 0 && dp < max_n && ((p % 4 == dp % 4) || (p / 4 == dp /4 ))){
				swap(C[p], C[dp]);
				if(!vis[C]){
					vis[C] = vis[B] + 1;
					que.push(C);
				}
			}
		}
	}
}

int main(){
	for(int i = 0; i < max_n; ++i) init[i] = i;
	vis[init] = 1;
	bfs(init);
	while(true){
		for(int i = 0; i < max_n; ++i) 
			if(scanf("%d", &final[i]) == EOF) return 0;
		printf("%d\n", vis[final] - 1);  
	}
	return 0;
}


Measured memory_bytes: 4912
#include <bits/stdc++.h>
using namespace std;
int a[100010];
int main()
{
    int n;
    while(cin>>n)
    {
        for(int i=0;i<n;i++)
        {
            cin>>a[i];
        }
        int sum=0;
        for(int i=0;i<n;i++)
        {
            sum+=abs(a[i]-a[i-1]);
        }
        sum+=abs(a[n-1]);
        int ans=0;
        //cout<<sum<<endl;
        for(int i=0;i<n;i++)
        {
            ans=sum;
            if(i==n-1)
            {
                ans=ans-abs(a[i]-a[i-1])-abs(a[n-1])+abs(a[n-2]);
            }
            else
            {
                ans=ans-abs(a[i]-a[i-1])-abs(a[i+1]-a[i])+abs(a[i+1]-a[i-1]);
            }
            cout<<ans<<endl;
        }
    }
}


Measured memory_bytes: 1664
#include<stdio.h>
#define Num 100000

int a[Num];

int search(int c){
   if(c == a[c])
      return c;
   return a[c] = search(a[c]);

}


int main(){
   int i,x,y,n,m,z;

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

   scanf("%d %d",&x,&y);

   for(i=0;i<y;i++){
      scanf("%d %d", &n,&m);
      if(search(n) != search(m)){
         a[search(m)] = search(n);
      }
   }

   scanf("%d",&z);

   for(i=0;i<z;i++){
      scanf("%d %d",&n,&m);
      if(search(n) == search(m))
         printf("yes\n");
      else
         printf("no\n");
   }

   return 0;

}

Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<string,int>;
const double PI = acos(-1);

int main() {
  ll mod = pow(10,9)+7;
  ll n,m;
  cin >> n >> m;
  ll ans;
  if(abs(n-m) > 1) ans = 0;
  else {
    ll in = 1,im = 1;
    for(ll i = 1; i <= n; i++) {
      in*=i;
      in = in%mod;
    }
    for(ll i = 1; i <= m; i++) {
      im*=i;
      im = im%mod;
    }
    if(n == m) ans = (in*im)*2%mod;
    else ans = (in*im)%mod;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3640
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cmath>

int main(){

    char a[7],b[4];
    int x = 0, y = 0;

    std::cin >> a >> b;

    std::strcat(a, b);

    x = std::atoi(a);

    y = (int)std::sqrt((double)x);

    if((y * y) == x){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }

    return 0;
}

Measured memory_bytes: 256
n=int(input())
s=list(map(int,input().split()))
q=int(input())
t=list(map(int,input().split()))
ans=0
for i in t:
    if i<s[0] or i>s[-1]: continue 
    lo,hi=0,len(s)
    while hi-lo>1:
        mid=(lo+hi)//2
        if s[mid]<i:
            lo=mid
        else:
            hi=mid
    l=[s[hi],s[lo]]
    if i in l:
        ans+=1
print(ans)


Measured memory_bytes: 16708
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
//#define MOD 1000000007
#define MOD 998244353
using namespace std;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)

ll mpow(ll x, ll n){ //x^n(mod M)
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % MOD;
        x = x*x % MOD;
        n = n >> 1;
    }
    return ans;
}

ll comb(long a, long b){     // C(a,b) = a! * b!^(M-2) * (a-b)^(M-2)
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % MOD;
    return tmp * fac[a] % MOD;
}

void pre_comb()
{
    fac[0] = 1;
    ifac[0] = 1;
    for(long i = 0; i<300000; i++){
        fac[i+1] = fac[i]*(i+1) % MOD; // n!(mod M)
        ifac[i+1] = ifac[i]*mpow(i+1, MOD-2) % MOD; // k!^{M-2} (mod M)
    }
    return;
}

int main(int argc, char* argv[])
{
    long n, a, b;
    ll   k;
    scanf("%ld%ld%ld%lld", &n, &a, &b, &k);

    pre_comb();

    ll ans=0;
    long i;
    for(i=0; i<=k/a && i<=n; i++) {
        if( (k-i*a)%b==0 ) {
            ll j = (k-i*a)/b;
            if(j<=n) {
                ans = (ans + comb(n, i) * comb(n, (long)j) %MOD) %MOD;
            }
        }
    }

    printf("%lld\n", ans);

    return 0;
}



Measured memory_bytes: 4992
n,c = [int(i) for i in input().split()]
d = [[int(i) for i in input().split()]for i in range(c)]
#d[A][B] はAからBになるときの違和感
color = [[int(i) for i in input().split()]for i in range(n)]

devcol = [[0 for i in range(3)] for j in range(c)]
for l in range(n):
        for row in range(n):
            devcol[color[l][row]-1][(l+row)%3] += 1
Dsum = [[0 for i in range(3)] for j in range(c)]
for i in range(c):
    for j in range(c):
        for k in range(3):
            Dsum[i][k] += d[j][i]*devcol[j][k] 
D = Dsum[0][0]+Dsum[1][1]+Dsum[2][2]
for c0 in range (c):
    for c1 in range (c):
        if c1 == c0:
            continue
        for c2 in range (c):
            if c2 == c1 or c2 == c0:
                continue
            D = min(D,Dsum[c0][0]+Dsum[c1][1]+Dsum[c2][2])
#O(c^3)のつもり
print(D)

Measured memory_bytes: 5492
a,b,k=map(int,input().split())
la=[]
lb=[]
for i in range(k):
    if a+i<=b:
        la.append(a+i)
    if a<=b-i:
        lb.append(b-i)
p=sorted(list(set(la+lb)))
for i in range(len(p)):
    print(p[i])


Measured memory_bytes: 3060
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const [A, B, H, M] = input[0].map(Number);

  const alpha = ((60 * H + M) / (60 * 12)) * 2 * Math.PI;
  const beta = (M / 60) * 2 * Math.PI;

  return Math.sqrt(A ** 2 + B ** 2 - 2 * A * B * Math.cos(alpha - beta));
};

console.log(main(read()));


Measured memory_bytes: 29712
#pragma region header
#include <bits/stdc++.h>
#define int long long
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr int inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
    int n;cin >> n;
    int count = 0;
    int k;cin >> k;
    count+=k/2;
    k%=2;
    // cout << endl;cout << count << endl;
    rep(i, n-1) {
        int a;cin >> a;
        count+=min(a,k);
        a-=min(a,k);
        count+=a/2;
        a%=2;
        k=a;
        // cout << count << endl;
        // cout << i << ":" << k << endl;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3604
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int compare(const void *a, const void *b) {
	return *(int *)b - *(int *)a;
}

int main(void) {
	int i;
	int m, n;
	int total_vote;
	int under;
	int *a;
	char buf[200000], *ch;

	//m, nを読む
	fgets(buf, sizeof(buf), stdin);
	ch = strtok(buf, " ");
	n = atoi(ch);
	ch = strtok(NULL, " ");
	m = atoi(ch);

	//aのメモリを確保して、読む
	a = (int *)calloc(n, sizeof(int));
	fgets(buf, sizeof(buf), stdin);
	ch = strtok(buf, " ");
	a[0] = atoi(ch);
	for(i = 1; i < n; i += 1) {
		ch = strtok(NULL, " ");
		a[i] = atoi(ch);
	}

	//総投票数を数える
	total_vote = 0;
	for(i = 0; i < n; i += 1) {
		total_vote += a[i];
	}
	under = total_vote / (4 * m);
	if(0 != total_vote % (4 * m)) {
		under += 1;
	}

	//得票数順にソートする
	qsort(a, n, sizeof(int), compare);

	//a[m-1]とunderを比較
	if(a[m - 1] >= under) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}

	free(a);
	return 0;
}


Measured memory_bytes: 128
import sys
input=sys.stdin.readline
N=int(input())
from collections import defaultdict
from collections import deque
branch=defaultdict(set)
for i in range(N-1):
    a,b=map(int,input().split())
    branch[a]|={b,}
    branch[b]|={a,}
brack=[float('inf')]*(N+1)
brack[1]=0
brack[N]=0
check=deque([1])
while len(check)>0:
    now=check.popleft()
    for i in branch[now]:
        if brack[i]>10**9:
            brack[i]=brack[now]+1
            check.append(i)
white=[float('inf')]*(N+1)
white[N]=0
white[1]=0
check=deque([N])
while len(check)>0:
    now=check.popleft()
    for i in branch[now]:
        if white[i]>10**9:
            white[i]=white[now]+1
            check.append(i)
brack[N]=float('inf')
white[1]=float('inf')
fennec=0
snuke=0
for i in range(1,N+1):
    if brack[i]<=white[i]:fennec+=1
    elif brack[i]>white[i]:snuke+=1
if fennec>snuke:print('Fennec')
elif fennec<=snuke:print('Snuke')

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

int main() {
    int s,w;
    cin >> s >> w;
    if(w >= s){
        cout << "unsafe" << endl;
    }else{
        cout << "safe" << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <assert.h>
//#include <bits/stdc++.h>

#define ll long long

using namespace std;


ll solve(ll a, ll b, ll dv, ll n){
    ll left = n - dv;
    
    if(b>1){
        if(n/(b-1) == n%(b-1))
            return b-1;
    }
    return 0;
    
    /*for(ll j = a; j <= b; ++j){
        if(n/j == n % j)
            cout  << a << " " << b << " " << dv << " "<< j<<endl;
    }
    return 0;*/
}

int main(){
    cin.sync_with_stdio(false);
    ll n;
    cin >> n;
    
    ll ans = 0;
    
    for(ll i = 1; i * i <= n; ++i){
        ll f = i;
        ll s = n/i;
        
        ans += solve(1 + n/(f+1), n/f, i, n);
        if(f != s){
            ans += solve(i, i, s, n);
        }
    }
    
    cout << ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}
ll dx[]={0, 0, -1, 1};
ll dy[]={1, -1, 0, 0};// up,down,left right

ll N ;
vector<pair<ll,ll> > num;
ll dp[105][105];

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

    cin >> N ;

    rep(i, N){
        ll a,b ;
        cin >> a >> b;

        num.pb(mp(a,b));
    }

    rep(i, N){
        dp[i][i] = 0;
    }
    
    rep(distance, N){
        rep(i, N){
            if(distance == 0){
                dp[i][i] = 0;
                continue;
            }
            
            ll from = i; ll to = i + distance;
            if(to >= N) continue;
            dp[from][to] = 1e13;
            for(int j = from; j <= to; j++){
                dp[from][to] = min(dp[from][to],
                                   dp[from][j] + dp[j+1][to] + num[from].first * num[j].second * num[to].second);
                                   
            }
        }
    }
    cout << dp[0][N-1] << endl;

    
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}



Measured memory_bytes: 3256
import sys

n = int(input())
ab_list = [list(map(int, input().split())) for _ in range(n)]
ab_list.sort(key=lambda i: i[1])
time = 0
for a, b in ab_list:
    time += a
    if time > b:
        print('No')
        sys.exit()
print('Yes')


Measured memory_bytes: 53600
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(){
    int n; cin>>n;
    bool a=false;
    for(int i=1;i<=9;i++){
        if(n%i==0 && n/i<=9) a=true;
    }
    if(a) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define Int long long




int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    Int n;
    cin>>n;
    Int cv=0;
    for(Int i = 1;i<=n;i++)
    {
        cv+=(i)*(n-i+1);
    }
    for(Int i = 1;i<n;i++)
    {
        Int x,y;
        cin>>x>>y;
        cv-=(min(x,y)*(n-max(x,y)+1));
    }
    cout<<cv<<endl;;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;
#define MAX_N 100000

ll dp[MAX_N + 1];

int main(){
	int n;
	cin >> n;
	int h[n];
	REP(i,n) cin >> h[i];
	REP(i,MAX_N + 1) dp[i] = INF;
	dp[0] = 0;
	for(int i = 1; i < n; i++){
		dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
		if(i != 1) dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
	}
	cout << dp[n - 1] << endl;
}

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(condition) if(condition){cout << "POSSIBLE" << endl;}else{cout << "IMPOSSIBLE" << endl;}
#define Possible(condition) if(condition){cout << "Possible" << endl;}else{cout << "Impossible" << endl;}
#define possible(condition) if(condition){cout << "possible" << endl;}else{cout << "impossible" << endl;}
#define Size(n) (n).size()

typedef long long ll;


using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;


long long int n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl=true;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

      
      cin>>x>>y;
      ans=(x+y)/2;
      if((x+y)%2!=0)ans++;
      Cout(ans);
     

       
return 0;
}


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

int main(){
  int x = 0;
  int m = 0;
  int n;
  string s;
   cin >> n >> s;

   for(int i=0;i<n;i++){
      if(s[i] == 'I'){
        x += 1;
      }else if(s[i] == 'D'){
        x -= 1;
      }
      if(x > m){
        m = x;
      }
   }
   cout << m << endl;
}

Measured memory_bytes: 256
A,B,C,X,Y=map(int,input().split())
ABset = 2*C
gokei = A*X+B*Y
for i in range(0,max(X+1,Y+1)):
    ABdai = i*ABset
    Adai = A*(X-i)
    if X<i:
        Adai = 0
    Bdai = B*(Y-i)
    if Y<i:
        Bdai = 0
    gokei = min(gokei,ABdai+Adai+Bdai)
print(gokei)

Measured memory_bytes: 65368
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
Scanner sc=new Scanner(System.in);
double r;
r=sc.nextDouble();
double f,n;
f=Math.PI*r*r;
n=Math.PI*2*r;
System.out.format("%.6f",f);
System.out.print(" ");
System.out.format("%.6f", n);
sc.close();
}
}


Measured memory_bytes: 28240
#include <iostream>
using namespace std;
typedef long long ll;

ll power(ll x, ll n){
    ll res = 1;
    for(int i = 0; i < n; i++) res *= x;
    return res;
}

int main()
{
    ll n, a;
    cin >> n >> a;
    if(n == 1){
        cout << 1 << endl;
        return 0;
    }
    ll ans = n;
    for(ll b = 2; b < 60; b++){
        ll i;
        for(i = 1; i < 1000002; i++){
            if(power(i, b) >= n){
                i--;
                break;
            }
        }
        ll s = i * b + a * (b - 1);
        ll d = power(i, b);
        while(d < n){
            d = d / i * (i + 1);
            s++;
        }
        ans = min(ans, s);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3616
n = int(input())
A = []
B = []
for i in range(n):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
cnt = 0
for i in range(n-1, -1, -1):
    t = (A[i]+cnt) % B[i]
    if t!=0:
        cnt += (B[i]-t)

print(cnt)

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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int mod = 1e9+7;
const int maxn = 2e3+3;
int dp[maxn][maxn];
int n,m; VI S,T;

int dfs(const int i, const int j)
{
    if (i == n || j == m)
        return 0;
    int& ans = dp[i][j];
    if (-1 == ans) {
        ans = 0;
        if (S[i] == T[j]) {
            ans += dfs(i+1,j+1);
            ans += 1;
            ans %= mod;
        }
        ans += dfs(i+1,j);
        ans %= mod;
        ans += dfs(i,j+1);
        ans %= mod;
        ans -= dfs(i+1,j+1);
        ans %= mod;
    }
    return ans;
}

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    while (cin >> n >> m) {
        memset(dp,-1,sizeof(dp));
        S = VI(n); T = VI(m);
        FOR(i,0,n)
            cin >> S[i];
        FOR(i,0,m)
            cin >> T[i];
        int ans= dfs(0,0) + 1;
        ans += mod;
        ans %= mod;
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 16384
#include<iostream> 
#include<math.h>
using namespace std;
 int main()
 {
     long long int N,K,X=0;
     int i;
     cin>>N;
     for(i=1;i<=N;i++)
     {
         cin>>K;
         X ^= K;
     }
     if(X==0)
      cout<<"Yes";
      else
      cout<<"No";
 }


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

using namespace std;

int main() {
    int dishes[5];
    for (int i = 0; i < 5; i++)
    {
        cin >> dishes[i];
    }

    int wasted[5];
    for (int i = 0; i < 5; i++)
    {
        if (dishes[i] % 10 == 0)
        {
            wasted[i] = 0;
        } else {
            wasted[i] = 10 - (dishes[i] % 10);
        }
    }

    sort(wasted, wasted + 5);

    int ans = 0;
    for (int i = 0; i < 4; i++)
    {
        ans += dishes[i] + wasted[i];
    }

    ans += dishes[4];
    cout << ans;
}


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

int main() {
  int n; cin >> n;
  int a[n], b[n], c[n-1];
  for(int i = 0; i < n; i++) cin >> a[i];
  for(int i = 0; i < n; i++) cin >> b[i];
  for(int i = 0; i < n-1; i++) cin >> c[i];
  int total = 0;
  int buf = 0;
  for(int i = 0; i < n;i++){
    total += b[a[i]-1];
    if(a[i]-1 > 0){
      if(a[i-1]+1 == a[i]){
        total += c[a[i-1]-1];
      }
    }
  }
  cout << total << endl;
}


Measured memory_bytes: 3628
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var x = cin.nextInt();
            var y = cin.nextInt();

            var a = new int[] { 1, 3, 5, 7, 8, 10, 12 };
            var b = new int[] { 4, 6, 9, 11 };
            var c = new int[] { 2 };
            var ans = (a.Contains(x) && a.Contains(y)) || (b.Contains(x) && b.Contains(y)) || (c.Contains(x) && c.Contains(y));

            Console.WriteLine(ans?"Yes":"No");
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


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

const int MAXN=1e5+10;
int a[MAXN];

int main(void){
    int n;
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    int ans=0, i=0;
    while(i<n){
        int k=i;
        while(i<n-1&&a[i+1]>=a[i]){
            i++;
        }
        while(k<n-1&&a[k+1]<=a[k]){
            k++;
        }
        i=max(k, i);
        ans++;
        i++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 768
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

N = I()
A = LI()
A.sort()


def f(n):
    a = sum(A[i] for i in range(n+1))
    for i in range(n+1,N):
        if a*2 >= A[i]:
            a += A[i]
        else:
            return False
    return True


left = -1  # ng
right = N-1  # ok
while left + 1 < right:
    mid = (left + right)//2
    if f(mid):
        right = mid
    else:
        left = mid
print(N-right)


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

int main() {
  int n;
  cin >> n;
  
  vector<int> p(n + 1);
  for (int i = 0; i < n; i++) {
    cin >> p.at(i) >> p.at(i + 1);
  }
  
  vector<vector<int> > m(n + 1, vector<int> (n + 1));
  
  for (int i = 1; i <= n; i++) {
    m[i][i] = 0;
  }
  
  for (int l = 2; l <= n; l++) {
    for (int i = 1; i <= n - l + 1; i++) {
      int j = i + l -1;
      m[i][j] = (1 << 21);
      for(int k = i; k <= j - 1; k++) {
        m[i][j] = min (m[i][j], m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j]);
      }
    }
  }                   
  cout << m[1][n] << endl;
}


Measured memory_bytes: 3160
#include<cstdio>
#include<iostream>

using namespace std;
int main(void) {

	int a, b;
	char c;

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

		
		if (c == '?')
			break;
		else if(c == '+')
		{
			printf("%d\n", a+b);
		}
		else if (c == '-')
		{
			printf("%d\n", a - b);
		}
		else if (c == '/')
		{
			printf("%d\n", a / b);
		}
		else if (c == '*')
		{
			printf("%d\n", a * b);
		}

	}

	return 0;
}


Measured memory_bytes: 3224
(D,),C,*I=[[*map(int,t.split())]for t in open(0)]
s=sum(C)
for d,q in I[731:]:
 I[d+D-1][0]=q;i,R,P,*L=[0]*29
 while i-D:t=I[i+D][0]-1;P+=s+(~i+L[t])*C[t];R+=I[i][t]-P;i+=1;L[t]=i
 print(R)

Measured memory_bytes: 89312
from collections import defaultdict, deque, Counter
import sys
import heapq
import math

# input = sys.stdin.readline

sys.setrecursionlimit(1000000000)

MIN = -10 ** 9
MOD = 10 ** 9 + 7


def main():
    N = int(input())
    d = [int(a) for a in input().split()]
    # H = [int(a) for a in input().split()]
    # xy = [
    #     [int(a) for a in input().split()]
    #     for _ in range(N)
    # ]
    s = 0
    for i in range(len(d)):
        for j in range(i + 1, len(d)):
            s += d[i] * d[j]
    print(s)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
s = raw_input()
N = len(s)
s = '0' + s
dp = [0] * (1+N)
# dp[0] = 1
for i in xrange(1, N+1):
    if s[i] == s[i-1]:  dp[i] = dp[i-3]+2 if i >= 3 else 1
    else:   dp[i] = dp[i-1] + 1
print(dp[N])

Measured memory_bytes: 9148