akhauriyash/Code-Regression huggingface dataset:
N,A,B,C=map(int,input().split())
S=[]
for i in range(N):
    S.append(input())

if A+B+C!=2:
    ans=[]
    for i in range(N):
        s=S[i]
        if s=="AB":
            if A>B:
                ans.append("B")
                A-=1
                B+=1
            else:
                ans.append("A")
                A+=1
                B-=1
        elif s=="BC":
            if B>C:
                ans.append("C")
                B-=1
                C+=1
            else:
                ans.append("B")
                B+=1
                C-=1
        else:
            if A>C:
                ans.append("C")
                A-=1
                C+=1
            else:
                ans.append("A")
                A+=1
                C-=1
        if min(A,B,C)<0:
            print("No")
            exit()

    print("Yes")
    for i in range(N):
        print(ans[i])
else:
    ans=[]
    for i in range(N):
        s=S[i]
        if s=="AB":
            if A>B:
                ans.append("B")
                A-=1
                B+=1
            elif A==B and i!=N-1:
                ns=S[i+1]
                if ns=="AC":
                    ans.append("A")
                    A+=1
                    B-=1
                elif ns=="BC":
                    ans.append("B")
                    A-=1
                    B+=1
                else:
                    ans.append("A")
                    A+=1
                    B-=1
            else:
                ans.append("A")
                A+=1
                B-=1
        elif s=="BC":
            if B>C:
                ans.append("C")
                B-=1
                C+=1
            elif C==B and i!=N-1:
                ns=S[i+1]
                if ns=="AC":
                    ans.append("C")
                    C+=1
                    B-=1
                elif ns=="AB":
                    ans.append("B")
                    C-=1
                    B+=1
                else:
                    ans.append("C")
                    C+=1
                    B-=1
            else:
                ans.append("B")
                B+=1
                C-=1
        else:
            if A>C:
                ans.append("C")
                A-=1
                C+=1
            elif A==C and i!=N-1:
                ns=S[i+1]
                if ns=="BC":
                    ans.append("C")
                    C+=1
                    A-=1
                elif ns=="AB":
                    ans.append("A")
                    A+=1
                    C-=1
                else:
                    ans.append("A")
                    A+=1
                    C-=1
            else:
                ans.append("A")
                A+=1
                C-=1
        if min(A,B,C)<0:
            print("No")
            exit()
    print("Yes")
    for i in range(N):
        print(ans[i])

Measured memory_bytes: 85556
#include <bits/stdc++.h>
#define int long long
using namespace std;

vector<vector<int>> dist;
const int INF=10000000000;
void warshall_floyd(int N){
	for(int i=0;i<N;i++)dist[i][i]=0;
	for(int k=0;k<N;k++){
		for(int i=0;i<N;i++){
			for(int j=0;j<N;j++){
				dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
			}
		}
	}
}


signed main(){
	int N,M,R; cin>>N>>M>>R;
	vector<int> town(R);
	for(int i=0;i<R;i++){cin>>town[i]; town[i]--;}
	dist.assign(N,vector<int>(N,INF));
	for(int i=0;i<M;i++){
		int A,B,C; cin>>A>>B>>C; A--; B--;
		dist[A][B]=C;
		dist[B][A]=C;
	}
	warshall_floyd(N);
	sort(town.begin(),town.end());
	int ans=10000000000;
	do{
		int start=town[0];
		int tmp_dist=0;
		for(int i=1;i<R;i++){
			tmp_dist+=dist[start][town[i]];
			start=town[i];
		}
		ans=min(tmp_dist,ans);

	}while(next_permutation(town.begin(),town.end()));

	cout<<ans<<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;
const int maxN = 190;
int dp[maxN][maxN][maxN][15];
char s[maxN];
int N, M, a[maxN][maxN];
int main() {
	scanf("%d %d", &N, &M);
	for(int i = 1; i <= N; ++i) {
		scanf("%s", s + 1);
		for(int j = 1; j <= M; ++j)
		if(s[j] == '.') a[i][j] = 0;
		else a[i][j] = 1;
		for(int j = 1; j <= M; ++j)
		a[i][j] = a[i][j - 1] + a[i - 1][j] - a[i - 1][j - 1] + a[i][j];
	}
	for(int i = 1; i <= N; ++i) {
		for(int j = 1; j <= M; ++j) 
		for(int k = j; k <= M; ++k) {
			int ans = i - 1;
			int l = i, r = N;
			while(l <= r) {
				int mid = (l + r) >> 1;
				int sum = a[mid][k] - a[i - 1][k] - a[mid][j - 1] + a[i - 1][j - 1];
				// (i..mid) (j..k)
				if(sum == 0 || sum == (mid - i + 1) * (k - j + 1))
				ans = max(ans, mid), l = mid + 1;
				else r = mid - 1;
			}
			dp[i][j][k][0] = ans;
		}
	}
	int k = 0;
	for(k = 1; dp[1][1][M][k - 1] < N; ++k) 
	for(int w = 1; w <= M; ++w) 
	for(int i = 1; i <= N; ++i) 
	for(int l = 1; l + w - 1 <= M; ++l) {
		int r = l + w - 1;
		if(dp[i][l][r][k - 1] == N) {dp[i][l][r][k] = N; continue;}
		dp[i][l][r][k]=dp[dp[i][l][r][k-1] + 1][l][r][k - 1];
		if(dp[i][l][r][k] == N) continue;
		int L = l, R = r - 1, ans = 0;
		while(L <= R) {
			int mid = (L + R) >> 1;
			int num1 = dp[i][l][mid][k - 1], num2 = dp[i][mid + 1][r][k - 1];
			ans = max(ans, min(num1, num2));
			if(num1 < num2) R = mid - 1;
			else L = mid + 1; 
		}
		dp[i][l][r][k] = max(dp[i][l][r][k], ans);
	}
	cout << k - 1 << endl;
	return 0;
}

Measured memory_bytes: 393728
import heapq

n, m = map(int, input().split())
lis = []
for i in range(m + 1):
    lis.append([])

for i in range(n):
    a, b = map(int, input().split())
    if a <= m:
        lis[a].append(-b)

cnd = []
heapq.heapify(cnd)
res = 0

for j in range(1, m + 1):
    for e in lis[j]:
        heapq.heappush(cnd, e)
    if cnd:
        res += -heapq.heappop(cnd)
print(res)


Measured memory_bytes: 17600
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }
void Taka() { cout << "Takahashi" << endl; }
void Aoki() { cout << "Aoki" << endl; }
void digit(int d) { cout << fixed << setprecision(d); }
void IOup() { cin.tie(0); ios::sync_with_stdio(false); }

