akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//using ll = long long;
using P = pair<int,int>;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int n,a[200010],sum = 0,ans = INF;
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> a[i];
		sum += a[i];
	}
	int tmp = 0;
	for(int i = 0;i < n - 1;i++){
		tmp += a[i];
		chmin(ans,abs(tmp - (sum - tmp)));
	}
	cout << ans << endl;
}

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

template <typename T>
struct FenwickTree {
	int n; // [1, n]
	vector<T> bit;
	FenwickTree(int n) : n(n), bit(n+1) {}
	T sum(int i) {
		T s = 0;
		while (i > 0) {
			s += bit[i];
			i -= i&-i;
		}
		return s;
	}
	void add(int i, T x) {
		while (i <= n) {
			bit[i] += x;
			i += i&-i;
		}
	}
};

int main() {
	int N, Q;
	cin >> N >> Q;
	vector<int> C(N);
	for (auto& x : C) cin >> x;
	vector<pair<int,int>> LR;
	vector<vector<pair<int,int>>> query(N+1);
	vector<int> ans(Q);
	for (int i = 0; i < Q; ++ i) {
		int x, y;
		cin >> x >> y;
		query[y].push_back({x,i});
	}
	vector<int> hoge(N+1, -1);
	FenwickTree<int> bit(N);
	for (int p = 1; p <= N; ++ p) {
		int prev = hoge[C[p-1]];
		if (prev != -1) {
			bit.add(prev, -1);
		}
		hoge[C[p-1]] = p;
		bit.add(p, 1);
		for (const auto& xi : query[p]) {
			int q = xi.first;
			ans[xi.second] = bit.sum(p) - bit.sum(q-1);
		}
	}
	for (auto x : ans) {
		cout << x << endl;
	}
}


Measured memory_bytes: 33224
using System;
using static System.Console;

class Program
{
    public static void Main()
    {
	string s = ReadLine();

	long ans = 0;
	int ct = 0;

	for (int i = 0; i < s.Length; i++)
	{
	    char c = s[i];
	    if (c == 'W')
	    {
		ans += (i - ct);
		ct++;
	    }
	}

	WriteLine(ans);
    }
}


Measured memory_bytes: 11744
#include "bits/stdc++.h"
#define int long long int
#define pb push_back
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define vvi vector<vector<int>>
#define vi vector<int>
#define f first 
#define s second 
using namespace std;
const int mod=1e9+7;
int logi(int n){int p=0;while(n/2){n=n/2;p++;}return p;}
int poww(int x,int y){int pro=1;while(y){if(y&1)pro=((pro%mod)*(x%mod)%mod);y=y>>1;x=((x%mod)*(x%mod)%mod);}return pro;}
int poww2(int x,int y){int pro=1;while(y){if(y&1)pro=pro*x;y=y>>1;x=x*x;}return pro;}
bool isprime(int n){ if(n==1) return false; for(int i=2;i<=sqrt(n);i++)	if(n%i==0) return false; return true;}
vector<vector<int>> adj(2e5);
vi visited(2e5,0);
/*

*/

void solve()
{
	string s;
	cin>>s;
	int cnt=0,mcnt=0;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='R') cnt++;
		else
		{
			mcnt=max(mcnt,cnt);
			cnt=0;
		}
	}
	mcnt=max(mcnt,cnt);
	cout<<mcnt;
}
int32_t main() {
/*#ifndef ONLINE_JUDGE
	//for getting input from input.txt
	freopen("input.txt","r",stdin);
	//for writing output to output.txt
	freopen("output.txt","w",stdout);
#endif*/
	fast;
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}


Measured memory_bytes: 9412
n=int(input())
a=list(map(int,input().split()))
if 0 in a:
    print(0)
    exit()
if max(a)>10**18:
    print(-1)
    exit()

a2=sorted(a, reverse=True)
ans=1
for i in range(n):
    ans=ans*a2[i]
    if ans>10**18:
        print(-1)
        exit()

print(ans)
    

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

using namespace std;

long long n,a[10000005];

int main () {
	cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	sort(a + 1, a + n + 1);
	cout << a[n/2+1] - a[n/2];
	return 0;
}

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

using namespace std;

// const int MAXN = 100000+10;

// int a[MAXN];


