akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;
public class Main implements Runnable{
	int N;
	int[] a;
    public void solve() {
    	N = nextInt();
    	a = new int[N];
    	for(int i = 0;i < N;i++){
    		a[i] = Integer.parseInt(next().replaceAll("\\.", ""));
    	}

    	long[] b = new long[4444];
    	for(int i = 0;i < N;i++){
    		b[a[i]+1]++;
    	}

    	for(int i = 0;i < 4443;i++){
    		b[i+1] = b[i+1] + b[i];
    	}

    	for(int i = 0;i < N;i++){
    		int c = a[i]+1;
    		out.println((b[c-1])* 3 + (b[c]-b[c-1]-1));
    	}
    }

    public static void main(String[] args) {
        new Thread(null,new Main(),"",64 * 1024 * 1024).start();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[2048];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

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

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

    public double nextDouble() {
        return Double.parseDouble(next());
    }

    @Override
    public void run() {
        out.flush();
        new Main().solve();
        out.close();

    }
}

Measured memory_bytes: 66944
#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

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

#define ll long long
#define ld long double
#define F first
#define S second
#define pb push_back
#define sqr(x) (x) * (x)

using namespace std;
using namespace __gnu_pbds;

mt19937_64 gen(time(0));

typedef tree<
pair <int, int>,
null_type,
less<pair <int, int>>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

//const int inf = 2e9 + 34333;
const ll mod = 1e9 + 7;
const int maxn = 2e5 + 55;


signed main()
{
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(false);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else

#endif
    int n, k;
    cin >> n >> k;
    vector <pair <ll, bool>> a;
    ll c = 0;
    a.reserve(n);
    for(int i = 0; i < n; ++i)
    {
        int x;
        cin >> x;
        if (x == 0) ++c;
            else if (x > 0) a.pb({x, true});
                else a.pb({-x, false});
    }
    sort(a.rbegin(), a.rend());
    if (k > int(a.size()))
    {
        cout << 0;
        return 0;
    }
    ll ans = 1;
    int mn1 = -1;
    int mn2 = -1;
    int cnt = 0;
    for(int i = 0; i < k; ++i)
    {
        if (!a[i].S) ++cnt;
        if (a[i].S)
        {
            if (mn1 == -1 || a[mn1].F > a[i].F)
                mn1 = i;
        }
        else
        {
            if (mn2 == -1 || a[mn2].F > a[i].F)
                mn2 = i;
        }
        ans *= a[i].F;
        ans %= mod;
    }
    if (cnt % 2 == 0)
    {
        cout << ans;
        return 0;
    }
    ll ans1 = 1;
    ll ans2 = 1;
    pair <ll, ll> fir = {-1, -1};
    pair <ll, ll> sec = {-1, -1};
    for(int i = k; i < int(a.size()); ++i)
    {
        if (a[i].S && fir.F == -1 && mn2 >= 0)
        {
            fir.F = a[i].F;
            fir.S = a[mn2].F;
            ans1 = a[i].F;
            for(int j = 0; j < k; ++j)
            {
                if (j == mn2) continue;
                ans1 *= a[j].F;
                ans1 %= mod;
            }
        }

        if (!a[i].S && sec.F == -1 && mn1 >= 0)
        {
            sec.F = a[i].F;
            sec.S = a[mn1].F;
            ans2 = a[i].F;
            for(int j = 0; j < k; ++j)
            {
                if (j == mn1) continue;
                ans2 *= a[j].F;
                ans2 %= mod;
            }
        }
    }
    if (fir.F == -1 && sec.F == -1)
    {
        if (c > 0)
        {
            cout << 0;
            return 0;
        }
        ans = 1;
        reverse(a.begin(), a.end());
        for(int i = 0; i < k; ++i)
        {
            ans *= a[i].F;
            ans %= mod;
        }
        ans = (mod - ans) % mod;
        cout << ans;
        return 0;
    }
    if (fir.F == -1)
        cout << ans2;
    else
        if (sec.F == -1)
            cout << ans1;
    else
    {
        if (fir.F * sec.S - sec.F * fir.S < 0) cout << ans2;
            else cout << ans1;
    }
    return 0;
}


Measured memory_bytes: 6348
#include <bits/stdc++.h>
using namespace std;
int main() {
  int m, f, r;
  cin >> m >> f >> r;

  while (m != -1 || f != -1 || r != -1) {
    if (m == -1 || f == -1) {
      cout << "F";
    } else if (m + f >= 80) {
      cout << "A";
    } else if (m + f >= 65) {
      cout << "B";
    } else if (m + f >= 50) {
      cout << "C";
    } else if (m + f >= 30) {
      if (r >= 50) {
        cout << "C";
      } else {
        cout << "D";
      }
    } else {
      cout << "F";
    }
    cout << endl;
    cin >> m >> f >> r;
  }
  return 0;
}



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

int main(){
/*     int N = 4;
   string s = "RRBR";
*/

    int N;
    string s;
    cin >> N >> s;
    int cnt_R = 0;

    for (int i = 0; i < s.size(); i++){
        if (s[i] == 'R'){
            cnt_R++;
        }
    }
    int cnt_B = s.size() - cnt_R;

    if (cnt_R > cnt_B){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;

}

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

int N;

int id(int n){
	if(n==0) return 2;
	if(n==1) return 3;
	if(n==2) return 4;
	if(n==3) return 0;
}

int main(){
	scanf("%d",&N);
	if(N==3) printf("%d %d %d",2,5,63);
	else if(N==4) printf("%d %d %d %d",2,5,20,63);
	else if(N==5) printf("%d %d %d %d %d",2,5,20,30,63);
	else{
		bool A[30030] = {0};
		int count = 0,num = 2,c = 0,sum = 0;
		while(count<N){
			if(num%6==id(c)){
				A[num] = true;
				c++;
				c %= 4;
				count++;
				sum += num;
			}
			num++;
		}
		if(sum%6==2){
			A[8] = false;
			while(1){
				if(num%6==0){
					A[num] = true;
					break;
				}
				num++;
			}
		}else if(sum%6==3){
			A[9] = false;
			while(1){
				if(num%6==0){
					A[num] = true;
					break;
				}
				num++;
			}
		}else if(sum%6==5){
			A[9] = false;
			while(1){
				if(num%6==4){
					A[num] = true;
					break;
				}
				num++;
			}
		}
		int ans = 0;
		for(int i=2;i<=30000;i++){
			if(A[i]){
				ans++;
				cout << i << (ans!=N? " ":"\n");
			}
			if(ans==N) return 0;
		}
	}
}

Measured memory_bytes: 384
N = int(input())

B = list(map(int,input().split()))
score = 0
for i in range(N):
    if i==0:
        score += B[i]
    elif i==N-1:
        score += B[N-2]
    else:
        score += min(B[i-1],B[i])

print(score)

Measured memory_bytes: 38484
#include <stdio.h>
#include <math.h>
int main()
{
    int n,i;
    unsigned int result=100000;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        result = result * 105/100;
        if((result%1000)!=0){
            result = (result/1000+1)*1000;
        }
    }
    printf("%d\n" ,result);
    return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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

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

  vector<int> csum(s.size()+1);
  rep(i,s.size()) {
    csum[i+1] = csum[i];
    if (s[i] == 'W') csum[i+1]++;
  }

  int ans = INF;
  rep(i,n) {
    int lw = csum[i];
    int re = (n-i-1) - (csum[n]-csum[i+1]);
    ans = min(ans, lw+re);
    //printf("%d %d %d\n", i, n-i-1, csum[n]-csum[i+1]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1796
#include<stdio.h>
#include<math.h>
int main(){
  double x1,y1,x2,y2,i,j;
  scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
  double ans =hypot(x2-x1,y2-y1);
  printf("%f\n",ans);
  return 0;
}

Measured memory_bytes: 664
#include <stdio.h>
#include <vector>
using namespace std;
const int C=100001;

int n, k, a[C], dp[C];

int abs(int a){return (a>0)?(a):(-a);}

int main(){
	int j;
	scanf ("%d %d", &n, &k);
	for (int i=1;i<=n;i++)	{
		scanf ("%d", &a[i]);
		if (i==1)	continue;
		if (i==2)	dp[i]=abs(a[i]-a[i-1]);
		else {
			dp[i]=1500000000;
			for (j=1;j<=k&&j<i;j++)	dp[i]=min(dp[i], dp[i-j]+abs(a[i]-a[i-j]));
		}
	}
	printf ("%d\n", dp[n]);
	
return 0;}

Measured memory_bytes: 896
#include<bits/stdc++.h>
#define ll long long
#define N 100010
using namespace std;
template <typename T> void read(T &x){
	x=0;char ch=getchar();int fh=1;
	while (ch<'0'||ch>'9'){if (ch=='-')fh=-1;ch=getchar();}
	while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=fh;
}
struct Info{ll b,l,r,mi,ma;}a[N];
ll ansn,su,n,X,s1[N],ans;
bool comp(const Info &a,const Info &b){return a.ma-a.mi>b.ma-b.mi;}
ll ch(ll x,ll y){return x/y+(x%y!=0);}
ll get(ll x,ll y){
	if (a[y].mi<=x){
		return ch(-x,a[y].l);
	}else{
		return a[y].b+ch(-x+a[y].mi,a[y].r);
	}	
}
int main(){
	read(n);read(X);
	for (int i=1;i<=n;i++){
		read(a[i].b);read(a[i].l);read(a[i].r);
		a[i].mi=-a[i].b*a[i].l;
		a[i].ma=(X-a[i].b)*a[i].r;
	}
	sort(a+1,a+n+1,comp);
	for (int i=1;i<=n;i++)ansn+=a[i].mi;
	for (int i=1;i<=n;i++)s1[i]=s1[i-1]+a[i].ma-a[i].mi;
	for (int i=1;i<=n;i++)if (ansn+s1[i]>=0){su=i-1;break;}
	ans=X;
	for (int i=1;i<=n;i++){
		ll p;
		if (i>su)p=ansn+s1[su];else p=ansn+s1[su+1]-a[i].ma+a[i].mi;
		ans=min(ans,get(p,i));
	}
	cout<<ans+su*X<<endl;
	return 0;
}

Measured memory_bytes: 4992
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

a = list(input())
b = list(input())
c = list(input())

def is_match(c1,c2):
    if c1 == '?' or c2 == '?' or c1 == c2:
        return True
    else:
        return False

def prefix_match_len(x,y):
    len_list = []
    n = len(x)
    m = len(y)
    for i in range(n):
        match = 0
        for j in range(i,min(i+m,n)):
            if is_match(x[j],y[j-i]):
                match += 1
            else:
                break
        len_list.append(match)
    return len_list

def concat(x,y,xy):
    index_list = []
    n = len(x)
    m = len(y)
    for i in range(n):
        if xy[i] == min(n-i,m):
            index_list.append(i)
    index_list.append(n)
    return index_list

def concat2(x,y,z,xz,yz,zy,index_list):
    n1 = len(x)
    n2 = len(y)
    m = len(z)
    candidate = []
    for i in index_list:
        flag = False
        for j in range(max(n1,n2+i)):
            if j <= n1-1:
                if xz[j] != min(n1-j,m):
                    continue
            if j >= i:
                if n2-j+i >= 1 and yz[j-i] != min(n2-j+i,m):
                    continue
            else:
                if m-i+j >= 1 and zy[i-j] != min(m-i+j,n2):
                    continue
            flag = True
            candidate.append(max(n1,n2+i,j+m))
            break
        if not flag:
            candidate.append(max(n1,n2+i)+m)
    return min(candidate)

ab = prefix_match_len(a,b)
ac = prefix_match_len(a,c)
ba = prefix_match_len(b,a)
bc = prefix_match_len(b,c)
ca = prefix_match_len(c,a)
cb = prefix_match_len(c,b)

index_list = concat(a,b,ab)
ret1 = concat2(a,b,c,ac,bc,cb,index_list)
index_list = concat(a,c,ac)
ret2 = concat2(a,c,b,ab,cb,bc,index_list)
index_list = concat(b,a,ba)
ret3 = concat2(b,a,c,bc,ac,ca,index_list)
index_list = concat(b,c,bc)
ret4 = concat2(b,c,a,ba,ca,ac,index_list)
index_list = concat(c,a,ca)
ret5 = concat2(c,a,b,cb,ab,ba,index_list)
index_list = concat(c,b,cb)
ret6 = concat2(c,b,a,ca,ba,ab,index_list)

print(min(ret1,ret2,ret3,ret4,ret5,ret6))

Measured memory_bytes: 65008
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define print(n) cout<<n<<endl
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
const int M=200111;
const int inf=1000000007;
const int MOD=1000000007;
const double PI = 3.1415926535897932384626433;
const long long INF=1e18;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};


struct UnionFind {
	vector<int> par;
	UnionFind(int n) : par(n, -1) { }

	int root(int x) {
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool same(int x, int y) {
		return root(x) == root(y);
	}

	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y); // merge technique
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x) {
		return -par[root(x)];
	}
};

vvl comb(int n) {
	vvl v(n + 1,vl(n + 1, 0));
	for (int i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int j = 1; j < v.size(); j++) {
		for (int k = 1; k < j; k++) {
			v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
		}
	}
	return v;
}

void sosu(ll x,bool f[]){
	ll y=x;
	for(ll i=2;i<=sqrt(y);i++){
		if(x%i==0){
			x/=i;
			f[i]=true;
			i--;
		}
	}
}

ll __gcd(ll x,ll y){
	if(x<y)swap(x,y);
	while(1){
		ll tmp=x%y;
		x=y;
		y=tmp;
		if(y==0)break;
	}
	return x;
}

int keta(ll a){
	int ke=1;
	while(a/=10)ke++;
	return ke;
}

vector<long long> enum_divisors(long long N) {
	vector<long long> res;
	for (long long i = 1; i * i <= N; ++i) {
		if (N % i == 0) {
			res.push_back(i);
			// 重複しないならば i の相方である N/i も push
			if (N/i != i) res.push_back(N/i);
		}
	}
	// 小さい順に並び替える
	sort(res.begin(), res.end());
	return res;
}

ll zyou(ll x,ll n){
	ll y=1;
	rep(i,0,n){
		y*=x;
	}
	return y;
}

int main() {
	int r,g,b;
	cin>>r>>g>>b;
	int x;
	x=b+10*g+100*r;
	if(!(bool(x%4)))print("YES");
	else print("NO");

}


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

int main() {
    ll n,ans=1,max=1000000000000000000;
    cin>>n;
    vector<ll> a(n);
    for(int i=0; i<n; i++) {
        cin>>a[i];
        if(a[i] == 0) {
            cout<<0<<endl;
            return 0;
        }
    }
    for(int i=0; i<n; i++) {
        if(ans > max / a[i]) {
            cout<<-1<<endl;
            return 0;
        }
        else ans *= a[i];
    }
    cout<<ans<<endl;
}

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

using ll = long long;
using vi = vector<int>;
using vll = vector<long long>;

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

template <typename T>
T _gcd(T a, T b) {
    return b ? _gcd(b, a % b) : a;
}

constexpr long long mod = 1000000007;

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

void f(ll n) {
    for (ll q = 1; q <= 3500; q++) {
        for (int p = q; p <= 3500; p++) {
            ll s = n * p * q;
            ll t = 4 * p * q - n * (p + q);

            if (t <= 0)
                continue;

            if (s % t == 0) {
                cout << p << " " << q << " " << s / t << endl;
                return;
            }
        }
    }
}

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

