akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;

int n;
int m;
int dp[2][10000000];
int maxx;
int deg[600];
char x[600][600];
char* c;
char* c1;
char* c2;

char result[600];
int ind,i,tot,j,counter;

void xorer(){
	c1 = result;
	c2 = x[ind];
	while(*c1!='\0'){
		if(*c1==*c2) *c1 = '0';
		else *c1 = '1';
		c1++;
		c2++;
	}
}
int main(){
	while(1){
		scanf("%d%d",&n,&m);
		if(n==0 && m==0) break;
		
		maxx = 0;
		char allzero[600];
		for(i=0;i<m;i++) allzero[i] = '0';
		allzero[i] = '\0';
		
		for(i=0;i<n;i++){
			scanf("%s",&x[i]);
			c = &x[i][0];
			deg[i] = 0;
			while(*c!='\0'){
				deg[i]*=2;
				deg[i]+=(*c)-'0';
				c++;
			}
		//	printf("deg[%d] = %d\n",i,deg[i]);
		}
		if(n<=20){
			tot = pow(2,n);
			for(i=0;i<tot;i++){
				j = i;
				ind = n-1;
				counter = 0;
				strcpy(result,allzero); ///////////////////////
				while(ind>=0){
					if(j%2==1){
						//result = xorer(result,x[ind]);
						xorer();
						counter++;
					}
					j/=2;
					ind--;
				}
				if(strcmp(allzero,result)==0){
					if(maxx<counter) maxx = counter;
				}
			}
		}
		else{
			tot = pow(2,m);
			for(i=0;i<tot;i++) dp[1][i] = 0;
			dp[1][0] = 1;
			
			for(i=0;i<n;i++){
				ind = i%2;
				tot = pow(2,m);
				for(j=0;j<tot;j++){
					dp[ind][j] = dp[!ind][j];
				}
				for(j=0;j<tot;j++){
					if(dp[!ind][j]>0 && dp[ind][j^deg[i]]<dp[!ind][j]+1){
						dp[ind][j^deg[i]] = dp[!ind][j]+1;
					}
				}
			}
			
			maxx = dp[(n-1)%2][0]-1;
		}
		printf("%d\n",maxx);
	}	
	return 0;
}


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

 bool is_prime(int x){
 if(x<=1) return false;
 for(int i=2;i*i<=x;i++)
 if(x%i==0) return false;
 return true;
 }

signed main(){
 int x;
 cin>>x;

 int p=x;
 while(!is_prime(p)) p++;

 cout<<p<<endl;
 return 0;
 }


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



int main(){

    int A, B;
    cin >> A >> B;
    double add, sub, mul;
    add = A + B;
    sub = A - B;
    mul = A * B;
    if(add > sub){
        if(add > mul)cout << add;
        else cout << mul;
    }else if(sub > mul)cout << sub;
    else cout << mul;

    return 0;
}

//g++ ファイル名 --input-charset=utf-8 --exec-charset=cp932
//日本語出力するときのやつ

Measured memory_bytes: 256
// problem: "https://atcoder.jp/contests/abc150/tasks/abc150_a"

#include<bits/stdc++.h>

using namespace std;

