akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define N 301
double dp[N][N][N];

void init()
{
	for(int i=0;i<N;i++)
		for(int j=0;j<N;j++)
			for(int k=0;k<N;k++)
				dp[i][j][k]=-1;
}

double fun(int a,int b,int c,int n)
{
	if(a==0 && b==0 && c==0)
		return 0;
	if(dp[a][b][c]!=-1)
		return dp[a][b][c];

	double res=((double)n)/(a+b+c);
	if(a>0)
	{
		res+=fun(a-1,b,c,n)*((double)a/(a+b+c));
	}	
	if(b>0)
	{
		res+=fun(a+1,b-1,c,n)*((double)b/(a+b+c));
	}
	if(c>0)
	{
		res+=fun(a,b+1,c-1,n)*((double)c/(a+b+c));
	}
	dp[a][b][c]=res;

	return dp[a][b][c];
}

int main()
{
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL); 

	init();

	int n;
	cin>>n;

	int a=0,b=0,c=0;
	for(int i=0;i<n;i++)
	{
		int x;
		cin>>x;
		if(x==1)
			a++;
		else if(x==2)
			b++;
		else
			c++;
	}
	double ans=fun(a,b,c,n);
	cout<<setprecision(15)<<ans;
}

Measured memory_bytes: 213376
import sys
# from collections import defaultdict, deque
import math
# import copy
# from bisect import bisect_left, bisect_right
# import heapq

# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline

getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = 10 ** 20
MOD = 1000000007

def move(cur, deg):
    # print(deg)
    x,y = cur
    x += math.cos(math.radians(deg))
    y += math.sin(math.radians(deg))
    # print(x, y)
    return (x, y)


def solve():
    # print(math.sin(math.radians(90)))
    n = getN()
    eps = 10**-5
    deg = n
    cur = (0, 0)
    ans = 0
    while(True):
        cur = move(cur, deg)
        deg += n
        ans += 1
        cx, cy = cur
        if abs(cx) < eps and abs(cy) < eps:
            print(ans)
            return


def main():
    n = getN()
    for _ in range(n):
        solve()
if __name__ == "__main__":
    # main()
    solve()


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