    ll n;
    cin >> n;

    f(n);
}

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

int main(){
    int h;
    cin >> h;
    int w;
    cin >> w;
    vector<string> a(h);
    for(int i = 0; i < h; i++){
        cin >> a[i];
    }
    
    vector<bool> row(h, false);
    vector<bool> col(w, false);
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(a[i][j] == '#'){
                row[i] = true;
                col[j] = true;
            }
        }
    }
    
    for(int i = 0;i < h; i++){
        if(row[i]){
            for (int j = 0; j < w; j++){
                if(col[j]){
                    cout << a[i][j];
                }
            }
            cout << endl;
        }
    }
}

Measured memory_bytes: 256
from sys import stdin
from collections import Counter
N = int(stdin.readline().rstrip())
D = [int(x) for x in stdin.readline().rstrip().split()]
mod = 998244353
ans = 1
if N == 1 and D[0] == 0:
    print(1)
elif len(set(D))==1:
    print(0)
elif D.count(0) != 1:
    print(0)
elif D[0] != 0:
    print(0)
else:
    tmp = 1
    cnt = Counter(D)
    #print(cnt)
    flag = True
    for i in range(1,max(D)+1):
        #print(cnt[i],tmp)
        if i != 1 and cnt[i] != tmp:
            flag = False
        c = (tmp**cnt[i]) % mod
        ans *= c % mod
        tmp = cnt[i]
        ans = ans % mod
    if flag:
        print(1)
    else:
        print(ans % mod)