int main()
{
	int n,k,x;
	scanf("%d %d",&n,&k);
	for(int i=1;i<=n;i++) 
	{
		scanf("%d",&x);
	};

	n--;k--;

	printf("%d",n%k==0?n/k:n/k+1);

	return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(void)
{
  	int a,b,c,d,e=0;
  	cin >> a >> b >> c >> d;
  	while(a>0 && c>0){
      	e++;
      	if(e%2) c-=b;
      	else a-=d;
    }
  	if(a<=0) cout << "No";
  	else cout << "Yes";
}


Measured memory_bytes: 3560
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll ;
#define rep(i, a, b) for (int i = a; i <= b; ++ i) 
const int N = 1e5 + 5, M = N << 1, inf = 1e9 + 7 ;
using namespace std ;

int n, e, ter[M], nxt[M], lnk[N], w[M], sz[N], fa[N] ;
ll ans ;

void add(int x, int y, int z) {
	ter[++ e] = y, nxt[e] = lnk[x], lnk[x] = e, w[e] = z ;
}

void dfs(int p, int las) {
	sz[p] = 1, fa[p] = las ;
	for (int i = lnk[p] ; i; i = nxt[i]) if (ter[i] != las) {
		dfs(ter[i], p) ;
		sz[p] += sz[ter[i]] ;
		ans += 2LL * w[i] * min(sz[ter[i]], n - sz[ter[i]]) ;
	}
}

int main() {
	scanf("%d", &n) ;
	int x, y, z ;
	rep(i, 1, n - 1) {
		scanf("%d%d%d", &x, &y, &z) ;
		add(x, y, z), add(y, x, z) ;
	}	
	ans = 0 ;
	dfs(1, 0) ;
	rep(i, 1, n) for (int j = lnk[i] ; j; j = nxt[j]) if (ter[j] != fa[i]) {
		if (sz[ter[j]] == n / 2 && n - sz[ter[j]] == n / 2) {
			printf("%lld\n", ans - w[j]) ;
			return 0 ; 
		}
	}
	rep(i, 1, n) {
		bool flg = true ; int mn = inf ;
		for (int j = lnk[i] ; j; j = nxt[j]) {
			if (ter[j] == fa[i]) flg &= (n - sz[i] <= n / 2) ;
				else flg &= (sz[ter[j]] <= n / 2) ;
			mn = min(mn, w[j]) ;
		}
		if (flg) {
			printf("%lld\n", ans - mn) ;
			return 0 ;
		}
	}
	return 0 ; 
}

Measured memory_bytes: 7808
#include <stdio.h>

int main(void)
{
	int n;
	int ans;
	char prime[1000000];
	int i, j;
	int p;
	
	while (scanf("%d", &n) != EOF){
	
		for (i = 0; i < n + 1; i++){
			prime[i] = 1;
		}
		prime[0] = prime[1] = 0;
		
		for (i = 2, p = 0; i <= n + 1; i++){
			if (prime[i]){
				for (j = 2 * i; j <= n; j += i){
					prime[j] = 0;
				}
			}
		}
		for (i = 0, p = 0;i <= n; i++){
			if (prime[i] == 1){
				p++;
			}
		}
		
		ans = p;
		printf("%d\n", ans);
		}
	
	return (0);
}

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

int main() {
    int n;
    while(cin >> n) {
        vector<int> res;
        for(int i=0; i<10; ++i) {
            if(n & (1 << i)) {
                res.push_back(1 << i);
            }
        }
        for(int i=0; i<res.size(); ++i) {
            cout << res[i] << " \n"[i == res.size()-1] << flush;
        }
    }
}

Measured memory_bytes: 2996
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+5;

int n,a[N],b[N],c[N];
int ans;

int main(){
	cin>>n;
	for(int i=1;i<=n;++i)cin>>a[i];
	for(int i=1;i<=n;++i)cin>>b[i];
	for(int i=1;i<n;++i)cin>>c[i];
	for(int i=1;i<=n;++i){
		ans+=b[a[i]];
		if(i>=2&&a[i-1]+1==a[i])ans+=c[a[i-1]];
	}
	cout<<ans<<endl;
} 

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBAG = false;

int main(){

    ll n;
    cin >> n;

    cout << (n - 1) / 2 << endl;

}

Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
a = inpl()
b = sorted(a)
l,r = b[n//2-1],b[n//2]
for i in a:
    if i <= l:
        print(r)
    else:
        print(l)

Measured memory_bytes: 86656
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890123456789LL
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) (((x) < 0)?-(x):(x))
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

using cat = long long;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N;
	cin >> N;
	vector<int> A(N);
	for(int i = 0; i < N; i++) cin >> A[i];
	vector<int> nonzero;
	cat ans = 0;
	for(int i = 0; i < N; i++) {
		int l = 0;
		int OR = A[i];
		for(int j = nonzero.size()-1; j >= 0; j--) {
			if(OR&A[nonzero[j]]) {
				l = nonzero[j]+1;
				break;
			}
			OR |= A[nonzero[j]];
		}
		ans += i-l+1;
		if(A[i] > 0) nonzero.push_back(i);
	}
	cout << ans << "\n";
	return 0;}

// look at my code
// my code is amazing


Measured memory_bytes: 2168
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
  
int n,pos;
vector<int> pre,in,post;
  
void rec(int l,int r){
    if(l>=r)
        return;
    int root = pre[pos++];
    int m = distance(in.begin(),find(in.begin(),in.end(),root));
    rec(l,m);
    rec(m+1,r);
    post.push_back(root);
}
  
void solve(){
    pos = 0;
    rec(0,pre.size());
    for(int i=0;i<n;i++){
        if(i)
            cout<<" ";
        cout<<post[i];
    }
    cout<<endl;
}
  
int main(){
    int k;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>k;
        pre.push_back(k);
    }
  
    for(int i=0;i<n;i++){
        cin>>k;
        in.push_back(k);
    }
    solve();
}


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

