akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
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; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vll a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    ll x = 0;
    for (int i = 0; i < n; i += 2) {
        x ^= a[i] ^ a[i + 1];
    }
    for (int i = 0; i < n; i++) cout << (x ^ a[i]) << (i == n - 1 ? '\n' : ' ');
    return 0;
}


Measured memory_bytes: 4720
s=input()
if s[0]=='A' and s[2:-1].count('C')==1:
    for i in range(len(s)):
        if not (i==0 or i==s[2:-1].index('C')+2):
            if not s[i].islower():
                print('WA')
                exit()
    print('AC')
    exit()
print('WA')


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

#define LINE_BUF_SIZE 1024
int line_sum(char s[]) {
        int n = 0;
        while (*s != '\n') {
                n += (int)*s++ - 48;
        }
        return n;
}
int main() {
  char line[LINE_BUF_SIZE];
        int n;
  if (fgets(line, sizeof(line), stdin) != NULL) {
                sscanf(line, "%d", &n);
                if (n % line_sum(line) == 0) {
                        printf("Yes");
                } else {
                        printf("No");
                }
        }
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <sstream>
using namespace std;

int scene[201][201];
int pic[4][51][51];
int n, m;

pair<int,int> getPos(int y, int x, int k) {
    int ry = -1, rx;
    for (int i=0; i<m; ++i) {
        for (int j=0; j<m; ++j) {
            if (0 <= pic[k][i][j]) {
                if (pic[k][i][j] != scene[y+i][x+j]) {
                    return make_pair(-1, -1);
                }
                if (ry == -1) {
                    ry = y+i+1, rx = x+j+1;
                }
            }
        }
    }
    return make_pair(ry, rx);
}

string solve() {
    pair<int,int> ret(101, 101);
    bool ok = false;
    for (int i=0; i+m-1<n; ++i) {
        for (int j=0; j+m-1<n; ++j) {
            for (int k=0; k<4; ++k) {
                pair<int,int> p = getPos(i, j, k);
                if (p.first != -1 && p < ret) {
                    ret = p;
                    ok = true;
                }
            }
        }
    }
    if (ok) {
        stringstream ss;
        ss << ret.second << " " << ret.first;
        return ss.str();
    }
    return "NA";
}

int main() {
    while (cin >> n >> m, n) {
        for (int i=0; i<n; ++i) {
            for (int j=0; j<n; ++j) {
                cin >> scene[i][j];
            }
        }
        for (int i=0; i<m; ++i) {
            for (int j=0; j<m; ++j) {
                cin >> pic[0][i][j];
                pic[1][j][m-1-i] = pic[0][i][j];
                pic[2][m-1-i][m-1-j] = pic[0][i][j];
                pic[3][m-1-j][i] = pic[0][i][j];
            }
        }
        cout << solve() << endl;
    }
    return 0;
}

Measured memory_bytes: 1340
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int mod = 1e9+7;
int dp[1<<21][21];

vector<int> a[21];
int DONE,n;

int solve(int bitmask, int ind){
    // base case
    if(bitmask==DONE){
        return 1;
    }
    if(ind>=n)
        return 0;
    if(dp[bitmask][ind]!=-1)
        return dp[bitmask][ind];
    int ans = 0;
    //cout<<"printing  "<<bitmask<<ind<<endl;
    for(int aa:a[ind]){
        //cout<<"printing  "<<bitmask<<" "<<ind<<endl;
        if((bitmask&(1<<aa))==0)
        ans+=solve(bitmask|(1<<aa),ind+1);
        ans%=mod;
    }
    //ans+=solve(bitmask,ind+1);
    ans%=mod;
    return dp[bitmask][ind]=ans;
}

int main()
{
    cin>>n;
    int x;
    DONE = (1<<n) - 1;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin>>x;
            //cout<<x<<endl;
            if(x==1)
                a[i].push_back(j);
        }
    }/*
    for(int i=0;i<n;i++){
        for(int aa:a[i])
            cout<<aa;
        cout<<endl;
    }*/
    memset(dp,-1,sizeof(dp));
    int ans = solve(0,0);
    cout<<ans<<'\n';
    return 0;
}

Measured memory_bytes: 175676
n, m, l = map(int, input().split())
A = [list(map(int, input().split())) for i in range(n)]
B = [list(map(int, input().split())) for i in range(m)]
C = [[0]*l for i in range(n)]

for i in range(n):
    for j in range(l):
        for k in range(m):
            C[i][j] += A[i][k]*B[k][j]

for i in range(n):
    print(*C[i], sep=' ')


Measured memory_bytes: 7040
#include <algorithm>
#include <iostream>

using namespace std;

typedef long long ll;

int a;
int b;

void solve() {
  cin >> a >> b;

  for (int i = 0; i < 1e4; ++i) {
    if (i * 2 / 25 == a && i / 10 == b) {
      cout << i << '\n';

      return;
    }
  }

  cout << -1 << '\n';
}