Measured memory_bytes: 21468
def main():
    N = int(input())
    A = list(map(int, input().split()))
    for i in A:
        if i % 2 == 0:
            if i % 3 == 0 or i % 5 == 0:
                continue
            else:
                return 'DENIED'
    return 'APPROVED'



print(main())


Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long N;cin>>N;
  vector<long>A(N);for(long i=0;i<N;i++)cin>>A[i];
  vector<long>B(N);for(long i=0;i<N;i++)B[i]=A[i]-(i+1);
  sort(B.begin(),B.end());
  long b1=B[N/2],b2=B[(N-1)/2];
  long s1=0,s2=0;
  for(int i=0;i<N;i++){
    s1+=abs(A[i]-(b1+i+1));
    s2+=abs(A[i]-(b2+i+1));
  }cout<<min(s1,s2);
}

Measured memory_bytes: 3328
MOD = 10**9+7
k = int(input())
s = input()
n = len(s)


U = n+k
fact = [0]*(U+1)
fact[0] = 1
for i in range(1, U+1):
    fact[i] = fact[i-1]*i % MOD


invfact = [0]*(U+1)
invfact[U] = pow(fact[U], MOD-2, MOD)
for i in reversed(range(U)):
    invfact[i] = invfact[i+1]*(i+1) % MOD