int main()
{
  string str = "";
  cin>>str;
  string r = "";
  for(int i = 0; i<str.size(); i++)
  {
    if(str[i] == '0' || str[i] == '1')
    r +=str[i];
    else if(str[i] == 'B')
    {
      if(r.size()!=0)
        r.pop_back();
    }
  //  cout<<"value of r: "<<r<<endl;
  }
  cout<<r<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <string.h>
#include <utility>
#include <algorithm>

using namespace std;

char s[100010];
      
int main() {
  int i;
  scanf("%s", s);
  int ans_front = 0;
  int ans_back = 0;
  for (i = 0; i < strlen(s)-1; i++) {
    if (s[i] == s[i+1]) {
      ans_front = i;
      ans_back = i+1;
      break;
    }
  }
  if (ans_front == ans_back) {
    for (i = 0; i < strlen(s)-2; i++) {
      if (s[i] == s[i+2]) {
	ans_front = i;
	ans_back = i+2;
	break;
      }
    }
  }
  if (ans_front == ans_back) {
    printf("-1 -1");
  } else {
    printf("%d %d", ans_front+1, ans_back+1);
  }
  return 0;
}


Measured memory_bytes: 256
n = gets.to_i
s = gets.chomp.chars

tally = s.tally
tally.default = 0
answer = tally['R'] * tally['G'] * tally['B']

(0...n).each do |i|
  (1..n).each do |d|
    break if (i + 2 * d) >= n

    if s[i] != s[i + d] && s[i + d] != s[i + 2 * d] && s[i + 2 * d] != s[i]
      answer -= 1
    end
  end
end

puts answer


Measured memory_bytes: 14528
from collections import defaultdict, deque

N = int(input())
edges = defaultdict(list)
for _ in range(N - 1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    w = w % 2 == 0  # True if even
    edges[u].append((v, w))
    edges[v].append((u, w))

colors = [None] * N
colors[0] = 0
queue = deque()
queue.append((0, 0))
while queue:
    v1, c1 = queue.popleft()
    for v2, w in edges[v1]:
        if colors[v2] is not None:
            continue
        if w:
            colors[v2] = c1
        else:
            colors[v2] = 1 - c1
        queue.append((v2, colors[v2]))
for c in colors:
    print(c)

Measured memory_bytes: 88664
import sys

H, W = map(int, input().split())
S = ['.'*(W+2)] + ['.' + input() + '.' for _ in range(H)] + ['.'*(W+2)]
for i in range(1, H+1):
  for j in range(1, W+1):
    if S[i][j] == '#':
      for x, y in [(-1, 0), (1, 0), (0, -1), (0, 1)]:
        if S[i+x][j+y] == '#':
          break
      else:
        print('No')
        sys.exit()
else:
  print('Yes')

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

using namespace std;

int main(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	int i=0;
	int j=n-1;
	int count=0;
	for(int i=0;i<n;i++){
      if(s[i]=='R') count++;
      
    }
  int ans=0;
  for(int i=0;i<count;i++){
    if(s[i]=='W') ans++;
  }
cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    string s;
    cin >> s;
    while (sz(s) > 0) {
        s = s.substr(0, sz(s) - 2);
        bool ok = true;
        int n = sz(s);
        REP(i, n / 2) {
            if (s[i] != s[n / 2 + i]) {
                ok = false;
                break;
            }
        }
        if (ok) {
            cout << n << endl;
            return;
        }
    }
}


Measured memory_bytes: 256
//shortest path
#include<vector>
#include<list>
#include<deque>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cctype>
#include<cmath>
#include<iostream>
#include<limits>
#include<utility>

#define c11
#ifdef c11
#include<unordered_set>
#include<unordered_map>
#endif

using namespace std;
typedef long long ll;
#define ull unsigned long long
#define PI acos(-1.0)
#define eps 1e-12
#define initz(x) memset(x,0,sizeof(x))
#define initm(x) memset(x,0x3f,sizeof(x))
#define forn(i, n) for(int i = 0; i < (int) n; ++i)
#define for1(i, n) for(int i = 1; i <= (int) n; ++i)
#define fore(i, l, r) for(int i = (int) l; i <= (int) r; ++i)
#define rforn(i, n) for(int i = (int) n - 1; i>= 0; --i)
#define fi first
#define se second

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

const int INF = 0x3f3f3f3f;
const int MAX_N = 30;
const int MAX_M = 15000;

typedef pair<int, int> P;
priority_queue<P, vector<P>, greater<P> > pq;

struct Edge{
  Edge() {}
  Edge(int vv, int cc, int ww): v(vv), c(cc), w(ww) {}
  int v, c, w;
};

vector<Edge> edges[MAX_M];
int pre[MAX_M];
int d[MAX_M];

void dijkstra(int n, int s) {
  initm(d);
  d[s] = 0;
  pq.push({d[s], s});
  while (!pq.empty()) {
    int u, v, c, m;
    m = pq.top().first;
    u = pq.top().second;
    pq.pop();
    if (m > d[u]) {
      continue;
    }
    for (auto it : edges[u]) {
      v = it.v;
      c = it.c;
      int t = d[u] + c;
      if (t < d[v]) {
        d[v] = t;
        pq.push({d[v], v});
        pre[v] = it.w;
      } else if (t == d[v]) {
        pre[v] = min(pre[v], it.w);
      }
    }
  }
}

int main() {
  int n, m, u, v, c, w;
  while (scanf("%d%d", &n, &m) != EOF && n) {
		for1(i, n) {
      edges[i].clear();
    }
		while(m--) {
		  scanf("%d%d%d%d", &u, &v, &c, &w);
      edges[u].push_back(Edge(v, c, w));
      edges[v].push_back(Edge(u, c, w));	
		}
		dijkstra(n, 1);
    int ans = 0;
    for (u = 2; u <= n; ++u) {
      ans += pre[u];
    }
    printf("%d\n", ans);
	}
  return 0;
}



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

using namespace std;

typedef long long ll;
typedef double db;

#define dbg(x) cout<<#x<<" is "<<x<<endl

const int maxn = (int) 2e5 + 9;

ll c5[maxn];
ll c2[maxn];
int n;
ll cc[45][45];
char s[maxn];

ll rint() {
    scanf("%s", s);
//    dbg(s);
    int l = strlen(s);
    int fl = -1;
    for (int i = 0; i < l; i++) {
        if (s[i] == '.') {
            fl = i;
            break;
        }
    }
    ll ans = 0;
    for (int i = 0; i < fl; i++) {
        ans = ans * 10 + s[i] - '0';
    }
//    dbg(ans);
    ll tmp = 0;
    for (int i = fl + 1; i < l; i++) {
        tmp = tmp * 10 + s[i] - '0';
    }
    if (fl > 0) {
        for (int i = 0; i < 9 - (l - fl - 1); i++) {
            tmp *= 10;
        }
        ans = ans * 1000000000 + tmp;
    } else {
        ans = tmp * 1000000000;
    }
    return ans;
}

void init() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        ll tmp = rint();
//        dbg(tmp);
        while (tmp % 2 == 0) {
            c2[i]++;
            tmp /= 2;
        }
        while (tmp % 5 == 0) {
            c5[i]++;
            tmp /= 5;
        }
        if (c2[i] >= 18) {
            c2[i] = 18;
        }
        if (c5[i] >= 18) {
            c5[i] = 18;
        }
    }
}

