akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define all(a)          (a).begin(), (a).end()
#define sort(a)         sort(all(a))
#define uniq(a)         sort(a);(a).erase(unique(all(a)), (a).end())
#define reverse(a)      reverse(all(a))
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }
#define pb              push_back
#define fst             first
#define int             long long
#define INF             __LONG_LONG_MAX__

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve() {
  string n; cin >> n;
  for (char c : n) {
    if (c == '7') {
      Yes();
      return;
    }
  }
  No();
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 3040
import java.util.*;

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

		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();

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

		String u = sc.next();

		if (s.equals(u)) {
			System.out.println(a - 1);
			System.out.println(b);
		} else if (t.equals(u)) {
			System.out.println(a);
			System.out.println(b - 1);
		}

	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define bit(n) (1LL << (n))
#define INF 2e9
#define MOD (1000000007)
#define EPS 1e-9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long long int lli;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  lli N, X;
  cin >> N >> X;

  lli sM = max(N - X, X);
  lli sN = min(N - X, X);
  lli ans = N; // 5
  //(3,2)+4
  //(2,1)+3
  while (sM % sN != 0) {
    ans += 2ll * sN * (sM / sN);
    lli tmp = sN;
    sN = sM % sN;
    sM = tmp;
  }

  ans += 2ll * sN * (sM / sN) - sN;
  cout << ans << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 1 << 21;
using pii = std::pair<int, int>;
#define SORT(v) std::sort(v.begin(), v.end())
int main(void) {
	std::string in;
	int k;
	std::cin >> in >> k;
	std::vector<std::string> s;
	for (size_t i = 0; i < in.size(); i++) {
		for (size_t j = 1; j <=k ; j++) {	
		s.push_back(in.substr(i, j));
		//std::cout << i <<" " <<i+j << " " << in.substr(i, j) <<std::endl;
		}
		//std::cout << " " << std::endl;
	}
	SORT(s);
	s.erase(std::unique(s.begin(), s.end()), s.end());
	/*for (size_t i = 0; i < s.size(); i++) {
		std::cout << s[i] << std::endl;
	}*/
	std::cout << s[k-1] << std::endl;
	
}

Measured memory_bytes: 1660
S=str(input())
Q=int(input())

Query=[]
for i in range(Q):
    Query.append(list(input().split()))

N=len(S)//2
S_left_reverse=S[:N+1][::-1]
S_right=S[N+1:]
#print(S_left_reverse,S_right)


check=1
for j in range(Q):
    if len(Query[j])==1:
        check*=-1
        #print(S_left_reverse,S_right)
    else:
        if Query[j][1]=='1':
            if check==1:
                S_left_reverse+=Query[j][2]
                #print(S_left_reverse,S_right)
            else:
                S_right+=Query[j][2]
                #print(S_left_reverse,S_right)
        else:
            if check==1:
                S_right+=Query[j][2]
                #print(S_left_reverse,S_right)
            else:
                S_left_reverse+=Query[j][2]
                #print(S_left_reverse,S_right)


ans=S_left_reverse[::-1]+S_right
if check==1:
    print(ans)
else:
    print(ans[::-1])




Measured memory_bytes: 31140
A,B,C,D=map(int,input().split())
def gcd(a,b):
    if b == 0:
        return(a)
    elif a < b:
        return(gcd(b,a))
    else:
        return(gcd(b,a%b))
A = A-1
E = gcd(C,D)
BSUM=B-B//C-B//D+B//(C*D//E)
ASUM=A-A//C-A//D+A//(C*D//E)
print(BSUM-ASUM)



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

using namespace std ;

#define IOS ios::sync_with_stdio(0); cin.tie(0), cout.tie(0)
#define ll long long int 

#define fr first
#define se second

#define all(v) v.begin(),v.end() 
#define rall(v) v.rbegin(),v.rend()
#define sz(v) v.size() 

#define pb push_back
#define mp make_pair 

#define PI 3.141592653589793238



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


//bool valid(int x, int y){return x > 0 && x < n && y > 0 && y < m;}


int a, t, n,ans;
double mm = DBL_MAX;


int main(){
  cin >> n >> t >> a;
  vector<int>v(n);
  for(int i = 0 ; i < n ; i++)
    cin >> v[i];
  for(int i = 0 ; i < n ; i++){
    double c = t-v[i]*.006;
    if(abs(a-c) < abs(a-mm))
      ans = i+1, mm = c;
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(x) ((int)x.size())
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
char s[4];
int main() {
	cin>>s;
	int res = 700;
	for(int i=0; i<3; i++)
		res += (s[i] == 'o') * 100;
	cout<<res;
	return 0;
}

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

public class Main{
    private static final int PAPER_SIZE = 10;
    private static int[] paper= new int[PAPER_SIZE * PAPER_SIZE];;
    private static int droppedCount = 0;
    private static int maxDropping = 0;
    
    private static final int SMALL_INK_DROP_SIZE = 3;
    private static final boolean[] SMALL_INK_DROP =
        {
           false, true, false,
           true , true, true,
           false, true, false
        };
    
    private static final int MEDIUN_INK_DROP_SIZE = 3;
    private static final boolean[] MEDIUM_INK_DROP =
        {
           true, true, true,
           true, true, true,
           true, true, true
        };
        
    private static final int LARGE_INK_DROP_SIZE = 5;
    private static final boolean[] LARGE_INK_DROP =
        {
           false, false, true, false, false,
           false, true,  true, true,  false,
           true,  true,  true, true,  true,
           false, true,  true, true,  false,
           false, false, true, false, false
        };
    
    
    public static void main(String args[]) throws IOException {        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String input = "";
        
        while(true) {
            input = br.readLine();
            if(input == null) break;
            
            String[] splittedStr = input.split(",");
            
            int x = Integer.parseInt(splittedStr[0]);
            int y = Integer.parseInt(splittedStr[1]);
            int dropSize = Integer.parseInt(splittedStr[2]);
            
            dropInk(x, y, dropSize);
        }
        
        System.out.println(PAPER_SIZE * PAPER_SIZE - droppedCount);
        System.out.println(maxDropping);
    }
    
    public static void dropInk(int x, int y, int inkSize) {
        switch(inkSize) {
        case 1:
            dropInk(x, y, SMALL_INK_DROP_SIZE, SMALL_INK_DROP);
            break;
        case 2:
            dropInk(x, y, MEDIUN_INK_DROP_SIZE, MEDIUM_INK_DROP);
            break;
        case 3:
            dropInk(x, y, LARGE_INK_DROP_SIZE, LARGE_INK_DROP);
            break;
        }
    }
    
    private static void dropInk(int x, int y, int dropSize, boolean[] drop) {
        for(int i = 0; i < dropSize; i++) {
            int tx = x - dropSize / 2 + i;
            if(tx < 0) continue;
            if(tx >= PAPER_SIZE) break;
            
            for(int j = 0; j < dropSize; j++) {
                if(!drop[i * dropSize + j]) continue;
                
                int ty = y - dropSize /2 + j;
                if(ty < 0) continue;
                if(ty >= PAPER_SIZE) break;
                
                if(paper[tx * PAPER_SIZE + ty]++ == 0 ) {
                    droppedCount++;
                }
                if(maxDropping < paper[tx * PAPER_SIZE + ty]) {
                    maxDropping = paper[tx * PAPER_SIZE + ty];
                }
            }
        }
    }
}

Measured memory_bytes: 16924
#include <iostream>
#include <stack>
#include <queue>
#include <vector>
using namespace std;
#define N 100
#define MAX 100000
#define NIL -1
#define rep(i, n) for(int i = 0; i < (n); ++i)

int n;
vector<int> G[MAX];
int color[MAX];

void dfs_visits(int r, int id){
    stack<int> S;
    S.push(r);
    color[r] = id;
    while(!S.empty()){
        int u = S.top(); S.pop();
        rep(j, G[u].size()){
            int v = G[u][j];
            if(color[v] == NIL) {
                color[v] = id;
                S.push(v);
            }
        }
    }
}

void dfs(){
    // initialization
    rep(i, n) color[i] = NIL;
    int id = 1;
    rep(u, n){
        if (color[u] == NIL) dfs_visits(u, id++);
    }
}

int main()
{
    int s, t, m, q;
    cin >> n >> m;
    rep(i, m){
        cin >> s >> t;
        G[s].push_back(t);
        G[t].push_back(s);
    }

    dfs();
    
    cin >> q;
    vector<string> ans(q);

    rep(i, q){
        cin >> s >> t;
        if(color[s] == color[t]) ans[i] = "yes";
        else ans[i] = "no";
    }

    rep(i, q){
        cout << ans[i] << endl;
    }

    return 0;
}




Measured memory_bytes: 9196
n=int(input())
#a,b=map(int,input().split())
#n,k=map(int,input().split())
#d=list(map(int,input().split()))
s=list(input())
s.append("?")
ans=0
for i in range(n):
    if s[i]!=s[i+1]:
        ans+=1
print(ans)


Measured memory_bytes: 4084
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <queue>
#include <map>
#include <set>
using namespace std;
using Int = int64_t;
const Int INF = 1<<30;
const Int MOD = (Int)1e9 + 7;
const Int MAX_N = (Int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

void solve()
{
    int n = 5;
    int ans = 0;
    for(int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        if(x == 0)
        {
            ans = i + 1;
        }
    }
    cout << ans << endl;
}

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 3648
/*
START BY THE NAME OF ALMIGHTY ALLAH
THIS WONT BE ACCEPTED
STOP_GIVING_UP
*/
#include<bits/stdc++.h>
#define l(i,a,n)for(int i=a;i<n;i++)
#define PB push_back
#define IN insert
#define MP make_pair
#define all(v) v.begin(),v.end()
//#define y cout<<"Yes"
#define LW(v) sort(v.begin(),v.end());
#define HI(v) sort(v.begin(),v.end(),greater<long long>());
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(nullptr);
    double t,r=1,r1=0,r2=0,k=0,a,b,c=0,m,d=0,n,e,f,x,g,p=0,q=0,y=0,z=0;
    vector<long long>v;
    vector<long long>u;
    set<long long>s;
    std::vector<int>::iterator it;
    string  s1,s2,s3,s4,s5;
    cin>>n;
    c=ceil(n/2);
    cout<<c<<endl;

}





Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int n=5,miss=0;
    int a[n];
    bool flg=false;
    for(int m=0;m<n;m++)
    cin >> a[m];
    for(int m=0;m<=n;m++)
    {
        flg = false;
        for(int k=0;k<n;k++)
        {
            if(a[k]==m)
            flg=true;
        }
        if(flg==false)
        {
            miss=m;
            break;
        }
    }
    cout << miss << endl;
return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>

#define DIV 1000000007
using namespace std;
using ll = long long;

queue<int> q;
vector<bool> visit;
vector<ll> dist;

typedef struct {
    vector<int> edge;
    int dis;
}node_t;
vector<node_t> node;

void bfs_u(vector<bool>& visit) {
    int x = q.front();
    q.pop();
    visit[x] = true;

    for (auto to : node[x].edge) {
        if (visit[to])continue;
        visit[to] = 1;
        node[to].dis = node[x].dis + 1;
        dist[node[to].dis]++;
        q.push(to);
    }

    if (!q.empty())
        bfs_u(visit);
}

int main() {
    int N, X, Y;
    cin >> N >> X >> Y;

    dist = vector<ll>(N + 1);
    node = vector<node_t>(N + 1);
    for (int i = 1; i <= N-1; i++) {
        node[i].edge.push_back(i + 1);
        node[i+1].edge.push_back(i);
    }
    node[X].edge.push_back(Y);
    node[Y].edge.push_back(X);

    for (int i = 1; i <= N; i++) {
        q.push(i);
        vector<bool> visit(N + 1);
        bfs_u(visit);
        for (int j = 1; j <= N; j++) {
            node[j].dis = 0;
        }
    }

    for (int i = 1; i <= N - 1; i++)
        cout << dist[i]/2 << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
const long long INF = 1LL << 60;

int main() {
  int n;
  cin >> n;
  vector<bool> s(4, false);
  rep(i, n) {
    char a;
    cin >> a;
    if (a == 'P')
      s[0] = true;
    else if (a == 'W')
      s[1] = true;
    else if (a == 'G')
      s[2] = true;
    else
      s[3] = true;
  }
  int count = 0;
  rep(i, 4) {
    if (s[i] == true) count++;
  }
  if (count == 3) {
    cout << "Three" << endl;
  } else
    cout << "Four" << endl;
}


Measured memory_bytes: 256
while True:
    N = int(input())
    if N == 0:break
    flgs = [0 for i in range(N)]
    for i in range(N):
        src = list(map(int,input().split()))
        for k in src[1:]:
            flgs[i] |= (1 << k)
    target = 0
    src = list(map(int,input().split()))
    for k in src[1:]:
        target |= (1 << k)

    ans = -1
    for i in range(N):
        if (flgs[i] | target) == flgs[i]:
            if ans < 0:
                ans = i+1
            else:
                ans = -1
                break
    print(ans)

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

int main()
{
  int N, sum = 0;
  cin >> N;
  for (int i = 0; i < N; i++)
  {
    int l, r;
    cin >> l >> r;
    sum += r - l + 1;
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

char s[128][128];//s[h][w]
char cs[4] = "@#*";

int h,w;
int sp = 0;

void check(int t,int sh,int sw){
	int nh,nw;
	s[sh][sw] = '.';
	nh = sh - 1,nw = sw;
	if(0 <= nh && nh < h && 0 <= nw && nw < w && s[nh][nw] == cs[t]) check(t,nh,nw);
	nh = sh,nw = sw - 1;
	if(0 <= nh && nh < h && 0 <= nw && nw < w && s[nh][nw] == cs[t]) check(t,nh,nw);
	nh = sh,nw = sw + 1;
	if(0 <= nh && nh < h && 0 <= nw && nw < w && s[nh][nw] == cs[t]) check(t,nh,nw);
	nh = sh + 1,nw = sw;
	if(0 <= nh && nh < h && 0 <= nw && nw < w && s[nh][nw] == cs[t]) check(t,nh,nw);
}

int main(void) {
	int i,j,k;
	while(scanf("%d%d",&h,&w) , h != 0){
		sp = 0;
		for(i = 0;i < 128;i++){
			for(j = 0;j < 128;j++){
				s[i][j] = '.';
			}
		}
		for(i = 0;i < h;i++){
			scanf("%s",s[i]);
		}
		for(i = 0;i <= 2 ;i++){
			for(j = 0;j < h;j++){
				for(k = 0;k < w;k++){
					if(s[j][k] == cs[i]){
						sp++;
						check(i,j,k);
					}
				}
			}
		}
		printf("%d\n",sp);
	}
	return 0;
}

Measured memory_bytes: 1544
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


def main():
    N,M = [int(i) for i in input().strip().split()]
    students = [[int(i) for i in input().strip().split()] for _ in range(N)]
    checkpoints = [[int(i) for i in input().strip().split()] for _ in range(M)]
    ans = [0] * N

    for i,student in enumerate(students):
        dist = [float("inf")] * M
        for j, checkpoint in enumerate(checkpoints):
            dist[j] = abs(student[0] - checkpoint[0]) + abs(student[1] - checkpoint[1])
        ans[i] = dist.index(min(dist)) + 1

    return ans


if __name__ == "__main__":
    for n in main():
        print(n)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> a(n+1,0);
    for(int i=1;i<=n;i++){
        int b=0;
        cin>>b;
        a[b]++;
    }
    for(int i=1;i<=n;i++){
        cout<<a[i]<<endl;
    }
}

Measured memory_bytes: 4052
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#define sqr(x) (x)*(x)
using namespace std;
int n,m,x,y,i;
int main()
{
	cin>>n>>m>>y;
	bool bo=0;
	if (y>m) bo=1;
	if (n==1)
	{
		if (m==y) cout<<"POSSIBLE";
			else cout<<"IMPOSSIBLE";
		return 0;
	}
	for (i=2;i<=n;i++)
	{
		scanf("%d",&x);
		if (x==m)
		{
			cout<<"POSSIBLE";
			return 0;
		}
		if (x>m) bo=1;
		y=__gcd(x,y);
	}
	if ((!bo))
	{
		cout<<"IMPOSSIBLE";
		return 0;
	}
	if (m%y)
	{
		cout<<"IMPOSSIBLE";
		return 0;
	}
	cout<<"POSSIBLE";
	return 0;
}

Measured memory_bytes: 256
//#include    <bits/stdc++.h>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <cassert>
#include <iterator>
#include <complex>
#define N  500005
#define mem(a,b) memset(a,b,sizeof(a))
#define IOS ios::sync_with_stdio(false)
#define INF 0x3f3f3f3f
template<typename T> inline T max(T a,T b,T c){
    return max(a,max(b,c));
}
template<typename T> inline T min(T a,T b,T c){
    return min(a,min(b,c));
}
template<typename T> inline T max(T a,T b,T c,T d){
    return max(a,max(b,c,d));
}
template<typename T> inline T min(T a,T b,T c,T d){
    return min(a,min(b,c,d));
}
const int  dx[]={0,1,0,-1,0,1,-1,1,-1};
const int  dy[]={0,0,1,0,-1,1,-1,-1,1};
const int MOD=1000000007;
typedef long long ll;
using namespace std;
int main(){
    IOS;
    ll n,m,sum;
    cin>>n>>m;
   if (n==1&&m==1)
      sum=1;
   else if (n==1||m==1)
     sum=n*m-2;
   else{
      sum=n*m-(n*2+(m-2)*2);
   }
   cout << sum << endl;
   return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc166/tasks/abc166_f

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

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DEBUG 1
#if DEBUG
  #define _GLIBCXX_DEBUG
  #define DUMP(a) REP(_i, a.size()) cout << a[_i] << (_i + 1 == a.size() ? "\n" : " ")
  #define DUMP2D(b) REP(_j, b.size()) DUMP(b[_j]); cout << endl
#else
  #define DUMP(a)
  #define DUMP2D(b)
#endif

const int N_MAX = 1e5;
const int A_MAX = 1e9;
const int B_MAX = 1e9;
const int C_MAX = 1e9;
const int A = 0;
const int B = 1;
const int C = 2;
const string ABC = "ABC";

int N;
int v[3];
vector<string> s;

vector<char> ans;

char move(int x, int y) {
  if (v[x] == 0 && v[y] == 0) {
    return '-';
  }
  if (v[x] <= v[y]) {
    v[x]++;
    v[y]--;
    return ABC[x];
  }
  v[x]--;
  v[y]++;
  return ABC[y];
}

int main() {
  cin >> N >> v[A] >> v[B] >> v[C];
  s = vector<string>(N + 1);
  REP(i, N) cin >> s[i];
  s[N] = "";

  char c;
  ans = vector<char>(N);

  REP(i, N) {
    if (s[i] == "AB") {
      if (s[i + 1] == "AC") {
        c = move(A, B);
      } else {
        c = move(B, A);
      }
    } else if (s[i] == "BC") {
      if (s[i + 1] == "AB") {
        c = move(B, C);
      } else {
        c = move(C, B);
      }
    } else { // "AC"
      if (s[i + 1] == "BC") {
        c = move(C, A);
      } else {
        c = move(A, C);
      }
    }
    if (c == '-') {
      cout << "No" << endl;
      return 0;
    } else {
      ans[i] = c;
    }
  }

  cout << "Yes" << endl;
  REP(i, N) cout << ans[i] << endl;
}


Measured memory_bytes: 6392
def resolve():
    import sys
    from collections import Counter

    input = sys.stdin.readline

    n = int(input().rstrip())

    words = [input().rstrip() for i in range(n)]
    words.sort()

    word_counter = Counter(words)

    max_count = word_counter.most_common()[0][1]

    output_words = [c[0] for c in word_counter.most_common() if c[1] == max_count]
    output_words.sort()

    [print(w) for w in output_words]
 
resolve()

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

using namespace std;

using ll = long long;

int main(){
	ll n, m, s, b;
	cin >> n >> m;
	if (n < 10){
		s = 100 * (10 - n);
		cout << m + s;
	}
	else cout << m;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	string s;
	cin >> s;
	int forw=0,backw=((int)s.size())-1;
	while(s[forw]!='A'){
		forw++;
	}
	while(s[backw]!='Z'){
		backw--;
	}
	cout << backw-forw+1 << endl;
	return 0;
}


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


int main() {
  string S ; 
  cin >> S ; 
  
  
  if (S == "SUN"){
    cout << 7 << endl ; 
  }
  else if (S == "MON"){
    cout << 6 << endl ; 
  }
    else if (S == "MON"){
    cout << 6 << endl ; 
  }
    else if (S == "TUE"){
    cout << 5 << endl ; 
  }
    else if (S == "WED"){
    cout << 4 << endl ; 
  }
    else if (S == "THU"){
    cout << 3 << endl ; 
  }
    else if (S == "FRI"){
    cout << 2 << endl ; 
  }
  else {
    cout << 1 << endl ; 
    
  }
  
  
  
  
  
}


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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair


ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }

const ll MOD=1000000007LL;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }
// ll comb(ll n, ll k) { ll v=1; for(ll i=1; i<=k; i++) v = DIV(MUL(v, n-i+1),i); return v; }
//

ll solve(int N,int X,int Y,int Z){
    ll dp[2][65536];

    mset(dp, 0);
    dp[0][0] = 1LL;
    ll goaled = 0;

    int goal = (1 << (X+Y+Z-1)) | (1 << (Y+Z-1)) | (1 << (Z-1));

    rep(z, N){ // 40
        int i0=z%2, i1=(z+1)%2;
#ifdef DEBUG
        fprintf(stderr,"%d->%d\n", i0, i1);
#endif
        goaled = MUL(goaled, 10LL);

        mset(dp[i1], 0);
        rep(st, 65536) {
            ll curr = dp[i0][st];
            if (!curr) continue;
#ifdef DEBUG
            // fprintf(stderr," st %04x : %lld\n", st, curr);
#endif
            rep1(a,10) {
                int ni = (st << a) | (1 << (a-1));
                if ((ni & goal) == goal) {
                    goaled = ADD(goaled, curr);
#ifdef DEBUG
                    fprintf(stderr," (%d) goaled += %lld\n", a, curr);
#endif
                } else {
                    ni &= 0xffff;
#ifdef DEBUG
                    // fprintf(stderr," (%d) newstat %04x += %lld\n", a, ni, curr);
#endif
                    dp[i1][ni] = ADD(dp[i1][ni], curr);
                }
            }
        }
    }
    return goaled;
}

int main() {
    int N,X,Y,Z; cin >>N>>X>>Y>>Z;
    cout << solve(N,X,Y,Z) << endl;
    // cout << (solve(N,a) ? "Yes":"No") << endl;
    return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	long long a,b,k,c;cin>>k>>a>>b;bool j=0;
	for(int i=a;i<=b;i++)
	{
		if(i%k==0)
		{
			j=1;break;
		}
	}
	cout<<(j?"OK":"NG");
	return 0;
 } 

Measured memory_bytes: 3624
import java.util.*;
public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);

    int A = sc.nextInt();
    int B = sc.nextInt();

    int  max = Math.max(A,B);

    for(int k = 0 ;k<max;k++){
       int AA = Math.abs(A-k);
       int BB = Math.abs(B-k);

        if(AA==BB){
          System.out.println(k);
          System.exit(0);
        }
    }
    System.out.println("IMPOSSIBLE");
  }
}

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

int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	int k;
	cin>>k;
	bool tmp=false,cnt=false;
	if(b>a)
		tmp=true;
	
	if(!tmp)
	{
		while(k>0 && b<=a)
		{
			b=b*2;
			k--;
		}
		if(b>a)
		{
			tmp=true;
		}
	}
	if(c>b)
		cnt=true;
	if(!cnt)
	{

		while(k>0 && c<=b)
		{
			c=c*2;
			k--;
		}
		if(c>b)
		{
			cnt=true;
		}
	}
	if(cnt && tmp)
	{
		cout<<"Yes\n";
	}
	else
	{
		cout<<"No\n";
	}
	return 0;
}