def nCr(n, r):
    if r < 0 or n < r:
        return 0
    return fact[n]*invfact[r]*invfact[n-r]


ans = 0
for x in range(k+1):
    ans += pow(26, x, MOD)*nCr(n+k-x-1, n-1)*pow(25, k-x, MOD)
    ans %= MOD
print(ans)

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

int main()
{
    int m,f,r;
    vector<char> g(0);
    for (int i=0; ; i++)
    {
        g.push_back(0);
        cin>>m>>f>>r;
        if (m==-1 && f==-1 && r==-1) break;
        if ((m==-1 || f==-1) || m+f<30) g[i]='F';
        else if ((m+f>=30 && m+f<50) && r<50) g[i]='D';
        else if (((m+f>=30 && m+f<50) && r>=50) || (m+f>=50 && m+f<65)) g[i]='C';
        else if (m+f>=65 && m+f<80) g[i]='B';
        else if (m+f>=80) g[i]='A';
    }
    for (int i=0; i<g.size()-1; i++)
    {
        cout<<g[i]<<'\n';
    }
    return 0;
}



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

signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int A, B, C;
    cin >> A >> B >> C;
    cout << max(C - (A - B), 0) << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <tuple>
#include <bitset>
#include <random>
#define REP(i,n) for(int i=0;i<n;i++)
#define INF 100000000000007
using namespace std;
using pii=pair<int,int>;
using LL=int64_t;



vector<pair<int64_t, int64_t>> fs;//素因数分解の素数，指数のペア
 

	
void factorization(int64_t base){//baseを素因数分解
    //base未満のiが約数か
    for(int64_t i=2;i*i<=base;i++){/*ここのint64_tをintにするとTLEする(キャストって結構時間かかるっぽい)*/
        //iで割り切れるなら限界まで割る
        
        if(base%i==0){
            int64_t cnt=0;
            while(base%i==0){
                base/=i;
                cnt++;
            }
            fs.push_back(make_pair(i,cnt));
        }
    }
    //baseが素数
    if(base>1){
        fs.push_back(make_pair(base,1));
    }
}
int main(){
    int64_t n;
    cin>>n;
    
    
    factorization(n);
    //prime_factorize(n);
    int64_t ans=0;
    for(auto p : fs){
        int64_t e;
        e=p.second;
        int k=1;
        while(e-k>=0){
            e-=k;
            k++;
            ans++;
        }
    }

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

Measured memory_bytes: 3148
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <sstream>
#include <numeric>
#include <queue>
#include <sstream>
#include <set>
using namespace std;



int main(){
    int n ;
    cin >> n ;
    string ss ;
    vector<int64_t> s(5,0) ;
    for (size_t i = 0; i < n; i++)
    {
        cin >> ss ;
        if (ss.at(0) == 'M')
        {
            s.at(0) ++ ;
        }
        if (ss.at(0) == 'A')
        {
            s.at(1) ++ ;
        }
        if (ss.at(0) == 'R')
        {
            s.at(2) ++ ;
        }
        if (ss.at(0) == 'C')
        {
            s.at(3) ++ ;
        }
        if (ss.at(0) == 'H')
        {
            s.at(4) ++ ;
        }
        
    }
    int64_t ans = 0 ;
    for (size_t i = 0; i < 5; i++)
    {
        for (size_t j = 0; j < 5; j++)
        {
            if (i == j)
            {
                continue ;
            }
            int64_t sum = 0 ;
            for (size_t k = 0; k < 5; k++)
            {
                if (k != i && k != j)
                {
                    sum += s.at(k) ;
                }
                
            }
            ans += s.at(i) * s.at(j) * sum ;
        }
        
    }
    ans /= 6 ;
    cout << ans << endl ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int N, A[100000];
ll t;

int main() {
	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
	for (int i = 0; i < N; ++i) {
		if (i & 1) {
			t -= A[i];
		}
		else {
			t += A[i];
		}
	}
	cout << t << sp;
	for (int i = 0; i < N - 1; ++i) {
		t = A[i] * 2 - t;
		cout << t;
		if (i != N - 2)cout << sp;
	}
	cout << endl;
}

Measured memory_bytes: 1664
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000)
INF = 1<<32


def solve(A: int, P: int):
    print((3*A+P)//2)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    P = int(next(tokens))  # type: int
    solve(A, P)

if __name__ == '__main__':
    main()


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

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String ans = br.readLine();

		ans = ans.replaceAll("1", "a");
		ans = ans.replaceAll("9", "1");

		System.out.println(ans.replaceAll("a", "9"));
	}

}