int main() {
  int t = 1;

#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);

  t = 3;
#endif

  ios_base::sync_with_stdio(false);
  cin.tie(0);

  while (t--)
    solve();
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bits/stdc++.h>
#include<queue>
#include <numeric>
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define fore(i,a) for(auto &i:a)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 

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

LL lcm(LL a, LL b){
    LL g = gcd(a,b);
    return a/g *b;
}


int main(){
    int N,M;
    cin >> N >> M;
    int p[M];
    string S[M];
    for(int i=0;i<M;++i){
        cin >> p[i] >> S[i];
    }
    int wrong=0;
    int ac=0;
    int pos=0;
    bool exist=false;
    int tmp=0;
    int wrong_sun=0;
    int dif=0;
    int a[N+100]={0};
    int b[N+100]={0};
    for(int i=0;i<M;++i){
        if(S[i]=="WA" && b[p[i]]==0){
            ++a[p[i]];
        }
        if(S[i]=="AC"){
            b[p[i]]+=1;
        }
    }
    for(int i=0;i<N+100;++i){
        if(b[i]>0){
        b[i]=1;
    }
    }
    for(int i=0;i<=N+10;++i){
        if(b[i]==1){
        ac+=b[i];
        wrong_sun+=a[i];
    }
    }
    cout << ac << " " << wrong_sun;
}

Measured memory_bytes: 6912
// ABC 155-B
// 2020.2.16 bal4u

#include <stdio.h>

int main()
{
	int N, A;

	scanf("%d", &N);
	while (N--) {
		scanf("%d", &A);
		if (A & 1) continue;
		if (A % 3 && A % 5) {
			puts("DENIED");
			return 0;
		}
	}
	puts("APPROVED");
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 998244353
#define INF 1145141919364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n;
bool bl;
int mi = INF;
int cnt;

signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		if (a != b)bl = true;
		if (a > b)mi = min(mi, b);
		cnt += a;
	}
	if (!bl)cout << 0 << endl;
	else cout << cnt - mi << endl;
}

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

int main() {
  
  int A,B;
  char op;
  cin >> A >> op >> B;

  int ans;
  
  if(op == '+'){
  	ans = A + B;
  }
 
  else{
    ans = A - B;
  }

  cout << ans << endl;
  
}



Measured memory_bytes: 3640
from collections import deque
from collections import Counter
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
#pypyではscipy, numpyは使えない
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
#from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
#import numpy as np
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')