int main() {
    long n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    for (int i = 0; i < n; i++) {
        if (c * (n - 1 - i) - d * i <= b - a && b - a <= d * (n - 1 - i) - c * i) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(void){
    int N;
    cin >> N;
    int count=0;
    vector<int> num(N);
    for(int i=0;i<N;i++){
        cin >> num.at(i);
        if(num.at(i)%2==1&&(i+1)%2==1){
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 3628
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [input() for _ in range(n)]

n = int(input())
l = list(map(int, input().split()))

if len(l) == len(set(l)):
    print("YES")
else:
    print("NO")




Measured memory_bytes: 31016
#include <iostream>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <iomanip>
#include <fstream>
//#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
const ll INF = (1 << 30);
const ll inf = (1LL << 50LL);
const int  maxn = 1e5 + 5;
int n;
int W;
int w[maxn], v[maxn];
ll dp[101][maxn];
ll rek(int at, int value){
    if(value == 0){
        return 0;
    }
    if(at == -1){
        return inf;
    }
    
    if(dp[at][value] != -1){
        return dp[at][value];
    }
    ll ret = inf;
    if(value - v[at] >= 0){
        ret = min(ret, rek(at - 1, value - v[at]) + w[at]);
    }
    ret = min(ret, rek(at - 1, value));
    return dp[at][value] = ret;
}
int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
//    ifstream cin("in.txt");
    cin >> n >> W;
    for(int i = 0; i < n; i ++){
        cin >> w[i] >> v[i];
    }
    memset(dp, -1, sizeof dp);
    int ret = 0;
//    cout << rek(n - 1,  10) << endl;
    for(int i = 1; i < maxn; i ++){
        if(rek(n - 1, i) <= W){
            ret = i;
        }
    }
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 79232
#include<stdio.h>
#include<algorithm>
#include<queue>
#include<vector>
using namespace std;

struct Call{
    int m,l,k;
    int finish;
    int nextcall;
}call[1010];

int m,t;

int gao(int n){
    priority_queue<int, vector<int>, greater<int> > que;
//    printf("n: %d\n",n);
    int i;
    for(i=0;i<n;i++){
//        printf("push: %d\n",call[i].m);
        que.push(call[i].m);
        call[i].finish=1;
    }
    for(i=n;i<m;i++){
        call[i].finish=0;
        call[i].nextcall=0;
    }
    for(i=1;i<=t;i++){
        int j;
//        printf("time: %d\n",i);
        for(j=0;j<m;j++){
            if(call[j].finish==0 && call[j].nextcall<=i && call[j].nextcall+call[j].l>=i){
                if(que.top()<=i){
                    que.pop();
                    que.push(i+call[j].m);
                    call[j].finish=1;
//                    printf("finish:%d\n",j);
                }else{
                    if(call[j].nextcall+call[j].l==i){
                        call[j].nextcall=i+call[j].k;
//                        printf("next: %d top: %d\n",j,que.top());
                    }
                }
            }
        }
    }
    for(i=0;i<m;i++){
//        printf("%d,%d\n",call[i].finish,call[i].nextcall);
        if(call[i].finish==0) return 0;
    }
    for(i=0;i<n;i++){
        if(que.top()>t) return 0;
        que.pop();
    }
    return 1;
}

int main(void){
    while(1){
        scanf("%d%d",&m,&t);
        if(m==0 && t==0) break;
        int i;
        for(i=0;i<m;i++) scanf("%d%d%d",&call[i].m,&call[i].l,&call[i].k);
        
        for(i=1;i<=m;i++){
            if(gao(i)){
                printf("%d\n",i);
                break;
            }
        }
        
//        int l=0,r=m;
//        while(l!=r){
//            int mid=(l+r)/2;
//            int re=gao(mid);
//            if(re==0) l=mid+1;
//            else r=mid;
//            printf("  %d %d\n",re,mid);
//        }
//        printf("%d\n",r);
    }
}

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

using namespace std;

int main(){
    cin.sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int N, L;
    cin >> N >> L;
    int sum = (L+N+L-1)*N/2;
    int mini = L;
    for(int i = L; i<N+L; i++){
        if(abs(i) <= abs(mini)){
            mini = i;
        }
    }
    sum -= mini;
    cout << sum << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <string>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <array>
#include <set>
#include <climits>
#include <cassert>
#include <bitset>
#include <numeric>
using namespace std;
#define mod 1000000007



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

#ifdef HELL_JUDGE
    freopen("input","r",stdin);
    freopen("output","w",stdout);
    freopen("error","w",stderr);
#endif 
    int n; cin>>n;
    bool ok = true;
    for(int i=0;i<n;++i){
        int x;cin>>x;
        if(x&1){
            continue;
        }
        ok&=((x%3==0)||(x%5==0));
        cerr<<"x = "<<x<<" ok = "<<ok<<endl;
    }
    if(ok){
        cout<<"APPROVED";
    }else{
        cout<<"DENIED";
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define mod 1000000007LL
#define eps 1e-13
// #define PI 3.141592653589793238L
#define INF 1000000011
#define INFLL 1000000000000000011LL
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define mp make_pair
#define F first
#define S second
#define pb push_back
#define fo(i,a,n) for(i = (a); i < (n); i++)
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define sws ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define gcd __gcd
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)((a).size())
#define io_file freopen("D:/Coding Problems/Contest/input_file.in", "r", stdin); freopen("D:/Coding Problems/Contest/output_file.out", "w", stdout)

ll modx(ll Base, ll exponent)
{
	ll ans = 1;
	if(Base == 1)
		return Base;
	while(exponent)
	{
		if(exponent & 1)
			ans = (ans * Base)%mod;
		Base = (Base * Base)%mod;
		exponent = exponent >> 1;
	}
	return ans;
}

ll inmodx(ll num)
{
	return (modx(num, mod-2LL));
}

bool cmp(pair < pii, int > a, pair < pii, int > b)//true for a before b
{
	if(a.F.F/300 < b.F.F/300)
		return 1;
	if(a.F.F/300 > b.F.F/300)
		return 0;
	if(a.F.S < b.F.S)
		return 1;
	if(a.F.S > b.F.S)
		return 0;
	if(a.F <= b.F)
		return 1;
	return 0;
}

const int N = (2e5) + 9;
const int M = (N<<2) + 9;
const int LOGN = ((int)log2(N)) + 3;
const int LOGM = ((int)log2(M)) + 3;
const int BUCK = 2*550;
const int SQRT = BUCK+9;

vll dig, temp;

ll digsum(ll n)
{
	ll ans = 0;
	while(n > 0LL)
	{
		ans += (n%10LL);
		dig.pb(n%10LL);
		n /= 10LL;
	}
	reverse(all(dig));
	return ans;
}

void solve()
{
	int i;
	ll n, ans, val;
	cin >> n;
	ans = digsum(n);
	temp = dig;
	temp[0]--;
	fo(i,1,sz(temp))
		temp[i] = 9LL;
	val = 0;
	for(auto x : temp)
		val += x;
	ans = max(ans, val);
	cout << ans << '\n';
	return;
}

int main()
{
	sws;
	clock_t clk;
	clk = clock();
	// io_file;
	// srand (time(NULL));

	//Code heresfhoffwdsdfsdfsd
	int t = 1, cs;
	cout << fixed << setprecision(9);
	// cin >> t;
	fo(cs,1,t+1)
	{
		// cout << "Case #" << cs << ": ";
		solve();
	}
	// Code ends here

	clk = clock() - clk;
	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  int ans = max(C - (A - B), 0);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=200010;
const double eps=1e-10;
int n,maxf,f[N],o2[N],o5[N],cnt[20][20];
double a[N];
ll ans;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%lf",a+i);
		double ep=eps;
		while(a[i]-(ll)a[i]>=ep&&f[i]<9){
			f[i]++;
			a[i]*=10;
			ep*=10;
		}
		maxf=max(maxf,f[i]);
		while((ll)(a[i]+0.5)%2==0){
			o2[i]++;
			a[i]/=2;
		}
		while((ll)(a[i]+0.5)%5==0){
			o5[i]++;
			a[i]/=5;
		}
	}
	for(int i=1;i<=n;i++){
		while(f[i]<maxf){
			o2[i]++;
			o5[i]++;
			f[i]++;
		}
	}
	maxf*=2;
	for(int i=1;i<=n;i++){
		o2[i]=min(o2[i],maxf);
		o5[i]=min(o5[i],maxf);
		for(int j=maxf-o2[i];j<=maxf;j++)
			for(int k=maxf-o5[i];k<=maxf;k++)
				ans+=cnt[j][k];
		cnt[o2[i]][o5[i]]++;
	}
	printf("%lld\n",ans);
	return 0;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int H, W;
std::string A[110];

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

    std::cin >> H >> W;

    for(int i=0;i<H;++i){
        std::cin >> A[i];
    }

    std::vector<int> rows, columns;
    for(int i=0;i<H;++i){
        if(std::any_of(A[i].begin(), A[i].end(), [](char c){return c == '#';})){
            rows.emplace_back(i);
        }
    }

    for(int j=0;j<W;++j){
        bool flag = false;

        for(int i=0;i<H;++i){
            if(A[i][j] == '#'){
                flag = true;
                break;
            }
        }

        if(flag){
            columns.emplace_back(j);
        }
    }

    for(int i : rows){
        for(int j : columns){
            std::cout << A[i][j];
        }
        std::cout << std::endl;
    }
}


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

using namespace std;

typedef long long int ll;
const ll MOD=1000000007;

ll n,k;
ll dp[1001][1001]={};

int main(){
	scanf("%lld %lld",&n,&k);
	dp[0][0]=1;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=k;j++){
			dp[i][j]+=dp[i-1][j-1];
			if(i>=j)
			dp[i][j]+=dp[i-j][j];
			dp[i][j]%=MOD;
		}
	}
	ll ans=0;
	for(int i=1;i<=k;i++){
		ans=(ans+dp[n][i])%MOD;
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 10972
def main():
    n, k = list(map(int, input().split()))
    mod = 1000000007
    N = list(range(n + 1))
    mn = [0] * (n + 1)
    mx = [0] * (n + 1)
    mx[0] = n
    for i in range(1, n + 1):
        mn[i] = mn[i - 1] + N[i]
        mx[i] = mx[i - 1] + N[n - i]
    ans = 0
    for a, b in zip(mn[k - 1:], mx[k - 1:]):
        ans += b - a + 1
        ans %= mod
    print(ans)

if __name__ == '__main__':
    main()


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

using namespace std;

typedef long long ll;

int main() {
    ll n, m;
    cin >> n >> m;
    if(n >= m / 2) {
        cout << m / 2 << endl;
    } else {
        ll ans = n;
        m -= 2 * n;
        ans += m / 4;
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	// カードの色の種類
	enum Color {
		R, G, B;
	}

	// 勝利条件(ペア数)
	final static int VictoryCondition = 3;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		// 入力回数の入力
		int inputCount = Integer.parseInt(sc.nextLine());

		for (int i = 0; i < inputCount; i++) {
			// 9枚のカードを入力(1行目に数字、2行目に色)
			ArrayList<Card> hand = inputHand(sc.nextLine(), sc.nextLine());

			// 勝利判定・出力
			if (VictoryDecision(hand)) {
				System.out.println("1");
			} else {
				System.out.println("0");
			}
		}

		sc.close();
	}

	// 2行の入力(数字、色)からカードを生成し、リストにして返す
	private static ArrayList<Card> inputHand(String numLine, String colorLine) {
		String[] colorStr = colorLine.split("[\\s]+");
		String[] numStr = numLine.split("[\\s]+");
		ArrayList<Card> hand = new ArrayList<Card>();
		for (int i = 0; i < numStr.length; i++) {
			hand.add(new Card(Integer.parseInt(numStr[i]), Color.valueOf(colorStr[i])));
		}
		return hand;
	}

	// カードリストから3枚1組のペア3つができるか判定
	static boolean VictoryDecision(ArrayList<Card> hand) {
		// 色ごとのリストを作成し、数字を格納する
		ArrayList<Integer> r = new ArrayList<Integer>();
		ArrayList<Integer> g = new ArrayList<Integer>();
		ArrayList<Integer> b = new ArrayList<Integer>();
		for (Card c : hand) {
			switch (c.color) {
			case R:
				r.add(c.num);
				break;
			case G:
				g.add(c.num);
				break;
			case B:
				b.add(c.num);
				break;
			}
		}

		// それぞれのリストからペアの数を判定し、合計が3であるか
		if (VictoryCondition == PairSearch(r) + PairSearch(g) + PairSearch(b)) {
			return true;
		}

		return false;

	}

	// リストからペアを見つけ、ペア数を返す
	static int PairSearch(ArrayList<Integer> list) {
		int pairCount = 0;
		// カードが3枚未満の場合終了
		while (list.size() >= 3) {
			// 昇順にソート
			Collections.sort(list);

			// 連番判定用のリスト内の最小値+1のカードの添え字(ない場合は-1が格納される)
			int secondIndex = Arrays.binarySearch(list.toArray(), list.get(0) + 1);
			// 連番判定用のリスト内の最小値+2のカードの添え字(ない場合は-1が格納される)
			int thirdIndex = Arrays.binarySearch(list.toArray(), list.get(0) + 2);

			// 連番のペアがあるか
			if (secondIndex > 0 && thirdIndex > 0) {
				// ペア数をカウントアップし、ペアをリストから除外
				pairCount++;
				list.remove(thirdIndex);
				list.remove(secondIndex);
				list.remove(0);
				// 同じカードのペアがあるか
			} else if (list.get(0) == list.get(1) && list.get(0) == list.get(2)) {
				// ペア数をカウントアップし、ペアをリストから除外
				pairCount++;
				list.remove(2);
				list.remove(1);
				list.remove(0);
			} else {
				// ペアが見つからないため、リストから除外
				list.remove(0);
			}
		}
		return pairCount;

	}

	// カードクラス(数字、色)
	static class Card {
		int num;
		Color color;

		Card(int num, Color color) {
			this.num = num;
			this.color = color;
		}
	}
}



Measured memory_bytes: 26480
// -D_GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define pi 3.1415926535
#define print(arr,n) for(int i=0;i<n;i++)cout<<arr[i]<<" ";cout<<endl
#define fastio ios_base::sync_with_stdio(false);
#define rep(a,b,in) for(int i=a;i<b;i+=in)
#define LET(x, a)  __typeof(a) x(a)
#define foreach(it, v) for(LET(it, v.begin()); it != v.end(); it++)
#define flush cin.tie(NULL);
using ll = long long int;
#define mod 1000000007
#define S Second
#define F first
#define mp make_pair
#define pb push_back
#define set0(a) memset(a,0,sizeof(a))
using namespace std;

int32_t main(){
	int n,d;
	cin>>n>>d;
	int points[n][d];
	set0(points);
	for(int i=0;i<n;i++){
		for(int j=0;j<d;j++){
			cin>>points[i][j];
		}
	}
	int count = 0;
	for(int i=0;i<n-1;i++){
		for(int j=i+1;j<n;j++){
			double sum = 0;
			for(int k=0;k<d;k++){
				sum += (pow(points[i][k]-points[j][k],2));
			}
			sum = sqrt(sum);
			if((int)(ceil(sum))==(int)(floor(sum))){
				count++;
			}
		}
	}
	cout<<count<<endl;
	return 0;
}

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


#define INF              (int)1000000007
#define EPS              1e-9
#define pb               push_back
#define mp               make_pair
#define all(c)           c.begin(), c.end()
#define forall(i,a,b)    for(int i=a;i<(b);++i)
#define trav(a,x)        for(auto & a: x)
#define in(a,b)          ((b).find(a) != (b).end())
#define sz(c)            (int)(c).size()
#define input(a)         for(auto & x : a) cin >> x;

using namespace std;

typedef vector<int>      vi;
typedef pair<int,int>    ii;
typedef vector<vi>       vvi;
typedef vector<ii>       vii;
typedef long long        ll;

#ifdef DEBUG
#define trace(...)       __f(#__VA_ARGS__, __VA_ARGS__)
#define debug(args...)   {dbg,args; clog<<endl;}
#define print_( a )      for( auto & x : a ) clog << x << ' '; clog << '\n';
#define printPair_( a )  for( auto & x : a ) clog << '(' << x.first << ',' << x.second << ')' << ' '; clog << '\n';
#else
#define trace(...)       
#define debug(args...)            
#define print_( a )               
#define printPair_( a )           
#endif

struct debugger {
  template<typename T> debugger& operator , (const T& x) {    
    clog << x << " ";    return *this;    
  }
}dbg;

template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << ": " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << " | ";
    __f(comma + 1, args...);
}

auto ____ =[]() { std::ios::sync_with_stdio(0); cin.tie(0); return nullptr; }();

int main( int argc, char * argv[] ){
  int n, m; cin >> n >> m; 
  cout << max(0, n-2*m) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define db(x) cout<<#x<<"="<<x<<endl
template<class T>bool maxi(T &a,const T &b){if(a<b){ a=b; return 1;} return 0;}
template<class T>bool mini(T &a,const T &b){if(b<a){ a=b; return 1;} return 0;}
#define y0 y3487465 //y1 j0 j1
#define INF2 4000000000000000037
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
#define EPS 1e(-9);
using namespace std;
typedef long long ll;



void Main(){

    ll N,K; cin>>N>>K;
    ll A[N];
    rep(i,N){
        cin>>A[i];
    }

    ll keta1[42]={};

    rep(i,N){
        rep(j,42){
            if(A[i]>>j &1) ++keta1[j];
        }
    }

    ll ans1,ans2;
    ans1=0; ans2=0;

    repr(i,41,0){ // 余裕karaha1,0入る genならKのけた0or1入る and yo0
        ans1*=2;
        ans2*=2;

        if(K>>i &1){
            if(ans2>0) ans2=max(ans2+max(keta1[i],N-keta1[i]), ans1+keta1[i]);
            else{
                ans2=ans1+keta1[i];
            }
            ans1+=N-keta1[i];
        }
        else{
            if(ans2>0) ans2=ans2+max(keta1[i],N-keta1[i]);
            ans1+=keta1[i];
        }
    }

    cout<< max(ans1, ans2)<<"\n";

}

//-----------------------------------
int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
   string s;
   cin>>s;
  
     int op=0;
     for(int i=0;i<3;i++)
     {
        if(s[i]==s[i+1])
        {
           op++;
         }
     }
     if(op==0)
        cout<<"Good";
  
       else
         cout<<"Bad";
   return 0;
}


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

int main(){
  int N,M;
  cin>>N>>M;

  priority_queue<pair<int,int>> q;
  vector<pair<int,int>> pr(N);
  int i;
  for(i=0;i<N;i++){
    int a,b;
    cin>>a>>b;
    pr.at(i)=make_pair(a,b);
  }

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

  int st=0;
  int j;
  long long ans=0;
  for(i=1;i<=M;i++){
    // bool chek=0;
    for(j=st;j<N;j++){
      if(pr.at(j).first==i){
        // chek=1;
        q.push(make_pair(pr.at(j).second,pr.at(j).first));
      }else{
        break;
      }
    }
    if(!q.empty()){
      ans+=q.top().first;
      q.pop();
    }
    st=j;
  }
  // for(i=0;i<N;i++){
  //   cout<<"f "<<pr.at(i).first<<" s "<<pr.at(i).second<<endl;
  // }
  // while(!q.empty()){
  //   cout<<"f "<<q.top().first<<" s "<<q.top().second<<endl;
  //   q.pop();
  // }


  cout<<ans<<endl;

}


Measured memory_bytes: 2168
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner reader = new Scanner(System.in);
        int[] num = {reader.nextInt(), reader.nextInt(), reader.nextInt()};
        Arrays.sort(num);
        
        System.out.println(num[0] + " " + num[1] + " " + num[2]);
    }
}


Measured memory_bytes: 26208
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;

typedef long long ll;
typedef vector<int> vi;

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

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

    int ans = max(a+b, a-b);
    ans = max(ans, a*b);

    cout << ans << endl;

    return 0;
}

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

int main()
{
	ll X, K, D; cin >> X >> K >> D;
	X = abs(X);

	ll ans;
	if (X / D > K)
	{
		ans = X - D * K;
	}
	else
	{
		ll e = X / D;
		K -= e;
		X -= e * D;
		if (K % 2 == 1) X = abs(X - D);
		ans = X;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  ll i,t,n,j,num,a[3][3];
  for(i=0;i<3;i++)
  {
    for(j=0;j<3;j++)
    cin>>a[i][j];
  }
  cin>>t;
  while(t--)
  {
      cin>>n;
      for(i=0;i<3;i++)
      {
        for(j=0;j<3;j++)
        {
          if(a[i][j]==n)
          a[i][j]=-1;
        }
      }
  }
  for(i=0;i<3;i++)
  {
    num=0;
    num=accumulate(a[i],a[i]+3,num);
    if(num==-3)
    {
      cout<<"Yes";
      return 0;
    }
  }
  for(i=0;i<3;i++)
  {
    num=0;
    for(j=0;j<3;j++)
    {
      num+=a[j][i];
    }
    if(num==-3)
    {
      cout<<"Yes";
      return 0;
    }
  }
  num=0;
  for(i=0;i<3;i++)
  num+=a[i][i];
  if(num==-3)
    {
      cout<<"Yes";
      return 0;
    }
    num=0;
    i=0;j=2;
  while(i!=3)
  {
    num+=a[i][j];
    i++;j--;
  }
  if(num==-3)
    {
      cout<<"Yes";
      return 0;
    }
  cout<<"No";
}


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

int main(){
    char s[4];
    cin>>s;
    int nedan = 700, i;
    for(i=0; i<3; i++){
        if(s[i]=='o'){
            nedan += 100;
        }
    }

    cout<<nedan<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
	int i,j,tmp;
	int x[3];
	for(i=0;i<3;i++){
		scanf("%d",&x[i]);
	}
	for(j=2;j>0;j--){
		for(i=0;i<j;i++){
			if(x[i]>x[i+1]){
				tmp=x[i];
				x[i]=x[i+1];
				x[i+1]=tmp;
			}
		}
	}
	printf("%d %d %d\n",x[0],x[1],x[2]);
	return 0;
}


Measured memory_bytes: 2128
def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()
    
    array_result.append(data.split(" "))

    flg = 1

    try:

        while flg:

            data = input()

            if(data != ""):
                
                array_result.append(data.split(" "))

            else:

                flg = 0
    finally:

        return array_result

arr_data = getinputdata()

n = int(arr_data[0][0])
x = int(arr_data[0][1])

arr=[int(arr_data[1][x]) for x in range(0,n)]

cnt=0

for i in range(n-1):
    
    zan=arr[i]+arr[i+1]-x
     
    if 0<arr[i+1]<=zan:

        cnt+=arr[i+1]
        zan-=arr[i+1]
        arr[i+1]=0

    elif arr[i+1]>zan>0:

        cnt+=zan
        arr[i+1]-=zan
        zan=0

    if 0<arr[i]<=zan:

        cnt+=arr[i]
        zan-=arr[i]
        arr[i]=0

    elif arr[i]>zan>0:

        cnt+=zan
        arr[i]-=zan
        zan=0

    
print(cnt)    

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

#define rep(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rrep(i, a, b) for (int i = (a); i >= (int)(b); i--)
#define all(x) (x).begin(), (x).end()
using i32 = int32_t;
using i64 = int64_t;
using f32 = float;
using f64 = double;
using P = pair<int, int>;

template <class T>
bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    } else {
        return false;
    }
}
template <class T>
bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    } else {
        return false;
    }
}