Measured memory_bytes: 3608
#include<stdio.h>

int main(void)
{
	int a,b,c,i,j,x;

	while(scanf("%d %d %d",&a,&b,&c)!=EOF){
		x=20-a-b;
		j=0;
		for(i=1;i<11;i++){
			if(i != a && i != b && i != c){
			   if(i <= x)
				   j++;
			}
		}
		if(j>3)
			printf("YES\n");
		else
		    printf("NO\n");
	}
  return 0;
}

Measured memory_bytes: 1004
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
int modpow(int x,int y,int md=mod){if(y==0)return 1;int ret=modpow(x,y>>1,md);ret=(ll)ret*ret%md;if(y&1)ret=(ll)ret*x%md;return ret;}
int a,b,c,n;
int main(){
	cin>>a>>b>>c>>n;ll ans=0;
	for(int i=0;i<=n;i++)
		for(int j=0;j<=n;j++){
			int k=n-i*a-j*b;
			if(k>=0&&k%c==0)ans++;
		}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define MAXN 100000
#define LL long long
#define MOD 
#define Pr pair<int,int>
#define X first
#define Y second
int n,sum,p;
int a[MAXN+5];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{scanf("%d",&a[i]);if(a[i])p=1;}
	if(!p){
		printf("Yes\n");return 0;
	}
	if(n%3!=0){
		printf("No\n");
	}
	else{
		sort(a+1,a+n+1);
		int p=n/3,F1=0,F2=0,F3=0;
		for(int i=2;i<=p;i++)
		if(a[i]!=a[i-1])F1=1;
		for(int i=p+2;i<=p*2;i++)
		if(a[i]!=a[i-1])F2=1;
		for(int i=p*2+2;i<=p*3;i++)
		if(a[i]!=a[i-1])F3=1;
		if(F1||F2||F3)printf("No\n");
		else{
			//printf("%d %d %d %d %d %d",a[p]^a[p*2]==a[p*3],a[p*2]^a[p*3]==a[p],a[p]^a[p*3]==a[p*2]);
			if((a[p]^a[p*2])==a[p*3])printf("Yes\n");
			else if((a[p*2]^a[p*3])==a[p])printf("Yes\n");
			else if((a[p]^a[p*3])==a[p*2])printf("Yes\n");
			else printf("No\n");
		}
	}
}


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

