akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define show(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define show(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<62;
const double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;

}

long long int euler_phi(long long int n){
    long long int res=n;
    for(long long int i=2; i*i<=n; ++i){
        if(n%i==0){
            res=res/i*(i-1);
            while(n%i==0) n/=i;
        }
    }
    if(n!=1) res=res/n*(n-1);
    return res;
}

void solve(){
    int n;
    cin >> n;
    cout << euler_phi(n) << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}

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

typedef long long int ll;

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

    if(s[s.size() - 1] == 's'){
        s += "es";
    }
    else{
        s += 's';
    }

    cout << s;

    return 0;
    
}


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

//imos法というものがあるらしい。程度は違うが同じことしようとしてた
int main() {
    int N, C; cin >> N >> C;
    vector<vector<int>> imos(30, vector<int> (200001, 0));
    for (int i = 0; i < N; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        a *= 2; b *= 2; a--; c--;
        imos[c][a] ++;
        imos[c][b] --;
    }
    for (int i = 0; i < C; i++) {
        for (int j = 1; j < 200001; j++) {
            imos[i][j] += imos[i][j-1];
        }
    }
    for (int i = 0; i < C; i++) {
        for (int j = 0; j < 200001; j++) {
            if (imos[i][j]) imos[i][j] = 1;
        }
    }

    int ans = 0;
    for (int i = 0; i < 200001; i++) {
        int val = 0;
        for (int j = 0; j < C; j++) {
            val += imos[j][i];
        }
        ans = max(ans, val);
    }
    cout << ans << endl;
}

