akhauriyash/Code-Regression huggingface dataset:
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef  long long ll;
typedef  vector<int> vi;
typedef  pair<int,int> pii;
typedef  pair<int,string> pis;
double pi=3.1415926535898;
#define speed      ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
#define lop(i,n)   for(int i=0;i<int(n);i++)
#define rep(i,a,b) for(int i=a;i<=int(b);++i)
#define rng(i,a,b) for(int i=a;i>=int(b);i--)
#define ms(x,a)    memset(x,a,sizeof(x))
#define all(x)     (x).begin(),(x).end()
#define sz(x)      int(x.size())
#define pb         push_back
#define r0         return 0;
#define CC         continue;
#define bb(x)      cerr<< x <<endl;
#define F          first
#define S          second       //  __builtin_popcount;
//freopen("output.txt","w",stdout),freopen("input.txt","r",stdin);
const ll M  = 1e9+7 ;
const int N = 100100;
const int inf = INT_MAX;
const double eps = 1e-7;
//////////////////////    Hi    ^_^  hack me if you can :P

bool used[100];
string s ;
int n;
int main()
{
    //speed;
    cin >> s;
    n = sz(s);
    int ans = 1e9;
    lop(i,n)
    {
        s[i]-='a';
        used[s[i]]=1;
    }
    for ( int i = n-1 ; i>= 0; i --)
    {
        int x = s[i];
        int mx = 0;
        int cnt = 0;
        for ( int j = i ; j>= 0; j --)
        {
            if (s[j] == x)
            {
                cnt = 0;
            }
            else
            {
                cnt ++ ;
            }
            mx = max(mx,cnt);
        }
        mx = max(mx,(n - i - 1) );
        ans = min(ans,mx);
    }
    cout << ans << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a>b)
     cout<<"a > b"<<endl;
    else if(a<b)
     cout<<"a < b"<<endl;
    else
      cout<<"a == b"<<endl;
    return 0;
}



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

int main(){
    string N;
    cin >> N;
    int Nsize = N.size();
    int A = N.at(Nsize - 1) - '0';
    if(A == 3) cout << "bon" << endl;
    else if(A == 0 || A == 1 || A == 6 || A == 8) cout << "pon" << endl;
    else cout << "hon" << endl;
}

Measured memory_bytes: 3628
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
L = Counter(list(i + 1 + A[i] for i in range(N)))
R = Counter(list(j + 1 - A[j] for j in range(N)))
# print(L, R)
ans = 0
for k, v in R.items():
    ans += L[k] *  v
print(ans)


Measured memory_bytes: 61692
#include<vector>
#include<iostream>
using namespace std;
#define df 0
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long int li;

int dfs(const vector<vector<int>>& adj,int a=0,int seen=-1){
  int s=0;
  for(int v:adj.at(a)){
    if(v==seen)continue;
    s^=dfs(adj,v,a)+1;
  }
  return s;
}

int main(){
  if(df) printf("*debug mode*\n");
  int n; cin >>n;
  vector<vector<int>> adj(n);
  rep(i,n-1){
    int x,y; cin >>x >>y; x--; y--;
    adj.at(x).push_back(y);
    adj.at(y).push_back(x);
  }
  int ans=dfs(adj);
  cout << (dfs(adj)?"Alice":"Bob");
}

/// confirm df==0 ///


Measured memory_bytes: 11904
#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
#define ll long long 
#define pb push_back
int main(){    
    fast;
   	ll n,k; cin>>n>>k;
   	if(n==k) cout<<"0";
   	else if(n>k){
   	ll r=n%k;
   		cout<<min(r,abs(r-k));
   		}
   	else {
   		if(n<k/2) cout<<n;
   		else {
   			cout<<abs(n-k);
   			}
   		}
   		}			
   			
    	
    	
    			
    	

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