template <class T>
void dump_vec(const vector<T>& v) {
    auto len = v.size();
    rep(i, 0, len) {
        cout << v[i] << (i == (int)len - 1 ? "\n" : " ");
    }
}

struct FastIO {
    FastIO() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} FASTIO;

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

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

signed main() {
    string s;
    cin >> s;
    cout << (s[0] == '7' || s[1] == '7' || s[2] == '7' ? "Yes" : "No") << "\n";
}


Measured memory_bytes: 3588
import sys
from collections import deque

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007

dxdy4 = ((-1, 0), (0, -1), (0, 1), (1, 0))


def main():
    H, W = map(int, readline().split())
    Ch, Cw = map(int, readline().split())
    Dh, Dw = map(int, readline().split())
    S = [readline().strip() for _ in range(H)]

    Ch -= 1
    Cw -= 1
    Dh -= 1
    Dw -= 1

    dist = [[INF] * W for _ in range(H)]
    dist[Ch][Cw] = 0
    seen = [[False] * W for _ in range(H)]
    queue = deque([(Ch, Cw)])
    while queue:
        x, y = queue.popleft()
        seen[x][y] = True
        for dx, dy in dxdy4:
            nx, ny = x + dx, y + dy
            if (
                0 <= nx < H
                and 0 <= ny < W
                and not seen[nx][ny]
                and (dist[nx][ny] == -1 or dist[nx][ny] > dist[x][y])
                and S[nx][ny] == '.'
            ):
                dist[nx][ny] = dist[x][y]
                queue.appendleft((nx, ny))
        for dx in range(-2, 3):
            for dy in range(-2, 3):
                nx, ny = x + dx, y + dy
                if (
                    0 <= nx < H
                    and 0 <= ny < W
                    and not seen[nx][ny]
                    and dist[nx][ny] > dist[x][y] + 1
                    and S[nx][ny] == '.'
                ):
                    dist[nx][ny] = dist[x][y] + 1
                    queue.append((nx, ny))

    if dist[Dh][Dw] == INF:
        print(-1)
    else:
        print(dist[Dh][Dw])

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 105780
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] A = Enumerable.Range(0, n).Select(a => int.Parse(Console.ReadLine())).ToArray();

            Console.WriteLine(GetLIS(A));
        }

        static int GetLIS(int[] A)
        {
            int n = A.Length, len = 1;
            List<int> L = new List<int>();
            L.Add(A[0]);

            for (int i = 1; i < n; i++)
            {
                if (L[len - 1] < A[i])
                {
                    L.Add(A[i]);
                    len++;
                }
                else
                {
                    int index = LowerBound(L, A[i]);
                    L[index] = A[i];
                }
            }
            return len;
        }

        static int LowerBound(List<int> arr, int val)
        {
            int low = 0, high = arr.Count;
            int mid;

            while (low < high)
            {
                mid = ((high - low) >> 1) + low;
                if (arr[mid] < val) low = mid + 1;
                else high = mid;
            }
            return low;
        }
    }
}

