akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
using System.Threading;
using System.Threading.Tasks;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var K = cin.ReadInt;
            var h = cin.ReadIntArray(N);
            Array.Sort(h);
            var ans = 10000000000;
            for (int i = 0; i <= N - K; i++)
            {
                ans = Min(ans, h[i + K - 1] - h[i]);
            }

            Console.WriteLine(ans);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}


Measured memory_bytes: 15568
#include <bits/stdc++.h>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/range/algorithm/sort.hpp>

using namespace std;
using boost::sort;
using boost::adaptors::reversed;

struct mint {
    static constexpr long MOD = 1000000007;
    long value;

    constexpr mint(long value = 0) noexcept : value((value % MOD + MOD) % MOD) {}
    constexpr mint operator-() const noexcept {
        return mint(-value);
    }
    constexpr mint& operator+=(const mint& rhs) noexcept {
        if ((value += rhs.value) >= MOD) value -= MOD;
        return *this;
    }
    constexpr mint& operator-=(const mint& rhs) noexcept {
        if ((value += MOD - rhs.value) >= MOD) value -= MOD;
        return *this;
    }
    constexpr mint& operator*=(const mint& rhs) noexcept {
        (value *= rhs.value) %= MOD;
        return *this;
    }
    constexpr mint operator+(const mint& rhs) const noexcept {
        mint res(*this);
        return res += rhs;
    }
    constexpr mint operator-(const mint& rhs) const noexcept {
        mint res(*this);
        return res -= rhs;
    }
    constexpr mint operator*(const mint& rhs) const noexcept {
        mint res(*this);
        return res *= rhs;
    }
    constexpr mint pow(long e) const noexcept {
        if (e == 0) return 1;
        mint a = pow(e >> 1);
        a *= a;
        if (e % 2 == 1) a *= *this;
        return a;
    }
    constexpr mint inv() const noexcept {
        return pow(MOD - 2);
    }
    constexpr mint& operator/=(const mint& rhs) noexcept {
        return *this *= rhs.inv();
    }
    constexpr mint operator/(const mint& rhs) const noexcept {
        mint res(*this);
        return res /= rhs;
    }
    friend constexpr mint pow(const mint& a, const long& b) noexcept {
        return a.pow(b);
    }
    friend ostream& operator<<(ostream& os, const mint& n) noexcept {
        os << n.value;
        return os;
    }
};

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    vector<mint> am(n);
    am[n - 1] = 0;
    for (int i = n - 2; i >= 0; i--) {
        am[i] = am[i + 1] + a[i + 1];
    }
    mint ans = 0;
    for (int i = 0; i < n; i++) {
        ans += am[i] * a[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 5632
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    
    string s,t; cin >> s >> t;
    sort(s.begin(),s.end());
    sort(t.rbegin(),t.rend());
    if(s < t) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 400010;

// aのn乗を求める。計算量はO(logn)
ll modpow(ll a, ll n) {
    if(n == 0) {
        return 1;
    }
    if(n%2 == 1) {
        return (a * modpow(a, n-1))%mod;
    }
    return (modpow(a, n/2) * modpow(a, n/2))%mod;
}

ll inverse(ll a) {
    return modpow(a, mod-2);
}

ll inv[MAX_N];  // inv[i] : iの逆数のmod
ll fact[MAX_N];  // fact[i] : iの階乗のmod
ll invfact[MAX_N];

void init() {
    inv[0] = fact[0] = invfact[0] = 1;
    inv[1] = 1;
    for(ll i = 1; i < MAX_N; i++) {
        if(i >= 2) {
            inv[i] = mod - inv[mod%i]*(mod/i)%mod;
        }
        fact[i] = (i*fact[i-1])%mod;
        invfact[i] = inverse(fact[i]);
    }
}
 
ll Comb(ll n, ll r) {
    if(r < 0 || n < 0 || n < r) {
        return 0;
    }
    ll res = fact[n];
    res = (res * invfact[r])%mod;
    res = (res * invfact[n-r])%mod;
    return res;
}

//--- main関数でinit()を呼び出すのを忘れるな ---//
int main() {
    ll n, k;
    cin >> n >> k;

    init();
    
    if(n-1 <= k) {
        out(Comb(2*n-1, n-1));
        re0;
    }

    // 以下 k <= n-2 
    ll ans = 1;
    if(k%2 == 1) {
        exrep(i, 1, k) {
            ans += (Comb(n, i)*Comb(n-1, i))%mod;
            ans %= mod;
        }
    }
    else if(k%2 == 0) {
        exrep(i, 1, k) {
            ans += (Comb(n, i)*Comb(n-1, i))%mod;
            ans %= mod;
        }
    }

    out(ans);
    re0;
}

Measured memory_bytes: 9600
import java.util.*;
public class Main {
	Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}

	public Main(){
		new AOJ0554().doIt();
	}
	
	class AOJ0554{
		void doIt(){
			int sum = 0;
			for(int i=0;i<4;i++)sum+=in.nextInt();
			int m = sum/60;
			int s = sum%60;
			System.out.println(m);
			System.out.println(s);
		}
	}
	
	
}

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

double getDis(double R,double r){return sqrt((R+r)*(R+r) - (R-r)*(R-r));}

int main(){
  int n;
  cin>>n;
  double A[501],x[501];
  for(int i=0;i<n;i++)cin>>A[i],x[i] = A[i];

  for(int i=1;i<n;i++)
    for(int j=0;j<i;j++){
      double R = A[i];
      double r = A[j];
      double d = getDis(R,r);
      x[i] = max(x[i],x[j]+d);
    }
  
  double ans = 0;
  for(int i=0;i<n;i++) ans=max(ans,x[i]+A[i]);
  printf("%.10f\n",ans);
  return 0;
}

Measured memory_bytes: 3292
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan= new Scanner(System.in);
        int N= scan.nextInt();
        int M= scan.nextInt();
        int[] arr= new int[M];
        int sum=0;
        for(int i=0;i<M;i++){
            arr[i]=scan.nextInt();
            sum+=arr[i];
        }
        if(N-sum>=0){
            System.out.println(N-sum);
        }
        else{
            System.out.println(-1);
        }

    }
}