int		main(void)
{
	int x;

	cin >> x;
	int ans = 1;

	for (int i = 2; pow(i, 2) <= x; i++)
	{
		for(int j = 2; pow(i, j) <= x; j++)
		{
			if (ans < pow(i, j))
				ans = pow(i, j);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 384
import random

class Dice():
    def __init__(self, number):
        self.number = number

    def S(self):
        temp = self.number
        self.number = [temp[4], temp[0], temp[2], temp[3], temp[5], temp[1]]

    def N(self):
        temp = self.number
        self.number = [temp[1], temp[5], temp[2], temp[3], temp[0], temp[4]]

    def E(self):
        temp = self.number
        self.number = [temp[3], temp[1], temp[0], temp[5], temp[4], temp[2]]

    def W(self):
        temp = self.number
        self.number = [temp[2], temp[1], temp[5], temp[0], temp[4], temp[3]]

    def order(self, str):
        for ch in str:
            if ch == "S":
                self.S()
            elif ch == "N":
                self.N()
            elif ch == "E":
                self.E()
            else:
                self.W()

    def query(self, top, front):
        while True:
            drc = random.randint(0, 3)
            self.order("NEWS"[drc])
            if self.number[0] == top and self.number[1] == front:
                return self.number[2]
                break

number = list(map(int, input().split()))
q = int(input())
dice = Dice(number)

for i in range(q):
    t, f = map(int, input().split())
    print(dice.query(t, f))


Measured memory_bytes: 8192
import math

a, b = map(int, input().split())
if b == 100:
  c = a * 1000 + b
elif b < 10:
  c = a * 10 + b
else:
  c = a * 100 + b

if math.sqrt(c).is_integer():
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; 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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int a,b;
  cin >> a >> b;

  cout << (a+b)%24 << endl;
  return 0;
}


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


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

    vector<int> lib(n), p(n), q(n);

    for(int i = 0; i < n; i++){
        lib[i] = i + 1;
    }

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

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

    int a = 0;
    int b = 0;
    int cnt = 0;
    do{
        if(lib == p){
            a = cnt;
        }
        if(lib == q){
            b = cnt;
        }
        cnt++;
    }while(next_permutation(lib.begin(), lib.end()));

    cout << abs(a - b) << endl;

    

    return 0;
}

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

using namespace std;

int cnt[200005];

int main(){
    int n, k;
    scanf("%d %d", &n, &k);

    memset(cnt, 0, sizeof(cnt));
    for (int i = n / k * k + 1; i <= n; i++) cnt[i % k]++;
    int buff = n / k;

    long long ans = 0;
    for (int i = 0; i < k; i++) {
        int cur = (k - i) % k;
        int nxt = (k - cur) % k;

        if ((i + nxt) % k != 0) continue;

        ans = ans + 1LL * (buff + cnt[i]) * (buff + cnt[cur]) * (buff + cnt[nxt]);
    }

    printf("%lld", ans);
    return 0;
}


Measured memory_bytes: 1024
def main():
    n = input()
    tree = MyTree(n)
    for i in range(n):
        id_k_cn = map(int,raw_input().split())
        id_node = id_k_cn.pop(0)
        k = id_k_cn.pop(0)
        tree.add(id_node,k,None,id_k_cn)
    
    tree.search_children()
    tree.set_depth(tree.nodes[tree.id_root],0)
    
    for node in tree.nodes:
        print "node {0}: parent = {1}, depth = {2}, {3}, {4}".format(node.id_self, node.id_parent, node.depth, node.node_type, node.id_children)


class MyTree():
    def __init__(self,num_nodes):
        self.nodes = [MyNode() for i in range(num_nodes)]
        self.id_root = None

    def add(self,id_node,n_children,id_parent,id_children):
        self.nodes[id_node].id_self = id_node
        self.nodes[id_node].n_children = n_children
        self.nodes[id_node].id_parent = id_parent
        self.nodes[id_node].id_children = id_children
    
    def search_children(self):
        for node in self.nodes:
            if node.n_children == 0:
                node.node_type = "leaf"
            else:
                node.node_type = "internal node"
            for j in node.id_children:
                self.nodes[j].id_parent = node.id_self

        for node in self.nodes:
            if node.id_parent == None:
                node.id_parent = -1
                node.node_type = "root"
                self.id_root = node.id_self
                break

    def set_depth(self,node,depth):
        node.depth = depth
        node.id_children
        for item in node.id_children:
            self.set_depth(self.nodes[item],depth+1)


class MyNode():
    def __init__(self):
        self.id_self = None
        self.id_parent = None
        self.id_children = None
        self.depth = None
        self.node_type = None
        self.n_children = 0
        


if __name__ == "__main__":
    main()

Measured memory_bytes: 143856
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 1000000007
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing

int main() {
	int n;
	cin >> n;
	vector <pair<int, int>> red(n), blue(n);
	for (int i = 0; i < n; i++) {
		cin >> red[i].ff >> red[i].ss;
	}
	for (int i = 0; i < n; i++) {
		cin >> blue[i].ff >> blue[i].ss;
	}
	auto cmp = [&](pair<int, int> x, pair<int, int> y) {
		if(x.ff == y.ff)
			return x.ss > y.ss;
		else
			return x.ff > y.ff;
	}; 
	sort(all(red), cmp);
	vector <bool> taken(n, false);
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int mny = MOD, pos = -1;
		for (int j = 0; j < n; j++) {
			if(!taken[j]) {
				if(blue[j].ff > red[i].ff && blue[j].ss > red[i].ss) {
					if(mny > blue[j].ss) {
						mny = blue[j].ss;
						pos = j;
					}
				}
			}
		}
		if(pos != -1) {
			taken[pos] = true;
			ans++;
		}
	}
	cout << ans;
}


Measured memory_bytes: 256
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = int.Parse(line[0]);
        var b = int.Parse(line[1]);
        var lcm = Lcm(a,b);
        var a2 = lcm / a;
        var b2 = lcm / b;
        var sa = Console.ReadLine().Trim();
        var sb = Console.ReadLine().Trim();
        if (check(a2, b2, sa, sb)) Console.WriteLine(lcm);
        else Console.WriteLine(-1);
    }
    public static bool check (long a , long b , string sa, string sb)
    {
        for (int i = 0; i < 100000; i++)
        {
            var ia =(int) b * i;
            if (ia >= sa.Length) break;
            var ib =(int) a * i;
            if (ib >= sb.Length) break;
            if (sa[ia] != sb[ib]) return false;
        }
        return true;
    }
    public static long Lcm (int a, int b)
    {
        var c = (long)a * b;
        var gcd = Gcd(a, b);
        return c / gcd;
    }
    public static int Gcd(int a, int b)
    {
        if (a < b) return Gcd(b, a);
        while (b != 0)
        {
            var w = a % b;
            a = b;
            b = w;
        }
        return a;
    }
}


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