int main()
{
    int k,x;
    cin>>k>>x;

    if(k*500 >= x)
        cout<<"Yes";

    else
        cout<<"No";

    return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

int main(){
    int N,X;
    cin>>N>>X;
    if(X<=500*N) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>

template <class T>
T abs(T a) { return (a < 0 ? -a : a); }

template <class T>
void add(std::vector<T>& v, T a, T w) {
    for (T x = a; x <= v.size(); x += x & -x) v[x] += w;
}

template <class T>
T get(std::vector<T>& v, T a) {
    T ret = 0;
    for (T x = a; x > 0; x -= x & -x) ret += v[x];
    return ret;
}

int main() {
    long long n, l = 0, r = 1;
    std::cin >> n;
    std::vector<long long> a(n), s(n + 1);
    for (auto i = 0ll; i < n; i++) {
        std::cin >> a[i];
        r = std::max(r, a[i]);
    }
    r++;

    while (r - l > 1) {
        auto mid = (l + r) / 2;
        for (auto i = 0ll; i < n; i++) {
            //v[i] = (v[i] >= mid ? 1 : -1);
            s[i + 1] = s[i] + (a[i] >= mid ? 1 : -1);
        }
        auto ret = 0ll;
        std::vector<long long> bit(2 * n + 1);
        for (auto it = s.begin(); it != s.end(); it++) {
            ret += get(bit, *it + n);
            add(bit, *it + n, 1ll);
        }
        if (ret >= n * (n + 1) / 2 / 2) l = mid;
        else r = mid;
    }

    std::cout << l << std::endl;
    
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
#define x first
#define y second

#ifdef LOCAL
#include "/Users/swad/Desktop/CP/debug.h"
#endif

const int N = int(2e5) + 10;

template <typename T>
class LazyST {
private:
	int n;
	vector<T> a;
	vector<T> st, lz;
	T lz_default;
	T (*st_merge)(T, T);
	T (*lz_merge)(T, T);

	void build(int stI, int L, int R) {
		if (L == R) {
			st[stI] = a[L - 1];
			return;
		}

		int mid = (L + R) >> 1;
		build(stI << 1, L, mid);
		build(stI << 1 | 1, mid + 1, R);

		st[stI] = st_merge(st[stI << 1], st[stI << 1 | 1]);
	}

	void update(int stI, int L, int R, int l, int r, T val) {
		if (l <= L && R <= r) lz[stI] = lz_merge(lz[stI], val);
		else {
			int mid = (L + R) >> 1;
			if (l <= mid) update(stI << 1, L, mid, l, min(r, mid), val);
			if (mid + 1 <= r) update(stI << 1 | 1, mid + 1, R, max(l, mid + 1), r, val);
		}


		if (L == R) st[stI] = lz_merge(a[L - 1], lz[stI]);
		else st[stI] = lz_merge(st_merge(st[stI << 1], st[stI << 1 | 1]), lz[stI]);
	}

	T query(int stI, int L, int R, int l, int r) {
		if (l <= L && R <= r) return st[stI];

		int mid = (L + R) >> 1;
		if (r <= mid) return lz_merge(query(stI << 1, L, mid, l, r), lz[stI]);
		else if (mid + 1 <= l) return lz_merge(query(stI << 1 | 1, mid + 1, R, l, r), lz[stI]);
		else return st_merge(
				lz_merge(query(stI << 1, L, mid, l, mid), lz[stI]),
				lz_merge(query(stI << 1 | 1, mid + 1, R, mid + 1, r), lz[stI])
			);
	}

public:
	LazyST(vector<T> a, T (*st_merge)(T, T), T (*lz_merge)(T, T), T lz_default, bool build_init) {
		n = a.size();
		this->a = a;
		st.resize(4 * n + 1);
		lz.resize(4 * n + 1, lz_default);
		this->lz_default = lz_default;
		this->st_merge = st_merge;
		this->lz_merge = lz_merge;
		if (build_init) build(1, 1, n);
	}
	T query(int l, int r) { // range [l, r], 1-based index
		return query(1, 1, n, l, r);
	}
	void update(int l, int r, T val) { // range [l, r], 1-based index
		update(1, 1, n, l, r, val);
	}
};

int n, m;
vector<pii> ranges_at[N];

int main() {
	#ifdef LOCAL
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
	#endif

	scanf("%d %d", &n, &m);

	for (int i = 1; i <= m; i++) {
		int l, r, val;
		scanf("%d %d %d", &l, &r, &val);
		ranges_at[l].push_back({r, val});
	}

	vector<ll> dps(n + 1, 0);
	LazyST<ll> lzst = LazyST<ll>(
			dps,
			[](ll i, ll j) {return max(i, j);},
			[](ll i, ll j) {return i + j;},
			0,
			false
		);

	for (int l = n; l >= 1; l--) {
		for (pii p : ranges_at[l]) lzst.update(l + 1, p.x + 1, p.y);
		lzst.update(l, l, max(0LL, lzst.query(l + 1, n + 1)));
	}

	printf("%lld\n", lzst.query(1, 1));

	return 0;
}

Measured memory_bytes: 28416
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<deque>
using namespace std;

int main() {
    string s; cin >> s;
    deque<char> q;
    for (int i = 0; i < s.size(); i++) q.push_back(s[i]); 

    int ans = 0;
    while (q.size() > 1) {
        if (q.front() != q.back()) ans++;
        q.pop_front();
        q.pop_back();
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
  int N;
  int mod = 1000000007;
  cin >> N;
  vector<int> A(N);
  long long sum =0;
  
  for(int i=0; i<N; i++){
    cin >>A[i];
    sum += A[i];
    sum %= mod;
  }
  
  long ans = 0;
  
  for(int i=0; i < N; i++){
    sum -= A[i];
    if(sum < 0){
      sum+=mod;
    }
    ans += A[i] * sum;
    ans %= mod;
  }
  
  cout << ans;
  return 0;
	
}
  

Measured memory_bytes: 4056
#include <iostream>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
int main(){
  int ans[1000000]={},sum[1000]={0};
  rep(i,1,1000){
    sum[i] = sum[i-1]+i;
  }
  rep(i,0,999){
    rep(j,i+2,1001){
      ans[ sum[j]-sum[i] ]++;
    }
  }
  int n;
  while(cin >> n){
    if(n==0)break;
    cout << ans[n] << endl;
  }
}

Measured memory_bytes: 7020
import Data.Ord
import Data.List
import Data.Maybe

main :: IO ()
main = interact $ unlines . map (show' . uncurry allr) . read' . lines
 where
  read' ("0 0":_) = []
  read' (_:r:xs) = (l,qs) : read' xs''
   where
    (l',(q:xs')) = splitAt (read r) xs
    (qs',xs'') = splitAt (read q) xs'
    l = map ((\[t,n,m,_] -> R (read t) (read n) (read m)) . words) l'
    qs = map ((\[ts,te,mq] -> Q (P (read ts) (read te)) (read mq)) . words) qs'
  show' = init . unlines . map show

data Record = R {t::Time, n::Pid, m::Uid} deriving (Eq, Ord)
data Question = Q {pq::Period, mq::Uid} deriving (Eq, Ord)
data Period = P {ts::Time, te::Time} deriving (Eq, Ord)

unionp :: Period -> Period -> Maybe Period
unionp p1 p2
 | te p1 < ts p2 = Nothing
 | te p2 < ts p1 = Nothing
 | ts p1 >= ts p2 && te p1 <= te p2 = Just p2
 | ts p1 <= ts p2 && te p1 >= te p2 = Just p1
 | ts p1 <= ts p2 && te p1 >= ts p2 = Just (P (ts p1) (te p2))
 | ts p2 <= ts p1 && te p2 >= ts p1 = Just (P (ts p2) (te p1))

intersectp :: Period -> Period -> Maybe Period
intersectp p1 p2
 | te p1 < ts p2 = Nothing
 | te p2 < ts p1 = Nothing
 | ts p1 >= ts p2 && te p1 <= te p2 = Just p1
 | ts p1 <= ts p2 && te p1 >= te p2 = Just p2
 | ts p1 <= ts p2 && te p1 >= ts p2 = Just (P (ts p2) (te p1))
 | ts p2 <= ts p1 && te p2 >= ts p1 = Just (P (ts p1) (te p2))

time :: Period -> Time
time p = (te p) - (ts p)

type Log = [Record]
type Time = Int
type Pid = Int
type Uid = Int

allr :: Log -> [Question] -> [Time]
allr l = map (analyze l)

analyze :: Log -> Question -> Time
analyze l q = count (period (query (mq q) l)) (pq q)

count :: [Period] -> Period -> Time
count ps p = sum $ map (maybe 0 time . intersectp p) (groupUnion (sort ps))

groupUnion :: [Period] -> [Period]
groupUnion [] = []
groupUnion [p] = [p]
groupUnion (p1:p2:ps)
 | unionp p1 p2 /= Nothing = groupUnion (fromJust (unionp p1 p2) : ps)
 | otherwise = p1 : groupUnion (p2:ps)

period :: Log -> [Period]
period = map (\[x,y] -> P x y) . groupAt 2 . map t . sortBy (comparing n)

query :: Uid -> Log -> Log
query x = filter ((==x) . m)

groupAt :: Int -> [a] -> [[a]]
groupAt n xs
 | null xs = []
 | otherwise = take n xs : groupAt n (drop n xs)

Measured memory_bytes: 5552
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <utility>
#include <tuple>
#include <map>
#include <ctime>
#include <cstdlib>
#include <random>
using namespace std;

#define int long long

int x;

signed main(){
	cin >> x;
	cout << (x/500)*1000 + ((x%500)/5)*5 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T> 
void print(vector<T> &x) {
    int n = x.size();
    REP(i,n) {
        if (i != n-1) cout << x[i] << " ";
        else cout << x[i] << endl;
    }
}

int main(int argc, char const *argv[]) {
    int n; cin >> n;
    vector<int> w(n);
    REP(i,n) cin >> w[i];
    vector<int> s(n+1);
    REP(i,n) {
        s[i+1] = s[i]+w[i];
    }
    int m = INF;
    for (int i = 1; i <= n; ++i) {
        int tmp = abs((s[i]-s[0])-(s[n]-s[i]));
        m = min(m,tmp);
    }
    cout << m << endl;
    return 0;
}

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

using ll = long long;

#define INF (1LL << 31 - 1)
#define MOD int(1e9+7)
#define repi(i,j,n) for(int i = (j); i < (n); ++i)
#define rep(i,n) repi(i,0,n)
#define fi first
#define se second

inline void init() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

ll x, ans;

int main() {
  init();
  cin >> x;

  ans = x / 11 * 2;
  if (x % 11 != 0) ans += ((x % 11 <= 6) ? 1 : 2);

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


Measured memory_bytes: 256
#include <iostream>
using namespace std;
inline int search(int a[], int  n, int key) {
	int i = 0;
	a[n] = key;
	while (a[i] != key) i++;
	return i != n;
}
int main() {
	const int num = 10001;
	int n, ar[num], q, key, sum = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> ar[i];
	}
	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> key;
		if (search(ar, n, key)) sum++;
	}
	cout << sum << endl;
}

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

int main()
{
    int N;
    string S;
    while ( cin >> N, N > 0 ) {
        cin >> S;
        int cnt[15] = {};
        int field = 0;
        for ( int t = 0; t < 100; t++ ) {
            switch ( S[t] ) {
            case 'M' :
                cnt[t % N]++;
                break;
            case 'S' :
                field += cnt[t % N] + 1;
                cnt[t % N] = 0;
                break;
            case 'L' :
                cnt[t % N] += field + 1;
                field = 0;
                break;
            }
        }
        sort(cnt, cnt + N);
        for ( int i = 0; i < N; i++ ) {
            cout << cnt[i] << " ";
        }
        cout << field << endl;
    }
}



Measured memory_bytes: 3152
#include<stdio.h>
#include<string.h>
int main()
{
	char a[10000];
	int n,i,p=0;
	scanf("%s",a);
	n=strlen(a);
	for(i=0;i<n;i++)
	{
		if(i&1&&a[i]=='R')
		p=1;
		if(i%2==0&&a[i]=='L')
		p=1;
	}
	if(p)
	printf("No\n");
	else
	printf("Yes\n");
}

Measured memory_bytes: 128
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};
const int N=100005,M=1000005,mod=1000000007;
const long long llinf=9223372036854775807ll;
int n,k,a[N],dp[N];
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>a[i],dp[i]=inf;
	dp[1]=0;
	for(int i=2;i<=min(k,n);i++)
		for(int j=1;j<i;j++)
			dp[i]=min(dp[i],abs(a[i]-a[j])+dp[j]);
	for(int i=k+1;i<=n;i++)
		for(int j=i-k;j<i;j++)
			dp[i]=min(dp[i],abs(a[i]-a[j])+dp[j]);
	cout<<dp[n];
	return 0;
}

Measured memory_bytes: 1024
n=int(input())

def digitSum(n):
    s = str(n)
    array = list(map(int, list(s)))
    return sum(array)

min=9999999
#b= n-a
for a in range(1,n):
    b=n-a
    sum_a=digitSum(a)
    sum_b=digitSum(b)
    sum_ab=int(sum_a)+int(sum_b)
   
    if sum_ab < min:
        min=sum_ab

print(min)



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

class Cube{
  public:
  int f[6];
  Cube(){}
  void roll_z(){roll(1,2,4,3);}
  void roll_y(){roll(0,2,5,3);}
  void roll_x(){roll(0,1,5,4);}
  void roll(int i,int j,int k,int l){
      int t=f[i];f[i]=f[j];f[j]=f[k];f[k]=f[l];f[l]=t;
  }
};

bool eq(Cube c1,Cube c2){
    for(int i=0;i<6;i++){
        if(c1.f[i]!=c2.f[i])return false;
    }
    return true;
}

bool equal(Cube c1,Cube c2){
    for(int i=0;i<6;i++){
        for(int j=0;j<4;j++){
            if(eq(c1,c2))return true;
            c1.roll_z();
        }
        if(i%2==0)c1.roll_y();
        else c1.roll_x();
    }
    return false;
}

int main(){
    Cube c1,c2;
    for(int i=0;i<6;i++)cin>>c1.f[i];
    for(int i=0;i<6;i++)cin>>c2.f[i];
    if(equal(c1,c2))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    
    
    return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

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, m;
    cin >> n >> m;
    vector<int> s(m);
    vector<char> c(m);
    for(int i = 0; i < m; i++){
        cin >> s[i] >> c[i];
    }
    int ans = -1;
    for(int i = 0; i < 1000; i++){
        string i_s = to_string(i);
        if(i_s.size() != n) continue;

        bool flg = true;
        for(int j = 0; j < m; j++){
            if(i_s[s[j]-1] == c[j]) continue;
            else flg = false;
        }

        if(flg == false) continue;
        ans = i;
        break; 
    }
    cout << ans << endl;
}


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

int main() {
  int N;
  cin>>N;
  if(N>30){
    cout<<"Yes"<<endl;
  }
  else{
    for(int i=0;i<=N/7;i++){
      if((N-7*i)%4==0){
        cout<<"Yes"<<endl;
        break;
      }
      else if(i==N/7){
        cout<<"No"<<endl;
      }
    }
  }
}

Measured memory_bytes: 3556
import java.io.*;
public class Main{
    public static void main(String[] args) throws IOException{
        Reader r = new Reader();        
        String S1 = r.s();
        String T = r.s();
        int l1 = S1.length();
        int l2 = T.length();
        String ans = "UNRESTORABLE";
        loop: for(int i = l1-l2; i >= 0; i--){
            for(int j = 0; j < l2; j++){
                if(T.charAt(j) != S1.charAt(i+j) && S1.charAt(i+j) != '?'){
                    continue loop;
                }                
            }
            char[] temp = S1.toCharArray();
            for(int j = 0; j < l2; j++){
                temp[i+j] = T.charAt(j); 
            }
            ans = new String(temp).replace("?", "a");
            break;
        }
        println(ans);
    }
    static void print(Object o){
        System.out.print(o.toString());
    }
    static void println(Object o){
        System.out.println(o.toString());
    }
    static int Int(String s){
        return Integer.parseInt(s);
    }
    static long Long(String s){
        return Long.parseLong(s);
    }
    static class Reader extends BufferedReader{
        Reader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Int(ss[j]);
            return ii;
        }
        long l() throws IOException{
            return Long(s());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long(ss[j]);            
            return ll;
        }
    }
}

Measured memory_bytes: 23124
#include <iostream>
#include <cmath>
using namespace std;
bool isPrime(int a)
{
    if(a==2)
        return true;
    for(int i =2;i<=sqrt(double(a))+1;i++)
    {
        if(a%i==0)
            return false;
    }
    return true;
}
int main()
{
    int n,m,cnt=0;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>m;
        if(isPrime(m))
            cnt++;
    }
    cout<<cnt<<endl;;
    return 0;
}

Measured memory_bytes: 3080
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
int main() {
  int h, a;
  cin >> h >> a;
  cout << (h + a - 1) / a << endl;
  return 0;
}

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

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  int sum = a + b + c, x;
  x = max({a, b, c});
  sum -= x;
  cout << x * 10 + sum << endl;
  return 0;
}