namespace practice
{
    class Program
    {
        static void Main(string[] args)
        {
            string s;
            string t;
            string[] str = Console.ReadLine().Split(' ');
            s = str[0];
            t = str[1];

            Console.WriteLine(t + s);
        }
    }
}

Measured memory_bytes: 13140
/***
*	??????????????????
*	???????????????????????£???????????£??\????´?????????????????????§????¬???????????????°?????????
*	?????????????°?????????£??\??????????´?????????????????????????????????§?°???¢?????????????????°???????????????
****/

#include <iostream>
#include <vector>
using namespace std;


int bubbleSort(vector<int> &str, int n, int *cnter){
	for( int i=0 ; i < n-1 ; i++ ){
		
		for(int j = 1 ; j< (n-i); j++){
			if( str[j-1] > str[j] ){//????????????????´???¨??????
				int temp = str[j];
				str[j]     = str[j-1];
				str[j-1]   = temp;
				(*cnter) ++;		//???????????°???????????? //??????????????????
			}
		}
	}
	return 0;
}

int main(void)		//???????????¢??°
{
	int n;
	cin >> n;
	
	vector <int> str;
	str.resize(n);
	
	for(int i =0; i < n ;  i++){	//????????\???
		cin >> str[i] ;
	}
	
	int cnter = 0;
//----------------------------------	?????????????????????????§?
	bubbleSort(str, n, &cnter);
	
//----------------------------------	???????????????
	for(int i =0; i<n ; i++){
		cout << str[i] ;
		if(i != (n-1)){
			cout << " ";
		}
	}
	cout << endl;
	
	cout << cnter << endl;//???????????°????????¢??°???????????¢?????°??¨?????°??????????????±?????????????????¨?????°???
	
	return 0;
}

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

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    int ans=0;
    for(int i=a; i<=b; i++){
        if(i%c==0) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pii std::pair<int,int>
#define pli std::pair<ll,int>
#define pil std::pair<int,ll>
#define psi std::pair<string,int>
#define pll std::pair<ll,ll>
#define pci std::pair<char,int>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define pb push_back
#define vll std::vector<ll>
#define vpi std::vector<std::pair<int,int>>
#define vi std::vector<int>
#define vvi std::vector<std::vector<int>>
#define vvpil std::vector<std::vector<std::pair<int,ll>>>
#define vlpii std::vector<std::list<pii>>
#define vlpil std::vector<std::list<pil>>
#define li std::list<int>
#define lpil std::list<pil>
#define Endl printf("\n")
#define vli vector<list<int>>
#define vvll vector<vector<ll>>
#define mp make_pair
#define ma 100000000
#define mod 1000000007
const ll  INF=10000000000000;
using namespace std;
ll dp[105][100005];
void add(ll& a , ll b){
    a += b ;
    a %= mod ;
}

int main()
{   IOS;
    int n,k;
    memset(dp , 0 , sizeof dp);
    cin>>n>>k;
    int a[n];
    for(int i = 0 ; i<n ; i++ ) cin >> a[i];
    dp[n][k] = 1 ;
    for(int i=n-1;i>=0;i--){
        vector<ll> v( k+1 , 0);
        v[k] = dp[i+1][k];
        for(int j = k-1 ; j>= k - a[i] ; j--) add(v[j] , v[j+1] + dp[i+1][j]);
        int f=k;
        for(int j = k - a[i] -1 ;j >= 0 ;j-- ) {add(v[j] , v[j+1] +dp[i+1][j] - dp[i+1][f]) ; if(v[j]<0) v[j]+=mod;f--;}
        for( int j = k ;j >= 0 ; j-- ){
            add(dp[i][j] , v[j]) ;
        }
    }
    cout << dp[0][0];
    return 0;
}


Measured memory_bytes: 83072
#include <bits/stdc++.h>
#include <math.h>
#include <vector>
#include <queue>
#include <iomanip>
#include <string>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_1 (i,j,n) for(int i=j;i<n;i++)
typedef long long ll;
typedef long l;
const ll l_INF = 101010101000;
const int INF = 1010101010;
const int dx[4] = {-1,0,1,0};
const int dy[4] = {0,-1,0,1};
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;

int main(){
  int n;
  cin >> n;
  map<ll,ll> a;
  rep(i,n){
    ll x;
    cin >> x;
    a[x]+=x;
  }
  ll ans=0;
  for(auto x : a){
    ans+=x.second;
  }
  int q;
  cin >>q;
  rep(i,q){
    ll b,c;
    cin >> b >> c;
    a[c]+=a[b]/b*c;
    ans += a[b]/b*c-a[b];
    a[b]=0;
    cout <<ans<<endl;
  }
}

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

int main(void){
    int A1, A2, A3;
    cin >> A1 >> A2 >> A3;

    int tmp = abs(A1-A2)+abs(A3-A1);
    if(abs(A2-A3)+abs(A1-A2) < tmp)
        tmp=abs(A2-A3)+abs(A1-A2);
    if(abs(A3-A1)+abs(A2-A3) < tmp)
        tmp=abs(A3-A1)+abs(A2-A3);

    cout << tmp << endl;
}

Measured memory_bytes: 256
from collections import defaultdict
def solve():
    N = int(input())
    A = list(map(int,input().split()))
    MOD = 10 ** 9 + 7

    d = defaultdict(int)

    for a in A:
        d[a] += 1
    
    num = 1
    if N % 2 != 0:
        if d[0] != 1:
            print(0)
            return
        num = 2
    
    while num < N:
        if d[num] != 2:
            print(0)
            return
        num += 2
    
    print(pow(2,N//2,MOD))
                
if __name__ == '__main__':
    solve()


Measured memory_bytes: 55532
#include <stdio.h>
int main(void){
    int A, B, C;
    scanf("%d %d %d",&A, &B, &C);

    if (A <= C && B <= C){
        if (A == 5 && B == 5 && C == 7){
            printf("%s", "YES");
        }
        else {
            printf("%s", "NO");
        }
    }
    else if (A <= B && C <= B){
        if (A == 5 && C == 5 && B == 7){
            printf("%s", "YES");
        }
        else {
            printf("%s", "NO");
        }
    }
    else if (B <= A && C <= A) {
        if (B == 5 && C == 5 && A == 7){
            printf("%s", "YES");
        }
        else {
            printf("%s", "NO");
        }
    }

    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int main(void)
{
	int n;
	int a,b;
	int d,x;
	int acal,bcal[10000],scal;
	int max;
	int i,j,temp;
	int c;
	c=0;
	
	scanf("%d",&n);
	scanf("%d %d",&a,&b);
	scanf("%d",&acal);
	max=acal/a;
	scal=acal;
	for(i=0;i<n;i++){
		scanf("%d",&bcal[i]);
	}
	for(i=0;i<n-1;i++){
		for(j=i+1;j<n;j++){
			if(bcal[i]<bcal[j]){
				temp=bcal[i];
				bcal[i]=bcal[j];
				bcal[j]=temp;
			}
		}
	}
	for(i=0;i<n;i++){
		scal+=bcal[i];
		c++;
		d=a+c*b;
		x=scal/d;
		if(max<x){
			max=x;
		}
	}
	printf("%d\n",max);
	return 0;
}

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

int main()
{

    long long n, ans = 0, min = 1000000001, flag = 0;
    cin >> n;
    vector<long long> a(n);
    for(int i = 0;i < n;i++){
        cin >> a[i];
        if(a[i] < 0){
            flag++;
        }
        if(min > abs(a[i])){
            min = abs(a[i]);
        }
    }

    if(flag % 2 == 0){
        for(int i = 0;i < n;i++){
            if(a[i] < 0){
                ans += -a[i];
            }
            else{
                ans += a[i];
            }
        }
    }
    else{
        for(int i = 0;i < n;i++){
            if(a[i] < 0){
                ans += -a[i];
            }
            else{
                ans += a[i];
            }
        }

        ans -= min * 2;
    }



    cout << ans;

    return 0;

}

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

int main()
{
    long long int n,k,i,j,x,sum=0,maxi=0,q;
    double z,y,p;
    cin>>n>>k;
    long long int a[n+1];
    for(i=0;i<n;i++)
        cin>>a[i];
    for(i=0;i<k;i++)
        sum+=a[i];
    maxi=sum;
    for(i=k;i<n;i++)
    {
        sum+=a[i];
        sum-=a[i-k];
        maxi=max(maxi,sum);
    }
    z=maxi;
    y=k;
    p=(z+y)/2.0;
    printf("%.12f\n",p);
    return 0;
}


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

using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n); i > 0; i--)
#define print(n) cout << n << endl

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    int n;
    cin >> n;
    vector<int> a(n-1);
    vector<int> b(n);
    rep(i,n-1) cin >> a[i];
    rep(i,n-1) b[a[i]-1]++;
    rep(i,n) print(b[i]);

    return 0;
}

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

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

  int s = 0;
  rep(i, n) s ^= a[i];
  rep(i, n) a[i] ^= s;
  rep(i, n) cout << (i == 0 ? "" : " ") << a[i];
  cout << endl;

  return 0;
}