const int N=1e5+5;
int A[N],B[N];
bool used[N];
int main() {
    int n;
    cin >> n;
    REP(i,n) cin >> A[i] >> B[i];
    vector<array<int,2>> a,b;
    REP(i,n) {
        a.push_back({A[i]+B[i],i});
        b.push_back({B[i]+A[i],i});
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    long long sum=0;
    REP(i,n) {
        if ( i%2 ) {
            while ( used[b.back()[1]] ) b.pop_back();
            int j=b.back()[1];
            used[j]=1;
            sum-=B[j];
            b.pop_back();
        } else {
            while ( used[a.back()[1]] ) a.pop_back();
            int j=a.back()[1];
            used[j]=1;
            sum+=A[j];
            a.pop_back();
        }
    }
    cout << sum << '\n';
    return 0;
}



Measured memory_bytes: 5796
#include <cstdio>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <vector>
using namespace std;

#define min(a,b) (a<b?a:b)
#define mem(a,n) memset(a,sizeof(a),n)
typedef long long ll;
const int mod=1e9+7;
const int N=1e5+5;
const int INF=0x3f3f3f3f;
bool vis[N][100];

int digit_sum(int x)
{
    int sum=0;
    while(x)
    {
        sum+=(x%10);
        x/=10;
    }
    return sum;
}
int n;
void dfs(int x,int sum)
{
    if(sum>=99||vis[x][sum]) return;
    vis[x][sum]=1;
    for(int i=0; i<10; i++)
        dfs((10*x+i)%n,sum+i);
}

int main()
{
    while(~scanf("%d",&n))
    {
        mem(vis,0);
        for(int i=0; i<n; i++)
            dfs(i,digit_sum(i));
        int ans=INF;
        for(int i=1; i<99; i++)
            if(vis[0][i])
                ans=min(ans,i);
        printf("%d\n",ans);
    }
    return 0;
}
/**
2
1 5
2 4
3 6
3
1 1 1
2 2 2
3 3 3
6
3 14 159 2 6 53
58 9 79 323 84 6
2643 383 2 79 50 288
**/


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

int main() {
    string str;
    getline(cin, str);
    while(str!="0") {
      int sum = 0;
      for(int i=0; i<str.length(); i++) {
        if(str[i]>='1' && str[i]<='9') {
          sum += (str[i]-'0');
        }
      }
      cout << sum <<endl;
      getline(cin, str);
    }
    return 0;
}




Measured memory_bytes: 3172
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int n;

int main() {
  cin >> n;
  vector<pair<int,int>> a(n);

  for(int i = 0; i < n; ++i) {
    int tmp;
    cin >> tmp;
    a[i] = (make_pair(tmp, i));
  }
  sort(a.begin(), a.end());

  for(int i = 0; i < n; ++i) {
    if(i == n -1) cout << a[i].second + 1;
    else cout << a[i].second + 1 << " ";
  }
  cout << endl;
}


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

int main() {
  long long n, k;
  cin >> n >> k;
  if (n > k) {
    if (n%k > k - n%k)
      cout << k - n%k << endl;
    else 
      cout << n%k << endl;
  }
  else if (n == k)
    cout << 0 << endl;
  else {
    if (k - n < n)
      cout << k - n << endl;
    else
      cout << n << endl;
  }
    
}

Measured memory_bytes: 256
sub f{my($u,$t,$p)=@_;push@$t,$u;$_-$p&&f($_,$t^R,$u)for@$u}@a=$,=$";@n=1..<>;map{push@$_,$u-$_+$;for($u,$;)=split}<>;f 1,b;map{$s=++$x;$s>$.or$a[$_]||=($s+=3)-3for@$_}@b>$./3&@0>$./3?(0,b):(@b>@0?b:0)x2,n;print@a

Measured memory_bytes: 272512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f
#define endl '\n'
#define ll long long
#define f first
#define int long long
#define s second
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define debug(x) cout << "DEBUG " << x << endl
#define debug2(x, y) cout << "DEBUG " << x << " " << y << endl
#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< endl
#define debug4(x, y, z, o) cout << "DEBUG " << x << " " << y << " " << z<< " " << o << endl
using namespace std;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int>> ppi;
typedef vector<vector<int>> mat;
const ll mod = 1e9+7;
const ll cfmod = 998244353;
const int MAXN = 5 * 1e5+5;


string s1, s2;

int cont[MAXN], ac[MAXN];

int32_t main() {
	int n, m;
	cin >> n >> m;
	while(m--) {
		int x;
		cin >> x >> s1;
		if(s1 == "WA" && !ac[x]) cont[x]++;
		else ac[x] = 1;
		
	}
	int a = 0, b = 0;
	for(int i = 1; i <= n; i++)
		if(ac[i]) {
			a++;
			b += cont[i];
		}
	cout << a << " " << b << endl;
}


Measured memory_bytes: 5120
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse = True)

s_A = 0
s_B = 0
for i in range(N):
    if i % 2 == 0:
        s_A += a[i]
    elif i % 2 == 1:
        s_B += a[i]

print(s_A - s_B)

Measured memory_bytes: 3064
n = int(input())
a = 'abcdefghijklmnopqrstuvwxyz'
S = []
for _ in range(n):
    S.append(input().strip())

for c in a:
    cnt = 50
    for s in S:
        cnt_s = s.count(c)

        if cnt_s < cnt:
            cnt = cnt_s
    print(c * cnt, end="")
print()

Measured memory_bytes: 2940
import sys
import numpy as np

def main():
    n, w = map(int, sys.stdin.buffer.readline().split())
    dp = np.zeros(w+1, dtype = int)

    for x in sys.stdin.buffer.readlines():
        w, v = map(int, x.split())
        np.maximum(dp[w:] , dp[:-w] + v, out = dp[w:])
    print(dp.max())

if __name__ == '__main__':
    main()

Measured memory_bytes: 28856
#include <iostream>
#include <cstdio>

using namespace std;
const int MAX = 2e5 + 111;
int n, cnt[MAX];

int main(){
    scanf("%d", &n);
    for (int i = 1; i < n; i++){
        int a;
        scanf("%d", &a);
        cnt[a]++;
    }
    for (int i = 1; i <= n; i++) printf("%d\n", cnt[i]);
}