void pt() {
    for (int i = 0; i < 20; i++) {
        for (int j = 0; j < 20; j++) {
            printf("%lld ", cc[i][j]);
        }
        cout << endl;
    }
}

int main() {
    memset(c2, 0, sizeof(c2));
    memset(c5, 0, sizeof(c5));
    memset(cc, 0, sizeof(cc));
    init();
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 20; j++) {
            for (int k = 0; k < 20; k++) {
                if (c2[i] + j >= 18 && c5[i] + k >= 18) {
                    if (cc[j][k] > 0) {
//                        printf("%d %d %d %lld %lld %lld\n", i, j, k, c2[i], c5[i], cc[j][k]);
                        ans += cc[j][k];
                    }

                }
            }
        }
        cc[c2[i]][c5[i]]++;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 6904
from typing import Counter


n = int(input())
nlis = list(map(int, input().split()))
m = int(input())
mlis = list(map(int, input().split()))

nc  =Counter(nlis)
mc = Counter(mlis)

flag = 1
for k, v in mc.items():
    if mc[k] > nc[k]:
        flag = 0
        break

if flag:
    print('YES')
else:
    print('NO')


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

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

    int h, w;
    while(1){
        cin >> h >> w;
        if (h == 0 && w == 0) break;
        else{
            rep(i, h){
                rep(j, w){
                    cout << '#';
                }
                cout << endl;
            }
        }
        cout << endl;
    }


    return 0;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
const int maxn=100005;

int n,q,sec=1;
int st[maxn],ed[maxn];
vector<int>G[maxn];
int a[maxn];

void add(int i,int v) {
    for (;i<=sec;i+=i&-i) a[i]+=v;
}

int query(int i) {
    int res=0;
    for (;i>0;i-=i&-i) res+=a[i];
    return res;
}

void dfs(int u,int p) {
    st[u]=sec++;
    for (int v:G[u])
        if (v!=p) dfs(v,u);
    ed[u]=sec;
}

int main() {
    cin>>n;
    for (int i=0;i<n;i++) {
        int m; cin>>m;
        for (int j=0;j<m;j++) {
            int v; cin>>v;
            G[i].pb(v);
            G[v].pb(i);
        }
    }
    dfs(0,-1);
    cin>>q;
    for (int i=0;i<q;i++) {
        bool op; cin>>op;
        if (op) {
            int u; cin>>u;
            cout<<query(st[u])<<'\n';
        }
        else {
            int v,w; cin>>v>>w;
            add(st[v],w);
            add(ed[v],-w);
        }
    }
}


Measured memory_bytes: 14484
#include<cstdio>
#include<string>
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	if((a+b)%3==0||a%3==0||b%3==0)
	{
		printf("Possible\n");
	}
	else
	{
		printf("Impossible\n");
	}
	return 0;
}

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