Measured memory_bytes: 11444
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	r := bufio.NewScanner(os.Stdin)
	b := make([]byte, 1000000)
	r.Buffer(b, 1000000)
	r.Scan()
	var S string
	S = r.Text()
	s := make([]string, len(S))
	for i, v := range S {
		s[i] = string(v)
	}
	a := make([]int, len(s))
	var dp [18][100010]int

	for i := 0; i < len(s); i++ {
		if s[i] == "R" {
			dp[0][i] = i + 1
		} else {
			dp[0][i] = i - 1
		}
	}
	for p := 0; p < 17; p++ {
		for i := 0; i < len(s); i++ {
			dp[p+1][i] = dp[p][dp[p][i]]
		}
	}
	for i := 0; i < len(s); i++ {
		a[dp[17][i]]++
	}
	for i := 0; i < len(a); i++ {
		fmt.Printf("%d ", a[i])
	}
	fmt.Println("")

}


Measured memory_bytes: 18816
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<math.h>
#include<string>
#include<stack>
#include<sstream>

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

using namespace std;

map<string,int> data;

int L;
string a;

string add_zero(string str) {
	while (L!=str.size())
	{
		str="0"+str;
	}
	return str;
}

string next_str(string str) {
	int mini,maxi;
	sort(str.begin(),str.end());
	istringstream is1(str);
	is1>>mini;

	sort(str.rbegin(),str.rend());
	istringstream is2(str);
	is2>>maxi;
	ostringstream os;
	os<<(maxi-mini);
	return add_zero(os.str());

}