Measured memory_bytes: 4488
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
//#pragma warning(disable : 4996)

#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#define __builtin_popcountll __popcnt64

#endif

#include <limits.h>
#include <math.h>
#include <time.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m - 1; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v, n) reverse(v, v + n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout << (x) << '\n'
#define pe(x) cout << (x) << " "
#define DEBUG(x) cout << #x << ": " << x << endl
#define lb(v, n) lower_bound(v.begin(), v.end(), (n))
#define ub(v, n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i, v.size()) cout << v[i] << " \n"[i==(int)v.size()-1]
template <typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template <typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9 + 7;
constexpr int MAX = 500050;
const double pi = acos(-1);
constexpr double EPS = 1e-8;
constexpr ll LINF = 1e17 + 1;
constexpr int INF = 1e9 + 1;
int dx[4] = { 0,0,-1,1 }, dy[4] = { 1,-1,0,0 };

int cx[300030], cy[300030];
set<int>stx[300030];
void solve() {
	int H, W, M; cin >> H >> W >> M;
	vector<int>X(M), Y(M);

	REP(i, M) {
		cin >> X[i] >> Y[i];
		X[i]--, Y[i]--;
		cx[X[i]]++;
		cy[Y[i]]++;
		stx[X[i]].insert(Y[i]);
	}
	int mxX = 0, mxY = 0;
	REP(i, H) {
		chmax(mxX, cx[i]);
	}
	REP(j, W)chmax(mxY, cy[j]);
	ll ans = mxX + mxY - 1;
	vector<int>xs, ys;
	REP(i, H) {
		if (cx[i] == mxX)xs.push_back(i);
	}
	REP(j, W) {
		if (cy[j] == mxY)ys.push_back(j);
	}
	bool ok = false;
	for (auto x : xs) {
		for (auto y : ys) {
			if (!stx[x].count(y)) {
				ok = true;
				goto END;
			}
		}
	}
END:;
	if (ok)ans++;
	print(ans);
}



signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q;
	//cin >> q;
	//while (q--)
	solve();

}