int a[200010];

int main() {
	int n, k, b;
	cin >> n >> k;
	for (int i = 0; i < n; ++i) {
		cin >> b;
		a[b]++;
	}
	sort(a, a + n + 1, greater<int>());
	int m = 0;
	for (int i = 0; ; ++i) {
		if (a[i] == 0)
			break;
		m++;
	}

	int ans = 0;
	for (int i = 0; i < m - k; ++i) {
		ans += a[m - i - 1];
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int mxn = 1e5 + 5;
int mod = 1e9 + 7;
vector < int > v[mxn];
int add(int x, int y){
	return (long long)(x + y) % mod;
}
int mul(int x, int y){
	return (long long) x * y % mod;
}
pair < int , int > dfs(int x, int p){
	int all_white = 1;
	int sth_black = 0;
	for(int i = 0; i < v[x].size(); i ++){
		if(v[x][i] != p){
			pair < int , int > p = dfs(v[x][i] , x);
			int cur_white = p.second;
			int cur_black = p.first;
			int cur_all = add(cur_black , cur_white);
			sth_black = add(mul(all_white , cur_black) , mul(sth_black , cur_all));
			all_white = mul(all_white , cur_white);
		} 
	}
	return make_pair(all_white , add(all_white , sth_black));
}
int main(){
	int n;
	cin >> n;
	for(int i = 1; i < n; i ++){
		int a, b;
		cin >> a >> b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	pair < int , int > ans = dfs(1 , 0);
	int res = add(ans.first , ans.second);
	cout << res << "\n";
}

Measured memory_bytes: 12672
s = gets.chomp
n = gets.to_i

head = Array.new(2*(10**5))
h = 0
tail = Array.new(2*(10**5))
t = 0

r = false
n.times do
    q = gets.split
    if q[0] == "1"
        r = !r
    else
        if (!r && q[1] == "1") || (r && q[1] == "2")
            head[h] = q[2]
            h += 1
        else
            tail[t] = q[2]
            t += 1
        end
    end
end

if r 
    print tail.join.reverse
    print s.reverse
    print head.join
    puts
else
    print head.join.reverse
    print s
    print tail.join
    puts
end

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

int main(){
    int n;cin>>n;
    for(int i=0;i<30;i++){
        for(int j=0;j<30;j++){
            if(4*i+7*j==n){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
    return 0;
}

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

const int MAX_N = 105;

int f[MAX_N][MAX_N][MAX_N], g[MAX_N][MAX_N][MAX_N];
int H, W, A[MAX_N][MAX_N], eX, eY;

inline void update(int &x, int y) {
  if (x < y) x = y;
}

inline int get_num(int a, int b, int c, int d) {
  if (a > c || b > d) return 0;
  return A[c][d] - A[a - 1][d] - A[c][b - 1] + A[a - 1][b - 1];
}

int main() {
  scanf("%d%d", &H, &W);
  for (int i = 1; i <= H; ++i) {
    static char S[MAX_N];
    scanf("%s", S + 1);
    for (int j = 1; j <= W; ++j) {
      A[i][j] = A[i - 1][j] + A[i][j - 1] - A[i - 1][j - 1] + (S[j] == 'o');
      if (S[j] == 'E') eX = i, eY = j;
    }
  }

  f[0][0][0] = 0;
  int res = 0;
  for (int i = 0; i < H; ++i) {
    memset(g, 0, sizeof g);
    for (int j = 0; j + i <= H; ++j)
      for (int k = 0; k < W; ++k)
	for (int m = 0; m + k <= W; ++m) {
	  res = max(res, f[j][k][m]);
	  int U = i + 1, D = H - j, L = k + 1, R = W - m;
	  int u = eX - j, d = eX + i, l = eY - m, r = eY + k;
	  if (U > D || L > R) continue;
	  if (d + 1 <= D && d + 1 >= U) update(g[j][k][m], f[j][k][m] + get_num(d + 1, max(L, l), d + 1, min(R, r)));
	  if (u - 1 >= U && u - 1 <= D) update(f[j + 1][k][m], f[j][k][m] + get_num(u - 1, max(L, l), u - 1, min(R, r)));
	  if (r + 1 <= R && r + 1 >= L) update(f[j][k + 1][m], f[j][k][m] + get_num(max(U, u), r + 1, min(D, d), r + 1));
	  if (l - 1 >= L && l - 1 <= R) update(f[j][k][m + 1], f[j][k][m] + get_num(max(U, u), l - 1, min(D, d), l - 1));
	}
    memcpy(f, g, sizeof f);
  }

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

Measured memory_bytes: 9344
#include<bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define P pair<int , int>
#define V vector<int>
#define M map<int, int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>
int search(int a, int b, int h[]){

    if(b < a)	return 0;
  	int res = 0;
 	while(true){

	  for(int i = a ; i <= b ; i++)
	 	if(!h[i])	return res + search(a , i - 1 , h) + search(i + 1 , b , h);

      res += 1;
	  for(int i = a ; i <= b ; i++)
	 	h[i] -= 1;
	}
}
	
int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
	int N;	cin >> N;
	int h[100];
  	for(int i = 0; i < N ; i++)	cin >> h[i];

	cout << search(0 , N - 1 , h) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  if ((s[0] == s[1]) && (s[1] == s[2]))
  {
    cout<<"No"<<endl;
  }
  else 
  {
    cout<<"Yes"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <fstream>
#include <queue>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <sstream>
#include <math.h>
#include <functional>

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

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
#define SORT(c) sort((c).begin(),(c).end())
#define vi(m,a) vector<int> m(a)
#define vti(m,a,i) vector<vector<int>> m(a,vector<int>(i))
#define ALL(it,a) for(auto it = a.begin(); it!=a.end(); it++)
#define Fe(it,a) for(auto &it : a)
#define all(a) begin(a),end(a)

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
#define WARU 1000000007

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

int main() {
	int n, m; cin >> n >> m;
	priority_queue<int> que;
	rep(i, n) {
		int tmp;
		cin >> tmp;
		que.push(tmp);
	}

	rep(i, m) {
		int top = que.top();
		que.pop();
		que.push(top / 2);
	}
	ll res = 0;
	while(!que.empty()){
		int top = que.top();
		que.pop();
		res += top;
	}
	cout << res << endl;


}



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

int main(){
    ll N;
    cin >> N;
    vector<pair<ll,ll>> bot(N);
    ll X,L;
    rep(i,N){
        cin >> X >> L;
        bot[i] = make_pair(X+L,X-L);
    }
    sort(bot.begin(),bot.end());
    ll ans = 0;
    ll now = -1000000001;
    for(int i=0;i<N;i++){
        if(now<=bot[i].second){
            ans++;
            now = bot[i].first;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
int main(){
  ll n,k;
  cin>>n>>k;
  if(500*n>=k) COUT("Yes");
  else COUT("No");
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  long long int n, k;
  cin >> n >> k;
  k = (k+2)%11;
  long long int ans = 0, t = max(0LL,n/11 - 1);
  n -= max(0ll,t)*11;
  for(int i = 1; i <= 11; ++i){
    for(int j = 1; j < 6; ++j){
      if((9*(7*i+j))%11 == k){
        ++ans;
      }
    }
  }
  ans *= t;
  for(int i = 1; i < n-1; ++i){
    for(int j = 1; j < 6; ++j){
      if((9*(7*i+j))%11 == k){
        ++ans;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

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

int main(){
    int N, K; cin >> N >> K;
    int A[N]; rep(i, N) cin >> A[i];
    int S = 0; rep(i, N) S += A[i];

    vector<int> sdiv; int D = 0;
    for(int x = 1; x*x <= S; x++){
        if (S % x == 0){ sdiv.push_back(x); sdiv.push_back(S / x); D += 1;}
    }

    for(int j = 0; j < D; j++){
        int div = sdiv[j * 2 + 1];
        int mod[N];
        rep(i, N) mod[i] = A[i] % div; 
        sort(mod, mod + N);

        int T[N]; T[0] = mod[0];
        rep(i, N-1) T[i+1] = T[i] + mod[i+1]; 
        int c = T[N-1] / div; //cout << "div="<<div<<", c="<<c<<endl;
        if (T[N - c - 1] <= K){
            cout << div << endl;
            return 0;
        }
    }

    for(int j = D-1; j >= 0; j--){
        int div = sdiv[j * 2];
        int mod[N];
        rep(i, N) mod[i] = A[i] % div; 
        sort(mod, mod + N);

        int T[N]; T[0] = mod[0];
        rep(i, N-1) T[i+1] = T[i] + mod[i+1]; 
        int c = T[N-1] / div; //cout << "div="<<div<<", c="<<c<<endl;
        if (T[N - c - 1] <= K){
            cout << div << endl;
            return 0;
        }
    }
    
    cout << 1 << endl;
}

Measured memory_bytes: 888
fun main(args: Array<String>) {
    val (n,m) = readLine()!!.split(" ").map { it.toInt() }
    val map = mutableMapOf<Int, Int>()
    var a = Array(m) {i -> i+1}.forEach { map[it] = 0 }
    for (i in 0 until n) {
        val numbers = readLine()!!.split(" ").map { it.toInt() }
        for (j in 1..numbers[0]) {
            val i1 = map[numbers[j]]!!
            map[numbers[j]] = i1 + 1
        }
    }
    println(map.values.count{ it == n })
}



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

int main(){
	int H, W, i, j;
	scanf("%d%d", &H, &W);
	vector<string> S(H + 2, string(W + 2, '#'));
	for(i = 1; i <= H; i++){
		string sub;
		cin >> sub;
		for(j = 1; j <= W; j++){
			S[i][j] = sub[j - 1];
		}
	}
	vector<vector<int>> L(H + 2, vector<int>(W + 2, 0));
	vector<vector<int>> R(H + 2, vector<int>(W + 2, 0));
	vector<vector<int>> U(H + 2, vector<int>(W + 2, 0));
	vector<vector<int>> D(H + 2, vector<int>(W + 2, 0));
	for(i = 1; i <= H; i++){
		for(j = 1; j <= W; j++){
			if(S[i][j] == '.'){
				L[i][j] = L[i][j - 1] + 1;
				U[i][j] = U[i - 1][j] + 1;
			}
		}
	}
	for(i = H; i > 0; i--){
		for(j = W; j > 0; j--){
			if(S[i][j] == '.'){
				R[i][j] = R[i][j + 1] + 1;
				D[i][j] = D[i + 1][j] + 1;
			}
		}
	}
/*	printf("L:\n");
	for(i = 0; i <= H + 1; i++){
		for(j = 0; j <= W + 1; j++){
			printf("%d ", L[i][j]);
		}
		printf("\n");
	}
	printf("R:\n");
	for(i = 0; i <= H + 1; i++){
		for(j = 0; j <= W + 1; j++){
			printf("%d ", R[i][j]);
		}
		printf("\n");
	}
	printf("U:\n");
	for(i = 0; i <= H + 1; i++){
		for(j = 0; j <= W + 1; j++){
			printf("%d ", U[i][j]);
		}
		printf("\n");
	}
	printf("D:\n");
	for(i = 0; i <= H + 1; i++){
		for(j = 0; j <= W + 1; j++){
			printf("%d ", D[i][j]);
		}
		printf("\n");
	}
*/	int ans = 0;
	for(i = 1; i <= H; i++){
		for(j = 1; j <= W; j++){
//			printf("(i, j) = (%d, %d)\n", i, j);
			if(S[i][j] == '.'){
//				printf("(%d, %d, %d, %d)\n", L[i][j - 1], R[i][j + 1], U[i - 1][j], D[i + 1][j]);
				ans = max(ans, L[i][j - 1] + R[i][j + 1] + U[i - 1][j] + D[i + 1][j] + 1);
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

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

int main() {

    int n;
    cin >> n;

    long long mn = 10000000000;
    long long mx = 0 - 10000000000;
    long long r;

    for (int i = 0; i < n; i++) {
        cin >> r;
        mx = max(mx, r - mn);
        mn = min(mn, r);
    }

    cout << mx << endl;

    return 0;

}


Measured memory_bytes: 3120
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter
from operator import mul
from functools import reduce

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

a.sort()

count = Counter(a)

b = [1 for i in range((max(a) + 1))]

for aa in a:
    for j in range(2*aa,len(b), aa):
        b[j] = 0

c = 0
for d in count.items():
    if d[1] == 1 and b[d[0]] == 1: c += 1

print(c)

Measured memory_bytes: 41356
n,y = map(int,input().split())
ans = [-1,-1,-1]
cnt = 0

for i in range(n+1):
    if cnt == 1:
        break
        
    for j in range(n-i+1):
        k = n-i-j
        
        if i*10000 + j*5000 + k*1000 == y:
            ans = [i,j,k]
            cnt += 1
            break
                
print(*ans,sep=" ")

Measured memory_bytes: 40684
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        java.io.PrintStream out = System.out;
        int a = scan.nextInt();
        String s = scan.next();
        if (a >= 3200) {
            out.println(s);
        } else {
            out.println("red");
        }
    }
}


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

int main() {
    string n;
    cin >> n;

    for(int i = 0; i < n.size(); i++) {
        if (n.at(i) == '7') {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
}

Measured memory_bytes: 3620
#include<iostream>
#include<string>
using namespace std;
typedef long long ll;
const int N = 1e7+600;
int main(){
    int a,b;
    cin>>a>>b;
    if(b%a == 0){
      cout<<a+b<<endl;
    }else{
      cout<<b -a <<endl;
    }
}


Measured memory_bytes: 256
import java.util.*;

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

        int a = sc.nextInt();
        int b = sc.nextInt();

        if((a * b) % 2 == 0) System.out.println("Even");
        else System.out.println("Odd");
    }
}

Measured memory_bytes: 22228
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double lld;

#define forn(i,n) for(ll i = 0;i<n;i++)
#define forne(i,j,n) for(ll i = j;i<n;i++)
const ll mod = 1e9+7;
const ll mod2 = 998244353;
const ll INF = 1000000001;
const ll N = 100001;
const lld PI = 3.141593;
#define F first
#define pb(a) push_back(a)
#define S second
#define pii pair<int,int>
typedef pair<ll,ll> pll;

ll powm(ll base,ll exp) {
	ll ans=1;
	while(exp){
		if(exp&1) ans=(ans*base)%mod;
		exp>>=1,base=(base*base)%mod;
	}
	return ans;
}

// ll dir[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
// bool valid(ll i, ll j) {
// 	return i >= 1 && i <= n && j >= 1 && j <= m; 
// }
// int maxdepth = INT_MAX;
// vector<int> edgeVector[100000];
// ll minans = 1;
// printf("1 %d D\n",abs(r));
// priority_queue<ll,vector<ll>,greater<ll>> pq;
// ll a[N],b[N];
// vector<vector<ll>> adj(N);
// vector<set<ll>> adjs(N);
// ll adj[1001][1001];
// vector<vector<ll>> ans(1001);
// bool visited[N];
// ll cnt[1001];
// ll h,c,t;
// vector<pair<int, pair<int, int> > > g[300043];



int main(){
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output1.txt", "w", stdout);
#endif
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

ll n,m,k;
cin>>n>>m>>k;
char a[n][m];
forn(i,n) forn(j,m) cin>>a[i][j];
ll fa = 0;
forne(i,0,(ll)pow(2ll,n)){
	ll p =i;
	set<ll> rs;
	forne(t,0,n){
		if((p&1) == 1){
			rs.insert(t);
		}
		p = p>>1;
	}
	forne(j,0,(ll)pow(2ll,m)){
		ll q = j;
		set<ll> cs;
		forne(t,0,m){
			if((q&1) == 1){
				cs.insert(t);
			}
			q = q>>1;
		}
		ll cur_k = 0;
		forn(e,n){
			if(rs.find(e) != rs.end()) continue;
			forn(w,m){
				if(cs.find(w) != cs.end()) continue;
				if(a[e][w] == '#') cur_k++;
			}
		}
		if(cur_k == k) {
			// cout<<rs.size()<<" "<<cs.size()<<" "<<cur_k<<endl;
			fa++;
		}
	}
}
cout<<fa<<endl;
}

Measured memory_bytes: 4080
var N,M,i,c,x,y:Longint;
A,B:Array[1..100000]of Longint;
begin
read(N,M);
for i:=1 to N do A[i]:=1;
B[1]:=1;
for i:=1 to M do begin
read(x,y);
dec(A[x]);
inc(A[y]);
if B[x]=1 then B[y]:=1;
if A[x]=0 then B[x]:=0;
end;
for i:=1 to N do inc(c,B[i]);
writeln(c);
end.


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

public class Main {
	boolean check(int[] a) {
		int n = a.length;
		if (a.length % 2 == 0) {
			int k = 1;
			for (int i = 0; i < n; i++) {
				if (a[i] != k) {
					return false;
				}
				if (i % 2 != 0) {
					k += 2;
				}
			}
		} else {
			int k = 0;
			for (int i = 0; i < n; i++) {
				if (a[i] != k) {
					return false;
				}
				if (i % 2 == 0) {
					k += 2;
				}
			}
		}
		return true;
	}

	long pow(int k, long MOD) {
		if (k == 0) {
			return 1;
		}
		long t = pow(k / 2, MOD);
		t *= t;
		t %= MOD;
		if (k % 2 != 0) {
			t *= 2;
			t %= MOD;
		}
		return t;
	}

	void run() {
		Scanner sc = new Scanner(System.in);

		long MOD = 1_000_000_000 + 7;
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		Arrays.sort(a);
		if (check(a)) {
			System.out.println(pow(n / 2, MOD));
		} else {
			System.out.println(0);
		}
	}

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


Measured memory_bytes: 33392
#include<bits/stdc++.h>
#define R register
#define ha 1000000007
using namespace std;

const int S=(1<<20)+5;
char buf[S],*H,*T;
inline char Get()
{
	if(H==T) T=(H=buf)+fread(buf,1,S,stdin);
	if(H==T) return -1;return *H++;
}
template<typename I> inline void read(I &x)
{
	x=0;char c=Get();
	while(!isdigit(c)) c=Get();
	while(isdigit(c)) x=x*10+c-'0',c=Get();
}
inline void readarr(bool *s)
{
	int tot=0;char c=Get();
	while(c!='#'&&c!='.') c=Get();
	while(c=='#'||c=='.') s[++tot]=(c=='#'),c=Get();
}

typedef long long LL;
const int N=1010;
bool black[N][N];
int n,m;
LL K;

struct Matrix
{
	int a[3][3];
	Matrix(){memset(a,0,sizeof(a));}
	int* operator [] (const int &x){return a[x];}
	
	friend Matrix operator * (Matrix &A,Matrix &B)
	{
		Matrix C;
		for(R int i=0;i<3;i++)
			for(R int j=0;j<3;j++)
				for(R int k=0;k<3;k++)
					C[i][j]=(C[i][j]+1ll*A[i][k]*B[k][j])%ha;
		return C;
	}
	
	friend Matrix operator ^ (Matrix &A,LL b)
	{
		Matrix ans;
		for(R int i=0;i<3;i++) ans[i][i]=1;
		for(;b;b>>=1,A=A*A) if(b&1) ans=ans*A;
		return ans;
	}
};

int Pow(int a,LL b)
{
	int ans=1;
	for(;b;b>>=1,a=1ll*a*a%ha)
		if(b&1) ans=1ll*ans*a%ha;
	return ans;
}

int main()
{
	read(n);read(m);read(K);
	for(R int i=1;i<=n;i++) readarr(black[i]);
	int plugup=0,plugleft=0,blacknum=0;
	for(R int i=1;i<=n;i++)
		for(R int j=1;j<=m;j++)
			blacknum+=black[i][j];
	for(R int i=1;i<=n;i++) plugleft+=(black[i][1]&&black[i][m]);
	for(R int i=1;i<=m;i++) plugup+=(black[1][i]&&black[n][i]);
	int cnt1=0,cnt2=0;
	for(R int i=1;i<=n;i++)
		for(R int j=1;j<=m;j++)
		{
			cnt1+=(black[i][j]&&black[i+1][j]);
			cnt2+=(black[i][j]&&black[i][j+1]);
		}
	if(plugleft&&plugup||K==1) puts("1");
	else if(!plugleft&&!plugup) printf("%d\n",Pow(blacknum,K-1));
	else
	{
		if(!plugup&&plugleft)
		{
			swap(plugleft,plugup);
			swap(cnt1,cnt2);
		}
		Matrix A,B;
		A[0][0]=A[1][1]=blacknum;
		A[1][2]=1;A[2][2]=plugup;
		A=A^(K-2);
		B[0][0]=blacknum;
		B[1][0]=cnt1;
		B[2][0]=1ll*plugup*cnt1%ha;
		B=A*B;
		printf("%d\n",(B[0][0]-B[1][0]+ha)%ha);
	}
	return 0;
}

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

// 総数を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 >= 1; 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; }

const string YES = "Yes";
const string NO = "No";

int main(){
    int n, m;
    cin >> n >> m;
    vi a(n);
    rep(i, n) cin >> a[i];
    int sum = 0;
    rep(i, n) sum += a[i];
    int ans = 0;
    rep(i, n) {
        if (a[i] * 4 * m >= sum) ++ans;
    }
    cout << (ans>=m?YES:NO) << endl;
    return 0;
}


Measured memory_bytes: 256
// Geothermals code. Testing to see if it passes aftercontest test cases

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

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

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);    
    int N; cin >> N;
    
    int M; cin >> M;
    
    ll P; cin >> P;
    vector<vpl > graph(N);
    vector<vi > graph2(N);
    F0R(i, M) {
		int A, B, C; cin >> A >> B >> C; A--; B--; C-=P;
		graph[A].pb(mp(B, C)); 
		graph2[B].pb(A);
	}
	
	bool foundEnd[N]; F0R(i, N) foundEnd[i] = false;
	queue<int> q;
	q.push(N-1);
	foundEnd[N-1] = true;
	while (!q.empty()) {
		int cur = q.front(); q.pop();
		F0R(i, sz(graph2[cur])) {
			int nxt = graph2[cur][i];
			if (!foundEnd[nxt]) {
				foundEnd[nxt] = true;
				q.push(nxt);
			}
		}
	}
	
	ll dist[N];
	F0R(i, N) {
		dist[i] = -1000000000000;
	}
	dist[0] = 0;
	
	bool found[N]; F0R(i, N) found[i] = false;
	
	found[0] = true;
	
	F0R(i, N) {
		F0R(j, N) {
			if (dist[j] == -1000000000000) continue;
			F0R(k, sz(graph[j])) {
				int nxt = graph[j][k].f;
				found[nxt] = true;
				if (dist[nxt] < dist[j] + graph[j][k].s) {
					dist[nxt] = dist[j]+graph[j][k].s;
				}
			
			}
		}
	}
	
	/*F0R(i, N) {
		cout << dist[i] << " ";
	} cout << endl;*/
	
	F0R(i, N) {
		F0R(j, sz(graph[i])) {
		
			int k = graph[i][j].f;
			if (dist[k] == -1000000000000 || dist[i] == -1000000000000) continue;
			if (dist[k] < dist[i] + graph[i][j].s && foundEnd[k]) {
				cout << -1 << endl; return 0;
			}
		}
	}
	
	cout << max(0LL, dist[N-1]) << endl;
	
    return 0;
}

// read the question correctly (ll vs int)
// template by bqi343


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int n;
	int d[100];
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> d[i];
	}
	sort(d, d + n);
	int k = 0;
	for(int i = 1;i < n;i++){
		if(d[i] == d[i - 1]) k++;
	}
	cout << (n - k) << endl;
}

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

using namespace std;

int main(){
    int n;
    cin>>n;
    vector<vector<int>> a(n,vector<int>(n-1));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n-1; ++j) {
            cin>>a[i][j];
            --a[i][j];
        }
    }
    vector<int> ichi(n);
    for (int i = 0; i < n; ++i) {
        ichi[i]=a[i][0];
    }
    vector<int> doko(n,0);
    int mada=n;
    int ans=0;
    while(mada>0){
        bool f=true;
        vector<bool> yattaze(n,false);
        for (int i = 0; i < n; ++i) {
            if(doko[i]>=n-1)continue;
            if(yattaze[i])continue;
            int aite=ichi[i];
            if(yattaze[aite])continue;
            if(ichi[aite]==i){//yaru
                f=false;
                yattaze[i]=true;
                yattaze[aite]=true;
                ++doko[i];++doko[aite];
                bool con1=false,con2=false;
                if(doko[i]>=n-1){--mada;con1=true;}
                if(doko[aite]>=n-1){--mada;con2=true;}
                if(!con1)ichi[i]=a[i][doko[i]];
                if(!con2)ichi[aite]=a[aite][doko[aite]];
            }
        }
        if(f){
            cout<<-1<<endl;
            return 0;
        }
        ++ans;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4224
S = input()

MOD = 10**9 + 7
dp = [[0] * 4 for _ in range(len(S) + 1)]
dp[len(S)][3] = 1
for i in range(len(S))[::-1]:
    dp[i][3] = 3 * dp[i + 1][3] if S[i] == "?" else dp[i + 1][3]
    dp[i][3] %= MOD
    if S[i] == "?":
        dp[i][0] = (3 * dp[i + 1][0] + dp[i + 1][1]) % MOD
        dp[i][1] = (3 * dp[i + 1][1] + dp[i + 1][2]) % MOD
        dp[i][2] = (3 * dp[i + 1][2] + dp[i + 1][3]) % MOD
    else:
        dp[i][0] = (dp[i + 1][0] + int(S[i] == "A") * dp[i + 1][1]) % MOD
        dp[i][1] = (dp[i + 1][1] + int(S[i] == "B") * dp[i + 1][2]) % MOD
        dp[i][2] = (dp[i + 1][2] + int(S[i] == "C") * dp[i + 1][3]) % MOD
print(dp[0][0])


Measured memory_bytes: 27600
#include <iostream>
#include <cmath>

using namespace std;

int main(){
  int x, i, j, max=1;
  cin >> x;

  for (i=2; i<=sqrt(x); i++) {
    j=2;
    while (pow(i, j)<=x) {
      j++;
    }
    if (pow(i, j-1)>max) max=pow(i, j-1);
    j=0;
  }
  printf("%d\n", max);
  return 0;
}

Measured memory_bytes: 640
w = gets.chomp.to_i
n = gets.chomp.to_i

array = []
a = []
b = []

for j in 1..w
  array[j] = j
end

for i in 1..n
  a, b =gets.chomp.split(",")
  a = a.to_i
  b = b.to_i

  for k in 1..w
    if a == k
      x = array[b]
      array[b] = array[k]
      array[k] = x
    end
  end  
end

for s in 1..w
    puts array[s]
end

Measured memory_bytes: 8572
#include<stdio.h>
int main()
{
	int N,i;
	float A[1000]={},B[1000]={},sum=0;
	scanf("%d",&N);
		for(i=0;i<N;i++){
			scanf("%f",&A[i]);
			B[i]=1/A[i];
			sum+=B[i];
		}
	printf("%f\n",1/sum);
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 0
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
using namespace std;

int n,m,k,ans;
vector<int> a,v;
signed main(){
	
	cin>>n;
	rep(i,n){
		int num;
		cin>>num;
		a.push_back(num);
	}
	rep(k,n){
		int keep=-1,j=0;
		rep(i,a.size()){
			if(i+1==a[i]){
				keep=a[i];
			}
		}
		if(keep!=-1){
			v.push_back(keep);
			a.erase(a.begin()+keep-1);
		}
	}
	if(a.size()==0){
		repb(i,n)cout<<v[i]<<endl;
	}
	else{
		cout<<-1<<endl;
	}
	
	
}


Measured memory_bytes: 256
import math
a,b,x = map(int,input().split())

if x < (a*a*b/2):
    tmp = 2*x/(b**2*a)
    ans = 90.0 - math.degrees(math.atan(tmp))
else:
    tmp = 2*b/a - 2*x/(a**3)
    ans = math.degrees(math.atan(tmp))
print(ans)


Measured memory_bytes: 2940
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val c = Array(3) { Array(3) { sc.nextInt() } }

  val c11 = c[0][0]
  val c21 = c[1][0]
  val c31 = c[2][0]
  val c22 = c[1][1]
  val c33 = c[2][2]

  val a1 = 0
  val b1 = c11
  val a2 = c21 - b1
  val a3 = c31 - b1
  val b2 = c22 - a2
  val b3 = c33 - a3

  val c12 = c[0][1]
  val c13 = c[0][2]
  val c23 = c[1][2]
  val c32 = c[2][1]

  var ok = false
  if (a1 + b2 == c12 && a1 + b3 == c13 && a2 + b3 == c23 && a3 + b2 == c32) {
    ok = true
  }

  if (ok) {
    println("Yes")
    return
  }
  println("No")
}


Measured memory_bytes: 36384
import java.util.Scanner; 
public class Main { 
    public static void main(String[] args) { 
        try (Scanner sc = new Scanner(System.in)) { 
            int w = sc.nextInt(); 
            int n = sc.nextInt(); 
            int[] values = new int[w]; 
            for (int i = 0; i < values.length; i++) { 
                values[i] = i + 1; 
            } 
            for (int i = 0; i < n; i++) { 
                String str = sc.next(); 
                String[] ab = str.split(","); 
                int a = Integer.parseInt(ab[0]) - 1; 
                int b = Integer.parseInt(ab[1]) - 1; 
                int c = 0; 
                c = values[a]; 
                values[a] = values[b]; 
                values[b] = c; 
            } 
            for (int i = 0; i < values.length; i++) { 
                System.out.println(values[i]); 
            }
        } 
    } 
}


Measured memory_bytes: 26112
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1

//{
#pragma GCC optimize ("O3","unroll-loops")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

//}

int ans=INT_MAX;

main(){
	int n;
	cin>>n;
	if(n==2){
		dump(1,2,2);
		return 0;
	}
	for(int h=1;h<=3500;h++){
		for(int w=1;w<=3500;w++){
			//debug(h,w);
			if((4*h*w-n*w-n*h)!=0&&((n*h*w)%(4*h*w-n*w-n*h))==0&&(n*h*w)/(4*h*w-n*w-n*h)>0){
				dump(h,w,((n*h*w)/(4*h*w-n*w-n*h)));
				return 0;
			}
		}
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int num,s,t;
int main(){

    int x[3];
    while(cin>>x[0]>>x[1]>>x[2]){
        sort(x,x+3);
        int a = x[0],b = x[1],c = x[2];
        if(a+b<=c)break;
        if(a*a+b*b==c*c)s++;
        else if(a*a+b*b>c*c)t++;
        num++;
    }
    cout<<num<<" "<<s<<" "<<t<<" "<<num-s-t<<endl;

    return 0;
}

Measured memory_bytes: 1184
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {
	int n;
	cin>>n;
	vector<ull> arr(n);
	ull sum = 0;
	for(ull &i:arr) {
		cin>>i;
		sum+=i;
	}
	cout<<sum-n;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3652
#include <cstdio>
#include <algorithm>
using namespace std;
int N, M, L = 1, R = 1e5;
int main() {
  scanf("%d %d", &N, &M);
  for(int i = 0, l, r; i < M; ++i) {
    scanf("%d %d", &l, &r);
    L = max(L, l);
    R = min(R, r);
  }
  printf("%d\n", max(R-L+1, 0));
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
    int arr[3][3];
    for(int i = 0; i<3; i++){
      for(int j = 0; j<3; j++){
        cin>>arr[i][j];
      }}
    int n;
    cin>>n;
    for(int i = 0; i<n; i++){
        int temp;
        cin>>temp;
        for(int i = 0; i<3; i++){
          for(int j = 0; j<3; j++){
            if(arr[i][j] == temp)arr[i][j] = -1;
          }}
    }
    bool baap = true;
    for(int i = 0; i<3; i++){
        bool flag = true;
        for(int j = 0; j<3; j++){
            if(arr[i][j] != -1)flag = false;
        }
        if(flag == true){
            baap = false;
            break;
        }
    }
    for(int j = 0; j<3; j++){
        bool flag = true;
        for(int i = 0; i<3; i++){
            if(arr[i][j] != -1)flag = false;
        }
        if(flag == true){
            baap = false;
            break;
        }
    }
    if(arr[0][0] == -1 && arr[2][2] == -1 && arr[1][1] == -1)baap = false;
    else if(arr[0][2] == -1 && arr[1][1] == -1 && arr[2][0] == -1)baap = false;
    if(baap == false)cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
  
}

Measured memory_bytes: 256
#include<stdio.h>
int max(int a,int b){
	if(a>b){return a;}
	else{return b;}
}
main(){
	int i,r1,r2,cumDif,maxDif,tmpDif;
	scanf("%d %d %d",&i,&r1,&r2);
	cumDif=r2-r1;
	maxDif=cumDif;
	r1=r2;
	while(scanf("%d",&r2)!=EOF){
		tmpDif=r2-r1;
		cumDif=tmpDif+max(cumDif,0);
		if(maxDif<cumDif){maxDif=cumDif;}
		r1=r2;
	}
	if(maxDif<cumDif){maxDif=cumDif;}
	printf("%d\n",maxDif);
	return 0;
}

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

#define pb push_back
#define mp make_pair
#define F(i, a, n, b) for(int i=a;i<n;i+=b)
#define REVF(i, a, b, c) for(int i=a;i>=b;i-=c)
#define REP(i, n) F(i, 0, n, 1)
#define REP1(i, n) F(i, 1, n+1, 1)
#define REV(i, n) REVF(i, n, 0, 1)
#define PTR(it, x) for(auto it=x.begin();it!=x.end();++it)
#define MOD 1000000007

typedef long long ll;

const int MAX = 1e6 + 5;

int n,d[50],ans = 0;
bool v[50][50];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin>>n;
	REP(i,n){
		cin>>d[i];
	}
	REP(i,n){
		F(j,i+1,n,1){
			if(!v[i][j]){
				v[i][j] = 1; v[j][i] = 1;
				ans += d[i] * d[j];
			}
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
   string str;
   cin>>str;
   int count=0;
   if(str[0]=='R')
     count++;
   if(str[1]=='R')
     count++;
   if(str[2]=='R')
   {
      if(str[1]=='R')
        count++;
      else
      {
         count=1;
      }
      
   }
   cout<<count<<endl;
   return 0; 
}

Measured memory_bytes: 3620
import sys

input = sys.stdin.readline


def main():
    N = int(input())
    abc = [0] * N
    for i in range(N):
        abc[i] = list(map(int, input().split()))

    dp = [[0] * 3 for _ in range(N)]
    dp[0] = abc[0]
    for i, (a, b, c) in enumerate(abc[1:], start=1):
        dp_i = dp[i]
        dp_im = dp[i - 1]
        dp_i[0] = max(dp_im[1], dp_im[2]) + a
        dp_i[1] = max(dp_im[0], dp_im[2]) + b
        dp_i[2] = max(dp_im[0], dp_im[1]) + c

    ans = max(dp[-1])
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 51044
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
#define ll long long
int gcd(int a,int b)
{
	return a%b==0?b:gcd(b,a%b);
}
int main()
{
	int k,i,j,l;
	ll m=0,sum=0;
	scanf("%d",&k);
	for(i=1;i<=k;i++)
	{
	  for(j=1;j<=k;j++)
		{
		  for(l=1;l<=k;l++)
			{
				m=gcd(i,j);
				sum+=gcd(m,l);
			}
		}
	}
	printf("%lld\n",sum);
	return 0;
} 

Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(2e5 + 5);
const double EPS = 1e-8;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

ll n, a[25][25], dp[25][1<<22];

// m人目の男性までみて残りの女性の集合がs
ll rec(ll m, ll s){
    if(m == 0) return s==(1<<n)-1;
    if(dp[m][s] >= 0) return dp[m][s];
    ll res = 0;
    REP(i, n){
        if(a[m-1][i] && ((s>>i)&1)==0) res += rec(m-1,s+(1<<i));
        res %= MOD;
    }
    dp[m][s] = res;
    return res;
}

int main() {
    cin >> n;
    REP(i,n)REP(j,n) cin >> a[i][j];
    REP(i,n+1)fill(dp[i],dp[i]+(1<<22),-1);
    cout << rec(n,0) << endl;
    return 0;
}


Measured memory_bytes: 723200
// https://github.com/PabloMessina/Competitive-Programming-Material/blob/master/Codejam_template.cpp
#pragma GCC optimize("Ofast") // OPTIONAL: for faster execution
#include <bits/stdc++.h>      // import everything in one shot
using namespace std;
// defines
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define invrep(i, a, b) for (int i = b - 1; i >= a; --i)
#define umap unordered_map
#define uset unordered_set
// typedefs
typedef unsigned int uint;
typedef unsigned long long int ull;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;
// -------------------------------

int main()
{
    // OPTIONAL: for faster input/output (only if using cin/cout)
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int N, M, a, b;
    cin >> N >> M;
    vi jobs[100001];
    rep(i, 0, N)
    {
        cin >> a >> b;
        jobs[a].push_back(b);
    }
    int ans = 0;
    multiset<int> free_jobs;
    invrep(i, 0, M)
    {
        for (int j : jobs[M - i])
            free_jobs.insert(j);
        if (free_jobs.empty())
            continue;
        ans += *prev(free_jobs.end());
        free_jobs.erase(prev(free_jobs.end()));
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
	int N;
	string s;
	int ans =0;
	char prev='A';
	cin>>N;
	cin>>s;
	for(int i=0; i< N; i++){
		if(s[i] != prev){
			prev = s[i];
			ans++;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <set>
#include <deque>
#include <map>
#include <iomanip>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <utility>
using namespace std;
int ky[8] = {-1,1,-2,2,-2,2,-1,1}; 
int kx[8] = {-2,-2,-1,-1,1,1,2,2};
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int ddy[8] = {-1,0,1,-1,1,-1,0,1};
int ddx[8] = {-1,-1,-1,0,0,1,1,1};
typedef long long ll;
#define pi pair
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define rep1(i,a,b) for(int i = a; i < b; i++)
#define rep2(i,a,b) for(int i = a; i <= b; i++) 
#define INF 999999999999
const double PI = acos(-1.0); 
int n,m;
vector<int> adj[200001];
int a,b;
set<pi<int,int>> s;
ll ans;
bool vis[200001];
ll cnt;
ll ret;

void dfs(int here){
    if(vis[here]) return;
    vis[here] = true;

    cnt++;
    int sz = adj[here].size();

    rep1(i,0,sz){
        int next = adj[here][i];
        dfs(next);
    }
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cin >> n >> m;
    rep1(i,0,m){
        cin >> a >> b;
        swap(a,b);
        if(s.count({a,b})) continue;
        s.insert({a,b});

        adj[a].PB(b);
        adj[b].PB(a);
    }

    rep2(i,1,n){
        cnt = 0;
        dfs(i);
        ans = max(ans, cnt);
    }

    //cout << ans << ' ' << ret << '\n';
    cout << ans;
	return 0;
}

Measured memory_bytes: 30388