Measured memory_bytes: 24576
#include<bits/stdc++.h>
using namespace std;
#define debug(x) cout<<"### "<<x<<endl;
#define For(a,b,c) for(int a=b;a<=c;++a)
#define Dor(a,b,c) for(int a=b;a>=c;--a)
inline int read(){
    int x=0;char c=getchar();
    while(c<'0'||c>'9')c=getchar();
    while(c>='0'&&c<='9')x=(x<<3)+(x<<1)+(c^48),c=getchar();
    return x;
}
int main(){
	int a,b;
	cin>>a>>b;
	cout<<(a+b-3)/(a-1)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    string S; cin >> S;
    string M="ACGT";
    int ans=0;
    rng(i,1,SZ(S)+1){
        rep(j,SZ(S)-i+1){
            string T=S.substr(j,i);
            bool can=true;
            rep(k,SZ(T)){
                if(M.find(T[k])==string::npos){
                    can=false;
                }
            }
            if(can) chmax(ans,i);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
int mod = (int)1e9 + 7;
int INF = (int)2e18;


signed main() {
    string S;
    cin >> S;
    string ans = "Good";
    for (int i = 0; i < S.length() - 1; i++) {
        if (S[i] == S[i + 1]) ans = "Bad";
    }
    cout << ans << endl;
}


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

int main()
{
	int N;
	long a[302][302];
	long b[302][302];
	bool v[302][302];
	cin >> N;

	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N; j++) {
			cin >> a[i][j];
			b[i][j] = a[i][j];
			
		}
	}

	for (int i = 1; i <= N; i++)
		for (int j = 1; j <= N; j++) v[i][j] = 1;

	for (int k = 1; k <= N; k++)
		for (int i = 1; i <= N; i++)
			for (int j = 1; j <= N; j++) if (a[i][j]>=a[i][k] + a[k][j]&&i!=k&&j!=k) {
				a[i][j] = a[i][k] + a[k][j];
				v[i][j] = v[j][i] = 0;
			}

	for (int i = 1; i <= N; i++)
		for (int j = 1; j <= N; j++)if (a[i][j] != b[i][j]) 
		{ 
			cout << -1;
			return 0; 
		}

	long long ans = 0;

	for (int i = 1; i <= N; i++) 
		for (int j = i+1; j <= N; j++) {
			if (v[i][j]) ans+=a[i][j];
		}

	cout << ans;

    return 0;
}

Measured memory_bytes: 1792
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

ll mod(ll a){
  return (a % 1000000007);
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}


int main(){
  ll n,k; cin >> n >> k; ll sum = 0;
  
  for(ll i=k; i <= n+1; i++){

    sum += mod((i*(2*n-i+1)/2) - (i*(i-1)/2) + 1);
    sum = mod(sum);

  }
  
  cout << sum << endl;
}

Measured memory_bytes: 3636
#include<stdio.h>
int main()
{
    int a,b,c;
    while(scanf("%d%d%d",&a,&b,&c)==3)
    {
        if(a==b)printf("%d\n",c);
        else if(a==c)printf("%d\n",b);
        else printf("%d\n",a);
    }
    return 0;
}


Measured memory_bytes: 128
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    H = I()
    W = I()

    ans = (N - H + 1) * (N - W + 1)
    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10052
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int w, h;
vector<vector<int>> m(50, vector<int>(50));
vector<vector<bool>> searched(50, vector<bool>(50, false));
vector<int> dx = {1, 1, 1, 0, -1, -1, -1, 0};
vector<int> dy = {-1, 0, 1, 1, 1, 0, -1, -1};

void DFS(int i, int j) {
    if (i < 0 || h <= i || j < 0 || w <= j) return;
    if (m[i][j] == 0) return;
    if (searched[i][j]) return;
    
    searched[i][j] = true;
    rep(k, 8) DFS(i + dx[k], j + dy[k]);
    return;
}

int main() {
    while (true) {
        cin >> w >> h;
        if (w == 0 && h == 0) break;
        rep(i, h) rep(j, w) cin >> m[i][j];
        rep(i, h) rep(j, w) searched[i][j] = false;
        
        int cnt = 0;
        rep(i, h) rep(j, w) {
            if (m[i][j] == 0) continue;
            if (searched[i][j]) continue;
            ++cnt;
            DFS(i, j);
        }
        
        cout << cnt << endl;
    }
    return 0;
}


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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    lint A, B, C, K;
    cin >> A >> B >> C >> K;
    lint ans = 0;
    if (K <= A) {
        cout << K << endl;
        return 0;
    } else if (K <= A + B) {
        cout << A << endl;
        return 0;
    } else {
        cout << A + (K - (A + B)) * (-1) << endl;
        return 0;
    }
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
#define ll long long
#define ld long double
using namespace std;

int graph[1010][1010], looking[1010], cyc[1010], N, M, looked[1010];
int dfs(int key, int now){
    looked[key]=1;
    looking[key]=now;
    cyc[now]=key;
    for(int i=1; i<=N; ++i){
        if(graph[key][i]){
            if(looking[i]) return looking[i];
            else if(looked[i]==0){
                int a=dfs(i, now+1);
                if(a) return a;
            }
        }
    }
    looking[key]=0;
    cyc[now]=0;
    return 0;
}

vector<int> sophis(vector<int> &v){
    int w=v.size();
    for(int i=0; i<w; ++i){
        for(int j=0; j<w; ++j){
            if(graph[v[i]][v[j]] && (i+1)%w!=j){
                vector<int> x;
                for(int k=j; (i+1)%w!=k; k=(k+1)%w){
                    x.push_back(v[k]);
                }
                return sophis(x);
            }
        }
    }
    return v;
}

int main() {
	cin >> N >> M;
	for(int i=0; i<M; ++i){
	    int a, b;
	    cin >> a >> b;
	    graph[a][b]=1;
	}
	for(int i=1; i<=N; ++i){
	    if(looked[i]==0){
	        int t=dfs(i, 1);
	        if(t){
	            vector<int> ans;
	            for(int j=t; cyc[j]>0; ++j) ans.push_back(cyc[j]);
	            ans=sophis(ans);
	            cout << ans.size() << endl;
	            for(int i=0; i<ans.size(); ++i) cout << ans[i] << endl;
	            return 0;
	        }
	    }
	}
	cout << -1 << endl;
	return 0;
}


Measured memory_bytes: 3712
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#define ll long long
#define db double
using namespace std;
int n,m,de[100010],cnt,x1[100010],r[200010],vt[200010];
ll va[200010],v[100010];
void add(int a,int b,ll k) 
{
	cnt++;r[cnt]=x1[a];x1[a]=cnt;vt[cnt]=b;va[cnt]=k;
	cnt++;r[cnt]=x1[b];x1[b]=cnt;vt[cnt]=a;va[cnt]=k;
} 
void dfs(int i,ll vv) 
{
	int s,a,b;
	v[i]=vv;
	a=x1[i];
	while(a)
	{
		b=vt[a];
		if(!de[b])de[b]=de[i]+1,dfs(b,vv+va[a]);
		a=r[a];
	}
} 
int main()
{
	int i,s,a,b,c,d,k;
	ll j;
	while(cin>>n)
	{
		cnt=0;for(i=1;i<=n;i++)x1[i]=de[i]=v[i]=0;
		for(i=1;i<n;i++)scanf("%d%d%lld",&a,&b,&j),add(a,b,j);
		scanf("%d%d",&m,&k);de[k]=1;dfs(k,0);
		for(i=1;i<=m;i++)scanf("%d%d",&a,&b),printf("%lld\n",(ll)(v[a]+v[b]));
	}
	return 0;
}

Measured memory_bytes: 9600
/*enjoy karo yaar*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

#include<bits/stdc++.h>
using namespace std;

#define     int          long long int
#define     ld           long double
#define     fast()       ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)       x.begin(),x.end()
#define     mem(a,b)     memset(a,b,sizeof(a))
#define     gcd(a,b)     (__gcd((a),(b)))
#define     lcm(a,b)     (((a)*(b))/gcd((a),(b)))
#define     pb           push_back
#define     ins          insert
#define     pii          pair<int,int>
#define     F            first
#define     S            second
#define     show(x)      for(auto c:x)cout<<c<<" ";cout<<"\n";

const int inf=1e18,M=1e9+7;
const int N=1;

void solve()
{
    int n,m;
    cin>>n>>m;

    vector<int> wa(n+1,0);
    set<int> mp;
    int x;
    string s;
    int ac=0,ans=0;
    for(int i=0;i<m;++i)
    {
        cin>>x>>s;

        if(s=="WA")
            wa[x]++;
        else
        {
            if(mp.find(x)==mp.end())
            {
                ans+=wa[x];
                ++ac;
            }

            mp.ins(x);
        }
    }

    cout<<ac<<" "<<ans;
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}



Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
int sum;
inline int read(){
    int f=1,x=0;
    char ch;
    do{
        ch=getchar();
        if(ch=='-'){
            f=-1;
        }
    }while(ch<'0'||ch>'9');
    do{
        x=x*10+ch-48;
        ch=getchar();
    }while(ch>='0'&&ch<='9');
    return f*x;
}
int main(){
    string s1,s2;
    cin>>s1>>s2;
    s1+=s2;
    for(register int i=0;i<s1.length();++i){
        sum=sum*10+s1[i]-48;
    }
    if(sqrt(sum)==(int)(sqrt(sum))){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
def snuke_coloring(H: int, W: int, N: int, queries: list) -> list:
    freq = {}
    for h, w in queries:
        # (h, w) を含む 9 この 3x3 行列に含まれる点の数を
        # 増やす。
        h, w = h-1, w-1
        for dh in range(-1, 1 + 1):
            for dw in range(-1, 1 + 1):
                if h + dh < 1 or H - 1 <= h + dh:
                    continue
                if w + dw < 1 or W - 1 <= w + dw:
                    continue

                freq.setdefault((h + dh, w + dw), 0)
                freq[(h + dh, w + dw)] += 1

    ret = [0] * 10
    # 点が 0 の 3x3 行列は freq に含まれないので、
    # (全ての 3x3 行列) - (点をもつ 3x3 行列) で求める。
    ret[0] = (H-2)*(W-2)
    for v in freq.values():
        ret[0] -= 1
        ret[v] += 1

    return ret


if __name__ == "__main__":
    N = 0
    H, W, N = map(int, input().split())
    queries = [tuple(int(s) for s in input().split()) for _ in range(N)]
    ans = snuke_coloring(H, W, N, queries)
    for a in ans:
        print(a)


Measured memory_bytes: 180044
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <random>
#include <vector>
#include <array>
#include <bitset>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
 
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

int main() {
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++){
    cin >> a[i];    
    }
    sort(a, a+n);
    reverse(a, a+n);
    int g = 0;
    for(int j = 0; j < n; j++){
        g = g + a[j];
    }
    g = g - a[0];
    if(a[0] < g){
        cout << "Yes";
    }else{
        cout << "No";
    }
    return 0;
}

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

#define ll long long

int main() {
  ll N;
  cin >> N;
  
  vector<ll> a(N), b(N);
  
  ll sum_a = 0, sum_b = 0;; 
  
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    sum_a += a[i];
  }
  
  for (int i = 0; i < N; i++) {
    cin >> b[i];
    sum_b += b[i];
  }
  
  if (sum_b - sum_a < 0) {
    cout << "No" << endl;
    return 0;
  }
  
  ll inc = 0;
  
  
  for (int i = 0; i < N; i++) {
    if (a[i] < b[i]) {
      inc += (b[i] - a[i] + 1) / 2;
    }
  }
  
  if (inc > sum_b - sum_a) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
  
  
}




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

int main(){
    ll N, W;  cin >> N >> W;
    vector<ll> w(N+1), v(N+1);
    for(int i=1; i<=N; i++) cin >> w[i] >> v[i];

    vector<vector<ll>> dp;
    dp = vector<vector<ll>>(N+1, vector<ll>(W+1, 0));
    for(int i=1; i<=N; i++){
        for(int j=1; j<=W; j++){
            if(w[i] <= j){
                dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i]] + v[i]);
            }else{
                dp[i][j] = dp[i-1][j];
            }
        }
    }

    ll ans = 0;
    for(int i=0; i<=W; i++) ans = max(ans, dp[N][i]);
    cout << ans << endl;
}

Measured memory_bytes: 80256
s = input()
q = int(input())
for _ in range(q):
    query = list(input().split())
    l,r = map(int,query[1:3])
    if query[0] == 'replace':
      p = query[3]
      s = s[:l] + p + s[r+1:]
    elif query[0] == 'reverse':
      s = s[:l] + ''.join(list(reversed(s[l:r+1]))) + s[r+1:]
    else:
      print(s[l:r+1])


Measured memory_bytes: 5612
#include <iostream>
#include <iomanip>
// std::cout << std::setprecision(2) << 3.141; // "3.1"
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
// #include <bits/stdc++.h> all

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;

static const int giga = pow(10,9);
// double pi = 3.141592653589793238463;

int main(void){
  int n; cin >> n;
  vector<int> d(n);

  for(int i = 0; i < n; i++){
    int temp; cin >> temp;
    d[i] = temp;
  }

  long long int ans = 0;

  for(int i = 0; i < n; i++){
    for(int j = i+1; j < n; j++){
      ans += d[i]*d[j];
    }
  }

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

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<cstdlib>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<queue>

using namespace std;

string s;

int main(){
  cin>>s;
  int len = (int)s.length();
  bool eq = (s[0] == s[len-1]);
  bool ev = ((len%2) == 1);
  if(!(eq ^ ev)){
    cout<<"Second"<<endl;
  } else {
    cout<<"First"<<endl;
  }
  return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
#define INF 0x3f3f3f3f
const int maxn=20;
#define _rep(i,a,b) for(int i=(a);i<=(b);++i)
int n,a[maxn],x[maxn][maxn],y[maxn][maxn],pan[maxn],ans;
vector<int> h;
bool check()
{
    // for(unsigned int i=0;i<h.size();i++)
    //     cout<<h[i]<<" ";
    // cout<<endl;

    for(int i=1;i<=n;i++)   pan[i]=0;
    for(unsigned int i=0;i<h.size();i++)
    {
        int p=h[i];
        pan[p]=1;
    }   
    for(unsigned int i=0;i<h.size();i++)
    {
        int p=h[i];
        for(int j=1;j<=a[p];j++)
        {
            if(pan[x[p][j]]==y[p][j])
                continue;
            else
                return false;
        }
    }
    return true;
}
void dfs(int k)
{
    if(k>n)
    {
        if(check())
            ans=max(ans,(int)h.size());
        return;
    }
    dfs(k+1);
    h.push_back(k);
    dfs(k+1);
    h.pop_back();
}

int main()
{
    #ifdef __LOCAL__
        freopen("1.in","r",stdin);
        freopen("1.out","w",stdout);
    #endif
    cin>>n;
    _rep(i,1,n)
    {
        cin>>a[i];
        _rep(j,1,a[i])
            cin>>x[i][j]>>y[i][j];
    }
    dfs(1);    
    cout<<ans<<endl;
    return 0;
}

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

int main() {
  ll N, A, B, C, D, E;
  cin >> N >> A >> B >> C >> D >> E;
  ll per = min({A, B, C, D, E});
  cout << N / per + (N % per != 0 ? 1 : 0) + 4 << endl; 
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <set>
#include <math.h>
#include <queue>
#include <stdio.h>
#include <sstream>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)

int main()
{   
    int n;
    cin >> n;
    i64 t[5] = {0};
    rep(i,n)
    {
        string s;
        cin >> s;
        s = s.substr(0,1);
        if(s=="M") t[0]++;
        else if(s=="A") t[1]++;
        else if(s=="R") t[2]++;
        else if(s=="C") t[3]++;
        else if(s=="H") t[4]++;
    }

    i64 cnt = 0;
    rep(i,3)
        rep2(j,i+1,4)
            rep2(k,j+1,5)
                cnt += t[i]*t[j]*t[k];

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);

    int n;
    cin >> n;

    string S;
    cin >> S;


    int r = 0, w = 0;

    for (auto c : S) {
        if (c == 'R') {
            ++r;
        } else {
            ++w;
        }
    } 

    int res = min(r, w);

    int cnt = 0;

    for (int l = 0, r = n - 1; l < r; ) {
        while (l < r && S[l] == 'R') {
            ++l;
        }
        while (l < r && S[r] == 'W') {
            --r;
        }
        if (l < r) {
            ++cnt;
            ++l;
            --r;
        }
    }

    res = min(res, cnt);

    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 3680
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}

int main()
{ //input->compute->output

        string S;
        cin >> S;
        sort(S.begin(), S.end());
        for (char c = 'a'; c <= 'z'; c++)
        {
                bool ok = true;
                for (int i = 0; i < S.size(); i++)
                {
                        if (c == S[i])
                        {

                                ok = false;
                        }
                }
                if (ok)
                {
                        cout << c << endl;
                        return 0;
                }
        }

        cout << "None" << endl;

        return 0;
}



Measured memory_bytes: 512
(* --------------Encoder-------------- *)
(* -----function----- *)
let encoder = float_of_string (read_line ())

(* -------test------- *)
let test1 = (encoder = 0.0)
(* ----------------------------------- *)

(* --------------Decoder-------------- *)
(* -----function----- *)
let decoder ans = string_of_float ans

(* -------test------- *)
(* ----------------------------------- *)

(* --------------Processor-------------- *)
(* -----function----- *)
(* purpose
 *      与えられた半径から周長を求める
*)

(* function type
        processor : float -> float
*)
let rec processor r = 2.0 *. Float.pi *. r
(* -------test------- *)
let test1 = (processor 0.0 = 0.0)
let test2 = (processor 1.0 = 6.28318530717958623200)
(* ----------------------------------- *)


(* ----------------main---------------- *)
(*let () = print_endline (decoder (processor encoder))*)
let main () =
        Printf.fprintf stdout "%.20f\n" (processor encoder)
let _ = main ()
(* ------------------------------------ *)


Measured memory_bytes: 3840
import java.util.*;
public class Main{
   public static void main(String[] args) {
     Scanner sc = new Scanner(System.in);
     int  N = sc.nextInt();
     int[] H = new int[N];
     int i,delta;
     boolean flag=true;
     for(i=0;i<N;i++){
       H[i]=sc.nextInt();
     }
     for(i=0;i<N-1;i++){
       delta=H[N-2-i]-H[N-1-i];
       if(delta>=2){
         flag=false;
         break;
       }else if(delta==1){
         H[N-2-i]--;
       }
     }
     if(flag){
       System.out.println("Yes");
     }else{
       System.out.println("No");
     }
   }
}


Measured memory_bytes: 50200
#include<iostream>
using namespace std;
int main(){
  int N;
  cin>>N;
 // int hen[N];
  int max=0;
  int sum=0;int a;
  for(int i=0;i<N;i++){
    cin>>a;
    sum+=a;
    if(max<a)max=a;
  }
  sum=sum-max;
  if(sum>max){
    cout<<"Yes";
  }else{
    cout<<"No";}
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long int
using namespace std;
template<typename T,typename U> using P=pair<T,U>;
template<typename T> using V=vector<T>;
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}
#define DUMP(x) cout<<#x<<" = "<<(x)<<endl
#define COUT(x) cerr<<#x<<" = "; cout<<(x)<<endl

struct edge { int to, cost; };

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

signed main()
{
   int n, Q; cin >> n >> Q;
   string s; cin >> s;
   V<int> l(Q), r(Q);
   for (int i = 0; i < Q; i++) {
      cin >> l[i] >> r[i];
      --l[i]; --r[i];
   }

   V<bool> a(n, false);
   for (int i = 1; i < n; i++) {
      if (s[i] == 'C' && s[i-1] == 'A') {
         a[i] = true;
      }
   }

   V<int> sum(n+1);
   for (int i = 0; i < n; i++) {
      sum[i+1] = sum[i] + (a[i] ? 1 : 0);
   }

   for (int i = 0; i < Q; i++) {
      int ans = sum[r[i]+1] - sum[l[i]] - (a[l[i]] ? 1 : 0);
      cout << ans << endl;
   }

   return 0;
}


Measured memory_bytes: 3456
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		long K = Long.parseLong(sc.next());
		Map<Integer, Long> map = new TreeMap<Integer, Long>();
		for(int i = 0; i < N; i++) {
			int a = Integer.parseInt(sc.next());
			long b = Long.parseLong(sc.next());
			if(map.containsKey(a)) {
				b += map.get(a);
			}
			map.put(a, b);
		}
		
		long cnt = 0;
		for(int key : map.keySet()) {
			cnt += map.get(key);
			if(cnt >= K) {
				System.out.println(key);
				return;
			}
		}
	}
}


Measured memory_bytes: 66396
#include <bits/stdc++.h>
#define sync                    \
  ios_base::sync_with_stdio(0); \
  cin.tie(0);                   \
  cout.tie(0)
#define ss second
#define ff first
#define ll long long
#define mp make_pair
#define endl "\n"
#define pb push_back
#define ld long double
#define M_PI 3.14159265358979323846
#define puss vector
#define ull unsigned long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for (int i = (b)-1; i >= (a); --i)

double EPS = 0.0000001;
const ll INF = 1000000007;

using namespace std;

int main(){
    int a,b;
    cin>>a>>b;
    string s;
    cin>>s;
    int ind=0, cnt=0;
    FOR(i, 0, s.size()) if (s[i]=='-') ind=i, cnt++;
    if (s.size()!=a+b+1||cnt>1||cnt==0||ind!=a){
        cout<<"No";
        return 0;
    }
    FOR(i, ind+1, s.size()) if(!(s[i]>='0'&&s[i]<='9')){
        cout<<"No";
        return 0;
    }
    cout<<"Yes";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <utility> // pair
#include <string>
#include <vector>
#define MAX_N 200001
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define FOR(i, a, b) for(ll i=a; i<b; i++)
#define REP(i, n) for(ll i=0; i<n; i++)
#define REV(i, n) for(ll i=n-1; i>=0; i--)
#define ALL(v) v.begin(), v.end()
#define pb push_back
const ll INF = 9e18;
ll n, a , b;

signed main(){
    cin >> a >> b;
    ll cnt = 0;
    if(b==1) cout << 0 << endl;
    else if(b <= a) cout << 1 << endl;
    else{
        b -= a;
        cnt++;
        while(b > 0){
            b -= (a - 1);
            cnt++;
        }
        cout << cnt << endl;
    }
    return 0;
}

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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;

int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];

    ll x = 0;
    for (ll i = 62; i >= 0; i--) {
        int c = 0;
        ll b = 1LL << i;
        REP(j, n) {
            if (a[j] & b) c++; else c--;
        }
        if (c <= 0 && x + b <= k) x += b;
    }

    ll ans = 0;
    REP(i, n) ans += a[i] ^ x;

    cout << ans << endl;
}

Measured memory_bytes: 1152
MOD = 10 ** 9 + 7

def pow(x, n, mod = MOD)
  ans = 1
  while n > 0 do
    ans = ans * x % mod if n.odd?
    x = x * x % mod
    n >>= 1
  end
  return ans
end

def inv(x, mod)
  return pow(x, mod - 2, mod)
end

@fact = [1]
def fact(n, mod = MOD)
  return @fact[n - 1] unless @fact[n - 1].nil?

  f = @fact[-1]
  (@fact.size + 1).upto(n) do |i|
    f = (f * i) % mod
    @fact << f
  end
  return @fact[n - 1]
end

def perm(n, r, mod = MOD)
  return n.downto(n - r + 1).reduce(1) {|ans, x| (ans * x) % mod }
end

def comb(n, r, mod = MOD)
  return 0 unless 0 <= r && r <= n
  return 1 if r == 0 || r == n
  return perm(n, r, mod) * inv(fact(r, mod) % mod, mod) % mod
end

n, a, b = gets.chomp.split(" ").map(&:to_i)

puts ((pow(2, n) - 1) - comb(n, a) - comb(n, b)) % MOD


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

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

    int i = 1;
    while(1){
       int x = i;
       

       if (x % 3 == 0){
          cout <<" " <<i;
          
       }
 
       else {
             while(1){
                 if (x %10 == 3){
                     cout<<" " <<i;
                     break;
                  }
                  x /=10;
                  if(x == 0) break;
              }
       }
       if (++i > n) break;
    }
     cout<<endl;
     return 0;
}
    
    


Measured memory_bytes: 3096
# N = int(sys.stdin.readline())
# INF = float("inf")
import sys

# N,M = map(int,sys.stdin.readline().split())
# abx = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(M)) # multi line with multi param

# imos=[[0]*(N) for _ in range(N)]

# for a,b,x in abx:
#     imos[a-1][b-1] += 1
#     if a+x-1+1 < N and b+x-1+1 < N:
#         imos[a+x-1+1][b+x-1+1] -= 1
#         imos[a+x-1+1][b-1+1] -= 1
# print(imos)
# for r in range(N):
#     for c in range(N):
#         imos[r][c] += imos[r-1][c-1]#+imos[r][c-1]
# print(imos)

a,b = map(int,sys.stdin.readline().split())
N = int(sys.stdin.readline())
sf = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(N)) # multi line with multi param
M = 1000
imos = [0]*(M+1)
imos[a] += 1
imos[b] -= 1

for s,f in sf:
    imos[s] += 1
    imos[f] -= 1
for i in range(M):
    imos[i+1] += imos[i]
for i in range(a,b+1):
    if imos[i] > 1:
        print("1")
        exit()
print("0")


Measured memory_bytes: 5612
/*  

    IITAPOORV094

/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
|                                        |
|   *******     *******     ********     |
|      |           |            |        |
|      |           |            |        |
|      |           |            |        |
|   *******     *******         |        |
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

*/

 
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>


#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define MEM(a, b) memset(a, (b), sizeof(a))

#define for0(i, n) for (int i = 0; i < (int)(n); ++i) // 0 based indexing
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i) // 1 based indexing
#define forc(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i) // closed interver from l to r r inclusive
#define forr0(i, n) for (int i = (int)(n) - 1; i >= 0; --i) // reverse 0 based.
#define forr1(i, n) for (int i = (int)(n); i >= 1; --i) // reverse 1 based