Measured memory_bytes: 49092
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solve(void)
{
 int H,W;
 cin>>H>>W;
 vector<vector<char> > data(H+2,vector<char>(W+2,'#'));
 for (int i = 0; i < H; i++)
 {
   for (int j = 0; j < W; j++)
   {
     cin>>data[i+1][j+1];
   }
 }

  for (int i = 0; i < H+2; i++)
  {
    for (int j = 0; j < W+2; j++)
    {
      cout<<data[i][j];
    }
    cout<<endl;
    
  }
  
 
  return; 
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2000000000;//10^9
ll MOD  = 998244353;

int main() {
    ll N,K;
    cin >> N >> K;
    if(K % 2){
        cout << (N/K) * (N/K) * (N/K) << endl; 
    }else{
        ll cnt = 0;
        while(true){
            if(K / 2 * (2 * cnt + 1) <= N){
                cnt++;
            }else{
                break;
            }
        }
        cout << (N/K) * (N/K) * (N/K) + cnt * cnt * cnt << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <algorithm>
#include <vector>
#define llint long long

using namespace std;

string s, t, ss;
llint succ[200005][26];
int nx[26];

int main(void)
{
	cin >> s >> t;
	int n = s.size();
	ss = s + s;
	
	for(int i = 0; i < 26; i++) nx[i] = 2*n;
	for(int i = 2*n-1; i >= 0; i--){
		for(int j = 0; j < 26; j++) succ[i][j] = nx[j];
		nx[ss[i]-'a'] = i;
	}
	for(int i = 0; i < n; i++){
		for(int j = 0; j < 26; j++){
			if(succ[i][j] < 2*n) succ[i][j] %= n;
		}
	}
	
	llint pos = nx[t[0]-'a'], ans = pos+1;
	if(pos >= n){
		cout << -1 << endl;
		return 0;
	}
	for(int i = 1; i < t.size(); i++){
		llint d = succ[pos][t[i]-'a'];
		if(d >= n){
			cout << -1 << endl;
			return 0;
		}
		if(pos < d) ans += d - pos;
		else ans += n - (pos - d);
		pos = d;
	}
	cout << ans << endl;
	
	
	return 0;
}

Measured memory_bytes: 41344
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <fstream>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

const int MAXN = 500005;

int n;
int l[MAXN];
int r[MAXN];

long long ans;

char s[MAXN];

int main()
{
	scanf("%s",s + 1);
	n = strlen(s + 1);
	int cnt = 0;
	for (int i = n;i >= 1;i--)
	{
		if (s[i] == '>')
			cnt++;
		else
			cnt = 0;
		r[i] = cnt;
	}
	cnt = 0;
	for (int i = 1;i <= n;i++)
	{
		if (s[i] == '<')
			cnt++;
		else
			cnt = 0;
		l[i] = cnt;
	}
	for (int i = 0;i <= n;i++)
		ans += max(l[i],r[i + 1]);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 4608
def has_no(s, digits):
    for ch in s:
        if digits.get(ch):
            return False
    return True

def main():
    N, K = [int(x) for x in input().split()]
    digits = {str(x): True for x in input().split()}

    for s in [str(i) for i in range(N, 100000)]:
        if has_no(s, digits):
            print(s)
            break
   
main()

Measured memory_bytes: 16012
#include<iostream>
#include<math.h>
#include<string.h>
using namespace std;

int seiyaku_check(long i,long Min,long Max){
	if(Min <= i && i <= Max){
		return 1;
	}else{
		exit(1);
		//return 0;
	}
}

int main(){
	
	string s,t,u,v;
	int i,j,k,l;
	cin >> s;
	
	i=s[0];
	j=s[1];
	k=s[2];
	l=s[3];
	
	
	if(s.length() != 4) exit(1);
	
	if(s[0] == s[1] || s[1] == s[2] || s[2] == s[3]){
		cout << "Bad" << endl;
	}else{
		 cout << "Good" << endl;
	}
	
return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());

        int n = N % 10;

        switch (n) {
            case(2):
            case(4):
            case(5):
            case(7):
            case(9):
                System.out.println("hon");
                break;
            case(0):
            case(1):
            case(6):
            case(8):
                System.out.println("pon");
                break;
            case(3):
                System.out.println("bon");
                break;
        }
    }
}


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

using namespace std;

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

  string s; 
  cin >> s;
  int n = s.size();
  cout << s[0] << n-2 << s[n-1] << endl;

  return 0;
}



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

void call(int n) {
	int x = 0;
	int i = 0;
	while ( ++i <= n ) {
		x = i;
		if ( x % 3 == 0) {
			cout << " " << i;
		} else {
		    do {
			    if ( x % 10 == 3 ) {
			        cout << " " << i;
			        break;
		        } 
		        x /= 10;
		    } while (x); //iなしだと無限に0を上のwhileに返す
		}
	}
	cout << endl;
}

int main() {
	int n;
	cin >> n;
	call(n);
	return 0;
}


Measured memory_bytes: 3108
#include<stdio.h>
#include<math.h>

int main() {
	int n,a=0,b;
	scanf("%d", &n);
	b = n;
	for (int i = 10; i >= 0; i--) {
		a += b/pow(10,i);
		b = b%(int)pow(10,i);
	}
	if (n%a == 0)printf("Yes\n");
	else printf("No\n");

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
string s;
int k;
ll dp[1005][5][3];
ll solve(int idx, int cnt, int state) {
    if (idx == s.size())
        return 0;
    ll &ret = dp[idx][cnt][state];
    if (ret != -1)
        return ret;
    ret = 0;
    for (int i = 0; i <= 9; i++) {
        int newcnt = cnt - (i > 0);
        if (newcnt < 0) continue;
        if (idx == s.size() - 1 && state == 2) continue;
        if (idx == s.size() - 1 && state == 1 && i > s[idx] - '0') continue;
        int newstate = state;
        if (newstate == 1 && i > s[idx] - '0') newstate = 2;
        if (newstate == 1 && i < s[idx] - '0') newstate = 0;
        ret += solve(idx + 1, newcnt, newstate) + (newcnt == 0);
    }
    return ret;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> s >> k;
    ll cnt = 0;
    memset(dp, -1, sizeof dp);
    for (int i = 1; i <= 9; i++) {
        if (s.size() > 1 && k == 1) cnt++;
        if (s.size() == 1 && k == 1 && i <= s[0] - '0') cnt++;
        int state = 0;
        if (i == s[0] - '0')
            state = 1;
        else if (i > s[0] - '0')
            state = 2;
        cnt += solve(1, k - 1, state);
    }
    cout << cnt;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } else return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } else return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll INF = 1e9+100;
const ll INFL = 1e18+100;
const ll MOD = 1e9+7;
const bool debug = 0;

ll D, G;
int p[10], c[10];

int main() {
	cin >> D >> G;
	REP(i, D) scanf("%d %d", p + i, c + i);
	
	int ans = INF;
	
	REP(s, 1 << D) {
		int cur = 0;
		ll score = 0;
		
		vector<pii> lvpro; // 残っている問題 (score, count)
		REP(i, D) {
			ll curscore = 100ll * (i + 1);
			if (s >> i & 1) {
				cur += p[i];
				score += p[i] * curscore + c[i];
			}
			else {
				lvpro.push_back(pii(curscore, p[i]));
			}
		}
		reverse(ALL(lvpro));
		
		ll diff = G - score;
		if (diff > 0 && !lvpro.empty()) {
			if (diff > lvpro[0].fi * lvpro[0].se) continue;
			cur += (diff + lvpro[0].fi - 1) / lvpro[0].fi;
			diff = 0;
		}
		
		if (diff <= 0) chmin(ans, cur);
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
//
// Created by 10034 on 2020/7/28.
//

#include <iostream>
using namespace std;
const int N=500010,mod=1e9+7;
typedef long long LL;
int fac[N];
void init(){
    fac[0]=1;
    for(int i=1;i<N;++i){
        fac[i]=(LL)fac[i-1]*i%mod;
    }
}
int qm(int a,int b){
    int res=1;
    while(b){
        if(b&1) res=(LL)res*a%mod;
        b>>=1;
        a=(LL)a*a%mod;
    }
    return res;
}
int A(int a,int b){
    return (LL)fac[a]*qm(fac[a-b],mod-2)%mod;
}
LL inv(LL t,LL p){
    return t==1 ? 1:(p-p/t)*inv(p%t,p)%p;
}

int C(int a,int b){
    return (LL)A(a,b)*qm(fac[b],mod-2)%mod;
}
int main(){
    int m,n;
    init();
    cin>>n>>m;
    LL res1=A(m,n);
    LL res2=0;
    for(int i=0;i<=n;++i){
        if(i%2)
            res2=(LL)(res2-(LL)A(m-i,n-i)*C(n,i)%mod+mod)%mod;
        else
            res2=(LL)(res2+(LL)A(m-i,n-i)*C(n,i)%mod)%mod;
    }
    cout<<(LL)res1*res2%mod;
    return 0;
}

Measured memory_bytes: 5128
import java.util.*;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		for(;;)
		{
			int n=in.nextInt();
			int h=in.nextInt();
			if((n|h)==0)
				return;
			boolean xy[][]=new boolean[501][501];
			boolean xz[][]=new boolean[501][501];
			boolean yz[][]=new boolean[501][501];
			int cnt=n*n*n;
			for(int i=0;i<h;i++)
			{
				String st=in.next();
				int a=in.nextInt();
				int b=in.nextInt();
				if(st.equals("xy"))
				{
					for(int z=1;z<=n;z++)
						if(!(xz[a][z]||yz[b][z]))
							cnt--;
					xy[a][b]=true;
				}
				else if(st.equals("xz"))
				{
					for(int y=1;y<=n;y++)
						if(!(xy[a][y]||yz[y][b]))
							cnt--;
					xz[a][b]=true;
				}
				else 
				{
					for(int x=1;x<=n;x++)
						if(!(xy[x][a]||xz[x][b]))
							cnt--;
					yz[a][b]=true;
				}
			}
			System.out.println(cnt);
		}
	}
}

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

long N, A, B;
vector<long> H;

bool f(long mid) {
  vector<long> V = H;
  for (auto &v : V) v -= B * mid;
  long cnt = 0, tmp = A - B;
  for (auto v : V) if (v > 0) cnt += (v + tmp - 1) / tmp;
  return (cnt <= mid) ? true : false;
}

int main() {
  cin >> N >> A >> B;
  H.resize(N);
  for (auto &h : H) cin >> h;
  long ok = 2e9, ng = -2e9;
    while (ok - ng > 1) {
      long mid = (ok + ng) / 2;
      (f(mid)) ? ok = mid : ng = mid;
    }
  cout << ok << "\n";
}

Measured memory_bytes: 4740
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1},dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(cv *a, cv *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(cv *a, cv *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(cv *left, cv *right) {return strcmp((char *)left,(char *)right);}
int downchar(cv *left, cv *right) {return strcmp((char *)right,(char *)left);}
void tmpInit(int *c,ll m) {ll i;rep(i,m) c[i]=i;}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1){
      res *= a; if(mod>=1) res %= mod;
    }
    a *= a; if(mod>=1) a %= mod;
    n >>= 1;
  }
  return res;
}
void initialize(){
  
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0,tmp;
  int a[LIMIT2]={0},b[1000020]={0};
  char s[LIMIT1];
  
  scanf("%lld",&n);
  k=0;
  rep(i,n){
    scanf("%d",&a[i]);
    b[a[i]]++;
    if(i==0) m = a[i];
    else m = min(m,a[i]);
    k = max(k,a[i]);
  }
  qsort(a,n,sizeof(int),upint);
  
  result = n;
  rep(tmp,n){
    i = a[tmp];
    if(b[i]==0) continue;
    if(b[i]>=2){
      result -= b[i];
      b[i]=0;
    }
    for(j=2*i;j<=k;j+=i){
      result -= b[j];
      b[j]=0;
    }
  }
  
  printf("%lld\n",result);
  return 0;
}