Measured memory_bytes: 23124
N = int(input())
X = list(map(int, input().split()))
Y = X.copy()
Y.sort()
for i in range(N):
	if X[i] < Y[int(N / 2)]:
		print(Y[int(N / 2)] )
	else:
		print(Y[int(N / 2 - 1)])

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

int main(){
  vector<int> vec(4);
  cin >> vec.at(0);
  cin >> vec.at(1);
  cin >> vec.at(2);
  cin >> vec.at(3);
  sort(vec.begin(),vec.end());
  if(vec[0]==1&&vec[1]==4&&vec[2]==7&&vec[3]==9) cout << "YES" << endl;
  else cout << "NO" << endl;
}

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


class Program
{
    public static int n;
    public static int a;
    public static int b;
    public static int c;
    public static int[] l;

    static void Main(string[] args)
    {
        // 入力
        //var s = Console.ReadLine();
        //var n = int.Parse(Console.ReadLine());
        int[] nabc = Console.ReadLine().Split().Select(int.Parse).ToArray();
        n = nabc[0];
        a = nabc[1];
        b = nabc[2];
        c = nabc[3];

        l = new int[n];
        for (int i = 0; i < n; i++)
        {
            l[i] = int.Parse(Console.ReadLine());
        }


        var ans = dfs(0, 0, 0, 0);

        // 出力
        Console.WriteLine(ans);
    }

    static int dfs(int cur, int x, int y, int z)
    {
        if (cur == n)
        {
            if (x == 0 || y == 0 || z == 0)
            {
                return int.MaxValue - 10;
            }
            else
            {
                return Math.Abs(x - a) + Math.Abs(y - b) + Math.Abs(z - c) - 30;
            }
        }
        else
        {
            int ret0 = dfs(cur + 1, x, y, z);
            int ret1 = dfs(cur + 1, x + l[cur], y, z) + 10;
            int ret2 = dfs(cur + 1, x, y + l[cur], z) + 10;
            int ret3 = dfs(cur + 1, x, y, z + l[cur]) + 10;

            var tmp = Math.Min(ret0, ret1);
            tmp = Math.Min(tmp, ret2);
            tmp = Math.Min(tmp, ret3);
            return tmp;
        }
    }
}

Measured memory_bytes: 13396
#include  <bits/stdc++.h>
using namespace std;
static int fast_io = []() { std::ios::sync_with_stdio(false); cin.tie(nullptr); return 0; }();

int main(){
  string s;
  unsigned int k;
  cin>>k>>s;
  if(s.size()<=k)
    cout<<s<<"\n";  
  else{
    cout<<s.substr(0,k)<<"..."<<endl;
  }
  
  return 0; 
}

Measured memory_bytes: 3608
#include <stdio.h>
#define min(a, b) ((a) < (b) ? (a) : (b))

int
main(int argc, char *argv[])
{
  int p, q, r;
  scanf("%d %d %d", &p, &q, &r);

  int a, b, c;
  a = p + q;
  b = r + q;
  c = r + p;
  int ans = min(a, min(b, c));
  printf("%d\n", ans);
  return 0;
}
  


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
const ll INF=100000000000000001;
const double PI=3.141592653589;


int main(){
  int k; cin>>k;
  if(k%2==0){
    cout<<(k/2)*(k/2)<<endl;
  }else{
    cout<<((k+1)/2)*(k/2)<<endl;
  }

  return 0;
}


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

void sub(int a[],int i,int j)
{
    for(int x=i;x<=j;x++) a[x]--;
}

int main()
{
    int n; cin>>n;
    int a[101]; for(int i=0;i<n;i++) cin>>a[i];
    int c=0;
    while(true)
    {
        int i=0; bool pos=true;
        while(i<n)
        {
            if(a[i]>0)
            {   
                pos=false;
                int j=i+1;
                while(a[j]>0 and j<n) j++;
                sub(a,i,j-1); c += 1;
                i=j;
            }
            else i += 1;
        }
        if(pos) break;
        i=0;
    }
    cout<<c<<endl;
}

Measured memory_bytes: 256
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0]);
    const S = arg[1].split("");
    
    const alpha = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"];
    
    let answer = [];
    
    for(let i in S) {
        let temp = alpha.indexOf(S[i]);
        
        if(temp + N >= 26) {
            temp = temp - 26;
        }
        
        answer.push(alpha[temp + N]);
    }
    
    console.log(answer.join(""))
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 12060
#include <iostream>

using namespace std;

int main(void) {

	int N, K, count, i, h;

	cin >> N >> K;

	count = 0;
	for (i = 1; i <= N; i++) {

		cin >> h;

		if (h >= K) {
			count += 1;
		}
		
		
	}
	cout << count << endl;
	return 0;

}

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin >> a[i];
  }
  sort(a.begin(), a.end(), greater<int>() );
  bool sug=false;
  long yuk=0;
  for(int i=1;i<N;i++){
    if(a[i]==yuk && a[i+1]==yuk){
      cout << yuk*yuk;
      break;
    }
    if(a[i]==a[i-1]){
      if(sug && yuk!=a[i]){
        cout << yuk*a[i];
        break;
      }
      else if(yuk==a[i])continue;
      else{
        sug=true;
        yuk=a[i];
      }
    }
    if(i==N-1)cout << 0;
  }
}


Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll LINF = 1001002003004005006LL;
const int INF = 1001001001;