def main():
  a, b, t = map(int, readline().split())
  print((t//a)*b)
  
  
  
  
if __name__ == '__main__':
  main()

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

int main(){
    int a,b; cin >> a >> b;
    int ans = 6;
    ans -= a;
    ans -= b;
    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
const int INF = numeric_limits<int>::max()/2;

vector<vector<ll>> comb2(ll n) {
  vector<vector<ll>> v(n + 1,vector<ll>(n + 1, 0));
  for (int i = 0; i < (int)v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (int j = 1; j < (int)v.size(); j++) {
    for (int k = 1; k < j; k++) {
      v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
    }
  }
  return v;
}

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

    ll n,a,b;cin>>n>>a>>b;
    vector<ll> v(n);
    vector<vector<ll>> com=comb2(60);
    map<ll,ll> mp,used;
    for(int i=0;i<n;i++){
        cin>>v[i];
        mp[v[i]]++;
    }
    sort(v.rbegin(),v.rend());
    ll sum=0;
    for(int i=0;i<a;i++){
        sum += v[i];
        used[v[i]]++;
    }
    ld s = sum;
    cout<<fixed<<setprecision(10)<<s/a<<endl;
    if(v[0]!=v[a-1]) cout<<com[mp[v[a-1]]][used[v[a-1]]]<<endl;
    else{
        ll res=0;
        for(int i=a;i<=min(mp[v[0]],b);i++){
            res += com[mp[v[0]]][i];
        }
        cout<<res<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;}
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll H, W;
        cin >> H >> W;

        ll ans = inf;
        rep(h, 1, H+1) {
                ll s1 = h * W;
                ll h1 = (H-h) / 2;
                ll h2 = h1;
                if ((H-h) % 2 != 0) ++h2;
                ll s2 = h1 * W;
                ll s3 = h2 * W;
                if ((H-h) % 2 != 0) ++s3;
                ll smax = max(s1, max(s2, s3));
                ll smin = min(s1, min(s2, s3));
                chmin(ans, smax-smin);

                ll w1 = W / 2;
                ll w2 = w1;
                if (W % 2 != 0) ++w2;
                s2 = w1 * (H-h);
                s3 = w2 * (H-h);
                smax = max(s1, max(s2, s3));
                smin = min(s1, min(s2, s3));
                chmin(ans, smax-smin);               


        }

        swap(H, W);
        rep(h, 1, H+1) {
                ll s1 = h * W;
                ll h1 = (H-h) / 2;
                ll h2 = h1;
                if ((H-h) % 2 != 0) ++h2;
                ll s2 = h1 * W;
                ll s3 = h2 * W;
                if ((H-h) % 2 != 0) ++s3;
                ll smax = max(s1, max(s2, s3));
                ll smin = min(s1, min(s2, s3));
                chmin(ans, smax-smin);

                ll w1 = W / 2;
                ll w2 = w1;
                if (W % 2 != 0) ++w2;
                s2 = w1 * (H-h);
                s3 = w2 * (H-h);
                smax = max(s1, max(s2, s3));
                smin = min(s1, min(s2, s3));
                chmin(ans, smax-smin);               


        }

        cout << ans << endl;
}






Measured memory_bytes: 3576
#include <iostream>
#include <vector>
#include <string>

int main()
{
    std::string A;
    std::cin >> A;

    std::vector<long long> count(26, 0);
    for(char& c: A) count[c - 'a']++;

    long long N = A.size();
    long long ans = N * (N-1) / 2 + 1;
    for(long long n: count) ans -= n * (n-1) / 2;

    // for(int i=0; i<26; i++) printf("%c: %lld\n", 'a'+i, count[i]);
    std::cout << ans << std::endl;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//using System.Threading.Tasks;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            for (int i = 0; i < input[0]; ++i)
            {
                string str = Console.ReadLine();
                Console.Write("{0}\n{0}\n", str);
            }
        }
    }
}


Measured memory_bytes: 3032
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(long long i=0;i<n;++i)
#define REPR(i,n) for(long long i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(v) {for(long long sitr=0;sitr<v.size();++sitr){cin>>v[sitr];}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  llong l, r;
  cin >> l >> r;

  llong ans = INF;
  if(r - l >= 2019){
    REP(i,2019){
      REP(j,2019){
        ans = min(ans, (i * j) % 2019);
      }
    }
  }else{
    for(llong i = l; i < r; ++i){
      for(llong j = i + 1; j <= r; ++j){
        ans = min(ans, (i * j) % 2019);
      }
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,ans,t;
  int a[1000];
  while(1){
  cin >> n;
  if(n==0) break;
  for(int i=0; i<n; i++){
	cin >> a[i];
  }
  for(int i=0; i<n; i++){
    for(int j=i+1; j<n; j++){
	t = a[i] - a[j];
	if(t<0) t = t*(-1);
	if(i==0 && j==i+1) ans = t;
	ans = min(ans,t);
    }
  }
  cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3080
#include<bits/stdc++.h>
#define fr(i1,m) for(int i1=0;i1<m;i1++)
using namespace std;
int main()
{
        long n;
        while(cin>>n)
        {
            long a,c=0,c1=0,x=0;
            fr(i,n)
            {
                cin>>a;
                if(a%2==1)
                    c++;
                else
                    c1++;
            }
            if(c%2==1)
            {
                cout<<"NO"<<"\n";
                continue;
            }
            cout<<"YES\n";


        }
        return 0;

}




Measured memory_bytes: 256
#-*- coding: utf-8
#  -*-
"""
oj dl https://atcoder.jp/contests/abc116/tasks/abc116_d -d test-d
oj test -d test-d -c "python abc116d.py"
oj test -d test-d -c "python abc116d.py" test-d/sample-3.in
"""
from collections import defaultdict
import sys
import math
from datetime import datetime

def sol(S):
    if len(S) == 1: return 1
    maxi = S[0]
    mini = S[0]
    counter = 0
    for i, n in enumerate(S):
        if maxi >= n and mini >= n:
            counter += 1
        maxi = max(maxi, n)
        mini = min(mini, n)
    #print(maxi, mini)
    return counter



do_submit = True
#do_submit = False

def input_parse(input_str):
    lines = [x.strip() for x in input_str.split("\n") if x.strip()]
    parsed_lines = [list(map(str, line.split())) for line in lines]
    print(parsed_lines)
    n = int(parsed_lines[0][0])
    k = int(parsed_lines[0][1])
    S = parsed_lines[1][0]
    return n, k, S


if not do_submit:
    a, b, c = input_parse("""
    3 1
    ABC
    """)
    print(sol(a, b, c))

    a, b, c = input_parse("""
    4 3
    CABA
    """)
    print(sol(a, b, c))

else:
    #a, b = list(map(int, input().split()))
    n = int(input().strip())
    S = list(map(int, input().split()))
    # a = int(input())
    # b = int(input())
    # T = input()
    print(sol(S))
    # S = input().strip()
    # print(sol(S))



Measured memory_bytes: 25372
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 2e5 + 10;
const int INF = 0x3f3f3f3f;
int n, x, y, le;
int vis[N], cnt[N];
int main() {
	scanf("%d%d%d", &n, &x, &y);
	le = y - x + 1;
	for (int i = x; i <= y; i++)vis[i] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = i + 1; j <= n; j++) {
			if (vis[i] && vis[j]) {
				cnt[min(j - i, le - (j - i))]++;
			}
			else if (vis[i]) {
				cnt[min(j - i, le - y + i + j - y)]++;
			}
			else if (vis[j]) {
				cnt[min(j - i, x - i + le - (j - x))]++;
			}
			else if(i<x&&j>y){
				cnt[min(j - i, j - y + le - (y - x) + x - i)]++;
			}
			else cnt[j - i]++;
		}
	}
	for (int i = 1; i < n; i++)printf("%d\n", cnt[i]);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

signed main(){
	string s;cin>>s;
	if(s.size()<4){
		puts("No");
		return 0;
	}
	puts(s.substr(0,4)=="YAKI"?"Yes":"No");
}

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

#define fi first
#define se second
#define long long long
typedef pair<int,int> ii;

int main()
{
	// freopen("input.in", "r", stdin);

	int x; scanf("%d", &x);
	for(int i = x; 1; i++)
	{
		bool bol = 1;
		for(int j = 2; j*j < i; j++)
			if(i%j == 0)
				bol = 0;
		if(bol)
		{
			printf("%d\n", i);
			break;
		}
	}
	
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;
inline int read()
{
	int f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x);putchar(' ');}
inline void pr2(int x){write(x);putchar('\n');}
const int MAXQ=200005;
const int MAXN=2005;
const int mod=1e9+7;
const int zero=2001;

int pow_mod(int a,int b)
{
	int ret=1;
	while(b)
	{
		if(b&1)ret=1LL*ret*a%mod;
		a=1LL*a*a%mod;b>>=1;
	}
	return ret;
}
int pre[4*MAXN],inv[4*MAXN];
int C(int n,int m){return 1LL*pre[n]*inv[m]%mod*inv[n-m]%mod;}
int f[2*MAXN][2*MAXN],g[2*MAXN];
struct pt{int x,y;}w[MAXQ];
int n,m;
void ad(int &x,int y){x+=y;if(x>=mod)x-=mod;}
void dl(int &x,int y){x-=y;if(x<0)x+=mod;}
int main()
{
//	freopen("a.in","r",stdin);
	pre[0]=1;for(int i=1;i<4*MAXN;i++)pre[i]=1LL*pre[i-1]*i%mod;
	inv[4*MAXN-1]=pow_mod(pre[4*MAXN-1],mod-2);
	for(int i=4*MAXN-2;i>=0;i--)inv[i]=1LL*inv[i+1]*(i+1)%mod;
	n=read();
	for(int i=1;i<=n;i++)w[i].x=read(),w[i].y=read(),m=max(m,max(w[i].x,w[i].y));
	for(int i=1;i<=n;i++)f[zero+w[i].x][w[i].y]++;
	for(int i=zero+m;i>=zero-m;i--)
	{
		for(int j=m;j>=0;j--)ad(f[i][j],f[i+1][j]),ad(f[i][j],f[i][j+1]);
		g[i]=f[i][1];//强行不走x轴 
	}
	int ans=0;
	for(int i=m;i>=-m;i--)
		ad(ans,1LL*f[zero+i][0]*g[zero-i]%mod);
	for(int i=1;i<=n;i++)dl(ans,C(w[i].x+w[i].x+w[i].y+w[i].y,w[i].x+w[i].x));
	ans=1LL*ans*pow_mod(2,mod-2)%mod;
	pr2(ans);
	return 0;
}


Measured memory_bytes: 64128
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
#define all(v) v.begin(), v.end()
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int N,M;
    scanf("%d%d",&N,&M);
    int N1,M1;
    if(N==1) N1=0;
    else N1=N*(N-1)/2;
    if(M==1) M1=0;
    else M1=M*(M-1)/2;
    cout<<N1+M1<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define erep(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
const int mod = 1e9+7;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
  string s;
  cin>>s;
  rep(i,0,s.size()-1){
    if(s[i]=='A'&&s[i+1]=='C'){
      cout<<"Yes\n";
      return 0;
    }
  }
  cout<<"No\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(var,cnt) for(int (var)=0; (var)<(int)(cnt); ++(var))
#define REP(var,init,cnt) for(int (var)=(init); (var)<(cnt); ++(var))
#define ran(var,vec) for(auto &(var):(vec))
#define all(v) (v).begin(),(v).end()
#define TF(flag) (flag)?1:0
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pi = pair<int,int>;
using pl = pair<ll,ll>;

template<typename T>
using vec = vector<T>;
template<typename T>
using mat = vector<vec<T>>;
template<typename T>
using cub = vector<mat<T>>;
template<typename T>
using val = valarray<T>;

template<typename T>
using pq = priority_queue<T>;
template<typename T>
using rpq = priority_queue<T,vec<T>,greater<T>>;

template<typename T1,typename T2>
ostream &operator<<(ostream &os, const pair<T1,T2> &p){
  os<<"P("<<p.first<<", "<<p.second<<") ";
  return os;
}

template<typename T1,typename T2>
istream &operator>>(istream &is, pair<T1,T2> &p){
  is>>p.first>>p.second;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, vector<T> &v){
  for(T &in:v) is>>in;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const valarray<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, valarray<T> &v){
  for(T &in:v) is>>in;
  return is;
}

// Usual Template End ================================================

// Template End ======================================================

int main(void){
  int N,L; cin>>N>>L;
  vec<string> S(N); cin>>S;
  sort(all(S));
  rep(i,N) cout<<S[i];
}














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

long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

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

    const int N = 2e5+5;

    vector<int> dp(N, 0);
    dp[0] = 0;

    for(int i=1; i<N; ++i){
        dp[i] = dp[(i)%(__builtin_popcount(i))] + 1;
    }

    int total = 0;
    int n;
    string s;
    cin >> n >> s;
    for(int i=0; i<n; ++i){
        if( s[i] == '1' ){ ++total; }
    }

    if( total == 0 ){
        for(int i=0; i<n; ++i){
            cout << 1 << '\n';
        }
        return 0;
    }

    vector<ll> mods(2, 0);
    for(int i=0; i<n; ++i){
        int dig = s[i] - '0';
        mods[1] *= 2;   mods[0] %= (total+1);
        mods[1] += dig; mods[1] %= (total+1);
        if( total == 1 ){ continue; }
        mods[0] *= 2;   mods[0] %= (total-1);
        mods[0] += dig; mods[0] %= (total-1);

    }
    
    for(int i=0; i<n; ++i){
        if( s[i] == '0' ){
            ll val = (mods[1] + binpow(2, n-i-1, total+1) ) % (total+1);
            cout << 1 + dp[val] << endl;
        }else{
            if( total == 1 ){
                cout << 0 << endl;
                continue;
            }
            ll val = (mods[0] - binpow(2, n-i-1, total-1) + total -1 ) % (total-1);
            if( val < 0 ){
                val += (total - 1);
            }
            val %= (total-1);
            cout << 1 + dp[val] << endl;
        }
    }



    return 0;
}


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

typedef long long ll;
typedef vector<vector<ll> > matrix;

int MOD;

matrix operator*(const matrix &a, const matrix &b){
	const int n = a.size();
	matrix res(n, vector<ll>(n));
	
	for(int k=0 ; k < n ; k++ ){
		for(int i=0 ; i < n ; i++ ){
			for(int j=0 ; j < n ; j++ ){
				res[i][j] += (a[i][k] * b[k][j]) % MOD;
				res[i][j] %= MOD;
			}
		}
	}
	return res;
}

vector<ll> operator*(const matrix &a, const vector<ll> &b){
	const int n = a.size();
	vector<ll> res(n);
	
	for(int i=0 ; i < n ; i++ ){
		for(int j=0 ; j < n ; j++ ){
			res[i] += (a[i][j] * b[j]) % MOD;
			res[i] %= MOD;
		}
	}
	return res;
}

matrix mod_pow(matrix m, int t){
	const int n = m.size();
	matrix res(n, vector<ll>(n));
	
	for(int i=0 ; i < n ; i++ ) res[i][i] = 1;
	while( t ){
		if( t & 1 ) res = res  * m;
		m = m * m;
		t >>= 1;
	}
	return res;
}

int main(){
	int N, M, A, B, C;
	ll T;
	while( cin >> N >> M >> A >> B >> C >> T , N ){
		vector<ll> S(N);
		MOD = M;
		for(int i=0 ; i < N ; i++ ){
			cin >> S[i];
		}
		
		matrix a(N, vector<ll>(N));
		for(int i=0 ; i < N ; i++ ){
			if( 0 <= i-1 ) a[i][i-1] = A;
			if( i+1 < N ) a[i][i+1] = C;
			a[i][i] = B;
		}
		vector<ll> ans = mod_pow(a, T) * S;
		for(int i=0 ; i < ans.size() ; i++ ){
			if( i ) cout << " ";
			cout << ans[i];
		}
		cout << endl;
	}
}

Measured memory_bytes: 1312
import java.util.Scanner;


public class Main {
    public static void main(String[] args) {
        Scanner input =new Scanner(System.in);
        String s = input.next();
        if(s.charAt(2)==s.charAt(3)&&s.charAt(4)==s.charAt(5)){
        System.out.println("Yes");}
        else System.out.println("No");
             
    }
}


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

vector<int>v[31];
ll dp[31][50];
int main() {
	int n;
	while (scanf("%d", &n), n) {
		rep(i, 31)v[i].clear();
		rep(i, n) {
			int f; scanf("%d", &f);
			rep(j, f) {
				int k; scanf("%d", &k);
				v[k].push_back(i);
			}
		}
		rep(i, n)dp[0][i] = 1LL << i;
		for (int i = 1; i <= 30; i++) {
			rep(j, n)dp[i][j] = dp[i - 1][j];
			rep(t, n)for (int j : v[i])for (int k : v[i]) {
				dp[i][j] |= dp[i][k];
				dp[i][k] |= dp[i][j];
			}
		}
		rep(i, 31)rep(j, n) {
			if (dp[i][j] == (1LL << n) - 1) {
				printf("%d\n", i); goto g;
			}
		}
		puts("-1");
	g:;
	}
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


string S;
unordered_map<string, i64> wtoi{
  {"Sunny", 0},
  {"Cloudy", 1},
  {"Rainy", 2},
};
unordered_map<i64, string> itow{
  {0, "Sunny"},
  {1, "Cloudy"},
  {2, "Rainy"},
};


int main() {
  cin >> S;

  cout << itow[(wtoi[S] + 1) % 3] << endl;

  return 0;
}

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

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}

int main(){
  int N;cin>>N;
  if(N>=195) cout<<5<<endl;
  else if(N>=189)cout<<4<<endl;
  else if(N>=165)cout<<3<<endl; 
  else if(N>=135)cout<<2<<endl;
  else if(N>=105)cout<<1<<endl;
  else cout<<0<<endl;
  
 
}

Measured memory_bytes: 256
N,K = map(int,input().split())
A = list(map(int,input().split()))
# A.sort()
P = []
M = []
z = 0
for a in A:
    if a==0:z += 1
    elif a>0:P.append(a)
    else: M.append(a)
P.sort()
M.sort()
def helper(n):
    if n < 0:
        res = 0
        p = 0
        for m in range(len(M)):
            while p < len(P) and P[p]*M[m] > n:
                p += 1
            res += len(P)-p
    elif n ==0:
        res = len(P)*len(M) + z*(N-z) + z*(z-1)//2
    else:
        res = len(P)*len(M) + z*(N-z) + z*(z-1)//2
        pr = len(P)-1
        for pl in range(len(P)):
            while pr > pl and P[pl]*P[pr] > n:
                pr-=1
            res += max(0,pr-pl)
        ml = 0
        for mr in range(len(M)-1,-1,-1):
            while mr >ml and M[ml]*M[mr] > n:
                ml += 1
            res += max(0,mr-ml)
    return res

l = -10**18
r = 10**18
while True:
    num = (l+r)//2
    if helper(num) < K:
        l = num
    else:
        r = num
    if r-l <=1:
        print(r)
        break


Measured memory_bytes: 99088
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
#define fori(i,s,n) for(ll i=s;i<=n;i++)
#define ford(j,s,n) for(ll i=n;i>=s;i--)
#define pb push_back
#define TEST int t; cin>>t; for(int T=1;T<=t;T++)
int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b,c=0,f=0;
    TEST{
        cin>>a>>b;
        if(a==b) 
            c++;
        else c=0;
        if(c>=3) f=1;
    }
    if(f) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}


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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using ll=long long;
using ld=long double;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const int MOD=1e9+7;

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


struct Union_Find{
    vector<int> par, depth;
    Union_Find(int n){init(n);}
    void init(int n){
        par.resize(n); depth.resize(n);
        for(int i=0; i<n; i++){
            par[i]=i;
            depth[i]=0;
        }
    }

    int find(int x){
        if(par[x] == x) return x;
        return par[x]=find(par[x]);
    }

    void unite(int x, int y){
        x=find(x), y=find(y);
        if(x == y) return;

        if(depth[x] < depth[y]) par[x]=y;
        else{
            par[y]=x;
            if(depth[x] == depth[y]) depth[x]++;
        }
    }

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


int main(){
    int N, M; cin >> N >> M;
    Union_Find uf(2*N);
    for(int i=0; i<M; i++){
        int x, y, z; cin >> x >> y >> z;
        x--, y--;
        if(z%2 == 0){
            uf.unite(x, y);
            uf.unite(x+N, y+N);
        }
        else{
            uf.unite(x, y+N);
            uf.unite(x+N, y);
        }
    }

    int ans=0;
    for(int i=0; i<N; i++){
        if(uf.par[i] == i) ans++;
    }
    cout <<ans << endl;
    return 0;
}

Measured memory_bytes: 4824
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+50,mod=2;
int n,cc[N];char a[N];bool fl;
int C(int n,int m){return m>n?0:n<2?1:C(n&1,m&1)*C(n>>1,m>>1);}
int main(){
	scanf("%d%s",&n,a+1);
	for(int i=1;i<=n;i++)if(a[i]=='2')fl=1;
	if(fl){
		int ans=0;
		// if(!(n&1)&&n!=2)ans+=a[2]+a[n-1];
		for(int i=1;i<=n;i++)if(a[i]=='2')ans+=C(n-1,i-1);
		putchar(ans&1?'1':'0');
	}
	else{
		int ans=0;
		for(int i=1;i<=n;i++)if(a[i]=='3')ans+=C(n-1,i-1);
		putchar(ans&1?'2':'0');
	}
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long
#define f(i, x, n) for(int i = x; i < (int)n; ++i)

int n, fn[100001];
ll in;

inline int gt(int i) { int an = 0; while (i)an += fn[i], i ^= i & -i; return an; }
inline void ad(int i) { while (i <= n)++fn[i], i += i & -i; }

struct L{
	int a, b, c;
	L(){}
	double x(double y) { return (c - y * b) / a; }
	bool operator <(L const &o)const{
		int a1 = -a, b1 = b, a2 = -o.a, b2 = o.b;
		if (a1 < 0)b1 = -b1, a1 = -a1;
		if (a2 < 0)b2 = -b2, a2 = -a2;
		return b1 * a2 < b2 * a1;
	}
}v[100000];

double mp[100000];

bool cmp(double const a, double const b) { return abs(a - b) < 1e-12; }

ll cn(double m){
	f(i, 0, n)mp[i] = v[i].x(m) + 1e-12;
	sort(mp, mp + n);
	/*printf("%.10lf\n", m);
	f(i, 0, n)printf("%.10lf ", mp[i]);
	printf("\n");*/
	int sz = unique(mp, mp + n, cmp) - mp;
	/*f(i, 0, sz)printf("%.10lf ", mp[i]);
	printf("\n");*/
	f(i, 1, n + 1)fn[i] = 0;
	ll an = 0;
	f(i, 0, n){
		int loc = lower_bound(mp, mp + sz, v[i].x(m)) - mp + 1;
		an += gt(loc - 1);
		ad(loc);
	}
	return an;
}

double bs(){
	double l = -1e9, r = 1e9;
	f(i, 0, 80){
		double m = (l + r) / 2.0;
		if (cn(m) >= in + 1 >> 1)r = m;
		else l = m;
	}
	return l;
}

int main(){
	scanf("%d", &n);
	in = (ll)n * (n - 1) >> 1;
	f(i, 0, n)scanf("%d%d%d", &v[i].a, &v[i].b, &v[i].c);
	sort(v, v + n);
	double an = bs();
	f(i, 0, n)swap(v[i].a, v[i].b);
	sort(v, v + n);
	printf("%.15lf %.15lf\n", bs(), an);
}

Measured memory_bytes: 1280
import itertools
n = int(input())
num = [0]*5
name = ['M','A','R','C','H']
for _ in range(n):
    s = str(input())
    for i in range(5):
        if s[0] == name[i]:
            num[i] += 1
            break
num = [k for k in num if k != 0]
c = num.count(0)
if 2 <= c:
    print(0)
else:
    d = 0
    for h,j,l in itertools.combinations(num,3):
        d += (h*j*l)
    print(d)

Measured memory_bytes: 9012
# -*- coding: utf-8 -*-
import math


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

    cnt = 0
    while True:

        is_exist_odd = False
        for _a in a:
            if _a % 2 == 1:
                is_exist_odd = True
                break

        if is_exist_odd:
            break

        a = list(map(lambda _a: _a / 2, a))
        cnt += 1

    print(cnt)


if __name__ == '__main__':
    main()




Measured memory_bytes: 3064
#include <iostream>
#include <climits>
using namespace std;
long long A,B,C,D;

long long divided_num(long long A,long long B,long long C){
	return B / C - (A-1)/C;
}

long long gcd(long long a, long long b) {
  if(a < b) return gcd(b, a);
  long long r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main(){
	cin >> A  >> B >> C >> D;
	
	long long divided_C = divided_num(A,B,C);

	long long divided_D = divided_num(A,B,D);
	
	long long divided_CD = divided_num(A,B,C*D/gcd(C,D));
	
	cout << (B - A + 1) - (divided_C + divided_D - divided_CD) << endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
typedef long long ll;
const ll maxn = 100000 + 10;

ll n, m, a[maxn], b[maxn], vis[maxn], d[maxn], ans[maxn];
ll k;

int main() {
  scanf("%lld", &n);
  for(ll i = 1, sum = 0;i <= n;i ++) {
    scanf("%lld", &a[i]);
    a[i] -= sum;
    sum += a[i];
    b[i] = i;
  }
  scanf("%lld%lld", &m, &k);
  for(ll i = 1;i <= m;i ++) {
    ll x; scanf("%lld", &x);
    swap(b[x],b[x + 1]);
  }
  for(ll i = 1, tot;i <= n;i ++) {
    if(!vis[i]) {
      tot = 0;
      for(ll j = i;!vis[j];j = b[j]) {
      	vis[j] = 1;
      	d[++ tot] = j;
      }
      for(ll j = 1;j <= tot;j ++) {
        ans[d[j]] = a[d[(j + k - 1) % tot + 1]];
	  }
	}
  }
  for(ll i = 1;i <= n;i ++) {
    ans[i] += ans[i - 1];
    printf("%lld.0\n", ans[i]);
  }
  return 0;
}

Measured memory_bytes: 5376
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M; cin >> N >> M;
	vector<int> d(M); rep(i, 0, M) { cin >> d[i]; }
	vector<int>dp(N + 1, INF);
	dp[0] = 0;
	rep(i, 0, M)rep(j, d[i], N + 1)
		chmin(dp[j], dp[j - d[i]] + 1);
	cout << dp[N] << endl;
	return 0;
}

Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
int n, d, x;
int amount_eat(int num){
  int sum = 1;
  for(int i=0;; i++){
    if(num * (i+1) + 1<= d){
      sum++;
    }
    else break;
  }
  return sum;
}
int main() {
  cin >> n >> d >> x;
  int a[110];
  for(int i=0; i<n; i++){
    cin >> a[i];
  }
  int amount = x;
  for(int i=0; i<n; i++){
    amount += amount_eat(a[i]);
  }
  cout << amount << endl;
}

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

int main() {
  long N,K,Q;
  cin >> N>>K>>Q;
  vector<int> a(Q);
  vector<int> p(N);

  for(int i=0;i<Q;i++) cin>>a[i];

  for(int i=0;i<Q;i++){
    p[a[i]-1] ++;
  }
  for(int i=0;i<N;i++){
    p[i] += K-Q;
  }
  for(int i=0;i<N;i++){
    if(p[i]>0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }



  }


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

long long int gcd(int x,int y){
  if(x<=y){
    int num1;
    num1 = y;
    y = x;
    x = num1;
  }
  if(x%y==0) return y;
  else{
    return(gcd(y,x%y));//最大公約数
  }
}

long long int lcm(long long int x,long long int y){
  return x*y/gcd(x,y);//最小公倍数
}

int main() {
  long long int a,b;
  cin >> a >> b;
  cout << lcm(a,b) << endl;
  return 0;
}

Measured memory_bytes: 256
/*
PROG: agc025b
LANG: C++11
    _____
  .'     '.
 /  0   0  \
|     ^     |
|  \     /  |
 \  '---'  /
  '._____.'
 */
#include <bits/stdc++.h>

using namespace std;

template<class T>
void readi(T &x)
{
	T input = 0;
	bool negative = false;
	char c = ' ';
	while (c < '-')
	{
		c = getchar();
	}
	if (c == '-')
	{
		negative = true;
		c = getchar();
	}
	while (c >= '0')
	{
		input = input * 10 + (c - '0');
		c = getchar();
	}
	if (negative)
	{
		input = -input;
	}
	x = input;
}
template<class T>
void printi(T output)
{
	if (output == 0)
	{
		putchar('0');
		return;
	}
	if (output < 0)
	{
		putchar('-');
		output = -output;
	}
	int aout[20];
	int ilen = 0;
	while(output)
	{
		aout[ilen] = ((output % 10));
		output /= 10;
		ilen++;
	}
	for (int i = ilen - 1; i >= 0; i--)
	{
		putchar(aout[i] + '0');
	}
	return;
}
template<class T>
void ckmin(T &a, T b)
{
	a = min(a, b);
}
template<class T>
void ckmax(T &a, T b)
{
	a = max(a, b);
}
long long randomize(long long mod)
{
	return ((1ll << 30) * rand() + (1ll << 15) * rand() + rand()) % mod;
}

#define MP make_pair
#define PB push_back
#define PF push_front
#define fi first
#define se second
#define debug(x) cerr << #x << " = " << x << endl;

const long double PI = 4.0 * atan(1.0);
const long double EPS = 1e-10;

#define MAGIC 347
#define SINF 10007
#define CO 1000007
#define INF 998244353
#define BIG 1000000931
#define LARGE 1696969696967ll
#define GIANT 2564008813937411ll
#define LLINF 2696969696969696969ll
#define MAXN 300013

long long normalize(long long x, long long mod = INF)
{
	return (((x % mod) + mod) % mod);
}

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int N;
ll A, B, K;
ll fact[MAXN], ifact[MAXN];
ll ans;

int32_t main()
{
	ios_base::sync_with_stdio(0); 
	srand(time(0));
	//	cout << fixed << setprecision(10);	
	//	cerr << fixed << setprecision(10);
	if (fopen("agc025b.in", "r"))
	{	
		freopen ("agc025b.in", "r", stdin);
		//	freopen ("agc025b.out", "w", stdout);
	}
	fact[0] = 1;
	for (int i = 1; i < MAXN; i++)
	{
		fact[i] = fact[i - 1] * i; fact[i] %= INF;
	}
	ifact[MAXN - 1] = 851579227;
	for (int i = MAXN - 2; i >= 0; i--)
	{
		ifact[i] = ifact[i + 1] * (i + 1);
		ifact[i] %= INF;
	}
	cin >> N >> A >> B >> K;
	for (ll i = 0; i <= N; i++)
	{
		ll j = K - A * i;
		if (j % B || j / B < 0 || j / B > N)
		{
			continue;
		}
		j /= B;
		ans += (fact[N] * ifact[i] % INF * ifact[N - i] % INF * fact[N] % INF * ifact[j] % INF * ifact[N - j] % INF);
		ans %= INF;
	}
	cout << ans << '\n';
	//	cerr << "time elapsed = " << (clock() / (CLOCKS_PER_SEC / 1000)) << " ms" << endl;
	return 0;
}


Measured memory_bytes: 4992