akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#define maxn 200005
#define ll long long
#define ld double
#define mod 998244353
using namespace std;
int a[4];
int main()
{
	for(int i = 0; i < 4; i++)
		cin>>a[i];
	sort(a, a + 4);
	if(a[0] == 1 && a[1] == 4 && a[2] == 7 && a[3] == 9)
		printf("YES\n");
	else printf("NO\n");
	return 0;
 } 

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	int min = a + b;
	
	if(min > b + c) min = b + c;
	if(min > a + c) min = a + c;
	
	printf("%d\n", min);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;
 
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;
 
const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;
 
#define _  %  MOD
#define __ %= MOD
 
#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))
 
#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
#define fbo find_by_order
#define ook order_of_key
 
ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent
 
int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
   	ll n;
	cin>>n;
   	ll div[n+1];
	memset(div,0,sizeof(div));
	for(ll i=1;i<=n;i++)
	{
		for(ll j=1;i*j<=n;j++) div[i*j]++; 
	}	
	ll ans=0;
	for(ll i=1;i<n;i++) ans+=div[i];
	cout<<ans<<'\n';
	return 0;
}
// JUST ASK YOURSELF DID YOU GIVE YOUR BEST ? ISSE ZYADA
// KUCH KAR BHI NAHI SAKTE !! ENJOY AND GIVE YOUR BEST!!



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

int main() {
 
  string s, ns;
  cin >> s;
  
  for(int i = 0; i < s.size(); i++) {
    if((i % 2) == 0) {
      ns += s[i];
    }
  }
  
  cout << ns << endl;
  
  return 0;
}

Measured memory_bytes: 512
N, X = map(int, input().split())

a, p = [1], [1]
for i in range(N):
  a.append(a[i] * 2 + 3)
  p.append(p[i] * 2 + 1)

def f(N, X):
  if N == 0:
    return 0 if X <= 0 else 1
  elif X <= 1 + a[N - 1]:
    return f(N-1, X-1)
  else:
    return p[N-1] + 1 + f(N-1, X-2-a[N-1])

print(f(N, X))

Measured memory_bytes: 3064
#include<cstdio>
#include<algorithm>
using namespace std;
#define LL long long
int a[200001];
LL sum[200001];
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	reverse(a+1,a+n+1);
	for(int i=1;i<=n;i++)
		sum[i]=sum[i-1]+a[i];
	LL ans=1LL<<62;
	for(int k=1;k<=n;k++){
		LL s=sum[k]*5;
		for(int i=k*2,j=2;;i+=k,j++){
			s+=(sum[min(i,n)]-sum[i-k])*(j*2+1);
			if(i>n||s>ans)break;
		}
		ans=min(ans,s+(LL)(k+n)*m);
	}
	printf("%lld",ans);
}


Measured memory_bytes: 2560
n,k=map(int,input().split())
p=list(map(int,input().split()))
c=list(map(int,input().split()))
ans=-10**9