const int mod = 1000000007;

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

int main() {
    ll n; cin >> n;
    auto res = prime_factorize(n);
    int ans = 0;
    for (auto p: res) {
        int cnt = 1;
        int b = p.second;
        //cout << "p: " << p.first << " n: " << b << endl;
        while (b > 0) {
            b -= cnt;
            if (b >=0) ++ans;
            ++cnt;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef vector< long long > vll;
typedef pair< int,int > ii;
typedef long long ll;
#define sz(a) int((a).size())
#define pb push_back
#define mp  make_pair
#define mod 1000000007
#define mod2 998244353
#define all(c) c.begin(),c.end()
#define tr(c,i) for(typeof(c).begin() 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 <= int(b); i++)
#define fo(i,n) for(ll i=0;i<n;i++)
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define Yes cout<<"Yes\n"
#define No cout<<"No\n"
#define nl "\n"
ll gcd (ll a, ll b) {
    if (b == 0)
        return a;
    else
        return gcd (b, a % b);
}

unsigned long long factorial[1000004]; 
    /*factorial[0] = 1; 
    for (int i = 1; i <= n; i++) {
        factorial[i] = (factorial[i - 1] * i) % mod3; 
    }*/




unsigned long long power(unsigned long long x, 
                         int y, int p) 
{ 
    unsigned long long res = 1; // Initialize result 
  
    x = x % p; // Update x if it is more than or 
    // equal to p 
  
    while (y > 0) { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res * x) % p; 
  
        // y must be even now 
        y = y >> 1; // y = y/2 
        x = (x * x) % p; 
    } 
    return res; 
} 



  
// Returns n^(-1) mod p 
unsigned long long modInverse(unsigned long long n, int p) 
{ 
    return power(n, p - 2, p); 
} 
unsigned long long nc(unsigned long long n, 
                                 int r, int p) 
{ 
    // Base case 
    if (r == 0) 
        return 1; 
  
    // Fill factorial array so that we 
    // can find all factorial of r, n 
    // and n-r 
 
  
    return (factorial[n]* modInverse(factorial[r], p) % p * modInverse(factorial[n - r], p) % p) % p; 
} 



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,x;
    int t;
    cin>>n>>x>>t;
    int ans = n/x;
    if(n%x!=0){
        ans++;
    }
    cout<<ans*t<<nl;
        
    

    


	return 0;
}


Measured memory_bytes: 3648
a,b,c,d,e,f = map(int,input().split())
L = []
for p in range(f//a+1):
    for q in range((f-a*p)//b+1):
        h = 100*(a*p+b*q)
        for r in range((f-h)//c+1):
            for s in range((f-h-c*r)//d+1):
                g = c*r+d*s
                if g+h !=0:
                    bool1 = (g/(g+h) <= e/(100+e))
                    if bool1 and g+h <= f:
                        if h !=0:
                            L.append((100*g/(g+h),g+h,g))
L.sort(reverse = True)  
#print(L)
print(L[0][1],L[0][2])

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

int main(){
	int n, t, e, x[100];
	
	scanf(" %d %d %d", &n, &t, &e);
	for(int i=0; i<n; ++i) scanf(" %d", &x[i]);
	
	int ans=-1;
	for(int i=t-e; i<=t+e; ++i){
		for(int j=0; j<n; ++j){
			if(i%x[j]==0){
				ans=j+1;
				break;			
			}
		}	
		
		if(ans!=-1) break;
	}
	
	printf("%d\n", ans);
}	

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                             \
  cerr << __LINE__ << ": " << #x << " = {";          \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) { \
    cerr << ((hoge) ? "," : "") << x[hoge];          \
  }                                                  \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int A[N];
  long long cnt[N];
  fill(cnt, cnt + N, 0);
  for (int i = 0; i < N; i++) cin >> A[i], cnt[--A[i]]++;
  long long sum = 0;
  for (int i = 0; i < N; i++) sum += cnt[i] * (cnt[i] - 1) / 2;
  for (int k = 0; k < N; k++) {
    cout << sum - (cnt[A[k]] * (cnt[A[k]] - 1) / 2)
                + ((cnt[A[k]] - 1) * (cnt[A[k]] - 2) / 2)
         << endl;
  }

  return 0;
}


Measured memory_bytes: 6016
#include <cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
int main() {
	ll n, m;
	cin >> n >> m;
	cout << abs(n - 2) * abs(m - 2) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

char alphabet(int remainder){
	if (remainder == 1){
		return 'a';
	}
	else if (remainder == 2){
		return 'b';
	}
	else if (remainder == 3){
		return 'c';
	}
	else if (remainder == 4){
		return 'd';
	}
	else if (remainder == 5){
		return 'e';
	}
	else if (remainder == 6){
		return 'f';	
	}
	else if (remainder == 7){
		return 'g';
	}
	else if (remainder == 8){
		return 'h';
	}
	else if (remainder == 9){
		return 'i';
	}
	else if (remainder == 10){
		return 'j';
	}
	else if (remainder == 11){
		return 'k';
	}
	else if (remainder == 12){
		return 'l';
	}
	else if (remainder == 13){
		return 'm';
	}
	else if (remainder == 14){
		return 'n';
	}
	else if (remainder == 15){
		return 'o';
	}
	else if (remainder == 16){
		return 'p';
	}
	else if (remainder == 17){
		return 'q';
	}
	else if (remainder == 18){
		return 'r';
	}
	else if (remainder == 19){
		return 's';
	}
	else if (remainder == 20){
		return 't';
	}
	else if (remainder == 21){
		return 'u';
	}
	else if (remainder == 22){
		return 'v';
	}
	else if (remainder == 23){
		return 'w';
	}
	else if (remainder == 24){
		return 'x';
	}
	else if (remainder == 25){
		return 'y';
	}
	else if (remainder == 26){
		return 'z';
	}
}

int main(){
	long long input;
	string ans = "";
	cin >> input;
	while(input){
		if(input%26==0){
			ans = 'z' + ans;
			input = input - 26;
		} else {
			int remainder = input % 26;
			char a = alphabet(remainder);
			ans = a + ans;		
		}
		input /= 26;
	}
	cout << ans << endl;
}	


Measured memory_bytes: 3572
N = int(input())
A = input()
B = input()
C = input()

cnt = 0

for n in range(N):
    if A[n] == B[n] and A[n] == C[n]:
        pass
    elif A[n] == B[n] or A[n] == C[n] or B[n] == C[n]:
        cnt += 1
    else:
        cnt += 2

print(cnt)

Measured memory_bytes: 3064
#include "bits/stdc++.h"

using namespace std;

#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define print(s) cout<<(s)<<endl
#define lint long long
#define yes "Yes"
#define no "No"

typedef pair<int, int> P;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b; cin>>a>>b;
    if(b>a) swap(a,b);
    int ans;
    if((a-b)>=2) ans = a+(a-1);
    else ans = a+b;
    print(ans);
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		ArrayList<Integer> d = new ArrayList<>();
		for(int i=0; i<n; i++) {
			d.add(sc.nextInt());
		}
		Collections.sort(d);
		int m1 = d.get(d.size()/2);
		int m2 = d.get(d.size()/2-1);
		System.out.println(m1-m2);
		sc.close();
	}
}


Measured memory_bytes: 61456
import math

N,D = map(int,input().split())

count = 0

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


# print(L)

for j in range(len(L)):
    x = L[j][0]
    y = L[j][1]
    d = math.sqrt(x**2 + y**2)
    if d <= D:
        count += 1

print(count)

Measured memory_bytes: 45296
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(12);
    ll N;
    string C;
    cin >> N >> C;
    ll whi = 0;
    REP(i,N)if(C[i] == 'R')whi++;
    ll mini = 0;
    REP(i,whi){
        if(C[i] == 'W')mini++;
    }
    cout << mini << "\n";
}

Measured memory_bytes: 3724
package main

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

const (
	m = 1000000007
)

func main() {
	h := readInt()
	w := readInt()
	a := make([]string, 2)
	a[0] = readString()
	a[1] = readString()
	dp := make([][]int, 2)
	dp[0] = make([]int, w)
	dp[1] = make([]int, w)
	dp[0][0] = 1
	for i := 0; i < h-1; i++ {
		for j := 0; j < w-1; j++ {
			if a[0][j+1] != '#' {
				dp[0][j+1] = (dp[0][j+1] + dp[0][j]) % m
			}
			if a[1][j] != '#' {
				dp[1][j] = dp[0][j]
			}
		}
		if a[1][w-1] != '#' {
			dp[1][w-1] = dp[0][w-1]
		}
		a[0], a[1] = a[1], readString()
		dp[0], dp[1] = dp[1], dp[0]
		for j := 0; j < w; j++ {
			dp[1][j] = 0
		}
	}
	for j := 0; j < w-1; j++ {
		if a[0][j+1] != '#' {
			dp[0][j+1] = (dp[0][j+1] + dp[0][j]) % m
		}
	}
	fmt.Println(dp[0][w-1])
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}

func printIntln(v ...int) {
	b := make([]byte, 0, 4096)
	for i := 0; i < len(v)-1; i++ {
		b = append(b, strconv.Itoa(v[i])...)
		b = append(b, " "...)
	}
	b = append(b, strconv.Itoa(v[len(v)-1])...)
	fmt.Println(string(b))
}


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

using namespace std;
vector<int> dp;

int calculate_path(vector<vector<int>> &graph, int s)
{
	if(s == graph.size()+1)
		return 0;

	if(dp[s] != -1)
		return dp[s];

	int ans = 0;
	for(int i = 0;i<graph[s].size(); i++)
	{
		ans = max(ans, calculate_path(graph, graph[s][i])+1);
	}

	dp[s] = ans;
	return dp[s];
}

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

	vector<vector<int>> graph(n+1, vector<int> ());

	for(int i = 0;i<m;i++)
	{
		int x,y;
		cin>>x>>y;
		graph[x].push_back(y);
	}
	for(int i = 0;i<=n;i++)
		dp.push_back(-1);

	int ans = 0;	
	for(int i = 1;i<=n;i++)
	{
		if(dp[i] == -1)
			ans = max(ans, calculate_path(graph, i));
	}

	cout<<ans<<endl;
}