int str_to_int(string str) {
	int n;
	istringstream is(str);
	is>>n;
	return n;
}

void solve() {
	int cnt=1;
	string str = add_zero(a);
	
	data.clear();
	data.insert(make_pair(str,0));


	str=next_str(str);
	while (true)
	{
		if(data.find(str)!=data.end()) break;

		data.insert(make_pair(str,cnt));
		str=next_str(str);
		cnt++;
	}

	cout<<data[str]<<" "<<str_to_int(str)<<" "<<cnt-data[str]<<endl;

}

int main() {
	while(cin>>a>>L) {
		if(a=="0"&&L==0) return 0;
		solve();
	}

	return 0;
}

Measured memory_bytes: 1264
package main

import (
  "bufio"
  "fmt"
  "os"
  "sort"
  "strconv"
  "strings"
)


func main() {
  var N int
  fmt.Scanf("%d", &N)
  
  var sc = bufio.NewScanner(os.Stdin)
  sc.Scan() 
  
  var vs []float64
  for _, vStr := range strings.Split(sc.Text(), " ") {
    v, _ := strconv.ParseFloat(vStr, 64)
    vs = append(vs, v)
  }
  
  sort.Float64s(vs)
  
  var result float64
  for i, v := range vs {
    switch i {
    case 0:
      result = v
    default:
      result = (result + v) / 2
    }
  }
  
  fmt.Println(result)
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define dbg(x) { cerr<<"> "<<#x<<": "<<x<< endl; }
#define dbg2(x,y) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl; }
#define dbg3(x,y,z) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<" , "<<#z<<": "<<z<<endl; }
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif

const int inf = INT_MAX;
const int MOD = 1e9 + 7;
const int N = 2e5 + 5;



signed main(){
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    #endif  
    IOS;

    string s, t;
    cin >> s >> t;
    int c = 0;
    for (int i = 0; i < 3; i++)
        if (s[i] == t[i]) c++;
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        try (Scanner scanner = new Scanner(System.in)) {
            while (true) {
                int a = scanner.nextInt();
                Operation operation = Operation.fromOperation(scanner.next().charAt(0));
                int b = scanner.nextInt();
                if (operation == Operation.FINISH) {
                    return;
                }
                System.out.println(operation.calc(a, b));
            }
        }
    }
}

enum Operation {
    PLUS('+') {
        @Override
        int calc(int a, int b) {
            return a + b;
        }
    },
    MINUS('-') {
        @Override
        int calc(int a, int b) {
            return  a - b;
        }
    },
    MULTI('*') {
        @Override
        int calc(int a, int b) {
            return a * b;
        }
    },
    DIVISION('/') {
        @Override
        int calc(int a, int b) {
            return a / b;
        }
    },
    FINISH('?') {
        @Override
        int calc(int a, int b) {
            throw new IllegalArgumentException();
        }
    };

    final char op;

    Operation(char op) {
        this.op = op;
    }

    static Operation fromOperation(char c) {
        return Arrays.stream(Operation.values()).filter(op -> op.op == c).findFirst().get();
    }


    abstract int calc(int a, int b);
}

Measured memory_bytes: 32080
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define pi 3.1415926535897932384
#define E9 1000000000

int main(){
  int n,q; cin >> n >> q;
  queue<pair<string,int>> Q;
  rep(i,n){
    string s;
    int t;
    cin >> s >> t;
    Q.push(make_pair(s,t));
  }
  
  int now = 0;

  while (Q.size()>0) {
    auto p = Q.front(); Q.pop();
    if (p.second>q) {
      Q.push(make_pair(p.first, p.second-q)); 
      now += q;
    } 
    else {
      now += p.second;
      cout << p.first << " " << now << endl;
    }
    
  }

  return 0;
}


Measured memory_bytes: 6332
N, M = map(int, input().split())
pref_and_year = []
for i in range(M):
    p, y = map(int, input().split())
    pref_and_year.append((p, y))

sorted_indices = sorted(range(len(pref_and_year)),
                        key=lambda k: pref_and_year[k][1])
sorted_perf_and_year = sorted(pref_and_year, key=lambda x: x[1])
count = [0 for _ in range(N)]
res = []
for i, x in zip(sorted_indices, sorted_perf_and_year):
    count[x[0]-1] += 1
    auth_number = str(x[0]).zfill(6) + str(count[x[0]-1]).zfill(6)
    res.append((i, auth_number))
res = sorted(res, key=lambda x: x[0])
for x in res:
    print(x[1])



Measured memory_bytes: 90584
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  vector<int> p(m),y(m);
  vector<vector<int>> c(n);
  map<int,pair<int,int>> mp;
  for(int i=0;i<m;i++){
    cin >> p[i] >> y[i];
    c[p[i]-1].push_back(y[i]);
  }
  for(int i=0;i<n;i++){
    sort(c[i].begin(),c[i].end());
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<c[i].size();j++){
      mp[c[i][j]]=make_pair(i+1,j+1);
    }
  }
  for(int i=0;i<m;i++){
    printf("%06d%06d\n",mp[y[i]].first,mp[y[i]].second);
  }
}