Measured memory_bytes: 3896
function Main(input){
  	var args = input.split(" ");
  	var num = parseInt(args[0], 10); // 10進数
	var str = num.toString(10);
  	var count = 0;
	for(var i=0; i<str.length; i++){
      if(str[i]=="1"){
        count += 1;
      }
    }
  	console.log(count);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int S;
    cin >> S;
    set<int> st;
    ll num = S;
    rep(i,1,INF){
        if(st.count(num)){
            cout << i << endl;
            return 0;
        }
        st.insert(num);
        if(num % 2 == 0)num /= 2;
        else num = num * 3 + 1;
    }
}

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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set

using namespace std;

const ll MOD = 1000000007;
const ll INF = (1LL << 62);

ll dp[100005];

int main() {
  // std::cout << std::fixed << std::setprecision(10);

  ll N, M;
  scanf("%lld %lld", &N, &M);

  vector<ll> h_list(N + 5);
  for (ll i = 0; i < N; i++) {
    ll v;
    scanf("%lld", &v);
    h_list[i + 1] = v;
  }

  for (ll i = 0; i < M; i++) {
    ll a, b;
    scanf("%lld %lld", &a, &b);

    dp[a] = max(dp[a], h_list[b]);
    dp[b] = max(dp[b], h_list[a]);
  }

  ll ans = 0;

  for (ll i = 1; i <= N; i++) {
    // cout << h_list[i] << endl;
    // cout << dp[i] << endl;
    ll h = h_list[i];

    if (h > dp[i]) {
      ans++;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 4916
package main

import "fmt"

// 2018-08-09T23:16:13+0800
// 2018-08-09T23:34:23+0800
// 2018-08-10T00:10:30+0800
func main() {
	var A, B int
	fmt.Scanf("%d%d", &A, &B)
	sq := make([][]bool, 100)
	h, w := 100, 100
	for i := 0; i < h; i++ {
		sq[i] = make([]bool, w)
	}

	A -= 1
	B -= 1

	for h := 0; A > 0; A -= w / 2 {
		for ii := 0; ii < w; ii += 2 {
			if ii/2 >= A {
				break
			}
			sq[h][ii] = true
		}
		h += 2
	}
	for h := 51; B > 0; B -= w / 2 {
		for ii := 0; ii < w; ii += 2 {
			if ii/2 >= B {
				break
			}
			sq[h][ii] = true
		}
		h += 2
	}

	fmt.Println(h, w)
	for i := 0; i < h; i++ {
		for ii := 0; ii < w; ii++ {
			if i < 50 {
				if sq[i][ii] {
					fmt.Print(".")
				} else {
					fmt.Print("#")
				}
			} else {
				if sq[i][ii] {
					fmt.Print("#")
				} else {
					fmt.Print(".")
				}
			}
		}
		fmt.Println()
	}
}

Measured memory_bytes: 640
N = int(input())
S = [input() for i in range(N)]
MARCH = ['M', 'A', 'R', 'C', 'H']
p = {i:0 for i in MARCH}

for i in range(N):
    if S[i][0] in MARCH:
        p[S[i][0]] += 1

from itertools import combinations
ans = 0
for t in combinations(MARCH, 3):
    ans += p[t[0]] * p[t[1]] * p[t[2]]

print(ans)

Measured memory_bytes: 55512
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin>>S;
  int N=S.size();
  bool flag=true;
  if(S.at(0)!='A'){
    flag=false;
  }
  if(S.at(1)=='C'||S.at(N-1)=='C'){
    flag=false;
  }
  if(islower(S.at(1))==0||islower(S.at(N-1))==0){
    flag=false;
  }
  int count=0;
  for(int i=2;i<N-1;i++){
    if(S.at(i)=='C'){
      count=count+1;
    }
    else{
      if(islower(S.at(i))==0){
        flag=false;
      }
    }
  }
  if(flag==true&&count==1){
    cout<<"AC"<<endl;
  }
  else{
    cout<<"WA"<<endl;
  }
}
      
    


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i,s,e) for(int i=s;i<e;i++)
#define endl '\n'
int main(){
    int S,W;cin>>S>>W;
    if(S<=W)cout<<"unsafe"<<endl;
    else cout<<"safe"<<endl;
}

Measured memory_bytes: 3576
# from scipy.misc import comb

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

N, K = map(int, input().split())
As = sorted(list(map(int, input().split())))

mod = 10**9+7 #出力の制限
# N = 10**4
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

upper = 0
lower = 0
for i in range(N - K + 1):
    # c = comb(K + i - 1, i, exact=True)
    c = cmb(K + i - 1, i, mod)
    upper = (upper + (As[K + i - 1] * c)) % (10 ** 9 + 7)
    lower = (lower + (As[N - K - i] * c)) % (10 ** 9 + 7)
print(((upper - lower) % (10 ** 9 + 7) + 10 ** 9 + 7) % (10 ** 9 + 7))

Measured memory_bytes: 20672
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        char[] t = sc.next().toCharArray();
        if(s.length != t.length) {
            System.out.println("No");
            return;
        }
        int len = s.length;
        ArrayList<Character> sl = new ArrayList<Character>();
        for(char c : s){
            sl.add(c);
        }
        for(int i = 0; i < len; i++){
            boolean bool = true;
            for(int j = 0; j < len; j++){
                if(sl.get(j) != t[j]){
                    bool = false;
                    break;
                }
            }
            if(bool){
                System.out.println("Yes");
                return;
            }
            Collections.rotate(sl,1);
        }
        System.out.println("No");
    }
}