Measured memory_bytes: 8312
x = int(input())
def fctr1(n): 
    f=[]
    c=0
    r=int(n**0.5)
    for i in range(2,r+2):
        while n%i==0:
            c+=1
            n=n//i
        if c!=0:
            f.append([i,c])
            c=0
    if n!=1:
        f.append([n,1])
    return f

def divisor(n):
    ass = []
    for i in range(1,int(n**0.5)+1):
        if n%i == 0:
            ass.append(i)
            if i**2 == n:
                continue
            ass.append(n//i)
    return ass 
def cal(a,b):
    return a-b
def cal1(a,b):
    return a**4 + a**3*b+a**2*b**2+a*b**3+b**4


# X  = divisor(x)
# X.sort()
# l = []
# print(len(X))
# print(X)
# for i in x:
k = []
for i in range(-200,200):
    for j in range(-200,200):
        if cal(i,j)*cal1(i,j) == x:
            print(i,j)
            exit()


Measured memory_bytes: 9236
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <complex>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
const double EPS = 1e-8;
const double INF = 1e12;
typedef complex<double> P;
namespace std {
  bool operator < (const P& a, const P& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}

double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}

struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
};
int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;
}


bool intersectLL(const L &l, const L &m) {
  return abs(cross(l[1]-l[0], m[1]-m[0])) > EPS || // non-parallel
    abs(cross(l[1]-l[0], m[0]-l[0])) < EPS;   // same line
}
bool intersectSS(const L &s, const L &t) {
  return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 &&
    ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0;
}
P crosspoint(const L &l, const L &m) {
  double A = cross(l[1] - l[0], m[1] - m[0]);
  double B = cross(l[1] - l[0], l[1] - m[0]);
  if (abs(A) < EPS && abs(B) < EPS) return m[0]; // same line
  if (abs(A) < EPS) assert(false); // !!!PRECONDITION NOT SATISFIED!!!
  return m[0] + B / A * (m[1] - m[0]);
}
int main(){
  int T; cin>>T;
  int xa,ya,xb,yb;
  while(cin>>xa>>ya>>xb>>yb){
    L newline(P(xa,ya),P(xb,yb));
    vector< pair<double, int> > cps;
    int n; cin>>n;
    while(n--){
      int x1,y1,x2,y2,o,l;
      cin>>x1>>y1>>x2>>y2>>o>>l;
      L ln(P(x1,y1),P(x2,y2));
      if(intersectSS(newline, ln)){
        cps.push_back(make_pair(abs(crosspoint(newline,ln)-newline[0]), o ^ l));
      }
    }
    sort(cps.begin(), cps.end());

    int ans = 0;
    FOR(i,1,cps.size()){
      if(cps[i].second != cps[i-1].second)ans++;
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 940
n,m = map(int,input().split())


correct = [0] * (n+1)
wrong = [0] * (n+1)



for _ in range(m):
    problem,result_text = input().split()
    problem = int(problem)
    
    if result_text == "AC":
        correct[problem]=1
        
    
    if result_text == "WA":
        if correct[problem] == 0:
            wrong[problem] += 1
    

for problem in range(n+1):
    if correct[problem] == 0:
        wrong[problem] = 0



print ( sum(correct), sum(wrong) )
        


Measured memory_bytes: 4596
#include<cstdio>
#include<algorithm>

using namespace std;

const long long inf = 1e15;

int L;
int A[200200];

void input(){
	scanf("%d", &L);
	for(int i = 0; i < L; ++i){
		scanf("%d", A + i);
	}
}

long long dp[200200][5];

int getCost(int a, int i){
	if(a == 0){
		if(i == 0 || i == 4) return 0;
		else if(i == 1 || i == 3) return 2;
		else return 1;
	}else{
		if(i == 0 || i == 4) return a;
		int x = a % 2;
		int v = (i == 2 ? 1 : 0);
		return x ^ v;
	}
}

long long solve(){
	for(int i = 0; i <= L; ++i){
		for(int j = 0; j < 5; ++j){
			dp[i][j] = inf;
		}
	}
	for(int i = 0; i < 5; ++i) dp[0][i] = 0;
	for(int i = 0; i < L; ++i){
		for(int j = 0; j < 5; ++j){
			for(int k = 0; k <= j; ++k){
				long long tmp = dp[i][k] + getCost(A[i], j);
				dp[i + 1][j] = min(dp[i + 1][j], tmp);
			}
		}
	}
	long long ans = inf;
	for(int j = 0; j < 5; ++j){
		ans = min(ans, dp[L][j]);
	}
	return ans;
}

int main(){
	input();
	long long ans = solve();
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 8704
N = int(input())

# 文字列(3,5,7)を後ろに付け加えていく

def dfs(S):
  if int(S) > N:
    return 0
  
  count = 1 if all(S.count(x) > 0 for x in '753') else 0
  for x in '753':
    count += dfs(S+x)
    
  return count

print(dfs('0'))
  

Measured memory_bytes: 2940
#include<stdio.h>
int main()
{
    int n,m,dp[3][110],a,b,ans;
    scanf("%d%d",&n,&m);
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < 3; j++)
        {
            dp[j][i] = -1;
        }
    }
    for(int i = 0; i < m; i++)
    {
        scanf("%d%d",&a,&b);
        for(int j = 0; j < 3; j++)
        {
            if(j == b - 1);
            else dp[j][a - 1] = 0;
        }
    }
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < 3; j++)
        {

            if(dp[j][i] == 0);
            else if(i == 0)dp[j][i] = 1;
            else if(i == 1)dp[j][i] = (dp[0][i - 1] + dp[1][i - 1] + dp[2][i - 1]) % 10000;
            else
            {
                dp[j][i] = 0;
                for(int k = 0; k < 3; k++)
                {
                    for(int l = 1; l < 3; l++)
                    {
                        dp[j][i] = (dp[j][i] + dp[k][i - l]) % 10000;
                    }
                }
                if(dp[j][i - 1] == 0)
                {
                    for(int k = 0; k < 3; k++)
                    {
                        dp[j][i] = (dp[j][i] - dp[k][i - 2]) % 10000;
                    }
                }
                else
                {
                    for(int k = 1; k < 3; k++)
                    {
                        dp[j][i] = (dp[j][i] - dp[j][i - k]) % 10000;
                    }
                }
            }
        }
    }
    ans = (dp[0][n - 1] + dp[1][n - 1] + dp[2][n - 1]) % 10000;
    if(ans < 0)ans = 10000 + ans;
    printf("%d\n",ans);
    return 0;
}

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

Measured memory_bytes: 600