int main () {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  sort(A.begin(), A.end());
  int x = min(100000, A.at(N-1));
  vector<int> B(x);
  int count = 0;
  for (int i = 0; i < N; i++) {
    if (A.at(i) > 100000) count++;
    else {
      int y = A.at(i);
      B.at(y-1)++;
    }
  }
  for (int i = 0; i < x; i++) {
    if (B.at(i) != 0 && B.at(i) < i+1) count += B.at(i);
    else if (B.at(i) != 0 && B.at(i) > i+1) count += B.at(i)-(i+1);
  }
  cout << count << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef  long long ll;
const int MAX_N=1e5+1; const ll OO=1e11;
int main(){
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
 int n; cin>>n; int now=1000;
 while(now<n){
     now+=1000;
 }
 cout<<now-n;
}

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

#define F first
#define S second
#define prev azaza
#define MP make_pair
#define PB push_back

using namespace std;
typedef long long ll;
typedef long double ld;

const int max_n = 1011, inf = 1000111222;
const ll mod = 1000000007;

int pr[max_n];
int sz[max_n];
int n, m;

void clr() {
    for (int i = 0; i < n; ++i) {
        pr[i] = i;
        sz[i] = 1;
    }
}

int get_pr(int a) {
    if (pr[a] == a) {
        return a;
    }
    pr[a] = get_pr(pr[a]);
    return pr[a];
}

void unite(int a, int b) {
    a = get_pr(a);
    b = get_pr(b);
    if (a == b) {
        return;
    }
    if (sz[a] > sz[b]) {
        pr[b] = a;
        sz[a] += sz[b];
    } else {
        pr[a] = b;
        sz[b] += sz[a];
    }
}

vector<pair<ll, pair<int, int>>> e;
ll x;

ll add(int from, int to, ll w) {
    if (get_pr(from) == get_pr(to)) {
        return 0;
    } else {
        unite(from, to);
        return w;
    }
}

ll get_mo(int ei) {
    clr();
    ll res = 0;
    res += add(e[ei].S.F, e[ei].S.S, e[ei].F);
    for (int i = 0; i < m; ++i) {
        res += add(e[i].S.F, e[i].S.S, e[i].F);
    }
    return res;
}

ll powm(ll a, ll b) {
    if (b == 0) {
        return 1;
    }
    if (b % 2 == 0) {
        return powm((a * a) % mod, b / 2);
    } else {
        return (a * powm(a, b - 1)) % mod;
    }
}

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> n >> m >> x;
    for (int i = 0; i < m; ++i) {
        int a, b, w;
        cin >> a >> b >> w;
        --a, --b;
        e.PB(MP(w, MP(a, b)));
    }
    sort(e.begin(), e.end());
    int cl = 0, ce = 0, cm = 0;
    for (int i = 1; i < m; ++i) {
        ll cur = get_mo(i);
        if (cur < x) {
            ++cl;
        } else if (cur == x) {
            ++ce;
        } else {
            ++cm;
        }
    }
    ll ans = (powm(2, ce) - 1 + mod) % mod;
    ans = (ans * powm(2, cm)) % mod;
    ans = (ans + ans) % mod;
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 384
import java.util.*;

public class Main {

	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int total = 0;
		for (int i = 0; i < n; i++) {
			int x = sc.nextInt();
			total += Math.min(Math.abs(x - 0), Math.abs(x - k)) * 2;
		}
		System.out.println(total);
	}
}


Measured memory_bytes: 21204
/**
 * @Author: yujirotakahashi
 * @Date:   2020-05-17T20:21:41+09:00
 * @Last modified by:   yujirotakahashi
 * @Last modified time: 2020-05-25T03:17:23+09:00
 */

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

/*******  All Required define Pre-Processors and typedef Constants *******/
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define Dcout(a) cout << setprecision(20) << a << endl
#define MP make_pair
#define PB push_back
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
//const ll INF = (1LL << 60);
//const double pi=acos(-1.0);
using ll = long long;
using PAIR = pair<int, int>;
#define debug cout << "line : " << __LINE__ << " debug" << endl
/****** Template of some basic operations *****/
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/**************************************/

/******** User-defined Function *******/
using Graph = vector<vector<int>>;
int dx[4] = {-1,0,0,1};
int dy[4] = {0,1,-1,0};
/**************************************/

/********** Main()  function **********/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n,m; cin >> n >> m;
  vector<int> c(n);
  rep(i,m) cin >> c[i];

  int dp[50010];
  rep(i,50010) dp[i] = n;

  dp[0] = 0;
  for(int i=0; i<=n; ++i){
      for(int j=0; j<m; ++j){
          if(i+c[j]<=n) chmin(dp[i+c[j]],dp[i] + 1);
          //chmin(dp[i+1], dp[i]+1);
      }
  }

  cout << dp[n] << endl;

  return 0;
}
/********  Main() Ends Here *************/



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

#define fto(i, x, y) for(auto i = (x); i <= (y); ++i)
#define fdto(i, x, y) for(auto i = (x); i >= (y); --i)
#define ftoa(i, x, y, a) for(auto i = (x); i <= (y); i += a)
#define ftoit(it, var) for (auto it = var.begin(); it != var.end(); ++it)

#define ii pair<int, int>
#define mp make_pair
#define ff first
#define ss second

#define vi vector<int>
#define vii vector<ii>
#define ll long long
#define vll vector<ll>

#define eb emplace_back
#define ef emplace_front
#define lb lower_bound
#define ub upper_bound

#define oo 1000000007
#define OO 1000000000000000007LL

using namespace std;

#define Pro "tmp"
#define maxN 500007