Measured memory_bytes: 13952
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mii map <int, int>
#define mll map <ll, ll>
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vi vector <int>
#define vd vector <double>
#define vll vector <ll>
#define fi first
#define se second
#define si set <int>
#define sll set <ll>
#define spii set <pii>
#define vs vector <string>
#define vpii vector <pair <int,int> >
#define vpll vector <pair <long long,long long> >
#define vvi vector <vector <int> >
#define vvpii vector <vector <pii > >
#define vb vector <bool>
#define vvb vector <vb>
#define mp make_pair
#define vvll vector <vll>
#define vsi vector <si>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define MANX MAXN
#define itn int
#define in(x); { for (auto &to : x) cin>>to;}
#define out(x); { for (auto &to : x) cout<<to<<" ";cout<<'\n'; }

const ll INFLL = 1e18;
const int MAXN = 1e6+100;
const ll INF = 1e9;
const ll mod1=1e9+7;
const ll mod2=2e9+11;

void solve()
{
    string s;
    cin>>s;
    if (s.back()=='s')
        cout<<s+"es";
    else
        cout<<s+"s";
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    #ifdef Mip182
    freopen("a.in","r",stdin);
    #endif
    int _t;
    _t=1;
  //  cin>>_t;
    while (_t--)
        solve();
    //n=1 ?
    //recursion - matrix exponential
    //linear algebra - just a joke
    //check ios_base, MAXN, mod1 before submit
    //if debug more than 15 minutes - write stress
    //compression
}