Measured memory_bytes: 8120
n = int(input())
A = list(map(int, input().split()))

count = 0
for i in range(n):
    if(A[i] % 2 == 0):
        if(A[i] % 3 != 0 and A[i] % 5 != 0):
            count += 1

if(count >= 1):
    print("DENIED")
else:
    print("APPROVED")


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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列 -92
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}



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

    sort(d);

    int x = d[n/2-1];
    int y = d[n/2];

    if(x==y){
        cout << 0 << endl;
    }else{
        cout << y-x << endl;
    }
}

Measured memory_bytes: 640
s = input()
n = len(s)
if n == 3:
    print("Yes")
elif (n//2)%2 == 0:
    l, r = s[:(n-1)//2], s[(n+1)//2:]
    m = len(l)
    ll, lr = l[:(m)//2], l[(m)//2:]
    rl, rr = l[:(m)//2], l[(m)//2:]
    if ll == lr[::-1] and rl == rr[::-1] and l == r:
        print("Yes")
    else:
        print("No")
else:
    l, r = s[:(n-1)//2], s[(n+1)//2:]
    m = len(l)
    ll, lr = l[:(m-1)//2], l[(m+1)//2:]
    rl, rr = l[:(m-1)//2], l[(m+1)//2:]
    if ll == lr[::-1] and rl == rr[::-1] and l == r:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>

using namespace std;

int main() {
    int a = 0;
    int b = 0;

    cin >> a >> b;

    if (a > b) {
        swap(a, b);
    }
    string out = "";

    for (int i = 0; i < b; i++) {
        out += to_string(a);
    }
    cout << out << "\n";
	return 0;  
}

Measured memory_bytes: 256
def A():
    temp = input().split()
    print(''.join(temp[::-1]))

def B():
    temp = [int(n) for n in input().split()]
    A = temp[0]
    B = temp[1]
    K = temp[2]
    to_minus = min(A, K)
    A -= to_minus
    K -= to_minus
    if K > 0:
        B -= min(B, K)
    print (A, B)

import math
def C():
    X = int(input())
    if X <= 2:
        print(2)
        return

    def isPrime(n):
        if n <= 3:
            return True
        if(n % 2 == 0 or n % 3 == 0): 
            return False
      
        for i in range(5,int(math.sqrt(n) + 1), 6):  
            if(n%i == 0 or n%(i + 2) == 0): 
                return False
        
        return True
    
    while True:
        if isPrime(X):
            print(X)
            return
        X += 1

C()

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b && a == c) {
        cout << "No" << endl;
        return 0;
    }
    if (a == b || a == c || b == c) {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    A, B, C, D = map(int, readline().split())

    print(max(A * B, C * D))


if __name__ == '__main__':
    main()


Measured memory_bytes: 61628
#include<bits/stdc++.h>
#define LL long long
using namespace std;
int VisCol[21],VisRow[21],N,M;
string Compos[21];
char Ch[21][21];
bool Mirrored(int C1,int C2){
	for(int J=1;J<=N;J++) if(Ch[VisRow[J]][C1]!=Ch[J][C2]) return 0;
	return 1;
}
void DFS2(int X,bool Can){
	if(X==M+1)  exit(!printf("YES\n"));
	if(VisCol[X]>0) return void(DFS2(X+1,Can));
	for(int I=X+1;I<=M;I++)
		if((!VisCol[I])&&(Mirrored(I,X))){
			VisCol[I]=X,VisCol[X]=I;
			DFS2(X+1,Can);
			VisCol[I]=VisCol[X]=0;
		}
	if(Mirrored(X,X)&&Can) VisCol[X]=X,DFS2(X+1,0),VisCol[X]=0;
}
void DFS1(int X,bool Can){
	if(X==N+1) return void(DFS2(1,M&1));
	if(VisRow[X]>0) return void(DFS1(X+1,Can));
	for(int I=X+1;I<=N;I++)
		if((!VisRow[I])&&(Compos[I]==Compos[X])){
			VisRow[I]=X,VisRow[X]=I;
			DFS1(X+1,Can);
			VisRow[I]=VisRow[X]=0;
		}
	if(Can) VisRow[X]=X,DFS1(X+1,0),VisRow[X]=0;
}
int main(){
	scanf("%d%d",&N,&M);
    for(int I=1;I<=N;I++){
    	for(int J=1;J<=M;J++){
    		char Str='\0';
    		while(!isalpha(Str)) Str=getchar();
    		Ch[I][J]=Str;
    		Compos[I]+=Ch[I][J];
		}
		sort(Compos[I].begin(),Compos[I].end());
	}
	DFS1(1,N&1);
	printf("NO\n");
	return 0;
}


Measured memory_bytes: 3720
#include <stdio.h>
#include <math.h>

int main(void)
{
    double a, b, c, d, e, f, x, y, det;

    while(scanf("%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f) != EOF)
    {
        det = a*e - b*d;
        x = (c*e - b*f)/det;
        y = (a*f - c*d)/det;
        if(x == fabs(x))
            x = fabs(x);
        else if(y == fabs(y))
            y = fabs(y);
        printf("%.3f %.3f\n", x, y);
    }

    return 0;
}


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

#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
#define INF 99999999999 //10^12-1
#define dev 998244353 //tenka1
#define P pair<int,int>
#define F first
#define S second
int n,k,ans=0;
int h[200000];
signed main(){
    cin>>n>>k;
    rep(i,n){
        cin>>h[i];
        if(h[i]>=k)ans++;
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,i,sum=0,k;
    cin>>a>>b>>k;
    for(i=min(a,b);i>=1;--i){
        if((a%i==0) && (b%i==0))sum++;
        if(sum==k)break;
    }
    cout<<i;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)

using namespace std;

int main(){
    int N;
    while(cin >> N && N){
        bool ok = true;
        vector<string> words(N);
        REP(i, N) cin >> words[i];
        bool g[30][30] = {};
        for(int i = 0; i < N; i++){
            for(int j = i + 1; j < N; j++){
                for(int k = 0; k < words[i].size(); k++){
                    if(k == words[j].size()){
                        ok = false;
                        break;
                    }
                    if(words[i][k] != words[j][k]){
                        g[ words[i][k] - 'a' ][ words[j][k] - 'a' ] = true;
                        break;
                    }
                }
            }
        }
        REP(k, 26) REP(i, 26) REP(j, 26) g[i][j] |= g[i][k] & g[k][j];
        REP(i, 26) if(g[i][i]) ok = false;
        cout << (ok ? "yes" : "no") << endl;
    }
    return 0;
}

Measured memory_bytes: 1244
#include<iostream>
using namespace std;
int main (void)
{
	string S, T;
	cin >> S >> T;
	int N = S.size ();
	int m = 0;
	for (int i = 0; i < N; i++)
	{
		if (S [i] == T [i])
		{
			continue;
		}
		else
		{
			m++;
		}
	}
	cout << m << endl;
}

Measured memory_bytes: 3916
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int arr[N] , cumulative[N];
int check(int num)
{
    int count = 0;
    while(num != 0)
    {
        count++;
        num /= 10;
    }
    return count;
}
void build()
{
    for(int i = 1; i <= N; i++)
    {
        if(check(i) % 2 != 0)
        {
            arr[i] = 1;
        }
    }
    for(int i = 1; i <= N; i++)
    {
        if(i == 1)
        {
            cumulative[i] = arr[i];
        }else
        {
            cumulative[i] = cumulative[i - 1] + arr[i];
        }
    }
}
int main()
{
    build();
    int n;
    int ans = 0;
    cin >> n;

    cout << cumulative[n] << endl;
    return 0;
}


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

#include <algorithm>
#include <array>
#include <chrono>
#include <cstdio>
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;

#define ll long long
#define ld long double
#define P pair<ll, ll>
#define FOR(i, n, m) for (ll i = n; i < (ll)m; i++)
#define FORr(i, m, n) for (ll i = n; i >= (ll)m; i--)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)
#define sortAl(v) sort(v.begin(), v.end())
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())
#define cout(n) cout << fixed << setprecision(n)

int main() {
  ll N;

  cin >> N;
  vector<ll> A(N + 1);

  FOR(i, 1, N + 1) {
    cin >> A[i];
    A[i] -= i;
  }

  vector<ll> tmp(N + 1);
  tmp = A;

  sort(tmp.begin() + 1, tmp.end());

  ll b;
  b = tmp[(N + 1) / 2];
  ll sum = 0;
  FOR(i, 1, N + 1) { sum += abs(A[i] - b); }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 3328
from operator import sub


def calc(a, b):
    r = sum(c ** 2 for c in map(sub, a, b)) ** (1 / 2)
    return r % 1 == 0


N, D = map(int, input().split())
x = [tuple(map(int, input().split())) for _ in range(N)]

cnt = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        if calc(x[i], x[j]):
            cnt += 1
print(cnt)


Measured memory_bytes: 3188
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <cassert>
#include <vector>
#include <array>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <numeric>
using ll = long long;
using namespace std;
using pii = pair<int, int>;

int N;
vector<int> A;

int main() {
	cin >> N;
	bool is_ok = false;
	int i;
	for (i = 1; i*i < 2*N; i++)
	{

	}
	int n=i-1;
	if (n*(n + 1) == 2 * N) {
		is_ok = true;
	}
	if (is_ok) {
		cout << "Yes" << endl;
		cout << n+1 << endl;
		cout << n << " ";
		for (int j = 1; j <= n; j++)
		{
			cout << j <<" ";
 		}
		cout << endl;
		vector<vector<int>> v(n+1);
		for (int i = 1; i <= n; i++)
		{
			v.at(i).push_back(i);
		}
		int num = n+1;
		for (int i = 1; i <= n; i++)
		{
			for (int j = i+1; j <= n; j++)
			{
				v.at(i).push_back(num);
				v.at(j).push_back(num);
				num++;
			}
			cout << n << " ";
			for (const auto &e : v.at(i))
			{
				cout << e << " ";
			}
			cout << endl;
		}
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 2304
#include <stdio.h>

int min(int a, int b){
	if(a < b){
		return a;
	}
	else{
		return b;
	}
}

int max(int a, int b){
	if(a > b){
		return a;
	}
	else{
		return b;
	}
}

int main(){
	int N, a, i, ans = 0, color[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
	scanf("%d", &N);
	for(i = 0; i < N; i++){
		scanf("%d", &a);
		color[min(8, a / 400)]++;
	}
	for(i = 0; i < 8; i++){
		if(color[i] > 0){
			ans++;
		}
	}
	printf("%d %d\n", max(1, ans), ans + color[8]);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
        int n,a,b,i;

        scanf("%d",&n);

        a=n;

        if ((n%7==0)||(n%4==0)){
                printf("Yes\n");
                return 0;
        }

        else if (n<4){
                printf("No\n");
                return 0;
        }

        while(1){
                a=a-7;
                if (a%4==0){
                        printf("Yes\n");
                        return 0;
                }
                else if (a<4){
                        printf("No\n");
                        return 0;
                }
        }
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int N;
int A[1<<18];
int mv1[1<<18];
int mv2[1<<18];
int ans[1<<18];
void upd(int a, int b)
{
  set<pair<int, int> > S;
  S.emplace(A[mv1[a]], mv1[a]);
  S.emplace(A[mv1[b]], mv1[b]);
  S.emplace(A[mv2[a]], mv2[a]);
  S.emplace(A[mv2[b]], mv2[b]);
  auto it = S.rbegin();
  auto it2 = it; ++it2;
  mv1[a] = it->second; mv2[a] = it2->second;
}
int main()
{
  scanf("%d", &N);
  for(int i=0; i<(1<<N); ++i)
  {
    scanf("%d", A+i);
    mv1[i] = i;
    mv2[i] = i;
  }
  for(int i=1; i<(1<<N); ++i)
  {
    for(int j=0; j<N; ++j)
      if(i&(1<<j)) upd(i, i-(1<<j));
    ans[i] = max(ans[i-1], A[mv1[i]]+A[mv2[i]]);
    printf("%d\n", ans[i]);
  }
  return 0;
}

Measured memory_bytes: 7168
#include<cstdio>
#include<iostream>
using namespace std;
int s[11];
int main()
{
	int i,j,n,m;
	while(cin>>n)
	{
		m=0;
		if(n==0)break;
		for(i=1;i<=9;i++)
		{
			cin>>s[i];
			m+=s[i];
		}
		j=n-m;
		cout<<j<<endl;
	}
	return 0;
}

Measured memory_bytes: 3072
#include <stdio.h>
#include <string.h>
int main(){
  char a[128];
  char* b[]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
  scanf("%s", a)+1;
  int idx;
  for(idx=0;;idx++){
    if (strcmp(a, b[idx])==0)break;
  }
  printf("%d\n", 7-idx);

  return 0;
}
  

Measured memory_bytes: 128
#include<iostream>

using namespace std;

int main(){
	int n,m;
	while(1){
		cin>>n>>m;
		if(n==0 && m==0){
			break;
		}
		int hon[150];
		for(int i=0;i<m;i++){
			cin>>hon[i];
		}
		
		int right,left;
		right=left=0;
		
		for(int i=0;i<m;i++){
			left+=hon[i];
		}
		
		while(1){
			double h=(double)(left+right)/2;
			//printf("%d %d %lf\n",right,left,h);
			
			int ans=0;
			
			int now=0;
			int dan=1;
			for(int i=0;i<m;i++){
				if(now+hon[i]>h){
					if(now==0){
						dan=100000;
						break;
					}
					now=0;
					dan++;
					i--;
					continue;
				}
				now+=hon[i];
			}
			
			//printf("%lf zi dan = %d\n",h,dan);
			
			if(dan<=n){
				ans=1;
			}
			if(ans==1){
				left=h+0.499;
			}else{
				right=h;
			}
			if((int)left==(int)right+1){
				printf("%d\n",left);
				break;
			}
		}
	}
}

Measured memory_bytes: 0