Measured memory_bytes: 21716
# abc168b
# https://atcoder.jp/contests/abc168/tasks/abc168_b

# Sの文字列の長さがK以下であれば、
# そのままSを出力
# K以上であれば、Kの文字列と'...'を付加して出力

k = int(input())
s = str(input())

if len(s) <= k:
    print(s)
else:
    s = s[:k] + '...'
    print(s)


Measured memory_bytes: 9100
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define lsc(x)      scanf("%lld",&x)
#define sc(x)       scanf("%d",&x)
#define lpr(x)      printf("%lld ",(long long)x)
#define pr(x)       printf("%d ",x)
#define n_l         printf("\n")
#define VI          vector<int>
#define VII         vector<long long int>
#define m_p         make_pair
#define pb          push_back
#define fi           first
#define se           second
#define mset(x,y)   memset(x,y,sizeof(x))
#define sz(v)       (int)v.size()
#define all(v)      v.begin(), v.end()
#define fr(i, a, n) for(int i=a;i<=n;i++)
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
const int N=(int)1e6+5;
const int mod = 1000000007;
typedef long long ll;
// order_of_key (val): returns the no. of values strictly less than val
// find_by_order (k): returns the kth largest element iterator.(0-based)
// vector<int>::iterator itr=lower_bound(v.begin(),v.end(),x);
// s.substr(pos[0-indexed], len(default=till end))
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