//short hand for usual tokens
#define pb push_back
#define fi first
#define se second

// to be used with algorithms that processes a container Eg: find(all(c),42)
#define all(x) (x).begin(), (x).end() //Forward traversal
#define rall(x) (x).rbegin, (x).rend() //reverse traversal

// traversal function to avoid long template definition. Now with C++11 auto alleviates the pain.
#define tr(c,i) for(__typeof__((c)).begin() i = (c).begin(); i != (c).end(); i++)

// find if a given value is present in a container. Container version. Runs in log(n) for set and map
#define present(c,x) ((c).find(x) != (c).end())

//find version works for all containers. This is present in std namespace.
#define cpresent(c,x) (find(all(c),x) != (c).end())

// Avoiding wrap around of size()-1 where size is a unsigned int.
#define sz(a) int((a).size())


using namespace std;

// Shorthand for commonly used types
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef double ld;
typedef map<int,int> MPI;
typedef set<int> SETI;
typedef multiset<int> MSETI;

ll dp[10001][101][2];


ll solve(string &k,ll D,ll d,ll pos,ll tght)
{
	ll ub=(tght) ? (k[pos]-'0') :9;

	if(dp[pos][d][tght]!=-1)
	{
		return(dp[pos][d][tght]);
	}
	if(pos==k.length()-1)
	{
		ll ans=0;
		forc(i,0,ub)
		{
			if(i%D==d)
			{
				ans++;
			}
		}
		return(ans);
	}
	
	ll ans=0;
	forc(i,0,ub)
	{
		ans=(ans+solve(k,D,(D+d-i%D)%D,pos+1,(tght)&&(i==ub)))%MOD;
	}
	return(dp[pos][d][tght]=ans);
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string k;
    cin>>k;
    MEM(dp,-1);
    ll D;
    cin>>D;
    cout<<(MOD+solve(k,D,0,0,1)-1)%MOD;  //as zero is included
    return 0;
}