for i in range(1,n+1):
    m=i
    co=0
    an=0
    for j in range(n):
        m=p[m-1]
        co+=1
        if m==i:
            break      
    m=i
    x=[0 for j in range(2*co)]
    for j in range(2*co-1):
        m=p[m-1]
        x[j+1]=x[j]+c[m-1]
    
    if k<=co:
        ans=max(ans,max(x[j] for j in range(1,k+1)))
    else:
        if x[co]<=0:
            ans=max(ans,max(x[j] for j in range(1,co+1)))
        else:
            f=max(0,(k//co)-1)
            an+=x[co]*f
            s=k-f*co
            ans=max(ans,an+max(x[j] for j in range(1,s+1)))
            
            
            
            
print(ans)
    



Measured memory_bytes: 137988
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

int main(){
	std::string s;
	std::string tmp= "keyence";
	std::cin>>s;

	bool ans=false;

	for(int i=0; i<8; i++){
		bool isEqFirst=true;
		bool isEqEnd=true;

		for(int j=0; j<i; j++){
			if(s[j]!=tmp[j])
				isEqFirst=false;
		}

		for(int j=i; j<8; j++){
			if(s[j+s.size()-7]!=tmp[j])
				isEqEnd=false;
		}

		if(isEqFirst && isEqEnd)
			ans= true;
	}

	if(ans)
		std::cout<<"YES"<<std::endl;
	else
		std::cout<<"NO"<<std::endl;


	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
// clang-format on

int N, D;

void solve()
{
  int ans = ceil((double)N / (2.0 * D + 1.0));
  cout << ans << endl;
}

int main(void)
{
  cin >> N >> D;
  solve();
  return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

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;
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;


signed main(){
	string S;cin>>S;
	if(S[0]==S[1]&&S[1]==S[2])cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
}


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


public class Main {

    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        System.out.println(s.next().replace(',',' '));
    }

}




class Scanner
{
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

    public String next() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    public int nextInt() throws IOException {return Integer.parseInt(next());}

    public long nextLong() throws IOException {return Long.parseLong(next());}

    public String nextLine() throws IOException {return br.readLine();}

    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

    public boolean ready() throws IOException {return br.ready();}


}

Measured memory_bytes: 25344
import math
N,D = map(int,input().split())
cnt = 0
while True:
	try:
		x,y = list(map(int, input().split()))
		ll = math.sqrt(x * x + y * y)
		if ll <= D:
			cnt+=1
		# print('listA', x,y,ll)
	except:
		break
print(cnt)

Measured memory_bytes: 9136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const ll mod = 1e9+7;

// void chmod(ll &M){
//     if(M >= mod) M %= mod;
//     else if(M < 0){
//         M += (abs(M)/mod + 1)*mod;
//         M %= mod;
//     }
// }

int main(){
    int H, W; cin >> H >> W;
    vector<vector<char>> fi(H+5, vector<char>(W+5, '.'));
    for(int i=1; i<=H; ++i) for(int j=1; j<=W; ++j) cin >> fi[i][j];

    int d1[4] = {1,0,-1,0};
    int d2[4] = {0,1,0,-1};

    for(int i=1; i<=H; ++i){
        for(int j=1; j<=W; ++j){
            if(fi[i][j] == '#'){
                bool flg = false;
                for(int k=0; k<4; ++k){
                    int ni = i+d1[k];
                    int nj = j+d2[k];
                    if(fi[ni][nj] == '#') flg = true;
                }
                if(!flg){
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }

    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_139
{
    class C
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            int[] hs = ReadInts();
            int[] sums = new int[n];
            sums[n - 1] = 0;
            for(int i = n - 2; i >= 0; i--)
            {
                if (hs[i] >= hs[i + 1]) sums[i] = sums[i + 1] + 1;
            }
            int res = 0;
            for (int i = 0; i < n; i++) res = Max(res, sums[i]);
            WriteLine(res);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 23388
#include <iostream>
#include <cmath>
#include <queue>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

void solve(long long N){
    queue<int> que;
    REP(i, 7) que.push(pow(2, 6 - i));
    REP(i, 7) if (N < que.front()) que.pop();
    cout << que.front() << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
class Node:
    def __init__(self, left, right):
        self.left = left
        self.right = right
        self.val = ''
    
    @classmethod
    def fromString(cls, s):
        pos = 1
        if s[pos] == '(':
            e = getEnd(s, 1)
            left = cls.fromString(s[1:e+1])
            pos = e + 2
        else:
            left = None
            pos += 1

        if s[pos] == '(':
            e = getEnd(s, pos)
            right = Node.fromString(s[pos:e+1])
        else:
            right = None

        return cls(left, right)

    def __str__(self):
        lstr = "" if self.left == None else str(self.left)
        rstr = "" if self.right == None else str(self.right)
        return "({},{})".format(lstr, rstr)

def getEnd(s, pos):
    count = 0
    while True:
        if s[pos] == '(':
            count += 1
        elif s[pos] == ')':
            count -= 1
        if count == 0:
            break
        pos += 1
    return pos

def intersection(root1, root2):
    if root1.left == None or root2.left == None:
        root1.left = None
    else:
        intersection(root1.left, root2.left)
    
    if root1.right == None or root2.right == None:
        root1.right = None
    else:
        intersection(root1.right, root2.right)

def union(root1, root2):
    if root1.left == None and root2.left == None:
        pass
    elif root1.left != None and root2.left == None:
        pass
    elif root1.left == None and root2.left != None:
        root1.left = root2.left
    else:
        union(root1.left, root2.left)
    
    if root1.right == None and root2.right == None:
        pass
    elif root1.right != None and root2.right == None:
        pass
    elif root1.right == None and root2.right != None:
        root1.right = root2.right
    else:
        union(root1.right, root2.right)

if __name__ == '__main__':
    try:
        while True:
            line = input().strip().split()
            c = line[0]
            a = Node.fromString(line[1])
            b = Node.fromString(line[2])

            if c == 'i':
                intersection(a, b)
            else:
                union(a, b)

            print(a)

    except EOFError:
        pass


Measured memory_bytes: 5588
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    string w;
    cin >> w;

    map<char, int> mp;

    for(char c : w){
        mp[c]++;
    }

    for(auto p : mp){
        if(p.second % 2 != 0){
            p_no();
            return 0;
        }
    }

    p_yes();
    return 0;
}

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

#define pb push_back
#define all(x) (x).begin(), (x).end()
#define make_unique(x) (x).resize(unique(all((x))) - (x).begin())

using namespace std;
using ll = long long;

const int mod = 1e9 + 7;
const int maxN = 100005;

int N, M, p[maxN], vis[maxN];
vector <int> g[maxN];

void dfs(int s, int cc) {
  vis[s] = cc;
  for (auto x : g[s]) {
    if (!vis[x]) dfs(x, cc);
  }
}

int main() {
  cin >> N >> M;
  for (int i = 1; i <= N; ++i) cin >> p[i];
  for (int i = 1; i <= M; ++i) {
    int x, y;
    cin >> x >> y;
    g[x].pb(y);
    g[y].pb(x);
  }
  int cc = 0;
  for (int i = 1; i <= N; ++i) if (!vis[i]) dfs(i, ++cc);
  int ans = 0;
  for (int i = 1; i <= N; ++i) if (vis[i] == vis[p[i]]) ++ans;
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 8576
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i,n) for (int i=0,_n=(int)(n); i < _n; i++)
template<class T> bool chmax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<class T> bool chmin(T &a, T b) { return a > b ? (a = b, true) : false; }
 
typedef long long ll;

bool solve(vector<int> a) {
  int N = (int)a.size();
  int ma = *max_element(a.begin(),a.end());
  vector<int> b(N);
  REP(i, N) b[a[i]]++;

  if (ma % 2 == 0) {
    for (int d = ma; d >= (ma) / 2; d--) {
      if (d == ma / 2) b[d] -= 1;
      else b[d] -= 2;
    }
    REP(i,N) if(b[i] < 0) return false;
    REP(i,N) if (b[i] > 0)
      if (!(ma/2+1 <= i && i <= ma)) return false;
  } else {
    for (int d = ma; d >= (ma+1) / 2; d--) {
      b[d] -= 2;
    }
    REP(i,N) if(b[i] < 0) return false;
    REP(i,N) if (b[i] > 0)
      if (!((ma+1)/2+1 <= i && i <= ma)) return false;
  }
  return true;
}

int main2() {

  int N; cin >> N;
  vector<int> a(N);
  REP(i, N) cin >> a[i];

  if (solve(a)) {
    cout << "Possible" << endl;
  } else {
    cout << "Impossible" << endl;
  }
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws) main2();
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int i;
	int n;
	int x, y;
	int bi, pi;
	int b, p;
	int ans;
	
	scanf("%d", &n);
	
	for (i = 0; i < n; i++){
		scanf("%d %d %d %d", &x, &y, &b, &p);
		
		if (b >= 5 && p >= 2){
			ans = (b * x * 0.8) + (p * y * 0.8);
		}
		else {
			bi = -1 * (b - 5);
			if (bi < 0){
				bi = 0;
			}
			pi = -1 * (p - 2);
			if (pi < 0){
				pi = 0;
			}
			if ((b * x) + (p * y) > ((b + bi) * x * 0.8) + ((p + pi) * y * 0.8)){
				ans = ((b + bi) * x * 0.8) + ((p + pi) * y * 0.8);
			}
			else {
				ans = (b * x) + (p * y);
			}
		}
		printf("%d\n", ans);
	}
	
	return (0);
}

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

int main() {
  long long X, K, D;
  cin >> X >> K >> D;
  X = abs(X);
  
  if (X / D >= K) {
    cout << (X - (K * D));
  } else {
    long long cnt = X / D;
    long long step = K - cnt; // 残回数
    long long near = X % D;
    if (step % 2 == 0) {
      cout << near;
    } else {
      cout << (near - D) * -1;
    }
  }
  
}


Measured memory_bytes: 3604
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <unordered_map>

int A, B, C;
 
int main(int argc, char **argv) {
    std::cin >> A >> B >> C;
    
    if ((A < C && C < B) ||
        (B < C && C < A)
    ) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }

    return 0;
}

Measured memory_bytes: 256
s = input()
if int(s[0]) + int(s[1]) + int(s[2]) + int(s[3]) == 7:
	print(s[0] + "+" + s[1] + "+" + s[2] + "+" + s[3] + "=7")
elif int(s[0]) - int(s[1]) + int(s[2]) + int(s[3]) == 7:
	print(s[0] + "-" + s[1] + "+" + s[2] + "+" + s[3] + "=7")
elif int(s[0]) + int(s[1]) - int(s[2]) + int(s[3]) == 7:
	print(s[0] + "+" + s[1] + "-" + s[2] + "+" + s[3] + "=7")
elif int(s[0]) + int(s[1]) + int(s[2]) - int(s[3]) == 7:
	print(s[0] + "+" + s[1] + "+" + s[2] + "-" + s[3] + "=7")
elif int(s[0]) - int(s[1]) - int(s[2]) + int(s[3]) == 7:
	print(s[0] + "-" + s[1] + "-" + s[2] + "+" + s[3] + "=7")
elif int(s[0]) - int(s[1]) + int(s[2]) - int(s[3]) == 7:
	print(s[0] + "-" + s[1] + "+" + s[2] + "-" + s[3] + "=7")
elif int(s[0]) + int(s[1]) - int(s[2]) - int(s[3]) == 7:
	print(s[0] + "+" + s[1] + "-" + s[2] + "-" + s[3] + "=7")
else:
	print(s[0] + "-" + s[1] + "-" + s[2] + "-" + s[3] + "=7")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  int n,m;
  cin >> n >> m;
  rep(i,n) {
    string s;
    R s;
    pr(s);
    pr(s);
  }
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


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

int main(){
  int s;
  int m;
  int h;
  
  cin >> s;

  h=s/3600;
  m=(s-3600*h)/60;
  s=s-3600*h-60*m;
  
  
  cout <<h<<":"<<m<<":"<<s<<endl;

  return 0;

}

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

int main(){

    int a,b,c;
    cin>>a>>b>>c;
    cout<<(a==5&&b==5&&c==7||a==5&&b==7&&c==5||a==7&&b==5&&c==5?"YES":"NO")<<endl;








    return 0;
}

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



int main(){
  const int MX=1e9+7;
  int a[1000][1000];
  fill(&a[0][0],&a[999][999],MX);
  for(int i=0;i<1000;i++){
    a[i][i]=0;
  }
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    int w;
    cin>>w;
    int m;
    cin>>m;
    for(int t=0;t<m;t++){
      int e;
      cin>>e;
      a[w][e]=1;
    }
  }
  for(int i=1;i<=n;i++){
    for(int t=1;t<=n;t++){
      for(int k=1;k<=n;k++){
	a[t][k]=min(a[t][k],a[t][i]+a[i][k]);
      }
    }
  }
  for(int i=1;i<=n;i++){
    cout<<i<<" "<<(a[1][i]==MX? -1:a[1][i])<<endl;
  }


  
  return 0;
}



Measured memory_bytes: 7000
import math

n = int(input())

nn = int(math.sqrt(n))
# print(nn)

fmin = 10
for a in range(1, nn + 1):
  if n % a == 0:
    b = n // a
    fab = max(len(str(a)), len(str(b)))
    if fmin >= fab:
      # print(fab, a, b)
      fmin = fab

print(fmin)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define speed ios_base::sync_with_stdio(false) , cin.tie(NULL) , cout.tie(NULL);

int main()
{
    speed;

    string s,ans;
    cin>>s;

    stack<char>st;

    for(int i=0;i<s.size();i++)
    {
        if(s[i]!='B') st.push(s[i]);

        else if(s[i]=='B' && !st.empty()) st.pop();
    }

    while(!st.empty())
    {
        ans+=st.top();
        st.pop();
    }

    reverse(ans.begin(),ans.end());

    cout<<ans<<"\n";
}

Measured memory_bytes: 3540
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

bool ok[10000];
bool t[10000];

int n, k;

void get1() {
  memset(t,0,sizeof(t));
  while(1) {  
    REP(i,n) if (!ok[i]) t[i] = rand()%2;
    printf("?");
    REP(i,n) printf("%d",t[i]);
    puts(""); fflush(stdout);
    int v;
    scanf("%d",&v);
    if (v) return;
  }
}

bool check(int a, int b) {
  printf("?");  
  REP(i,n) printf("%d",(i>=a&&i<b)?t[i]:0);
  puts(""); fflush(stdout);
  int v;
  scanf("%d", &v);
  return v;
}

int main() {
  scanf("%d%d",&n,&k);
  vector<int> v;
  REP(i,k) {
    int a = 0, b = n;
    get1();
    while(a+1<b) {
      int mid = (a+b)/2;
      if (check(a, mid)) b = mid;
      else a = mid;
    }
    ok[a] = 1;
    v.push_back(a+1);
  }
  printf("!");
  REP(i,v.size()) {
    if (i) printf(" ");
    printf("%d", v[i]);
  }
  puts("");
  fflush(stdout);
}

Measured memory_bytes: 952
#include <stdio.h>

int main(void){
  int h1, m1, h2, m2, k, sum1, sum2, result;
  scanf("%d %d %d %d %d", &h1, &m1, &h2, &m2, &k);
  
  sum1 = h1 * 60;
  sum1 = sum1 + m1;
  
  sum2 = h2 * 60;
  sum2 = sum2 + m2;
  
  result = sum2 - sum1;
  result = result - k;
  
  printf("%d", result);
  
  return 0;
  
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
using namespace std;
int main(void){
   string N;
   cin >> N;
   int A = N[0]-'0';
   int B = N[1]-'0';
   int C = N[2]-'0';
   int D = N[3]-'0';
   if(A+B+C+D == 7) cout << A << '+' << B << '+' << C << '+' << D << '=' << 7 << endl;
   else if(A-B+C+D == 7) cout << A << '-' << B << '+' << C << '+' << D << '=' << 7 << endl;
   else if(A+B-C+D == 7) cout << A << '+' << B << '-' << C << '+' << D << '=' << 7 << endl;
   else if(A+B+C-D == 7) cout << A << '+' << B << '+' << C << '-' << D << '=' << 7 << endl;
   else if(A-B-C+D == 7) cout << A << '-' << B << '-' << C << '+' << D << '=' << 7 << endl;
   else if(A+B-C-D == 7) cout << A << '+' << B << '-' << C << '-' << D << '=' << 7 << endl;
   else if(A-B+C-D == 7) cout << A << '-' << B << '+' << C << '-' << D << '=' << 7 << endl;
   else if(A-B-C-D == 7) cout << A << '-' << B << '-' << C << '-' << D << '=' << 7 << endl;
}


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

#define N 107
#define MOD 10000

#define rep(i, n) for(int i=0; i<n; ++i)
#define repl(i, j, n) for(int i=j; i<n; ++i)

int main() {
	int dp[N][3][2], spe[N], n, k;
	cin >> n >> k;
	rep(i, n+1) {
		spe[i] = -1;
		rep(j, 3) rep(k, 2) dp[i][j][k] = 0;
	}
	rep(i, k) {
		int a, b;
		cin >> a >> b;
		spe[a-1] = b-1;
	}
	if(spe[0]==-1) rep(i, 3) dp[0][i][0] = 1;
	else dp[0][spe[0]][0] = 1;
	rep(i, n-1) {
		if(spe[i+1]==-1) {
			rep(j, 3) {
				rep(k, 3) {
					if(j==k) {
						dp[i+1][j][1] = (dp[i+1][j][1] + dp[i][j][0])%MOD;
					}else {
						dp[i+1][j][0] = (dp[i+1][j][0] + dp[i][k][0] + dp[i][k][1])%MOD;
					}
				}
				//cout << i+1 << " " << j << " : " << dp[i+1][j][0] << " " << dp[i+1][j][1] << endl;
			}
		}else {
			int s = spe[i+1];
			rep(j, 3) {
				if(s==j) {
					dp[i+1][s][1] = (dp[i+1][s][1] + dp[i][s][0])%MOD; 
				}else {
					dp[i+1][s][0] = (dp[i+1][s][0] + dp[i][j][0] + dp[i][j][1])%MOD;
				}
			}
			//cout << i+1 << " " << s << " : " << dp[i+1][s][0] << " " << dp[i+1][s][1] << endl;
		}
	}
	int sum = 0;
	rep(i, 3) sum += dp[n-1][i][0] + dp[n-1][i][1];
	cout << sum%MOD << endl;
	return 0;
}

Measured memory_bytes: 1164
import Control.Applicative
import Data.Char

alphabet :: String
alphabet = ['a'..'z']

search :: String -> Char -> String
search str c = [c] ++ " : " ++ show (length (filter (== c) str))

solver :: String -> [String]
solver str = map (search str) alphabet

main :: IO()
main = do
  str <- map toLower . unwords . lines <$> getContents
  mapM_ putStrLn $ solver str

Measured memory_bytes: 3976
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
#define INF 1000000000000000000
typedef long long ll;
int main(){
    int a,p;cin>>a>>p;
    cout<<(a*3+p)/2;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


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

  if(N == 1){
    cout << "Hello World" << endl;
  }else{
    int A, B;
    cin >> A >> B;
    cout << A + B << endl;
  }
  
  return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  	long long a[100000];
  	int n;
	long long prod = 1;
  
 	scanf("%d", &n);
  
  	for(int i=0;i<n;i++) {
    	scanf("%lld", &a[i]);
    }

  	for(int i=0;i<n;i++) {
    	if(a[i]==0) {
        	printf("0\n");
          	return 0;
        }
    }
  
  	for(int i=0;i<n;i++) {
    	if (a[i] <= 1000000000000000000 / prod) {
        	prod *= a[i];
        } else {
            printf("-1\n");
          	return 0;
        }
    }
  
 	printf("%lld", prod);
}

Measured memory_bytes: 2460
n, m = map(int, input().split())
dp = [0] * (n+1)
isSafe = [0] * (n+1)
a = [0] * m
for i in range(m):
    isSafe[int(input())] = 1

dp[0] = 1
dp[1] = 1 if isSafe[1] == 0 else 0

for i in range(2, n+1):
    if isSafe[i-2] == 0:
        dp[i] += dp[i-2]
        dp[i] %= 1000000007
    if isSafe[i-1] == 0:
        dp[i] += dp[i-1]
        dp[i] %= 1000000007

print(dp[len(dp)-1])

Measured memory_bytes: 8032
X, Y, Z, K = map(int, input().split())
*A, = sorted(map(int, input().split()), reverse=True)
*B, = sorted(map(int, input().split()), reverse=True)
*C, = sorted(map(int, input().split()), reverse=True)
AB = [a+b for a in A for b in B]
AB.sort(reverse=True)
AB = AB[:K]
XY = len(AB)
ABC = [ab+c for c in C for ab in AB]
ABC.sort(reverse=True)
ABC = ABC[:K]
for abc in ABC:
    print(abc)


Measured memory_bytes: 160192
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<climits>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define MOD 1000000007
#define EPS 1e-9
#define ll long long
#define Pll pair<ll, ll>
#define Pii pair<int, int>
 
using namespace std;

int main(){
    vector<int> v(100001, 0), fact(100001, 1);
    fact[0] = 0;
    fact[1] = 0;
    for(int i=2;i<=100000;i++){
        if(!fact[i]) continue;
        int j = 2*i;
        while(j <= 100000){
            fact[j] = 0;
            j += i;
        }
    }
    for(int i=3;i<=100000;i++){
        if(fact[i] && fact[(i+1)/2]) v[i] = 1;
        v[i] += v[i-1];
    }

    int q, l, r;
    cin >> q;
    rep(q){
        cin >> l >> r;
        cout << v[r]-v[l-1] << endl;
    }
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define maxn 100005
int a[maxn],b[maxn];
int main(){
	int n,w;scanf("%d",&n);
	long long ans=0;
	for(int i=0;i<=n;i++){
		scanf("%d",a+i);
	}
	for(int i=1;i<=n;i++){
		scanf("%d",b+i);
		w=min(a[i-1],b[i]),b[i]-=w,ans+=w;
		w=min(a[i],b[i]),a[i]-=w,ans+=w;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  int data[4][3][10] = {};

  int n;
  cin >> n;
  REP(i, n) {
    int b, f, r, v;
    cin >> b >> f >> r >> v;
    b--;
    f--;
    r--;
    data[b][f][r] += v;
  }

  REP(i, 4) {
    REP(j, 3) {
      REP(k, 10) { cout << " " << data[i][j][k]; }
      cout << endl;
    }
    if (i != 3) {
      cout << "####################" << endl;
    }
  }
}



Measured memory_bytes: 3096
def solve(s, x, y):
    def update(move):
        ncx = set()
        cx = cxy[is_x]
        for x in cx:
            ncx.add(x + move)
            ncx.add(x - move)
        cxy[is_x] = ncx

    spl = map(len, s.split('T'))
    is_x = 1
    cxy = [{next(spl)}, {0}]
    for l in spl:
        update(l)
        is_x ^= 1

    return x in cxy[0] and y in cxy[1]


s = input()
x, y = map(int, input().split())
print('Yes' if solve(s, x, y) else 'No')


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

int main()
{
    int n;
    std::cin >> n;
    switch (n) {
    case 1:
        std::cout << "Hello World" << std::endl;
        break;
    case 2:
        int a, b;
        std::cin >> a >> b;
        std::cout << a + b << std::endl;
        break;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<algorithm>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

template<typename T>
std::vector<std::vector<T>> mk2d(size_t s1, size_t s2, T const& val) {
  std::vector<T> tmp(s2, val);
  return std::vector<std::vector<T>>(s1, tmp);
}

struct V { int x, y; V(int x_=0, int y_=0): x(x_), y(y_) {} };

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

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int N; std::cin >> N;
  auto wall = mk2d<bool>(N+2, N+2, true);
  auto dist = mk2d<int>(N+2, N+2, 0);
  for(int i = 0; i < N; ++i) {
    int mi = std::min(i, N-1-i);
    for(int j = 0; j < N; ++j) {
      int mj = std::min(j, N-1-j);
      dist[i+1][j+1] = std::min(mi, mj);
    }
  }
auto f = [&]() {
std::cout << "\n"; 
for(int y = 0; y < N; ++y) {
  for(int x = 0; x < N; ++x) std::cout << dist[x][y];
  std::cout << "\n";
}
};
  int ans = 0;
  for(int n = 0; n < N*N; ++n) {
    int P; std::cin >> P; --P;
    int i = P%N, j = P/N;
    ans += dist[i+1][j+1];
    // bfs
    wall[i+1][j+1] = false;
    std::queue<V> q;
    q.emplace(i+1, j+1);
    while(!q.empty()) {
      V v = q.front(); q.pop();
      int d = dist[v.x][v.y] + (wall[v.x][v.y]? 1: 0);
      for(int k = 0; k < 4; ++k) {
        int nx = v.x + dx[k];
        int ny = v.y + dy[k];
        if(dist[nx][ny] > d) {
           dist[nx][ny] = d;
           q.emplace(nx, ny);
        }
      }
    }
  }
  fin(ans);
  return 0;
}


Measured memory_bytes: 4648
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(10 ** 7)

#import math
#import numpy as np
N, M = map(int, input().split())
xy = [list(map(int, input().split())) for _ in range(M)]

G = {i: [] for i in range(1, N + 1)}

for x, y in xy:
    G[x].append(y)

dp = [-1] * (N + 1)

def dfs(num):
    if dp[num] != -1:
        return dp[num]

    t = 0

    for g in G[num]:
        t = max(t, dfs(g) + 1)

    dp[num] = t
    return t

ans = 0
for i in range(1, N + 1):
    ans = max(ans, dfs(i))

print(ans)

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

long long step[40];

void count() {
  step[0] = 1;
  step[1] = 1;
  step[2] = 2;
  for(int i = 3; i < 40; i++) {
    step[i] = step[i-1] + step[i-2] + step[i-3];
  }
}

int main() {
  int n;
  count();
  while(cin >> n, n) {
    int ans = step[n]/3650 + 1;
    cout << ans << endl;
  }
}

Measured memory_bytes: 1164
#include "bits/stdc++.h"
using namespace std;

class Vertice{
    private:
    int idx;
    vector<Vertice*> neighbors;
    public:
    void clear(){
        this->neighbors.clear();
    }
    void addNeighbor(Vertice* neighbor){
        this->neighbors.push_back(neighbor);
    }
    vector<Vertice*> &getNeighbors(){
        return this->neighbors;
    }
    void setIndex(const int index){
        this->idx=index;
    }
    int getIndex(){
        return this->idx;
    }
};

class Operation{
    private:
    int v, d, c;
    public:
    Operation(const int lhs, const int mhs, const int rhs){
        this->v=lhs;
        this->d=mhs;
        this->c=rhs;
    }
    int getV() const{
        return this->v;
    }
    int getD() const{
        return this->d;
    }
    int getC() const{
        return this->c;
    }
};

vector<int> painting(const int n, const vector<Operation> &operations, const vector<Vertice> &vertices){
    vector<int> foo(n, -1);
    vector<int> dst(n, 0);
    vector<int> vst(n, -1);
    for(int i=operations.size()-1; i>=0; i--){
        const Operation &operation=operations[i];
        queue<Vertice*> que;
        dst[operation.getV()]=operation.getD();
        if(dst[operation.getV()]>vst[operation.getV()]){
            vst[operation.getV()]=dst[operation.getV()];
            que.push((Vertice*)(&vertices[operation.getV()]));
        }
        for(; !que.empty(); que.pop()){
            Vertice *u=que.front();
            if(!~foo[u->getIndex()])
                foo[u->getIndex()]=operation.getC();
            if(dst[u->getIndex()]>0){
                for(Vertice *v : u->getNeighbors()){
                    if(dst[u->getIndex()]-1>vst[v->getIndex()]){
                        dst[v->getIndex()]=dst[u->getIndex()]-1;
                        que.push(v);
                        vst[v->getIndex()]=dst[v->getIndex()];
                    }
                }
            }
        }
    }
    for(int &x : foo){
        x=max(x, 0);
    }
    return foo;
}

int main(){
    int n, m, q;
    while(scanf("%d%d", &n, &m)!=EOF){
        vector<Vertice> vertices;
        vertices.resize(n);
        for(int i=0; i<n; i++){
            vertices[i].setIndex(i);
        }
        for(int i=0; i<m; i++){
            int u, v;
            scanf("%d%d", &u, &v);
            u--;
            v--;
            vertices[u].addNeighbor(&vertices[v]);
            vertices[v].addNeighbor(&vertices[u]);
        }
        scanf("%d", &q);
        vector<Operation> operations;
        for(int i=0; i<q; i++){
            int v, d, c;
            scanf("%d%d%d", &v, &d, &c);
            operations.push_back(Operation(v-1, d, c));
        }
        vector<int> foo=painting(n, operations, vertices);
        for(const int r : foo){
            printf("%d\n", r);
        }
    }
    return 0;
}


Measured memory_bytes: 10480
#include <bits/stdc++.h>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
const int MOD=1000000007;

bool isPowerOfTwo (ll x)  
{  
    return x && (!(x&(x-1)));  
}
bool isPrime(int n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
int highestPowerof2(unsigned int n) 
{ 
    // Invalid input 
    if (n < 1) 
        return 0; 
  
    int res = 1;
    for (int i=0; i<8*sizeof(unsigned int); i++) 
    { 
        int curr = 1 << i; 
        if (curr > n) 
           break; 
  
        res = curr; 
    } 
  
    return res; 
} 
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}       
////////////////////////////////////////////////////////////////////
ll k;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(NULL);
  int t=1;
  while(t--)
  {
    ll n;
    cin>>n;
    ll a[n];
    REP(i,n)cin>>a[i];
    ll ans=0;
    for(ll i=0;i<61;i++)
    {
        ll z=0,o=0;
        for(ll j=0;j<n;j++)
        {
            if((a[j]>>i)&1)
            o++;
            else z++;
        }
        k=(1LL<<i);
        k%=MOD;
        k*=(o*z)%MOD;
        ans+=k;
        ans%=MOD; 
    }
    printf("%I64d",ans);
  }  
  return 0;
}

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

int main() {
	// your code goes 
	long long int n,k;
	cin>>n>>k;
	long long int a[n];
	for(long int i=0;i<n;i++)
	{
	    cin>>a[i];
	}
	long long int l=1,r=1e9;
	long long int ans=1e9;
	while(l<=r)
	{
	    long long int mid = (l+r)/2;
	    long long int ss=0;
	    for(long int i=0;i<n;i++)
	    {
	        ss+=a[i]/mid;
	        if(a[i]%mid==0)
	        ss--;
	    }
	    if(ss>k)
	    {
	        l=mid+1;
	    }
	    else
	    {
	        ans=min(ans,mid);
	        r=mid-1;
	    }
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 5148
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define LEN 101
int judgeAsRing(char*,char*);
int main(void)
{
  char str1[LEN];
  char str2[LEN];
  scanf("%s%s",str1,str2);
  if(judgeAsRing(str1,str2)==1) printf("Yes\n");
  else printf("No\n");
  return 0;
}
int judgeAsRing(char *str1,char *str2)
{
  char *ringStr=(char*)malloc(sizeof(char)*(strlen(str1)*2+1));
  strcpy(ringStr,str1);
  strcpy(ringStr+strlen(str1),str1);
  if(strstr(ringStr,str2)!=NULL) return 1;
  else return 0;
}


Measured memory_bytes: 2112
import copy

N=int(input())
ANS=[]
def next_s(L,x):
    #print(L,x)
    if min(L)!=-1:
        ANS.append(L)
        return
    EMPTY=[]
    for i in range(N):
        if L[i]==-1:
            EMPTY.append(i)

    L[EMPTY[0]]=x

    LEN=len(EMPTY)-1
    for i in range(1<<LEN):
        S=copy.deepcopy(L)
        for j in range(LEN):
            if i & (1<<j)!=0:
                S[EMPTY[j+1]]=x

        #print(i,L,S)

        next_s(S,x+1)

next_s([-1]*N,0)

ANS.sort()
for al in ANS:
    b=[chr(a+97) for a in al]
    print("".join(b))
                
            


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

int main() {
    int h, w;
    while(true) {
        cin >> h >> w;
        if (h == 0 && w == 0) {
            break;
        }
        for (int i = 0;i < h;i++) {
            for (int j = 0;j < w;j++) {
                cout << '#';
            }
            cout << '\n';
        }
        cout << '\n';
    }
}


Measured memory_bytes: 3056
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>
#include <iterator>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define INF 1000000007
#define int long long

typedef pair<int, int> pint;
typedef long long ll;

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

signed main()
{
    int N;
    cin >> N;
    int data[N];
    rep(i, N)
    {
        cin >> data[i];
    }

    int ans = data[0];
    rep(i, N - 1)
    {
        if (data[i + 1] % ans == 0)
        {
            ans = data[i + 1];
        }
        else if (ans % data[i + 1] == 0)
        {
            continue;
        }
        else
        {
            int tmp = gcd(ans, data[i + 1]);
            data[i + 1] /= tmp;
            ans *= data[i + 1];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int length = scanner.nextInt();
        final int counter = scanner.nextInt();
        scanner.nextLine();

        final String people = "1" + scanner.nextLine() + "1";
        final List<OneIndex> oneIndexList = new ArrayList<>();

        for (int i = 0; i < people.length(); i++) {
            if (people.charAt(i) == '0') {
                continue;
            }

            int j = i;
            for (; j < people.length(); j++) {
                if (people.charAt(j) == '0') {
                    break;
                }
            }

            oneIndexList.add(new OneIndex(i, j));
            i = j;
        }

        if (oneIndexList.size() <= counter) {
            System.out.println(length);
            return;
        }

        final int[] results = new int[oneIndexList.size() - counter];
        for (int i = 0; i < results.length; i++) {
            results[i] = oneIndexList.get(i + counter).getEnd() - oneIndexList.get(i).getBegin();
        }

        results[0]--;
        results[results.length - 1]--;

        Arrays.sort(results);

        System.out.println(results[results.length - 1]);
    }

    static class OneIndex {
        private final int begin;
        private final int end;

        OneIndex(final int begin, final int end) {
            this.begin = begin;
            this.end = end;
        }

        int getBegin() {
            return begin;
        }

        int getEnd() {
            return end;
        }
    }
}


Measured memory_bytes: 28348
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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

const ll MOD = 1000000007;
const int INF = 1<<29;
//const ll INF = (ll)1e18 + 1;

int main(){
  string S; cin >> S;
  string tmp_pre, tmp_post;
  int N = S.size();
  for (int i = 0; i < 2; ++i){
    tmp_pre += S[i];
    tmp_post += S[i + 2];
  }
  int pre, post;
  for (int i = 0; i < 2; ++i){
    pre += pow(10, -i + 1) * (tmp_pre[i] - '0');
    post += pow(10, -i + 1) * (tmp_post[i] - '0');
  }

  bool pre_MM = false, post_MM = false;
  if (pre >= 1 && pre <= 12) pre_MM = true;
  if (post >= 1 && post <= 12) post_MM = true;

  if (pre_MM && post_MM) cout << "AMBIGUOUS" << endl;
  else if (pre_MM && !post_MM) cout << "MMYY" << endl;
  else if (!pre_MM && post_MM) cout << "YYMM" << endl;
  else cout << "NA" << endl;
}


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();
    List<Integer> arr = new ArrayList<>();
    int count = 0;
    for(int i = 0; i < n; i++) {
      arr.add(sc.nextInt());
    }
    for(int i = 0; i < n; i++) {
      for(int j = n - 1; j > i; j--) {
        if(arr.get(j) < arr.get(j - 1)) {
          int v = arr.get(j);
          arr.set(j, arr.get(j - 1));
          arr.set(j - 1, v);
          count++;
        }
      }
      if(i == n - 1) {
        System.out.println(arr.get(i));
        System.out.println(count);
      } else {
        System.out.print(arr.get(i) + " ");
      }
    }
  }
}



Measured memory_bytes: 26388
from collections import Counter
N = int(input())
A = list(map(int, input().split()))

A.sort()
max_num = A[-1]
counter = Counter(A)
s = set()
cnt = 0
for a in A:
    if a in s:
        continue
    if counter[a] == 1:
        cnt += 1
    idx = 1
    while a * idx <= max_num:
        s.add(a * idx)
        idx += 1
print(cnt)

        


Measured memory_bytes: 103208
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <string>
#include <queue>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

using namespace std;

int c[3][3];

int main()
{
    REP(i, 3) {
        REP(j, 3) {
            cin >> c[i][j];
        }
    }
    if (c[0][0] - c[0][1] != c[1][0] - c[1][1] || c[1][0] - c[1][1] != c[2][0] - c[2][1]) {
        cout << "No" << endl;
        return 0;
    }
    if (c[0][0] - c[0][2] != c[1][0] - c[1][2] || c[1][0] - c[1][2] != c[2][0] - c[2][2]) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
H=list(map(int,input().split()))
l = [[]*i for i in range(N)]
for i in range(M):
    A,B=map(int,input().split())
    l[A-1].append(B)
    l[B-1].append(A)
ans=0
for j in range(N):
    if all(H[elem-1] < H[j] for elem in l[j])==True:
        ans +=1
print(ans)

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

public class Main {

    public static void main(String[] args) throws IOException {

        BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
        String line = stdin.readLine();

        int i = Integer.valueOf(line);
        if(i >= 30 )
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}


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

int main() {
    ll n, m;
    cin >> n >> m;

    if (n == 1 && m == 1)
        cout << 1;
    else if (n == 1 || m == 1)
        cout << max(n, m) - 2;
    else
        cout << (n - 2) * (m - 2);

    cout << endl;

    return 0;
}

Measured memory_bytes: 256