Measured memory_bytes: 3652
#include <string>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <cmath>
#include <limits>
#include <tuple>
#include <queue>
#include <stack>

using namespace std;
typedef long long ll;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()

int main()
{
	int A, B;
	cin >> A >> B;
	string ans = (A <= 8 && B <= 8) ? "Yay!" : ":(";
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
using namespace std;
const int maxn = 101;
char g[maxn][maxn];
int d[4][2] = {0 , 1 , 1 , 0 , 0 , -1 , -1 ,0};
void dfs(int si , int sj , int n , int m , char ch)
{
    g[si][sj] = '1';
    for(int i = 0 ; i < 4 ; i ++){
        int x = si + d[i][0];
        int y = sj + d[i][1];
        if(x < 0 || x >= n || y < 0 || y >= m || g[x][y] != ch) continue;
        dfs(x , y , n , m , ch);
    }
}

int main()
{
    #ifdef DoubleQ
    freopen("in.txt" , "r" , stdin);
    #endif // DoubleQ
    int n , m;
    while(cin >> n >> m){
        if(n == 0 && m == 0) break;

        string str;
        for(int i = 0 ; i < n ; i ++){
            cin >> str;
            for(int j = 0 ; j < m ; j ++){
                g[i][j] = str[j];
            }
        }
        int cnt = 0;
        /*
        for(int i = 0 ; i < n ;i ++){
            for(int j = 0 ; j < m ; j ++){
                cout << g[i][j] << " ";
            }
            cout << endl;
        }
        */

        for(int i = 0 ; i < n ; i ++){
            for(int j = 0 ; j < m ; j ++){
                if(g[i][j] != '1'){
                    dfs(i , j , n , m , g[i][j]);
                    cnt ++;
                }
            }
        }
        cout << cnt << endl;

    }
}

Measured memory_bytes: 1996
import sys
import math
def i():return int(sys.stdin.readline().replace("\n",""))
def i2():return map(int,sys.stdin.readline().replace("\n","").split())
def s():return str(sys.stdin.readline().replace("\n",""))
def l():return list(sys.stdin.readline().replace("\n",""))
def intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def strl():return [str(k) for k in sys.stdin.readline().replace("\n","").split()]
def lx():return list(map(lambda x:int(x)*-1,sys.stdin.readline().replace("\n","").split()))
def t():return tuple(map(int,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":pass
n = i()
a = intl()
A = list(set(a))
d = {}
c = 0
def f(c):
    return (c*(c-1))//2
for i in range(n):
    try:
        d[a[i]] += 1
    except KeyError:
        d[a[i]] = 1
for i in A:
    c += f(d[i])
for i in range(n):
    t = d[a[i]]
    if t > 1:
        print(c-t+1)
    else:
        print(c)

Measured memory_bytes: 26760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > pi;
typedef pair< ll,ll > pll;
typedef vector <pi> vii;
typedef vector < ll > vll;
typedef vector< vll > vvll;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)
#define present(c,x) (c.find(x) != c.end())
#define cpresent(c,x) (find(all(c),x) != c.end())
#define REP(i,a,b) for(int i =a;i<b;i++)


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string v;
	int problems, veredicts,p;
	  cin >> problems >> veredicts;
	vi answer(problems);
ll penalty = 0;
ll ans =0;
	REP(i,0,veredicts){
		cin >> p >> v;
		if(answer[p-1]!=-1){
			if(v=="AC"){
				penalty+=answer[p-1];
				ans++;
				answer[p-1]=-1;
			}
			else{
				answer[p-1]++;
			}
		}
	}

	cout << ans << " " << penalty << "\n";
	
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int ans=1,k,n;
int main(){
	scanf("%d%d",&n,&k);
	while(n--){
       /// printf("%d %d\n",ans,k);
		ans+=min(ans,k);
	}
	printf("%d",ans);
	return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define F first
#define S second
#define M 1000000007
#define SI(x) scanf("%d", &x)
#define PI(x) printf("%d\n", x)
#define SL(x) scanf("%I64d", &x)
#define PL(x) printf("%I64d\n", x)
#define PB push_back
#define MP make_pair

using namespace std;

int main()
{
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;

    cout << char(toupper(s1[0])) << char(toupper(s2[0])) << char(toupper(s3[0])) << endl;
}


Measured memory_bytes: 256
r, c = map(int, raw_input().split(" "))
table1 = [[0 for j in range(c)] for i in range(r)]
for i in range(r):
    table1[i] = map(int, raw_input().split(" "))

table2 = [0 for j in range(c+1)]
ans = ""
for i in range(r):
    tmp = 0
    for j in range(c):
        ans += str(table1[i][j]) + " "
        tmp += table1[i][j] 
        table2[j] += table1[i][j]
    ans += str(tmp) + "\n"
for j in range(c+1):
    ans += str(table2[j])
    table2[c] += table2[j]
    if j!=c:
        ans += " "

print ans

Measured memory_bytes: 6516
import java.util.Scanner;
import java.util.regex.Pattern;


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

		Scanner sc = new Scanner(System.in);


		int n = sc.nextInt();
		int k = sc.nextInt();
		char d[] = new char[k];

		String s="";
		String f="";

	    for (int i = 0; i < k ;i++){
	    	f += sc.next();
	    	if(i+1 !=k)f += "|";

	    }


	    Pattern p = Pattern.compile(f);

		for (; ;) {
			s = String.valueOf(n);

			if(!p.matcher(s).find()){
				break;
			}

			n++;
		}

		System.out.println(n);




		sc.close();
	}
}


Measured memory_bytes: 18564
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func readInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := readInt()
	for i := 0; i < n; i++ {
		a := readInt()
		if a%2 == 0 {
			if !(a%3 == 0 || a%5 == 0) {
				fmt.Println("DENIED")
				return
			}
		}
	}
	fmt.Println("APPROVED")
}


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