Measured memory_bytes: 17024
r, l = map(int, (input().split()))

ans = 0 if l - r >= 2019 else 2018
max_l = min(l, (r//2019+1)*2019)

for i in range(r, max_l):
    for j in range(i+1, max_l+1):
        ans = min((i * j) % 2019, ans)
    
        if ans == 0:
            break
    
print(ans)


Measured memory_bytes: 39664
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            int T = in.nextInt();

            out.println(T / a * b);
        }

    }
}



Measured memory_bytes: 23252
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		
		int count = 0;
		for(int i = 1; i<=N ; i++) {
			int length = (String.valueOf(i)).length();
			if(length %2 != 0) {
				count++;
			}
		}
		
		System.out.println(count);
		
		sc.close();	
	}

}

Measured memory_bytes: 28116
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define all(v) v.begin(), v.end()
int garr[100001];
vector<pair<pair<int, int>, int>> gvec;
int gv, gk;
int dp[100001][3];
long long whatdo(int n, int prev) { //-1 swim , 0 catch bugs, 1 homework
  long long ans = 0;
  if (n > gv)
    return 0;
  if (dp[n][prev + 2] != -1)
    return dp[n][prev + 2];
  if (prev != -1) {
    ans = max(ans, whatdo(n + 1, -1) + gvec[n].first.first);
  }
  if (prev != -0) {
    ans = max(ans, whatdo(n + 1, 0) + gvec[n].first.second);
  }
  if (prev != 1) {
    ans = max(ans, whatdo(n + 1, 1) + gvec[n].second);
  }
  return dp[n][prev + 2] = ans;
}