int a[7];

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

	string str = "keyence";
	int i = 0;

	while (i < 7 && s[i] == str[i]) ++i;

	int j = 0;
	while (j < 7 && s[(int)s.size()-j-1] == str[7-j-1]) ++j;

	if (i+j >= 7) puts("YES");
	else puts("NO");

	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = System.Console.ReadLine().Trim().Split(' ');
            decimal iT = decimal.Parse(sS[0]);
            decimal iX = decimal.Parse(sS[1]);

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            decimal iA = iT / iX;

            // 出力
            System.Console.WriteLine("{0}", iA.ToString());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


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

int main ()
{
    long long int a,i,sum=0,b,d;
    cin>>a;
    b=a;
    for(i=1;i<=b;i++)
    {
        if(a<10)
            {
                sum=sum + a;
                break;
            }
        else
        {
            sum=sum + a%10;
            a=a/10;

        }
    }
if(b%sum==0)
    cout<<"Yes"<<endl;
else
    cout<<"No"<<endl;

}


Measured memory_bytes: 256
# B
N, D = map(int, input().split())
X = []
for i in range(N):
    X.append(list(map(int, input().split())))
    
ans = 0
for i in range(N):
    for k in range(i, N):
        if i == k:
            pass
        else:
            d_lst = []
            for s in range(D):
                d_lst.append((X[i][s] - X[k][s]) ** 2)
            b = sum(d_lst)
            a = int(sum(d_lst) ** 0.5)
            if abs(a * a - b) < 0.0000001:
                ans += 1

print(ans)                
                

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    int x;
    x = a + b;
    if (x >= c) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
const main = (input) => {
  const args = input.split('\n')
  const hwk = args.shift().split(' ').map(v => Number(v))
  const map = args.map(v => v.split(''))
  let sum = 0
  for (let i = 0; i < 2 ** hwk[0]; i++) {
    for (let j = 0; j < 2 ** hwk[1]; j++) {
      const binaryH = i.toString(2).padStart(hwk[0], '0').split('')
      const binaryW = j.toString(2).padStart(hwk[1], '0').split('')
      const filledRow = map.map((l, idx) => binaryH[idx] === '1' ? l.map(_ => 'r') : l)
      const filledAll = filledRow.map(v => v.map((v, idx) => binaryW[idx] === '1' ? 'r' : v))
      const count = filledAll.flat().filter(v => v === '#').length
      if (count === hwk[2]) {
        sum++
      }
    }
  }
  console.log(sum)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 36232
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <iomanip> 

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline void print(T&& x){cout<<x<<endl;}// 改行付き出力
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int ctoi(char c){return c-'0';}

// TODO: write
int main() {

  int n;cin>>n;
  vector<int> a(n);rep(i,n)cin>>a[i];
  sort(all(a),greater<int>());
  
  int aMax = a[0];
  bool b[int(1e7)];
  rep(i,aMax+100)b[i] = true;
  
  rep(i,n){
    while(i < n-1 && a[i] == a[i+1]){
      b[a[i++]] = false;
    }

    int tmp = a[i];
    while(tmp <= aMax){
      tmp += a[i];
      b[tmp] = false;
    }
  }

  int cnt = 0;
  rep(i,n){
    if(b[a[i]])cnt++;
  }
  print(cnt);

  return 0;
}


Measured memory_bytes: 5816
#include<stdio.h>

int main()
{
  int n, i;

  scanf("%d", &n);

  int a[n];
  for(i = 0 ; i < n ; i++){
    scanf("%d", &a[i]);
  }
  n--;
  i = n;
  while(1){
    printf("%d", a[i]);
    if(i==0)break;
    printf(" ");
    i--;
  }
  printf("\n");
  return 0;
}  

Measured memory_bytes: 600
hash = Hash.new(0)

while line = gets
  a, b = line.chomp.split(',').map(&:to_i)
  break if a == 0 && b == 0
  hash[a] += b
end

scores = hash.values.uniq.sort { |a, b| b <=> a }

while line = gets
  c = line.chomp.to_i
  puts scores.count { |x| x > hash[c] } + 1
end

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

using namespace std;

int main() {
	map<string, int> votes;
	set<string> win;
	string v;
	int n;
	cin >> n; cin.ignore();
	int big = -1;
	while(cin >> v) {
		if(votes[v]) votes[v]++;
		else votes[v] = 1;
		big = max(big, votes[v]);
	}
	for(auto x : votes) {
		if(x.second == big) {
			win.insert(x.first);
		}
	}
	for(auto x : win) {
		cout << x << endl;
	}
	return 0;
}

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

bool check(int mid, vector<int> &a, int k)
{
    int n = a.size();
    int cnt = 0;
    rep(i,n) cnt += (a[i] - 1) / mid;
    return (cnt <= k);
}

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

    int ok = 1e9, ng = 0;
    while(abs(ok - ng) > 1)
    {
        int mid = (ok + ng) / 2;
        if(check(mid, a, k)) ok = mid;
        else ng = mid;
    }
    cout << ok << endl;

    return 0;
}

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

int main(){
  string s;
  cin >> s;
  
  int zero=0;
  int one=0;
  int n=s.length();
  for (int i=0;i<n;++i){
    if (s[i]=='0'){
      zero++;
    }
    if (s[i]=='1'){
      one++;
    }
  }
    cout << 2*min(zero, one) << "\n";
}

Measured memory_bytes: 512
S = input()

if S == 'SUN':
    print('7')
elif S =='MON':
    print('6')
elif S == 'TUE':
    print('5')