Measured memory_bytes: 46220
#include <stdio.h>
int main(void){
    int N,M;
    scanf("%d %d",&N,&M);
    int flag=0;
    int a[200001]={};
    int kari1,kari2;
    for(int i=0;i<M;i++){
        scanf("%d %d",&kari1,&kari2);
        if(kari1==1)a[kari2]++;
        if(a[kari2]==2)flag=1;
        if(kari2==N)a[kari1]++;
        if(a[kari1]==2)flag=1;
    }
    if(flag==1)printf("POSSIBLE");
    else printf("IMPOSSIBLE");
}


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

using namespace std;

int main(void)
{
	int W,H,N; cin>>W>>H>>N;
	int x[N],y[N],a[N]; for(int i = 0; i < N; i++) cin>>x[i]>>y[i]>>a[i];
	int ld[2],lu[2],rd[2],ru[2];
	ld[0] = 0, ld[1] = 0;
	lu[0] = 0, lu[1] = H;
	rd[0] = W; rd[1] = 0;
	ru[0] = W; ru[1] = H;
	for(int i  = 0; i < N; i++){
		if(a[i] == 1){
			if(ld[0] < x[i]) ld[0] = x[i];
			if(lu[0] < x[i]) lu[0] = x[i];
		}
		else if(a[i] == 2){
			if(rd[0] > x[i]) rd[0] = x[i];
			if(ru[0] > x[i]) ru[0] = x[i];
		}
		else if(a[i] == 3){
			if(ld[1] < y[i]) ld[1] = y[i];
			if(rd[1] < y[i]) rd[1] = y[i];
		}
		else if(a[i] == 4){
			if(lu[1] > y[i]) lu[1] = y[i];
			if(ru[1] > y[i]) ru[1] = y[i];
		}
	}
	int ans = 0;
	ans = (lu[1] - ld[1])*(rd[0] - ld[0]);
	if(ans < 0 || lu[1] - ld[1] < 0 || rd[0] -ld[0] < 0) cout<<0<<endl;
	else cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 256
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = s_inpl()   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = inpl()	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import math
import copy
from collections import defaultdict, Counter
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
from bisect import bisect_left, bisect_right
# import numpy as np

def s_inpl(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
INF = float("inf")

N = int(input())
T, A = [], []
for _ in range(N):
    t, a = s_inpl()
    T.append(t)
    A.append(a)

ans_t, ans_a = 1, 1
for ti, ai in zip(T, A):
    n = max(ans_t//ti, ans_a//ai)
    if ans_t>ti*n or ans_a>ai*n:
        n += 1
    ans_t = ti*n
    ans_a = ai*n

print(ans_t+ans_a)



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

def check(limit):
    idx_k = 0
    idx_n = 0
    temp = 0
    array = list(ws)

    while True:
        if idx_k == k or idx_n == n:
            break
        if temp + array[idx_n] <= limit:
            temp = temp + array[idx_n]
            idx_n += 1
        else:
            temp = 0
            idx_k += 1
    if idx_n < n:
        return False
    else:
        return True

for i in range(n):
    ws.append(int(input()))

limit = 1
left = 1
right = 100000 * 10000
mid = int((left + right) / 2)
ans = right

while left <= right:
    if check(mid):
        ans = mid
        right = mid-1
        mid  = (left + right) // 2
    else:
        left = mid+1
        mid = (left + right) // 2

print(ans)




Measured memory_bytes: 10352
#include <bits/stdc++.h>
 
int main() {
    int n, x; std::cin >> n >> x;
    int l[n]; for(int i=0; i<n; i++) std::cin >> l[i];
 
    int length = 0;
    int count = 1;

    for (size_t i = 0; i < n; i++) {
        length += l[i];
        if (length > x) break;
        count += 1;
    }

    printf("%d\n", count);
    return 0;
}

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

using namespace std;

int arr[100005];
int n;

int main()
{
    cin >> n;
    int i;
    for(i=0;i<n;i++)
        cin >> arr[i];
    int ans=0;
    for(i=0;i<n;i++)
    {
        if(arr[arr[i]-1]==i+1)
            ans++;
    }
    cout << ans/2 << endl;
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(void){
    int a,b,c,x,kumachan=0;
    cin>>a>>b>>c>>x;
    for (int i=0; i <= a; i++){
        for(int j=0; j <= b; j++){
            for(int t=0; t <= c; t++){
                if(500*i + 100*j + 50*t == x){
                    kumachan++;
                }
            }
        }
    }
    cout<<kumachan<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int a,b,c,d;
	scanf("%d",&a);
	b=a%10;
	c=a%100-b;
	d=(a-c-b)/100;
	if (b==d)
	{
		printf("Yes\n");
	}else
	{
		printf("No\n");
	}
}

Measured memory_bytes: 128
#include <set>
#include <map>
#include <queue>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <bitset>
#include <vector>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
using namespace std;
typedef double db;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pa;
typedef unsigned int uint;
typedef unsigned long long ull;
#define w1 first
#define ls (x<<1)
#define w2 second
#define ins insert
#define rs (x<<1|1) 
#define mp make_pair
#define pb push_back
#define mid ((l+r)>>1)
#define sqr(x) ((x)*(x))
#define cle(x) ((x).clear())
#define lowbit(x) ((x)&(-x))
#define SZ(x) (int((x).size()))
#define All(x) (x).begin(),(x).end()
#define ms(x,y) memset(x,y,sizeof (x))
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define per(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define Rep(p,x) for(int (p)=head[(x)];(p);(p)=nxt[(p)]) 
#define Rep2(p,x) for(int (p)=cur[(x)];(p);(p)=nxt[(p)])
template<class T>inline void read(T&num){
	num=0;T f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')num=num*10+ch-'0',ch=getchar();
	num*=f;
}
inline int getgcd(int x,int y){if(!x)return y;return getgcd(y%x,x);}
inline int power(int x,int k,int p){int res=1;for(;k;k>>=1,x=(ll)x*x%p)if(k&1)res=(ll)res*x%p;return res;}
const double pi=acos(-1);	
inline void judge(){
	freopen("input.txt","r",stdin);
} 
//********************************head*************************************
const int maxn=2e3+5,mod=924844033;
int n,k;
int f[maxn][maxn][3],g[maxn],ng[maxn];
int fac[maxn],ifac[maxn];
int add(int x,int y){return x+y>=mod?x+y-mod:x+y;}
int sub(int x,int y){return x-y<0?x-y+mod:x-y;}
void upd(int &x,int y){x=add(x,y);}
int main(){
	read(n);read(k);
	fac[0]=1;rep(i,1,n)fac[i]=1ll*fac[i-1]*i%mod;
	rep(i,0,n)ifac[i]=power(fac[i],mod-2,mod);
	g[0]=1;
	rep(i,1,min(2*k,n)){
		f[0][0][0]=1;
		int c=1;
		for(int j=i;j<=n;j+=2*k,c++){
			rep(l,0,c){
				f[c][l][0]=f[c][l][1]=f[c][l][2]=0;
				upd(f[c][l][0],f[c-1][l][0]);
				upd(f[c][l][0],f[c-1][l][1]);
				upd(f[c][l][0],f[c-1][l][2]);

				if(!l)continue;
				if(j-k>=1){
					upd(f[c][l][1],f[c-1][l-1][0]);
					upd(f[c][l][1],f[c-1][l-1][1]);
				}
				if(j+k<=n){
					upd(f[c][l][2],f[c-1][l-1][0]);
					upd(f[c][l][2],f[c-1][l-1][1]);
					upd(f[c][l][2],f[c-1][l-1][2]);
				}
			}
		}
		c--;
		memset(ng,0,sizeof ng);
		per(j,n,0)rep(l,0,min(j,c)){
			int num=add(add(f[c][l][0],f[c][l][1]),f[c][l][2]);
			upd(ng[j],1ll*g[j-l]*num%mod);
		}
		per(j,n,0)g[j]=ng[j];
	}
	int ans=0;
	rep(i,0,n)
		if(!(i&1))ans=add(ans,1ll*fac[n-i]*g[i]%mod);
		else ans=sub(ans,1ll*fac[n-i]*g[i]%mod);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 23168
#include <iostream>
#include <sstream>
#include <fstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include<iomanip>
#define sqr(x) (x)*(x)
#define ll long long
using namespace std;
ll n,m,ans=100000000000;
void get(ll x,ll y,ll z)
{
	ans=min(ans,max(max(x*m,y/2*z),(y+1)/2*z)-min(min(x*m,y/2*z),(y+1)/2*z));
}
int main()
{
	cin>>n>>m;
	get((n+2)/3,n-((n+2)/3),m);
	get((n+2)/3,m,n-((n+2)/3));
	get(n/3,n-(n/3),m);
	get(n/3,m,n-(n/3));
	swap(n,m);
	get((n+2)/3,n-((n+2)/3),m);
	get((n+2)/3,m,n-((n+2)/3));
	get(n/3,n-(n/3),m);
	get(n/3,m,n-(n/3));
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>

using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f3f3f3f3fLL
#define SIZE 8080
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
ll MOD=1e9+7;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
int N;

int main(){
	
	cin>>N;
	ll mi = 1e9 + 5;
	ll sum=0;
	for(int i=0;i<N;i++){
		ll a,b;
		cin>>a>>b;
		sum+=b;
		if(a>b){
			mi=min(mi,b);
		}
	}
	if(mi==(1e9 + 5)){
		cout<<0<<endl;
	}else{
		sum-=mi;
		cout<<sum<<endl;
	}
	
}

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

int main()
{    
    ll h;
    cin >> h;

    ll ans = 0;
    int count = 0;
    while(h){
        ans += pow(2, count);
        h = h/2;
        count++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 384
n = gets.to_i
l = gets.chomp.split(" ").map(&:to_i).sort.reverse

ans = 0
(n-2).times do |i|
  j = i+1
  k = n-1
  while j < k
    if l[i] < l[j] + l[k]
      ans += k-j
      j += 1
    else
      k -= 1
    end
  end
end

puts ans

Measured memory_bytes: 1912
import sys
N = int(input())
S,T = input().split()

if not ( 1 <= N <= 100 ): sys.exit()
if not ( len(S) == len(T) and len(S) == N ): sys.exit()
if not ( S.islower() and T.islower() ): sys.exit()

for I in range(N):
    print(S[I],end='')
    print(T[I],end='')

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

using namespace std;

int main(void) {
    int N, M;
    cin >> N >> M;
    vector< vector<string> > v(N);
    for(int i=0; i<M; i++) {
        int p;
        string S;
        cin >> p >> S;
        v[p-1].push_back(S);
    }

    int ac = 0, wa = 0;
    for(int i=0; i<N; i++) {
        if(find(v[i].begin(), v[i].end(), "AC") != v[i].end()) {
            ++ac;
            wa += distance(v[i].begin(), find(v[i].begin(), v[i].end(), "AC"));
        }
    }

    cout << ac << " " << wa << endl;
    return 0;
}


Measured memory_bytes: 10368
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long 
#define FI first 
#define SE second
#define pb push_back 
#define eb emplace_back
#define mod 1000000007
#define all(c) (c).begin(),(c).end()
#define LB  lower_bound
#define UB  upper_bound
#define max3(a,b,c) max(c,max(a,b))
#define min3(a,b,c) min(c,min(a,b))
#define mems(s, n) memset(s, n, sizeof(s))
#define NINF -1e18
#define INF 1e18
#define int ll int
#define OOK order_of_key  //no of elements less than
#define FBO find_by_order //iterator pointing kth element;indexing starts from 0
#define CK3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define CK4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl

typedef pair<int,int> PII;
typedef pair<pair<int,int>,int> PPII;
typedef pair<int,pair<int,int>> PIPI;
typedef map<int,int>MII;
typedef vector<int> VI;
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

/*int power(int a, int b)
{int x=1,y=a;while(b>0){if(b%2){x =(x*y)%mod;}y =(y*y)%mod;b/=2;}return x%mod;}
*/
//int modInverse(int a, int m) {return power(a, m-2);} //gcd(a,m)=1 


signed main()
{
ios::sync_with_stdio(false); cin.tie(0);
int T=1,T1=0;//cin>>T;
while(T1++<T)
{
    int a;
    cin>>a;
    long double b,c;
    cin>>b;
    c=a*b;
    int d=c;
    cout<<d<<endl;
   
    
}


return 0;
}





Measured memory_bytes: 3744
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <memory.h>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <ctime>
#include <iostream>
#include <functional>
#include <complex>
#include <iomanip>
#pragma comment(linker, "/STACK:836777216")

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<pii, int> p3i;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<p3i> v3i;
typedef vector<vii> vvii;
typedef vector<p3i> vp3i;
typedef long double ld;
typedef vector<ld> vld;

#define pb push_back
#define mp make_pair
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define REPD(i, n) for (int (i) = (n) - 1; (i) >= 0; (i)--)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define FORD(i,a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define sz(v) (int)(v).size()
#define all(v) (v).begin(), (v).end()
#define rv(v) reverse(all(v))
#define CL(v, val) memset((v), (val), sizeof((v)))
#define SORT(a) sort(all(a))
#define un(v) SORT(v), (v).resize(unique(all(v)) - (v).begin())
#define eps 1.0e-7
#define X first
#define Y second
#define bit(n) (1 << (n))
#define bit64(n) (ll(1) << (n))
#define sqr(n) ((n) * (n))

double x[3], y[3];
double l[3];

double GetDist(int a, int b) {
  return sqrt(sqr(x[a] - x[b]) + sqr(y[a] - y[b]));
}

int main(void) {
  int n;
  scanf("%d", &n);
  REP(i, n) {
    REP(j, 3) {
      scanf("%lf%lf", &x[j], &y[j]);
    }

    double D = 2 * (x[0] * (y[1] - y[2]) + x[1] * (y[2] - y[0]) + x[2] * (y[0] - y[1]));
    double xc = 1.0 / D * ((sqr(x[0]) + sqr(y[0])) * (y[1] - y[2]) + (sqr(x[1]) + sqr(y[1])) * (y[2] - y[0]) + (sqr(x[2]) + sqr(y[2])) * (y[0] - y[1]));
    double yc = 1.0 / D * ((sqr(x[0]) + sqr(y[0])) * (x[2] - x[1]) + (sqr(x[1]) + sqr(y[1])) * (x[0] - x[2]) + (sqr(x[2]) + sqr(y[2])) * (x[1] - x[0]));

    double p = 0;
    REP(j, 3) {
      l[j] = GetDist(j, (j + 1) % 3);
      p += l[j];
    }

    p /= 2;

    double r = 1;
    double z = p;
    REP(j, 3) {
      r *= l[j];
      z *= (p - l[j]);
    }

    r = r / (4 * sqrt(z));

    printf("%.3lf %.3lf %.3lf\n", xc, yc, r);


  }
  return 0;
}

Measured memory_bytes: 3152
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int h = Integer.parseInt(sa[0]);
		int w = Integer.parseInt(sa[1]);
		char[][] a = new char[h][w];
		for (int i = 0; i < h; i++) {
			a[i] = br.readLine().toCharArray();
		}
		br.close();

		boolean[] r = new boolean[h];
		boolean[] c = new boolean[w];
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (a[i][j] == '#') {
					r[i] = true;
					c[j] = true;
				}
			}
		}

		char[][] ans = new char[h][w];
		for (int i = 0; i < h; i++) {
			Arrays.fill(ans[i], ' ');
		}
		int p = -1;
		for (int i = 0; i < h; i++) {
			if (r[i]) p++;
			int q = -1;
			for (int j = 0; j < w; j++) {
				if (c[j]) q++;
				if (r[i] && c[j]) {
					ans[p][q] = a[i][j];
				}
			}
		}

		for (int i = 0; i < h; i++) {
			if (ans[i][0] == ' ') {
				break;
			}
			for (int j = 0; j < w; j++) {
				if (ans[i][j] == ' ') {
					break;
				}
				System.out.print(ans[i][j]);
			}
			System.out.println();
		}
	}
}


Measured memory_bytes: 23124
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cpp,赤波線出るけどコンパイルできる

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll a,b,d,n,maxi=0,f=0,mini=INF,sum=0;
    ll w=0,h,x,y,k;
    //string str[3];
    string str;
    ll e=0;
    ll m;
	cin>>n;
    vector<ll> v(n);
    rep(i,n) cin>>v[i];
    a=round((double)accumulate(all(v),0)/v.size());
    rep(i,n)sum+=abs(a-v[i])*abs(a-v[i]);
    cout<<sum<<endl;

    return 0;
}



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

ll M = 1000000007;

int main(){
	ll n;
	cin >> n;
	vector<ll> a(n);
	rep(i,n) cin >> a[i];
	ll ans = 0;
	rep(i,61){
		ll count = 0;
		rep(j,n){
			if(a[j] >> i & 1) count++;
		}
		ll two = 1;
		rep(j,i){
			two *= 2;
			two %= M;
		}
		ll p = count*(n-count) % M;
		ans += two*p;
		ans %= M;
	}
	cout << ans << endl;
    return 0;
}



Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
using ll = long long; 
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
template<class T> using pq = priority_queue<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
const ll BetsuMOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -MOD * MOD;
const long double pi = 3.141592653589793;
int main() { // 問題文はしっかり読め!!!
	string s;
	cin >> s;
	int k;
	cin >> k;
	int n = s.size();
	rep(i, n) {
		int dist = (26 - (s[i] - 'a')) % 26; // 優先順位には気を付けよう！
		if (dist <= k) s[i] = 'a', k -= dist;
	}
	k %= 26;
	rep(i, k) {
		if (s[n - 1] == 'z') s[n - 1] = 'a';
		else s[n - 1]++;
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 512
def main():
    s = input()
    
    s_set = set(s)
    if len(s_set) == 4:
        print("Yes")
    elif len(s_set) == 2:
        if ("N" in s_set and "S" in s_set) or ("W" in s_set and "E" in s_set):
            print("Yes")
        else:
            print("No")
    else:
        print("No")
        
        
if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main(){
    while(1){
        int n,x;
        cin >> n >> x;
        if(n ==  0 && x == 0) break;
        
        int  count = 0;
        for(int i = 1; i <=n; i++){
            for(int j = i+1; j <= n; j++){
                for(int k = j+1; k <= n; k++){
                    if(i+j+k == x) count++;
                }
            }
        }

        cout << count << endl;

    }
}


Measured memory_bytes: 3100
n = int(input())
w = list(map(int, input().split()))
t = 10**9
for i in range(1,n):
    s1 = sum(w[:i])
    s2 = sum(w[i:])
    if abs(s1-s2) < t:
        t = abs(s1-s2)
print(t)

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



int main(){
    int N;
    cin >> N;
    bool ok = false;
    for(int i = 0;i<=N/4;i++){
        for(int j = 0;j<=N/7;j++){
            if(4*i + 7*j == N){
                ok = true;
            }
        }
    }

    if(ok == true){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
using namespace std;
using P = pair<int,int>;
typedef long long ll;
 
int main() {
    int n;
    string s;
    cin >> n >> s;

    int ans=0;
    rep(i,n) {
        if(s[i]=='A') {
            if(s[i+1]=='B') {
                if(s[i+2]=='C') {
                    ans++;
                }
            }
        }
    }
    
    cout<<ans<<endl;

 return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
int main(){
  long long X; cin >> X;
  long long money = 100;
  long long ans = 0;
  while(money < X){
    ans++;
    money *= 1.01;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3624
import sys
from bisect import *
from heapq import *
from collections import *
from itertools import *
from functools import *
from math import *
from fractions import *

sys.setrecursionlimit(100000000)
input = lambda: sys.stdin.readline().rstrip()

def main():
    ans = 10 ** 9
    N, A, B, C = map(int, input().split())
    l = []
    for _ in range(N):
        l.append(int(input()))
    for i in range(4 ** N):
        group = []
        for j in range(N):
            k = i
            for _ in range(j):
                k //= 4
            group.append(k % 4)
        sm = [0] * 3
        for j in range(N):
            if group[j] < 3:
                sm[group[j]] += l[j]
        if min(sm) > 0:
            ans = min(ans, 10 * (N - group.count(3) - 3) + sum(abs(i - j) for i, j in zip(sorted(sm), [C, B, A])))
    print(ans)


main()


Measured memory_bytes: 72664
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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;
}
void dijkstra(ll n,vl &d,vvpl &g,ll s){
    pqueue(pl) que;
    que.push({0,s});
    d[s]=0;
    while(!que.empty()){
        pl p=que.top();
        que.pop();
        ll v=p.se;
        if(d[v]<p.fi)continue;
        rep(i,g[v].size()){
            pl ed=g[v][i];
            if(d[ed.fi]>d[v]+ed.se){
                //prev[ed.fi]=v;
                d[ed.fi]=d[v]+ed.se;
                que.push({d[ed.fi],ed.fi});
            }
        }
    }
}

int main(){
    ll n,m,s,t;cin >> n >> m >> s >>t;s--;t--;
    vvpl ga(n),gb(n);
    rep(i,m){
        ll a,b,c,d;cin >> a >> b >> c >>d;
        a--;b--;
        ga[a].pb({b,c});
        ga[b].pb({a,c});
        gb[a].pb({b,d});
        gb[b].pb({a,d});
    }
    vl da(n,INF/10),db(n,INF/10);
    dijkstra(n,da,ga,s);
    dijkstra(n,db,gb,t);
    vl ans(n);priority_queue<ll,vl,greater<ll>> que;
    per(i,n){
        que.push(da[i]+db[i]);
        ans[i]=que.top();
    }
    rep(i,n)cout << 1000000000000000-ans[i] <<endl;
}

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

int main()
{
    double n,cnt=0;
    double m;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        if(i%2!=0)
        {
            cnt++;
        }

    }
     m=cnt/n;
    printf("%.10lf",m);
}

Measured memory_bytes: 3736
#include <stdio.h>

void call (int n);

int main (void) {
    int n;

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

    return 0;
}

void call (int n) {
    for (int i=1; i<=n; i++) {
        int x = i;

        if (x%3==0) printf(" %d", i);
        else {
            for (;;) {
                if (x%10==3) {
                    printf (" %d", i);
                    break;
                }
                x /= 10; 
                if (x==0) break;
            }
        }
    }
    printf("\n");
}


Measured memory_bytes: 2048
#![allow(non_snake_case, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $var = read_value!($next, $t); input_inner!{$next $($r)*} }; }
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, [ $t:tt ]) => { { let len = read_value!($next, usize); (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() } }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        S: chars,
    }
    let n = S.len();
    let mut ans:Vec<i64> = vec!(-1,-1);
    for i in 0..n-1{
        if S[i]==S[i+1] {
            ans[0] = i as i64 +1;
            ans[1] = i as i64 +2;
            break;
        }
    }
    for i in 0..n-2{
        if S[i]==S[i+2] && S[i]!=S[i+1]{
            ans[0] = i as i64 +1;
            ans[1] = i as i64 +3;
            break;
        }
    }
    println!("{} {}", ans[0],ans[1]);
}


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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> food(M, 0);
  int K;
  int A;
  rep(i, 0, N) {
    cin >> K;
    rep(j, 0, K) {
      cin >> A;
      food[A - 1]++;
    }
  }
  int ans = 0;
  rep(i, 0 , M) {
    if (food[i] == N) ans++;
  }
  cout << ans << endl;
};


Measured memory_bytes: 256
class Array
  def gcd
    inject(:gcd)
  end
end
n, x = gets.chomp.split(" ").map(&:to_i)
spots = gets.chomp.split(" ").map(&:to_i)
abss = []
spots.each do |spot|
  abss << (spot - x).abs
end
abss.uniq!
puts abss.gcd


Measured memory_bytes: 18564
#include<bits/stdc++.h>
using namespace std;
#define fastio() ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define M 1000000007
#define inf 1e9
#define pi 3.1415926536
#define mod 1000000007
#define fr(i,a,b,in) for(int i=a;i<b;i+=in)
#define frn(i,a,b,dc) for(int i=a;i>=b;i-=dc)
#define test(t) int t; cin>>t; while(t--)
int main()
{
	fastio();
	string st;
	cin>>st;
	int i=0,ans=0;
	while(i<3){
		if(st[i]=='R'){
			int c=0;
			while(st[i]=='R'){
				i++;
				c++;
			}
			ans=max(ans,c);
		}
		else i++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3636
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<set>
using namespace std;
int d[310];
int c[510];
int v[310];
int at[30];
int n;
int tmp[30];
int sz;
set<vector<int> >S;
inline int ABS(int a){return max(a,-a);}
void solve(int a,int b){
	if(a==n){
		for(int i=0;i<n;i++)tmp[i]=at[i];
		
		std::sort(tmp,tmp+n);
		vector<int>val;
		for(int i=0;i<n;i++)val.push_back(tmp[i]);
		if(S.count(val))return;
		S.insert(val);
		for(int i=0;i<n-1;i++){
			if(i){
				printf(" ");
				printf("%d",tmp[i+1]-tmp[i]);
			}else printf("%d",tmp[1]);
		}
		printf("\n");
		return ;
	}
	for(int i=b;i>0;i--){
		if(!c[i])continue;
		for(int j=0;j<a;j++){
			if(at[j]-i>0){
				bool ok=true;
				//c[i]--;
				int t=at[j]-i;
				for(int k=0;k<a;k++){
					if(!c[ABS(t-at[k])])ok=false;
					c[ABS(t-at[k])]--;
				}
				if(ok){
					at[a]=t;
					solve(a+1,i);
				}
				//c[i]++;
				for(int k=0;k<a;k++)c[ABS(t-at[k])]++;
			}
			if(at[j]+i<d[0]){
				bool ok=true;
				//c[i]--;
				int t=at[j]+i;
				for(int k=0;k<a;k++){
					if(!c[ABS(t-at[k])])ok=false;
					c[ABS(t-at[k])]--;
				}
				if(ok){
					at[a]=t;
					solve(a+1,i);
				}
				//c[i]++;
				for(int k=0;k<a;k++)c[ABS(t-at[k])]++;
			}
		}
		break;
	}
}
int main(){
	int a;
	while(scanf("%d",&a),a){
		n=a;
		S.clear();
		sz=n*(n-1)/2;
		for(int i=0;i<a*(a-1)/2;i++)scanf("%d",d+i);
		for(int i=0;i<510;i++){
			c[i]=0;
		}
		for(int i=0;i<310;i++)v[i]=0;
		for(int i=0;i<a*(a-1)/2;i++)c[d[i]]++;
		c[d[0]]--;
		
		at[0]=d[0];
		at[1]=0;
		solve(2,d[0]-1);
		printf("-----\n");
	}
}

Measured memory_bytes: 1076
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main(int argc, char *argv[])
{
  for(;;) {
    string s, t;
    cin >> s;
    if(s == ".") break;
    cin >> t;
    auto f = [](string &str, vector<string> &ts, vector<string> &ss) {
      int n = str.length();
      for(;;) {
        int j = str.find("\"");
        if(j < 0) break;
        ts.push_back(str.substr(0,j));
        str = str.substr(j+1);
        int k = str.find("\"");
        ss.push_back(str.substr(0, k));
        str = str.substr(k+1);
        //cout << *ts.rbegin() << endl;
        //cout << *ss.rbegin() << endl;
      }
      ts.push_back(str);
      //cout << *ts.rbegin() << endl;
    };
    vector<string> ss1, ts1;
    f(s, ts1, ss1);
    vector<string> ss2, ts2;
    f(t, ts2, ss2);
    if((ss1.size() != ss2.size()) || (ts1.size() != ts2.size())) {
      cout << "DIFFERENT" << endl;
    } else {
      auto g = [](const vector<string> &x1, const vector<string> &x2) {
        int dd = 0;
        for(int i = 0; i < x1.size(); i++) {
          if(x1[i] != x2[i]) dd++;
        }
        return dd;
      };
      int ds = g(ss1, ss2);
      int dt = g(ts1, ts2);
      if(ds == 0 && dt == 0) {
        cout << "IDENTICAL" << endl;
      } else if (ds == 1 && dt == 0){
        cout << "CLOSE" << endl;
      } else {
        cout << "DIFFERENT" << endl;
      }
    }
  }
  return 0;
}

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

#define fi first
#define se second
#define show(x) cerr << #x << "=" << "\n"
typedef long long ll;
typedef unsigned long long ull;

using namespace std;
const ll llinf = LLONG_MAX;
const ull ullinf = ULLONG_MAX;

int n, m, q;
int a[511][511];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;
#ifdef LOCAL_DEFINE
  FILE *stream1;
  //FILE *stream2;
  stream1 = freopen("in.txt", "r", stdin);
  //stream2 = freopen("out.txt", "w", stdout);
  if (stream1 == NULL) return 0;
  //if (stream2 == NULL) return 0;:w
#endif
	cin >> n >> m >> q;
	for (int i = 0; i < m; i++) {
		int l, r;
		cin >> l >> r;
		l--; r--;
		a[l][r]++;
	}
	for (int i = 0; i < n; i++) {
		for (int j = 1; j < n; j++) {
			a[i][j] = a[i][j] + a[i][j - 1];
		}
	}
	for (int i = 0; i < q; i++) {
		int l, r;
		cin >> l >> r;
		l--; r--;
		int res = 0;
		for (int j = l; j <= r; j++) {
			res += a[j][r];
		}
		cout << res << endl;
	}
#ifdef LOCAL_DEFINE
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
  fclose(stream1);
  //fclose(stream2);
#endif
  return 0;
}



Measured memory_bytes: 1920
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) (X).begin(),(X).end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

#define MAXINT 1000001
vi d,d2;
int main(){
	int t = 1;
	while(1){
		int tmp = t*(t+1)*(t+2)/6;
		if(tmp>MAXINT) break;
		d.pb(tmp);
		if(tmp%2==1) d2.pb(tmp);
		t++;
	}

	int dp[MAXINT];
	int dp2[MAXINT];
	REP(i,MAXINT){
		dp[i] = 500; dp2[i] = 500;
	}
	REP(i,d.size()) dp[d[i]] = 1;
	REP(i,d2.size()) dp2[d2[i]] = 1;
	REP(i,MAXINT){
		REP(k,d.size()){
			if(i+d[k]>=MAXINT) continue;
			dp[i+d[k]] = min(dp[i+d[k]],dp[i]+1);
		}
	}
	REP(i,MAXINT){
		REP(k,d2.size()){
			if(i+d2[k]>=MAXINT) break;
			dp2[i+d2[k]] = min(dp2[i+d2[k]],dp2[i]+1);
		}
	}
	while(1){
		int n;
		cin >> n;
		if(n==0) break;
		cout << dp[n] << " " << dp2[n] << endl;
	}

}

Measured memory_bytes: 9032
#include <bits/stdc++.h>
using namespace std;
#include <cmath>
#include <iomanip>
#include <iostream>

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll  = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rep1r(i, n) for (int i = ((int)(n)); i > 0; --i)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

struct Point {
    double x, y;
};

void koch(int n, Point a, Point b) {
    cout << fixed << setprecision(4);

    if (n == 0) return;
    Point  s, t, u;
    double th = PI * 60.0 / 180.0;
    s.x       = (2.0 * a.x + 1.0 * b.x) / 3.0;
    s.y       = (2.0 * a.y + 1.0 * b.y) / 3.0;
    t.x       = (1.0 * a.x + 2.0 * b.x) / 3.0;
    t.y       = (1.0 * a.y + 2.0 * b.y) / 3.0;
    u.x       = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
    u.y       = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;
    koch(n - 1, a, s);
    cout << s.x << " " << s.y << endl;
    koch(n - 1, s, u);
    cout << u.x << " " << u.y << endl;
    koch(n - 1, u, t);
    cout << t.x << " " << t.y << endl;
    koch(n - 1, t, b);
}

int main() {
    cout << fixed << setprecision(4);

    int   n;
    Point a, b;
    cin >> n;
    a.x = 0.0;
    a.y = 0.0;
    b.x = 100.0;
    b.y = 0.0;
    cout << a.x << " " << a.y << endl;
    koch(n, a, b);
    cout << b.x << " " << b.y << endl;
    return 0;
}



Measured memory_bytes: 3276
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define INF 9000000000000000000
#define ff first
#define ss second
#define mod 1000000007
#define endl "\n"
#define BS binary_search

int32_t main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int tc=1;
    //cin>>tc;
    while(tc--){
        int a,b,c;cin>>a>>b>>c;
        int k;cin>>k;
        int i=0;
        while(a>=b){
            b*=2;
            i++;
        }
        while(b>=c){
            c*=2;
            i++;
        }
        if(i<=k){
            cout<<"Yes"<<endl;
        }
        else{
            cout<<"No"<<endl;
        }
    }
}


Measured memory_bytes: 3640
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INFI = 1000000007;
const int mod = 1000000007;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

// mint N;

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

// combination c(N);
// mint ans = c(N,n);
// cout << ans.x << endl;

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


int main(){
  int N;
  cin >> N;
  int shop[110][10];
  for(int i=0; i<N; i++){
    for(int j=0; j<10; j++){
      cin >> shop[i][j];
    }
  }
  int P[110][15];
  for(int i=0; i<N; i++){
    for(int j=0; j<11; j++){
      cin >> P[i][j];
    }
  }
  int ans=-INFI;
  for(int bit=1; bit<(1<<10); bit++){
    int sum=0;
    for(int i=0; i<N; i++){
      int count=0;
      for(int j=0; j<10; j++){
        if(bit & (1<<j) && shop[i][j]){
          count++;
        }
      }
      sum += P[i][count];
    }
    ans = max(ans, sum);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256