void solve() {
  //----------------------VARs---------------------------------------------
  char car, car2;
  string s, st;
  long long n = 0, a = 0, b = 0, c = 0, e, d = 0, m = 0, t = 0, q = 0, r = 0,
            l = 0, middle = 0, count = 0, add = 0, k, ans = 300, temp = 0,
            rootsa, save = 0, bigg = 0, save2 = 0, counter = 0, counter2 = 0,
            sum = 0, x, y;
  bool flag = false, flag2;

  //-------- --------------VARs--------------------------------------------
  vector<int> vec;
  memset(dp, -1, sizeof(dp));
  cin >> gv;
  for (int i = 1; i <= gv; i++) {
    cin >> a >> b >> c;
    gvec.push_back(make_pair(make_pair(a, b), c));
  }
  cout << whatdo(0, 2);
}
int main() {
#ifndef ONLINE_JUDGE
  system("clear");
  freopen("Test0.in", "r", stdin);
#endif
  ios_base::sync_with_stdio(false), cin.tie(0);

  cout << fixed << setprecision(10);
  int t = 1;
  // cin >> t;
  while (t--) {
    solve();
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 13572
#include<stdio.h>
#include<stdlib.h>

#define MAX 2000001
#define AMAX 10000

int main() {
  int n,i,j,*A,*B;
  int C[AMAX+1];

  scanf("%d",&n);

  A = (int *)malloc(sizeof(int) * n+1);
  B = (int *)malloc(sizeof(int) * n+1);
  
  for(i = 0 ; i <= AMAX ; i++) {
    C[i] = 0;
  }

  for(i = 0 ; i < n ; i++) {
    scanf("%d",&A[i+1]);
    C[A[i+1]]++;
  }

  for(i = 1 ; i <= AMAX ; i++) {
    C[i] = C[i] + C[i-1];
  }

  for(j = 1 ; j <= n ; j++) {
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

  for(i = 1 ; i <= n-1 ; i++) {
    printf("%d ",B[i]);
  }
  printf("%d\n",B[i]);
  return 0;
}



Measured memory_bytes: 17392
#include <stdio.h>

int main(void)
{
	double menseki, ensyu,hankei,pi;
	pi = 3.141592653589793238462643383279502884197169399375105820974944;

	scanf("%lf", &hankei);
	if (1 < hankei < 10000)
	{

		menseki = hankei * hankei * pi;
		ensyu = (hankei * 2)* pi;

		printf("%f %f", menseki, ensyu);

	}
	return 0;
}


Measured memory_bytes: 2028
#include<bits/stdc++.h>
#define pb push_back
#define sz(v) (v).size()
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define mp make_pair
#define inf 2000000005
#define mod 1000000007
using namespace std;
template <typename T> T Max(T x,T y){return x>y?x:y;}
template <typename T> T Min(T x,T y){return x<y?x:y;}
template <typename T> void chmax(T &x,T y){x=x>y?x:y;return;}
template <typename T> void chmin(T &x,T y){x=x<y?x:y;return;}

int n,x,y,max1=-inf,min1=inf,max2=-inf,min2=inf;

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&x,&y);
		chmax(max1,x+y);
		chmin(min1,x+y);
		chmax(max2,x-y);
		chmin(min2,x-y);
	}
	printf("%d\n",Max(max1-min1,max2-min2));
	return 0;
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
#define inf INFINITY
#define file freopen( "input.txt" , "r" , stdin) ; freopen( "output.txt" , "w" , stdout) ;
#define Gamed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define _3102_ main()
#define endl '\n'
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using namespace std;
const int N = 3e3 + 100;
const ll MX = 1e9;
const ll mod = 1e9 + 7;
const double eps = 1e-9 ;



int dp[N][N], step[N][N] ;  
string a , b ;

void show ( int i , int j ){
    if ( step[i][j] == 1){
        show(i-1, j -1 ) ; 
        cout << a[i] ; 
    }
    else if ( step[i][j] == 2){
        show  ( i - 1 , j ) ; 
    }
    else if ( step[i][j] == 3){
        show ( i , j-1) ; 
    }
}

int _3102_{
	Gamed
    cin >> a >> b ; 
    a.insert(0," ") , b.insert(0," ") ; 
    for ( int i = 1 ; i < a.size() ; i ++){
        for ( int j = 1 ; j < b.size() ; j++){
            if ( a[i] == b[j] ){
                dp[i][j] = dp[i-1][j-1] + 1 ; 
                step[i][j] = 1 ; 
            }
            else if ( a[i] != b[j]){
                int l1 = dp[i-1][j] , l2 = dp[i][j-1] ;
                if ( l1 > l2){
                    step[i][j] = 2 ;
                }
                else {
                    step[i][j] = 3 ;
                }
                dp[i][j] = max ( l1 , l2) ; 
            }
        }
    }
    //cout << dp[a.size()-1][b.size()-1] << endl ;  
    show ( a.size() - 1 , b.size() - 1 ) ; 
    return 0;
}



Measured memory_bytes: 76352
#[allow(unused_macros)]
macro_rules! read_i {
    ( $($args:expr ; $t:ty),* ) => {{
        let line = read_string();
        let mut line = line.split_whitespace();
        $(
            let tmp:$t = line.next().unwrap().parse().unwrap();
            *$args = tmp;
        )*
    }};
}
pub fn read_string() -> String{
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim().to_owned().to_string()
}
pub fn read_vec_i(n:usize) -> Vec<i32> {
    let mut v:Vec<i32> = Vec::new();
    let line = read_string();
    let mut line = line.split_whitespace();
    for _i in 0..n {
        let x = line.next().unwrap().parse().unwrap();
        v.push(x);
    }
    v
}
pub fn read_vec2_i(n:usize, m:usize) -> Vec<Vec<i32>> {
    let mut v:Vec<Vec<i32>> = Vec::new();
    for i in 0..n {
        let v1:Vec<i32> = Vec::new();
        v.push(v1);
        let line = read_string();
        println!("> {}", line);
        let mut line = line.split_whitespace();
        for _j in 0..m {
            let x = line.next().unwrap().parse().unwrap();
            v[i].push(x);
        }
    }
    v
}
fn main(){
    let mut n = 0;
    read_i!(&mut n;usize);
    let x = read_vec_i(n);

    let mut ans = 99999999;
    for i in 0..100 {
        let mut sum = 0;
        for j in &x {
            sum += (j - i).pow(2);
        }
        if sum < ans {
            ans = sum;
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
N = int(input())
D, X = map(int, input().split())
A = [int(input()) for i in range(N)]
sum = N

for i in range(N):
    count = 1
    for j in range(1, D+1):
        if j == count * A[i] + 1:
            sum += 1
            count += 1

print(sum + X)


Measured memory_bytes: 3060
using System;
class Practice
{
    public static void Main()
    {
        while (true)
        {
            int n = int.Parse(Console.ReadLine());
            if (n == 0)
            {
                break;
            }
            else
            {
                int[,] mat = new int[n + 1, n + 1];
                for (int i = 0; i < n; ++i)
                {
                    string[] inp = Console.ReadLine().Split();
                    for (int j = 0; j < n; ++j)
                    {
                        mat[i, j] = int.Parse(inp[j]);
                        mat[i, n] += mat[i, j];
                    }
                }
                for (int i = 0; i < n; ++i)
                {
                    for (int j = 0; j <= n; ++j)
                    {
                        mat[n, j] += mat[i, j];
                    }
                }
                for (int i = 0; i <= n; ++i)
                {
                    for (int j = 0; j <= n; ++j)
                    {
                        Console.Write("{0,5}", mat[i, j]);
                    }
                    Console.WriteLine();
                }
            }
        }
        return;
    }
}


Measured memory_bytes: 17932
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                                     \
  ifstream in("atcoder-problems/abc118_c.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v)                        \
  rep(l, v.size()) { cout << v[l] << " "; } \
  cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N;
  cin >> N;

  vector<int> c(N);
  rep(i, N) { cin >> c[i]; }
  sort(c.begin(), c.end());

  ll ans = c[0];
  repi(i, 1, N) {
    ll tmp = c[i];
    while (tmp % ans) {
      ll bef = ans;
      ans = tmp % ans;
      tmp = bef % ans;
    }
    if (ans == 1) {
      break;
    }
  }

  cout << ans << endl;
}

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

int main() {
	int n; cin >> n;
	map<int, int> M;
	int num;
	for(int i=0; i<n-1; i++){
		cin >> num;
		M[num]++;
	}
	
	for(int i=1; i<=n; i++)
		cout << M[i] << "\n";

	return 0;
}

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

const int MOD = ( int ) 1e9 + 7;
const int MAXN = ( int ) 1e6;

int N;
int dp[ MAXN + 1 ];
int pdp[ MAXN + 1 ];

signed main(){
  ios::sync_with_stdio( 0 );
  cin >> N;
  pdp[ 0 ] = dp[ 0 ] = 1;
  pdp[ 1 ] = dp[ 1 ] = N;
  ++pdp[ 1 ];
  for( int i = 2; i <= N; ++i ){
    dp[ i ] = ( 1LL * pdp[ i - 1 ] - ( i - 2 >= 0 ? dp[ i - 2 ] : 0 ) + ( N - ( i - 1 ) ) ) % MOD;
    ( dp[ i ] += 1LL * ( N - 1 ) * ( N - 1 ) % MOD ) %= MOD;
    pdp[ i ] = ( pdp[ i - 1 ] + dp[ i ] ) % MOD;
  }
  if( dp[ N ] < 0 ) dp[ N ] += MOD;
  cout << dp[ N ] << endl;
  return 0;
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
inline long long mod(long long n,long long m){return(n%m+m)%m;}
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    long long n,m,c; cin>>n>>m>>c;
    long long b[m]; rep(i,m) cin>>b[i];
    int ans=0;
    rep(q,n){
        long long sum=0;
        rep(i,m){
            long long a; cin>>a;
            sum+=a*b[i];
        }
        if(sum+c>0) ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256