elif S == 'WED':
    print('4')
elif S == 'THU':
    print('3')
elif S == 'FRI':
    print('2')
elif S == 'SAT':
    print('1')

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

static class CodeJam
{
    static int[] Solve(int N, long L, long[] A)
    {
        for (int i = 0; i + 1 < N; ++i)
        {
            if (A[i] + A[i + 1] >= L)
            {
                var ans = new List<int>();
                for (int j = 0; j < i; ++j) { ans.Add(j + 1); }
                for (int j = N - 2; j >= i + 1; --j) { ans.Add(j + 1); }
                ans.Add(i + 1);
                return ans.ToArray();
            }
        }
        return null;
    }

    static void Main(string[] args)
    {
        long[] V = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
        long[] A = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
        var ans = Solve((int)V[0], V[1], A);
        if (ans != null)
        {
            Console.WriteLine("Possible");
            foreach (int n in ans) { Console.WriteLine(n); }
        }
        else
        {
            Console.WriteLine("Impossible");
        }
    }
}


Measured memory_bytes: 30684
//order of pair chooosen is doesn't matter. Therefore we only consider choose left/right
#include <bits/stdc++.h>
#define ll long long
#define maxn 200100
#define base 1000000007

using namespace std;

int n,a[maxn];
ll ans=1;
string s;


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
   // freopen("input.txt", "r", stdin);
    cin>>n;
    cin>>s;
    a[0] = (s[0]=='W'?0:1);
    for (int i=1;i<2*n;i++) a[i] = (s[i]==s[i-1]?1-a[i-1]:a[i-1]);
    int cnt=0;
    for (int i=0;i<2*n;i++) {
        if (a[i]==0) {
            if (cnt==0) {
                cout<<0;
                return 0;
            }
            ans = (1ll*ans*cnt)%base;
            cnt--;
        } else cnt++;
    }
    if (cnt!=0) {
        cout<<0;
        return 0;
    }
    for (int i=1;i<=n;i++) ans = (1ll*ans*i)%base;
    cout << ans;
}


Measured memory_bytes: 1360
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var n = int.Parse(input.ReadLine());
        var dic = new Dictionary<int, int>();

        foreach(var z in input.ReadLine().Split(' ')){
            var x = int.Parse(z);
            if (!dic.ContainsKey(x)) dic[x] = 0;
            dic[x]++;
        }

        var c = 0L;
        foreach(var rec in dic) {
            if (rec.Key < rec.Value) c += rec.Value - rec.Key;
            if (rec.Key > rec.Value) c += rec.Value;
        }

        return c;
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 24924
/*#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>*/
#include<bits/stdc++.h>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
const ll mod = 1e9 + 7;
ll dx[4] = {1,0,-1,0};
ll dy[4] = {0,1,0,-1};

int main(){
    ll a,b,c;
	cin >> a >> b >> c;
	rep(i,1000000){
		if((b * i + c) % a == 0) {
			cout << "YES\n";
			return 0;
		}
	}
	cout << "NO\n";
	return 0;
}  


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

using namespace std;

int a[5];
int main()
{

   int flag=0;
   for(int i=0;i<3;i++)
    cin>>a[i];
   sort(a,a+3);
   if(a[0]==a[1]&&a[1]!=a[2])
     flag=1;
   if(a[1]==a[2]&&a[0]!=a[1])
    flag=1;
   if(flag)
    cout<<"Yes"<<endl;
   else
    cout<<"No"<<endl;
}


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

using namespace std;

#define PB push_back
#define SZ(a) (int)a.size()
#define MP make_pair

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int,int> PII;

int main() {

	int N,X,Y;
	scanf("%d %d %d", &N, &X, &Y);

	vector<int> C(N);

	for (int i = 1; i < N; i++) {
		for (int j = i+1; j <= N; j++) {
			int d = abs(i-X) + abs(j-Y) + 1;
			C[min(d, j-i)]++;
		}
	}

	for (int i = 1; i < N; i++) printf("%d\n", C[i]);

	return 0;
}


Measured memory_bytes: 256
hash = Hash.new
n1 = gets.to_i
[*0..(n1-1)].each{|i|
  str = gets.chomp.to_s
  if hash[str] == nil then
    hash[str] = 1
  else
    hash[str] += 1
  end
}

n2 = gets.to_i
[*0..(n2-1)].each{|i|
  str = gets.chomp.to_s
  if hash[str] == nil then
    hash[str] = -1
  else
    hash[str] -= 1
  end
}

score = 0
hash.each{|key, val|
  if val > score then
    score = val
  end
}

puts score

Measured memory_bytes: 1788
package main

import (
	"fmt"
)

func yes() {
	fmt.Println("Yes")
}
func no() {
	fmt.Println("No")
}
func main() {
	var n int
	fmt.Scanln(&n)
	w := make([]string, n)
	table := make(map[string]int)
	for i := 0; i < n; i++ {
		fmt.Scanln(&w[i])
		table[w[i]] += 1
		if table[w[i]] > 1 {
			no()
			return
		}
	}
	for i := 0; i < n-1; i++ {
		if w[i][len(w[i])-1] != w[i+1][0] {
			no()
			return
		}
	}
	yes()
}