int main()
{
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    bool flag = false;
    for (int i = 0; i < k; i++)
    {
        for (int j = 0; j < k - i; j++)
        {
            if (pow(2, i) * a < pow(2, j) * b && pow(2, j) * b < pow(2, k - i - j) * c)
            {
                flag = true;
                break;
            }
        }
    }
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


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

int main() {
    string s;
    cin>>s;
    int ans=0;
    rep(i,4) {
        if (s[i]=='+') ans++;
        else ans--;
    }
    cout<<ans<<endl;
} 


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

using namespace std;

#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const ll MAX = 1000000;
static const ll INFTY = 1e12;
static const ll MOD = 1000000007;

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };

struct edge {
    ll to, cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;


const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

// 深さ優先探索
vector<bool> seen;
vector<int> colors;

int H, W, N;
int sx, sy, gx, gy; 
vector<vector<char>> field;
vector<vector<int>> dist;
//vector<pair<int, int>> gx, gy;
deque<pair<int, int>> que;

typedef vector<vector<int> > Matrix;

const int INF = 100000000;


int main() {

    int N;
    cin >> N;

    while(N>0){

        if(N - ((N / 10) * 10) == 7){
            cout << "Yes";
            return 0;
        }

        N /= 10;
    }

    cout << "No" << endl;
    return 0;


}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/


Measured memory_bytes: 3604
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
import copy
C = copy.deepcopy(A)

for i in reversed(range(N)):
    if B[i] <= A[i+1]:
        A[i+1] = A[i+1] - B[i]
        B[i] = 0
    else:
        B[i] = B[i] - A[i+1]
        A[i+1] = 0
    if B[i] <= A[i]:
        A[i] = A[i] - B[i]
        B[i] = 0
    else:
        B[i] = B[i] - A[i]
        A[i] = 0
S, E = 0, 0
for i in range(N+1):
    S += C[i]
    E += A[i]
print(S - E)

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

int a[21], n, h, sol;
bool sees;

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> h;
		a[i] = h;
		sees = true;
		for (int j = 0; j < i; j++){
			if (a[j] > h){
				sees = false;
				break;
			}
		}
		if (sees){
			sol += 1;
		}
	}
	cout << sol;
	return 0;
}

Measured memory_bytes: 256