Measured memory_bytes: 3624
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		int h,w;
		Scanner scan = new Scanner(System.in);
		while(true){
			h=scan.nextInt();
			w=scan.nextInt();
			if(h==0&&w==0)
				break;
			for(int i = 1; i <= h; i++){
				for(int j = 1; j <= w; j++){
					if(i==1||i==h||j==1||j==w)
						System.out.print("#");
					else
						System.out.print(".");
				}
				System.out.println();
			}
			System.out.println();
		}		
	}
}


Measured memory_bytes: 32228
from functools import lru_cache

mod = 10 ** 9 + 7

@lru_cache(maxsize=None)
def f(n):
    if n <= 1:
        return n + 1
    return (f(n // 2) + f((n - 1) // 2) + f((n - 2) // 2)) % mod

N = int(input())
print(f(N))

Measured memory_bytes: 3700
#include<stdio.h>

int main(void){
	int W=0;
	int H=0;
	int x=0;
	int y=0;
	int r=0;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	
	
	if((x-r)<0){
		printf("No\n");
	}else if((x+r)>W){
		printf("No\n");
	}else if((y-r)<0){
		printf("No\n");
	}else if((y+r)>H){
		printf("No\n");
	}else{
		printf("Yes\n");
	}
	
	
return 0;
}




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

int main(){
  int N, K, R, S, P; cin >> N >> K >> R >> S >> P;
  string T; cin >> T;
  int ans=0;
  for(int i=0;i<K;i++){
    if(T[i]=='s'){
      ans+=R;
    }
    if(T[i]=='p'){
      ans+=S;
    }
    if(T[i]=='r'){
      ans+=P;
    }
  }
  for(int i=K;i<N;i++){
    if(T[i]==T[i-K]){
      T[i]='j';
    }
    else {
      if(T[i]=='s'){
        ans+=R;
      }
      if(T[i]=='p'){
        ans+=S;
      }
      if(T[i]=='r'){
        ans+=P;
      }
    }
  }
  cout << ans << endl;
}
      

    

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int b,c,e;
int main() {
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int t;
    cin>>t;
    while(t--){
        cin>>b>>c>>e;
        auto p1=a.begin()+c;
        auto p2=a.begin()+e;
        if(b==0){
            cout<< *min_element(p1,p2)<<endl;
        }
        else{
            cout<< *max_element(p1,p2)<<endl;
        }
    }
}



Measured memory_bytes: 3104
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>

using namespace std;

int main(int argc, char const *argv[]){
    long long s;
    long long x1,y1,x2,y2;
    long long t;
    long long INF=1;
    
    for(int i=0;i<9;i++){
        INF*=10;
    }
    cin >> s;
    for(long long i=0;i<=INF;i++){
        if((i*i)>(s-1)){
            x1 = i;
            break;
        }
    }
    y2 = x1;
    y1 = 1;
    x2 = x1*y2-s;

    if(x2>INF){
        t = (long long)(sqrt(x1*y2-s));
        for(long long i=t;i>0;i--){
            if((x1*y2-s)%i==0){
                y1 = i;
                x2 = (x1*y2-s)/i;
                break;
            }
        }
    }

    if(x2>INF){
        y2 = x1-1;
        t = (long long)(sqrt(x1*y2-s));
        for(long long i=t;i>0;i--){
            if((x1*y2-s)%i==0){
                y1 = i;
                x2 = (x1*y2-s)/i;
                break;
            }
        }
    }
    cout << "0 0 " << x1 <<  " " << y1  << " " << x2 <<  " " << y2 <<endl;
    return 0;
}

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

int main()
{
		int n[10000], x[10000], i, m, a, b, c;
		while (1) {
				cin >> n[m] >> x[m];
				if (n[m]==0 && x[m]==0) break;
				m++;
		}
		int ans[m];
		for (i=0; i<m; i++) ans[i]=0;

		for (i=0; i<m; i++) {
				for (c=n[i]; c>0; c--) {
						for (b=c-1; b>0; b--) {
								for (a=b-1; a>0; a--) {
										//cout << a << " + " << b << " + " << c << " = " << a+b+c << "\n";
										if (a+b+c==x[i]) ans[i]++;
								}
						}
				}
		}

		for (i=0; i<m; i++) cout << ans[i] << "\n";
}

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

int main() {
	
	int n;
	cin >> n;
	map<int, int> occ;
	for (int i=0; i<n; i++) {
		int x;
		cin >> x;
		occ[x]++;
	}
	int ans = 0;
	for (map<int, int>::iterator x = occ.begin(); x != occ.end(); x++) {
		if (x->second >= x->first) {
			ans += (x->second - x->first);
		}
		else {
			ans += (x->second);
		}
	}
	cout << ans << endl;
	
	
}


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

using namespace std;

typedef long long ll;

int main(){
	int N;
	cin >> N;
	string s;
	cin >> s;

	std::vector<int> S(N+1);
	for (int i = 0; i < N; i++){
		S[i] = s[i]-'0';
	}

	int count =0;

	for (int a = 0; a <= 9; a++){
		for (int b = 0; b <= 9; b++){
			for (int c = 0; c <= 9; c++){
				int i,j,k;
				i = 0;
				//cout << a << b << c << endl;
				while(S[i] != a){
					if(i >= N)break;
					i++;
					//cout << "i"<< i << endl;
				}
				j = i+1;
				while(S[j] != b){
					if(j >= N)break;
					j++;
					//cout << "j" << j << endl;
				}
				k = j+1;
				while(S[k] != c){
					if(k >= N)break;
					k++;
					//cout << "k" << k << endl;
				}
				if(k < N){
					count++;
					//cout << a << b << c <<endl;
				}
			}
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
public static void main(String[] args) throws IOException {

BufferedReader br =new BufferedReader (new InputStreamReader (System.in));

String x = br.readLine( );
String y = br.readLine( );
String z = br.readLine( );
 
int a = Integer.parseInt(x);
int b = Integer.parseInt(y);
int c = Integer.parseInt(z);

System. out. println((a+b)*c/2);
}}


Measured memory_bytes: 20948
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()

def F(x):
    return (len(str(x)) % 2) == 1
answer = 0
for i in range(1, N+1):
    if F(i):
        answer += 1

print(answer)


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

#define lli long long int 
vector<vector<lli > >dp(101,vector<lli >(100001,-1));
lli back(vector<pair<lli ,lli > > &v,lli  w,lli  i,lli  val){
	if(w<0)return INT_MIN;
	if(w==0)return 0;
	if(i==v.size())return 0;
	if(dp[i][w]!=-1)return dp[i][w];
	lli  consider=0,notconsider=0;
	consider = v[i].second + back(v,w-v[i].first,i+1,val+v[i].second);
	notconsider = back(v,w,i+1,val);
	dp[i][w]= max(consider,notconsider);
	
	return dp[i][w];
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    lli  n,w;
    cin>>n>>w;
    vector<pair<lli ,lli > > v(n);
    for(lli i=0;i<n;i++){
    	cin>> v[i].first >> v[i].second;	
	}
	lli ans = back(v,w,0,0);
	cout<<ans;
	return 0;	
	
}

Measured memory_bytes: 83024
import java.util.Scanner;

/**
 * @author author
 *
 */
public class Main {


  /**
   * @param args
   */
  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int n = Integer.parseInt(sc.next());
    int[] h = new int[n];
    for (int i = 0; i < n; i++) {
      h[i] = Integer.parseInt(sc.next());
    }

    int returnMax = 0;
    int count = 0;
    for (int i = 0; i < n - 1; i++) {
      int leftPoint = i;
      count = 0;
      for (int j = i + 1; j < n; j++) {
        if (h[leftPoint] >= h[j]) {
          leftPoint = j;
          count++;
          if (returnMax < count) {
            returnMax = count;
            if (returnMax >= (n - i)) {
              break;
            }
          }
        } else {
          break;
        }
      }
      if (returnMax >= (n - i)) {
        break;
      }
    }
    System.out.println(returnMax);
  }
}

Measured memory_bytes: 48668
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int X;
	vector<int> dp;
	
	cin>>X;
	
	dp.resize(X+1 + 200);
	
	dp[0] = 1;
	
	for(int i = 0; i <= 5; i++){
		for(int j = 0; j <= X; j++){
			if(dp[j]) dp[j + 100 + i] = 1;
		}
	}
	
	cout<<dp[X]<<endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define int long long
#define N 100005
using namespace std;
int t[N],n,m;
int a[N],top,b[N];
int bi(int x)
{
	int l=1,r=top;
	while(l<=r)
	{
		int mid=(l+r)>>1;
		if(b[mid]>x)r=mid-1;
		else l=mid+1;
	}
	return r;
}
signed main()
{
	scanf("%lld%lld",&n,&m);
	b[++top]=n;
	for(int i=1;i<=m;i++)
	{
		int tmp;scanf("%lld",&tmp);
		while(top&&tmp<=b[top])top--;
		b[++top]=tmp;
	}
	t[top]=1;
	for(int i=top;i>=1;i--)
	{
		int k=b[i];
		if(i!=1)
		{
			t[i-1]+=b[i]/b[i-1]*t[i];
			k=b[i]%b[i-1];
		}
		while(k>b[1])
		{
			int p=bi(k);
			t[p]+=k/b[p]*t[i];
			k%=b[p];
		}
		a[1]+=t[i];a[k+1]-=t[i];
	}
	int now=0;
	for(int i=1;i<=n;i++)
	{
		now+=a[i];
		printf("%lld\n",now);
	}
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

struct coord { ll x; ll y; };
vector<ll> f, l;

int lis() {
  l[0] = f[0];
  ll len = 1;
  repr(i,1,f.size()) {
    if (l[len-1]<f[i]) { l[len]=f[i]; len++; }
    else {
      ll pos = lower_bound(l.begin(), l.begin()+len, f[i]) - l.begin();
      l[pos] = f[i];
    }
    // debug(l.begin(), l.end());
  }
  return len;
}

int main() {
  ll x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
  ll N; cin >> N;
  coord pos[N]; rep(i,N) { int X, Y; cin >> X >> Y; pos[i] = {X,Y}; }
  if (x1>x2) { rep(i,N) pos[i].x = (x1+x2)-pos[i].x; swap(x1,x2); }
  if (y1>y2) { rep(i,N) pos[i].y = (y1+y2)-pos[i].y; swap(y1,y2); }
  sort(pos,pos+N,[](const coord &x, const coord &y){return x.x<y.x;});
  rep(i,N) {
    // cout << pos[i].x << ":" << pos[i].y << endl;
    bool okx = x1<=pos[i].x&&pos[i].x<=x2;
    bool oky = y1<=pos[i].y&&pos[i].y<=y2;
    if (okx&&oky) f.push_back(pos[i].y);
  }
  l.resize(f.size());

  double result = ((x2-x1)+(y2-y1))*100;
  if (f.size()) {
    int li = lis();
    if (x2-x1==li-1||y2-y1==li-1) {
      result += 10*M_PI - 20;
      result -= (20 - 5*M_PI) * (li-1);
    }
    else result -= (20-5*M_PI)*li;
  }
  cout << fixed << setprecision(10) << result << endl;
  return 0;
}

Measured memory_bytes: 6768
N,A,B = map(int,input().split())

S = input()

na = 0
nb = 0

for i in S:

    if i == "a" and na+nb < A+B:
        print ("Yes")
        na += 1
    elif i == "b" and na + nb < A+B and nb < B:
        print ("Yes")
        nb += 1
    else:
        print ("No")
        


Measured memory_bytes: 53080
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=vector<pair<int,int>>;

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

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

long long INF = 1LL<<60;
int main( ){
    ll n;
    cin>>n;
    string s;
    cin>>s;
    vll cnt(3,0);
    rep(i,0,s.size()){
        if(s[i]=='R')cnt[0]++;
        else if(s[i]=='G')cnt[1]++;
        else cnt[2]++;
    }
    ll res=cnt[0]*cnt[1]*cnt[2];
    rep(i,0,n){
        rep(j,i+1,n){
            ll k=2*j-i;
            if(k>=n||k<0||k<=j)continue;
            if(s[i]==s[j])continue;
            if(s[j]==s[k])continue;
            if(s[i]==s[k])continue;
            res--;
        }
    }
    cout<<res<<endl;
    return 0;
}




Measured memory_bytes: 3608
#include<stdio.h>

#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head=0, tail=0, n;

void enqueue(P x){
  
  Q[tail] = x;
  if(tail+1 == n) tail = 0;
  else tail++;
}

P dequeue(){
  
  P x;
  x = Q[head] ;
  if(head+1 == n)head = 0;
  else head++;

  return x;
}


int main(){
  int elaps = 0, c=0;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 0; i < n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  
  while(c < n){
    if(Q[head].t <= q){
      elaps = elaps + Q[head].t;
      u = dequeue();
      printf("%s %d\n",u.name,elaps);
      c++;
    }
    else{
      Q[head].t = Q[head].t - q;
      elaps = elaps + q;
      u = dequeue();
      enqueue(u);
    }
  }
  
  return 0;
}



Measured memory_bytes: 6784
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

main() {
    int64_t n;
    cin >> n;

    vector<int64_t> a(n), b(n);
    vector<int64_t> s(n);
    int64_t sb = 0;
    for (auto i : irange(0L, n)) {
        cin >> a[i] >> b[i];
        s[i] = a[i] + b[i];
        sb += b[i];
    }

    sort(s.rbegin(), s.rend());
    int64_t ans = -sb;
    for (int64_t i = 0; i < n; i += 2) {
        ans += s[i];
    }

    cout << ans << endl;
}

Measured memory_bytes: 2560
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include<ext/pb_ds/tag_and_trait.hpp>
// using namespace __gnu_pbds;
// #include<boost/multiprecision/cpp_int.hpp>
// namespace multiprecisioninteger = boost::multiprecision;
// using cint=multiprecisioninteger::cpp_int;
using namespace std;
using ll=long long;
#define double long double
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
// using llset=tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,b,a) for(i=b-1;i>=(ll)a;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define eb emplace_back
#define print(v) cout<<v<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define printYES cout<<"YES"<<endl
#define printNO cout<<"NO"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
// const ll mod=998244353;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas x,ddatas y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

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

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  if(n<r)return 0;
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

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

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

int main(){
  // startupcpp();
  // int codeforces;cin>>codeforces;while(codeforces--){
  ll i,j,N,H,W,ans=0;
  string s;
  cin>>N;
  rep(i,N+1){
    if(i%3&&i%5)ans+=i;
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

typedef long long ll;
int main()
{
	int t=1;
	// cin >> t ;

	while(t--)
	{
		int n;
		cin>>n;

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

		vector<int> ans(n);
		
		ans[n-1]=0;
		ans[n-2]=abs(h[n-1]-h[n-2]);
		
		for(int i=n-3; i>=0; i--)
		{
			ans[i] = min(ans[i+1]+abs(h[i+1]-h[i]), ans[i+2]+abs(h[i+2]-h[i]));
		}		
		cout<<ans[0]<<endl;
	}
	return 0;
}

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

int main() {
	int num,b,a;
	cin >> num;
	b = num / 100;
	a = num % 100;
	if (a > 0 && a < 13) {
		if (b > 0 && b < 13) {
			cout << "AMBIGUOUS";
		}
		else {
			cout << "YYMM";
		}
	}
	else if(b > 0 && b < 13) {
		cout << "MMYY";
	}
	else {
		cout << "NA";
	}

}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    
    while(true){
        string txt;
        cin >> txt;
        if(txt=="-")break;
        
        int m;
        cin >> m;

        for(int i=0;i<m;i++){
            int n;
            cin >>n;
            txt = txt.substr(n) + txt.substr(0,n);
        }
        cout << txt << endl;
    }
    
    
}

Measured memory_bytes: 1216
n, k = map(int, input().split())
a = []

for i in range(k):
    d = int(input())
    ai = list(map(int, input().split()))
    a = a+ai

a = set(a)
ans = 0

for i in range(1, n+1):
    if i not in a:
        ans += 1

print(ans)

Measured memory_bytes: 9188
#include <stdio.h>
int main(void)
{
    int a,b,c,d,n,cnt;
    
    while(scanf("%d",&n)!=EOF)
    {
        cnt=0;
        for(a=0;a<=9;a++)
        {
            for(b=0;b<=9;b++)
            {
                for(c=0;c<=9;c++)
                {
                    for(d=0;d<=9;d++)
                    {
                        if(a+b+c+d==n) cnt++;
                    }
                }
            }
        }
        printf("%d\n",cnt);
    }
    return 0;
}



Measured memory_bytes: 2044
#include <cmath>
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;
#define ll long long
#define it map<par,int>::iterator

int n;
struct par{
	int x,y;par(int xx,int yy):x(xx),y(yy){}
	bool operator <(const par &B)const{return x==B.x?y<B.y:x<B.x;}
};
map<par,int>mp;
ll ans=0;

int main()
{
	cin>>n;
	for(int i=1;i<=n;i++){
		long double x;cin>>x;
		ll y=llround(x*1e9);int c=0,d=0;
		while(y%2==0)y/=2,c++;
		while(y%5==0)y/=5,d++;
		mp[par(c,d)]++;
	}
	for(it i=mp.begin();i!=mp.end();i++){
		for(it j=mp.begin();j!=mp.end();j++){
			if(i->first.x+j->first.x>=18&&i->first.y+j->first.y>=18){
				if(i==j)ans+=1ll*i->second*(i->second-1);
				else ans+=1ll*i->second*j->second;
			}
		}
	}
	cout<<ans/2ll;
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define FOR0(i,n) for(int i=0, _##i=(n); i<_##i; ++i)
#define FOR(i,l,r) for(int i=(l), _##i=(r); i<_##i; ++i)
#define FORD(i,l,r) for(int i=(r), _##i=(l); --i>=_##i; )
#define repi(i,a) for(__typeof((a).begin()) i=(a).begin(), _##i=(a).end(); i!=_##i; ++i)
#define dwni(i,a) for(__typeof((a).rbegin()) i=(a).rbegin(), _##i=(a).rend(); i!=_##i; ++i)
#define printCase() "Case #" << caseNum << ": "
#define pb push_back
#define mp make_pair
#define INF (int)1e9
#define EPS 1e-9
#define SYNC std::ios::sync_with_stdio(false)
#define ff first
#define ss second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
int main() {SYNC;
	ll ans = -(1e16);
	int n, a[3*100000 + 5];
	ll sl[3*100000 + 5] = {}, sr[3*100000 + 5] = {};
	cin >> n; FOR0(i, 3*n) cin >> a[i];
	priority_queue<int,vi,greater<int>> pq;
	FOR0(i, 3*n) {
		sl[i] += a[i];
		pq.push(a[i]);
		if(i >= n) {
			sl[i] -= pq.top(); pq.pop();
		}
		sl[i+1] = sl[i];
	}
	priority_queue<int,vi> pq2;
	FORD(i, 1, 3*n) {
		sr[i] += a[i];
		pq2.push(a[i]);
		if(i < 2*n) {
			sr[i] -= pq2.top(); pq2.pop();
		}
		sr[i-1] = sr[i];
	}
	FOR(i,n-1,2*n) ans = max(ans, sl[i] - sr[i+1]);
	cout << ans << endl;
}

Measured memory_bytes: 7288
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout << fixed
#define endl '\n'

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

const int MAX_A = 1000001;

void solve(istream& cin, ostream& cout) {
  int n;
  cin >> n;
  vector<int> a(n);
  REP(i, n) cin >> a[i];
  SORT(a);
  vector<int> cnt(MAX_A);
  EACH(x, a) {
    if (cnt[x] != 0) {
      cnt[x] = 2;
      continue;
    }
    for (int j = x; j < MAX_A; j += x) cnt[j]++;
  }
  int ans = 0;
  EACH(x, a) {
    if (cnt[x] == 1) ans++;
  }
  cout << ans << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


Measured memory_bytes: 7940
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
/*
ぴったりだすとか？
ああ、
109 =10
110-1=3

105=6
110-5=7
106=7
110-4=6
6=5
5=5
7=4
8=3
9=2
99=2
999=2
990=2
9909=10010-101=4
10000

9
9or2
99

 9
10
73
103=30=7
76=100-24=7
109=110-1=3
6以上がきたら10ではらう、それ以降はずっと引き算とか
618
 618
1020-618=402
677
1000-677=333
995=1000-5=6
1005
9955=10005-50=11
10000-45=10

55=10
100-55=45=10
555=15
1000-555=455=15
54=9
loopに入る頭は6以上。
5以上ならloop継続

655 = 1000-345=13
639=1040-401=10
1040040-400401=18
 639639=18
1040040040-400400401=26
 639639639=26
1004-350=13
 654=13
10050=3504=18
10550=4004=19
10000=3454=17
10000=3454=17
 6546=18
100000-34535=21
 65465=22
これか
10444=4000=17
 6444=18

44がきたら切り上げ中止
645645645はずっと

繰り下げると1個前が1へる
直接足す

*/
int main(){
  string S; cin>>S;
  ll ssz=S.size(),ans=0;
  vector<ll> DP1(ssz+10,0),DP2(ssz+10,0);
  DP2[ssz]=10;
  for(ll i=ssz-1; i>=0; i--){
    ll n=S[i]-'0';
    DP1[i]=min(DP1[i+1]+n,DP2[i+1]+n+1);//直接足す
    DP2[i]=min(DP1[i+1]+10-n,DP2[i+1]+10-n-1);//繰り上げ
  }
//  for(ll i=ssz-1; i>=0; i--) cout<<"i:"<<i<<" DP1:"<< DP1[i]<<" DP2:"<<DP2[i]<<endl;
  cout<<min(DP1[0],DP2[0]+1)<<endl;
}

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

// int/long:		-2147483648 - 2147483648 (-2^31 <= int < 2^31)
// long/long long:	-9223372036854775808 - 9223372036854775807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536870912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// bit: &/and, |/or, ^/xor, ~/not

#define	MOD 1000000007

void	comb(vector<vector<long long int> > &v){
	for (int i=0; i<v.size(); i++){
		v.at(i).at(0)=1;
		v.at(i).at(i)=1;
	}
	for (int k=1; k<v.size(); k++){
		for (int j=1; j<k; j++){
			v.at(k).at(j)=((v.at(k-1).at(j-1)+v.at(k-1).at(j)));
		}
	}
}

int	main() {
	int N, P;
	cin >> N >> P;
	vector<vector<long long int> > v(N+1, vector<long long int>(N+1, 0));
	comb(v);
	/*
	for (int i=0; i<=N; i++){
		cout << N << 'C' << i << " = " << v.at(N).at(i) << endl;
	}
	*/
	int ODD=0;
	for (int i=0; i<N; i++) {
		int A;
		cin >>A;
		if (1==A%2)
			ODD++;
	}
	int EVEN=N-ODD;
	long long S=pow(2, EVEN);
	long long SS=0;
	if (1==P) {
		for (int i=1; i<=ODD; i +=2) {
			SS += v.at(ODD).at(i);
		}
	} else {
		for (int i=0; i<=ODD; i+=2) {
			SS += v.at(ODD).at(i);
		}
	}
	S *=SS;
	cout <<S <<endl;
	return 0;
}



Measured memory_bytes: 256
#include <vector>
#include <cstdio>
#include <cstring>
#include <queue>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <map>
#include <complex>
#include <ctime>
#include <numeric>
#include <set>

using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL)

typedef long long ll;

typedef struct node {
    int s, e, val, pos;
    bool operator<(const node& n) const {
        if (e != n.e) return e < n.e;
        return val > n.val;
    }
    node() {};
    node(int ss, int ee, int v, int p) {
        s = ss, e = ee, val = v, pos = p;
    }
} node;

int occs[(int)1e6 + 5], tree[600005], n, ans[600005];

void update(int x, int val) {
    while (x <= n) {
        tree[x] += val;
        x += x & -x;
    }
}

int query(int x) {
    int ret = 0;
    while (x > 0) {
        ret += tree[x];
        x -= x & -x;
    }
    return ret;
}

int main()
{
// #ifndef ONLINE_JUDGE
//     freopen("in.in", "r", stdin);
// #endif
    fast;
    int q, s, e;
    vector<node> v;
    scanf("%d", &n);
    scanf("%d", &q);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &s);
        v.push_back(node(i, i, s, -1));
    }
    for (int i = 0; i < q; i++) {
        scanf("%d %d", &s, &e);
        v.push_back(node(s, e, 0, i));
    }

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

    for (int i = 0; i < v.size(); i++) {
        if (v[i].val == 0) {
            ans[v[i].pos] = query(v[i].e) - query(v[i].s - 1);
        } else {
            if (occs[v[i].val] != 0) update(occs[v[i].val], -1);
            update(v[i].s, 1);
            occs[v[i].val] = v[i].s;
        }
    }

    for (int i = 0; i < q; i++) {
        printf("%d\n", ans[i]);
    }

    return 0;
}



Measured memory_bytes: 25412
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K, Q;
  cin >> N >> K >> Q;
  vector<int> life(N, 0);
  int correct;
  for (int i = 0 ; i < Q; i++) {
    cin >> correct;
    life.at(correct-1)++;
  }
  for (int i = 0 ; i < N; i++) {
    if(life.at(i) > Q - K) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 1024
#include <cstdlib>
#include <iostream>
#include <queue>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
typedef unsigned long long u64;
typedef signed long long l64;
u64 over = 1000000007;

u64 gcd(u64 a, u64 b)
{
  while (a!=b) {
    if (a<b) {
      u64 d = a;
      a = b;
      b = d;
    }
    if (a%b==0) return b;
    a = abs(a-b);
  }
  return a;
}

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  u64 n, k;
  cin >> n >> k;
  u64 a[n];
  u64 m = 0;
  for (u64 i = 0; i < n; ++i) {cin >> a[i]; m = max(m, a[i]);}
  if (m<k) {cout << "IMPOSSIBLE" << endl; return 0;}
  u64 d = a[0];
  for (u64 i = 1; i < n; ++i) {
    d = gcd(d, a[i]);
  }
  cout << (k%d==0 ? "POSSIBLE" : "IMPOSSIBLE") << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <tuple>
#include <stdlib.h>
using namespace std;
#define PI 3.14159265358979
typedef long long int ll;


int main()
{
	int a, b, c;
	string s, t;
	cin >> a;
	cout << a*a;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string a,b;
	cin>>a;
	b.push_back(toupper(a[0]));
cin>>a;
	b.push_back(toupper(a[0]));
	cin>>a;
	b.push_back(toupper(a[0]));
	cout<<b<<endl;
	return 0;
}

Measured memory_bytes: 256