ll fmod(ll x){if (x<mod) return x;return x%mod;}
ll mul(ll a, ll b, ll c){
	ll ret=0;while(b){if (b%2) ret=(ret+a)%c;a=(a*2)%c;b>>=1;}
    return ret;
}
int modpow(ll a, ll b){
    ll ret=1;while(b){if (b%2) ret=(ret*a)%mod;a=(a*a)%mod;b>>=1;}
    return (int)ret;
}
inline int inv(int x){ return modpow(x, mod-2);}
int isprime[N];
void calc_prime(){
	isprime[1]=1;for(ll i=2;i<N;i++) if (!isprime[i]) for(ll j=i*i;j<N;j+=i) isprime[j]=1;
}
int bulb[N], p[N];
int main(){
    int n, m;sc(n);sc(m);
    fr(i, 1, m){
        int x;sc(x);
        int val = 0;
        fr(j, 1, x){
            int s;sc(s);
            val += 1<<(s-1);
        }
        bulb[i] = val;
    }
    fr(j, 1, m) sc(p[j]);
    int ans = 0;
    fr(i, 0, (1<<n) - 1){
        int tmp[m+1] = {0};
        fr(j, 1, n){
            int val = (1<<(j-1));
            if (val&i){
                // trace(i, j);
                fr(k, 1, m){
                    if (bulb[k] & val) {
                        // trace(i, j, k);
                        tmp[k] = (tmp[k] + 1)%2;
                    }
                }
            }
        }
        int flag = 0;
        fr(j, 1, m){
            if (tmp[j] != p[j]) flag=1;
        }
        if (!flag) ans++;
        // trace(ans);
    }
    pr(ans);n_l;
    return 0;
}



Measured memory_bytes: 3796
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> p(n), c(n);
    rep(i,n) cin >> p[i];
    rep(i,n) cin >> c[i];
    rep(i,n) p[i]--;
    ll ans = -1e18;
    rep(si,n) {
      int x = si;
      vector<int> s;
      ll tot = 0;
      while (1) {
        x = p[x];
        s.push_back(c[x]);
        tot += c[x];
        if (x == si) break;
      }
      int l = s.size();
      ll t = 0;
      rep(i,l) {
        t += s[i];
        if (i+1 > k) break;
        ll now = t;
        if (tot > 0) {
          ll e = (k-(i+1))/l;
          now += tot*e;
        }
        ans = max(ans, now);
      }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3708
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

//グローバル変数


//ライブラリ挿入


int main(){
    int N;
    cin >> N;
    vector<ll> A(N);
    REP(i,N) cin >> A[i];
    multiset<int> st;
    st.insert(A[0]);
    REP2(i,1,N){
        auto itr = st.lower_bound(A[i]);
        if(itr==st.begin()){
            st.insert(A[i]);
        }else{
            itr--;
            st.erase(itr);
            st.insert(A[i]);
        }
    }

    cout << st.size() << endl;
    
}

Measured memory_bytes: 5760