Measured memory_bytes: 512
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int main() {
	LL n,m;
	cin >> n >> m;
	if(m<n){
		swap(m,n);
	}
	if(n==1){
		if(m==1){
			cout << 1;
		}
		else{
			cout << m-2;
		}
	}
	else{
		cout << (n-2)*(m-2);
	}
	cout << endl;


	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
typedef long long int ll;
typedef long double ld;
#define MOD 1000000007
#define ALL(obj) (obj).begin(),(obj).end()
template<class T>inline bool chmax(T& a,T b){if (a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T& a,T b){if (a>b){a=b;return 1;}return 0;}
const long long INF = 1LL << 60;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
//四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

struct edge{//グラフに使うヤツ
    ll from,to,cost;
};

typedef vector<vector<edge> > G;
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}


int main(){
    string s;
    cin >> s;
    bool f=true;
    if (s.size()==1){
        cout << s[0] << endl;
        return 0;
    }
    for (ll i=1;i<s.size();i++){
        if (s[i]!='9'){
            f=false;
            break;
        }
    }
    if (f){
        cout << 9*(s.size()-1)+(s[0]-'0') << endl;
    }else{  
        cout << 9*(s.size()-1)+(s[0]-'0')-1 << endl;
    }
    return 0;
}


Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        int x, y;
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int p = 0;
        for (int i=0;i<s.length();i++) {
            char c = s.charAt(i);
            if (c == 'p') {
                p++;
            }
        }

        System.out.println(s.length()/2 - p);
    }
}


Measured memory_bytes: 24732
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		int c=scan.nextInt();
		int d=scan.nextInt();
		if(a*b>=c*d) {
		System.out.println(a*b);
	}else {
		System.out.println(c*d);
	}
		}
	}

Measured memory_bytes: 21844
import java.io.*;
 
class Main
{
  public static void main(String args[])
  {
    int num;
    String buf;
    try {
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      buf = br.readLine();
      num = Integer.parseInt(buf);
      System.out.println(num * num * num);
    } catch(Exception e) {}
  }
}


Measured memory_bytes: 24128
#include <iostream>
#include <string>

using namespace std;

int n;
int a, b, c, d;
string s;

int main(void)
{
	cin >> n;
	cin >> a >> b >> c >> d;
	cin >> s;
	s = "#" + s + "#";
	
	int p = b; bool flag = false;
	while(1){
		if(s[p-1] == '.' && s[p+1] == '.') flag = true;
		if(p == d) break;
		if(s[p+1] == '.') p++;
		else if(s[p+2] == '.') p+=2;
		else{
			cout << "No"<< endl;
			return 0;
		}
	}
	p = a;
	while(1){
		if(p == c) break;
		if(s[p+1] == '.') p++;
		else if(s[p+2] == '.') p+=2;
		else{
			cout << "No"<< endl;
			return 0;
		}
	}
	if(d < c && !flag) cout << "No" <<endl;
	else cout << "Yes" << endl;
	
	return 0;
}


Measured memory_bytes: 900
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int col[200010];
ll n,ans[200010],sum[200010],sz[200010];//sum[i]是指在一定范围内离根最近的有颜色i的点的子树大小（或子树的一部分） 
vector<int> g[200010];
ll mul(ll x) {
	return x*(x-1)/2+x;
}
void dfs(int pos,int fa) {
	sz[pos]=1;
	ll c=col[pos],s=sum[c];
	for(int i=0;i<g[pos].size();++i)
		if(g[pos][i]!=fa) {
			int tmp=sum[c];
			dfs(g[pos][i],pos);
			sz[pos]+=sz[g[pos][i]];
			ans[c]-=mul(sz[g[pos][i]]-(sum[c]-tmp));
		}
	sum[c]=s+sz[pos];
}
int main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;++i) scanf("%d",&col[i]);
	for(int i=1,x,y;i<n;++i) {
		scanf("%d%d",&x,&y);
		g[x].push_back(y);
		g[y].push_back(x);
	}
	for(int i=1;i<=n;++i) ans[i]=mul(n);
	dfs(1,0);
	for(int i=1;i<=n;++i) ans[i]-=mul(n-sum[i]),printf("%lld\n",ans[i]);
	return 0;
}

Measured memory_bytes: 38868
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

// ceil of a/b
inline int ceil(int a, int b) { return (a%b?a/b+1:a/b); }


signed main() {
	int n,k;
	std::cin >> n >> k;
	int r,s,p;
	std::cin >> r >> s >> p;
	std::string t;
	std::cin >> t;
	std::vector<std::string> map(k,"");
	rep(i,n) {
		map[i%k]+=t[i];
	}
	std::map<char,int> point;
	point['r'] = p;
	point['s'] = r;
	point['p'] = s;
	int sum = 0;
	debug(map);
	for(auto x:map) {
		char curr = 'o';
		int count = 0;
		for(auto c:x) {
			if(curr!=c) {
				sum+=ceil(count,2)*point[curr];
				count = 1;
				curr = c;
			} else {
				count++;
			}
		}
		sum+=ceil(count,2)*point[curr];
	}
	print(sum);


	return 0;
}


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


int main(){
  long long X;
  cin >> X;

  int year = 0;
  long long money = 100;
  
  while (money < X){
    money += money/100;
    year++;
  }

  cout << year << endl;
}

Measured memory_bytes: 3520