akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define MAXN 100005
#define trace(x) cout<<#x<<" = "<<x<<'\n'
#define trace2(x, y) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<'\n'
#define trace3(x, y, z) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<'\n'
#define sz(x) (int)(x).size()
using namespace std;
struct ii {
	int a, b;
	bool operator < (ii o) const { return tie(a, b) < tie(o.a, o.b); }
};
struct iii {
	int a, b, c;
	bool operator < (iii o) const { return tie(a, b, c) < tie(o.a, o.b, o.c); }
};
int TC, N, M, K, Q, x, y, z;

int arr[MAXN];

int main() {
	#ifdef FAIRUZI10
	freopen("/home/fairuzi/Documents/CP/input.in", "r", stdin);
	#endif
	
	scanf("%d", &N);
	int state = 0;
	int ans = 1;
	scanf("%d", &arr[0]);
	for (int i = 1; i < N; i++) {
		scanf("%d", &arr[i]);
		if (state == 0) {
			if (arr[i-1] < arr[i]) state = 1;
			else if (arr[i-1] > arr[i]) state = 2;
		} else if (state == 1 && arr[i-1] > arr[i]) {
			ans++;
			state = 0;
		} else if (state == 2 && arr[i-1] < arr[i]) {
			ans++;
			state = 0;
		}
	}
	printf("%d\n", ans);
	
	return 0;
}



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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = INT_MAX / 2; const ll INF = LLONG_MAX / 2;
//template end



int main(){
    int n,m; scanf("%d%d",&n,&m);
    vector<int> a(m),c(m,0);
    rep(i,0,m){
        int b; scanf("%d%d",&a[i],&b);
        rep(j,0,b){
            int p; scanf("%d",&p); p--;
            c[i]|=(1<<p);
        }
    }
    int dp[1<<12]; Fill(dp,inf); dp[0]=0;
    rep(mask,0,1<<n){
        rep(i,0,m){
            chmin(dp[mask|c[i]],dp[mask]+a[i]);
        }
    }
    printf(dp[(1<<n)-1]==inf?"-1\n":"%d\n",dp[(1<<n)-1]);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}



signed main(){
    int a, n;
    cin >> n >> a;
    if(n%500 > a ) cout <<"No\n";
    else cout <<"Yes\n";
  
  return 0;
}



struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;



Measured memory_bytes: 256
n=int(input())
a=input().split()
for j in range(n):
    a[j]=int(a[j])
m=[]
m.append(a[0])
for k in range(n-1):
    x=max(m)
    if x<=a[k+1]:
        m.append(a[k+1])
print(len(m))

Measured memory_bytes: 3060
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,a) for(ll i=0;i<a;i++)
#define jkl ll debug = 0;
#define RREP(i,a) for(ll i=a;i>0;i--)
#define rrep(i,a,b) for(ll i=a-1;i>=b;i--)
#define printall(n,array) {for(ll i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
#define mp make_pair
typedef long long ll;
typedef pair<ll, ll> Pi;
typedef pair<ll, Pi> V;
typedef vector<ll> VE;
const ll mod = 1e9 + 7; //10^9+7

int main(){
    ll n, m;
    cin >> n >> m;
    ll maxGcd = m / n;
    RREP(i, maxGcd){
        if(m % i)continue;
        ll cnt = m / i;
        if(cnt < n)continue;
        print(i);
        return 0;
    }
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0LL)
#define mapmin(v) v.rbegin()->first
#define mapmax(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK cerr<<"OK\n"
#define OK1 cerr<<"OK1\n"
#define OK2 cerr<<"OK2\n"
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n
#define endl '\n'

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const ll mod=1000000007;
const ll mod2=998244353;

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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;}

void YES(bool b) {cout << ((b)?"YES\n":"NO\n");}
void Yes(bool b) {cout << ((b)?"Yes\n":"No\n");}
void yes(bool b) {cout << ((b)?"yes\n":"no\n");}
void Yay(bool b) {cout << ((b)?"Yay!\n":":(\n");}

void out(){cout << "\n";}
template<class T,class... Args>
void out(const T &x,const Args &... args){
	cout << x << " ";
	out(args...);
}

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll h,w,a,b;
	cin >> h >> w >> a >> b;
	rep(i,h){
		rep(j,w){
			if((i<b && j<a) || (i>=b && j>=a)) cout << 0;
			else cout << 1;
		}
		cout << endl;
	}
}

Measured memory_bytes: 1280
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        StringBuilder sb = new StringBuilder();
        while (true) {
            int n = sc.nextInt();
            if (n == 0) {
                break;
            }
            int[] dice = new int[]{1, 2, 6, 5, 3, 4};
            int total = 1;
            for (int i = 0; i < n; i++) {
                String order = sc.next();
                if (order.equals("North")) {
                    int tmp = dice[0];
                    dice[0] = dice[1];
                    dice[1] = dice[2];
                    dice[2] = dice[3];
                    dice[3] = tmp;
                } else if (order.equals("South")) {
                    int tmp = dice[0];
                    dice[0] = dice[3];
                    dice[3] = dice[2];
                    dice[2] = dice[1];
                    dice[1] = tmp;
                } else if (order.equals("East")) {
                    int tmp = dice[0];
                    dice[0] = dice[5];
                    dice[5] = dice[2];
                    dice[2] = dice[4];
                    dice[4] = tmp;
                } else if (order.equals("West")) {
                    int tmp = dice[0];
                    dice[0] = dice[4];
                    dice[4] = dice[2];
                    dice[2] = dice[5];
                    dice[5] = tmp;
                } else if (order.equals("Right")) {
                    int tmp = dice[1];
                    dice[1] = dice[4];
                    dice[4] = dice[3];
                    dice[3] = dice[5];
                    dice[5] = tmp;
                } else if (order.equals("Left")) {
                    int tmp = dice[1];
                    dice[1] = dice[5];
                    dice[5] = dice[3];
                    dice[3] = dice[4];
                    dice[4] = tmp;
                }
                total += dice[0];
            }
            sb.append(total).append("\n");
        }
        System.out.print(sb);
    }
}



Measured memory_bytes: 33344
[N,K]=list(map(int, input().split()))
p=list(map(int, input().split()))

def ex(p,n):
    return (p[n]+1)/2


list=[]
s=0
for i in range (0,N):
    s=s+ex(p,i)
    list.append(s)

max=list[K-1]
for i in range (0,N-K):
   if list[i+K]-list[i] >= max:
        max=list[i+K]-list[i]
        
print(max)

Measured memory_bytes: 75784
while true
	a,op,b = gets.split
	a = a.to_i
	b = b.to_i
	if op == "?"
		break
	elsif op == "+"
		puts a + b
	elsif op == "-"
		puts a - b
	elsif op == "*"
		puts a * b
	else
		puts a / b
	end
end


Measured memory_bytes: 8880
#include <iostream>

using namespace std;

int n, a, b;
int mc = 0;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> a >> b;
	int ct = 0;
	while (true) {
		if (ct == 0) {
			if (a < b-1) a++;
			else if (a == b-1 && a > 1) a--;
			else {
				cout << "Borys\n";
				return 0;
			}
		}
		else {
			if (b > a+1) b--;
			else if (b == a+1 && b < n) b++;
			else {
				cout << "Alice\n";
				return 0;
			}
		}
		ct = (ct+1)%2;
		mc++;
		if (mc > 10000000) {
			cout << "Draw\n";
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)){
			while(true){
				int H = sc.nextInt();
				int W = sc.nextInt();

				if(H ==0 && W == 0)break;

				for(int i = 0;i < H;i++) {
					for(int j = 0;j < W;j++) {
						System.out.print("#");
					}
					System.out.println("");
				}
				System.out.println("");
			}
		}
	}
}


Measured memory_bytes: 34468
//
//  main.cpp
//  Atcoder
//

#include <cstdio>
#include <queue>
#include <algorithm>
using namespace std;
int H,W;
const int maxn=1000+10;
char A[maxn][maxn];
struct Node{int i,j,level;};

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


bool check(int x,int y){
    return x>0&&x<=H&&y>0&&y<=W;
}
int bfs(){
    int ans=0;
    queue<Node>q;
    for(int i=1;i<=H;i++){
        for(int j=0;j<=W;j++){
            if(A[i][j]=='#'){
                q.push(Node{i,j,0});
            }
        }
    }
    
    while(!q.empty()){
        Node cur=q.front();q.pop();
        for(int i=0;i<4;i++){
            int x=cur.i+dx[i],y=cur.j+dy[i];
            if(check(x,y)&&A[x][y]=='.'){
                A[x][y]='#';
                q.push(Node{x,y,cur.level+1});
                ans=max(ans,cur.level+1);
            }
        }
    }
    return ans;
}

int main(int argc, const char * argv[]) {
    
    scanf("%d%d",&H,&W);
    for(int i=1;i<=H;i++){
        scanf("%s",A[i]+1);
    }
    int ans=bfs();
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 13328
#include <stdio.h>

int
main()
{
	for (;;)
	{
		int w, h;
		scanf("%d %d", &h, &w);

		if (w == 0 && h == 0)
			break;

		int x, y;
		int is_hash;
		for (y = 0; y < h; y++)
		{
			for (x = 0; x < w; x++)
			{
				is_hash = (x+y)%2 == 0;
				printf("%c", is_hash ? '#' : '.');
			}
			printf("\n");
		}
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 572
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;

int main() {
    int i,j,k;
    //vector<vector<int>> b(3, vector<int>(3));
    int b[3][3];
    for (i=0; i<3; i++)
    {
        for (j=0; j<3; j++)
        {
            cin >> b[i][j];
        }
    }
   int n;
    cin >> n;
    for (i=0; i<n; i++)
    {
        int tmp;
        cin >> tmp;
        for (j=0; j<3; j++)
        {
            for (k=0; k<3; k++)
            {
                if(b[j][k] == tmp)
                    b[j][k] = 0;
            }
        }
    }

    if ((!b[0][0]&&!b[1][1]&&!b[2][2]) || (!b[0][2]&&!b[1][1]&&!b[2][0]) ||(!b[0][0]&&!b[0][1]&&!b[0][2]) ||(!b[1][0]&&!b[1][1]&&!b[1][2]) ||(!b[2][0]&&!b[2][1]&&!b[2][2]) ||(!b[0][0]&&!b[1][0]&&!b[2][0]) ||(!b[0][1]&&!b[1][1]&&!b[2][1]) ||(!b[0][2]&&!b[1][2]&&!b[2][2]))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
void chmax(LL& a, LL b) {
	a = max(a, b);
}
void chmin(LL& a, LL b) {
	a = min(a, b);
}

template<typename T>
void IN(vector<T> &A,int N=-1) {
	if (N == -1) {
		N = A.size();
	}
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
}

template<typename T>
void SO(vector<T> &A,bool F=false) {
	sort(A.begin(), A.end());
	if (F) {
		reverse(A.begin(), A.end());
	}
}
//////////////

void solve() {
	int N;
	cin >> N;
	vector<LL> B(N);
	IN(B);
	SO(B);

	int len = N;
	LL ans = 0;
	for (int i = 0; i < len; ++i) {
		for (int j = i + 1; j < len; ++j) {
			LL terL = 0;
			chmax(terL, B[i] - B[j]);
			chmax(terL, B[j] - B[i]);

			LL R = lower_bound(B.begin(), B.end(), B[i] + B[j]) - B.begin();
			LL L = upper_bound(B.begin(), B.end(), terL) -B.begin();
			chmax(L, j + 1);
			LL res = R - L;
			chmax(res, 0);
			ans += res;
		}
	}
	cout << ans << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


Measured memory_bytes: 256
using System;

namespace atcoderA
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int a = input[0];
            int b = input[1];
            int c = input[2];
            int d = input[3];
            int ab = Math.Abs(a - b);
            int bc = Math.Abs(b - c);
            int ac = Math.Abs(a - c);

            if (ac <= d)
            {
                Console.WriteLine("Yes");
            }
            else if (ab <= d && bc <= d)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


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

#define in cin
#define out cout

#define REP(i,n) for(int i=0; i<n; i++)
#define REP2(i,s,e) for(int i=s; i<e; i++)
#define REPE(i,s,e) for(int i=s; i<=e; i++)
#define REPR(i,s,e) for(int i=s; i>=e; i--)

#define all(v) v.begin(), v.end()
#define pb push_back

#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define rd(n) scanf("%d", &n)

#define x first
#define y second
#define intINF 2147483647
#define llINF 9223372036854775807LL
#define MOD 1000000007

int main()
{
    int a, b, h; in >> a >> b >> h;
    out << (h*(a+b))/2;

    return 0;
}


Measured memory_bytes: 256
from collections import Counter
n = int(input())
s = [input() for _ in range(n)]

ct = [27] * 26
ans = ''
for i in s:
    C = Counter(i)
    for j in range(26):
        k = C[chr(97 + j)]
        ct[j] = min(ct[j], k)

for i in range(26):
    ans += chr(97 + i) * ct[i]
print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,d,e,f,ansz=0,anss=0;
    cin>>a>>b>>c>>d>>e>>f;
    for(int i=0;i<=f;i+=100*a){
        for(int j=0;i+j<=f;j+=100*b){
            for(int k=0;(i+j)/100*e>=k;k+=c){
                for(int l=0;(i+j)/100*e>=k+l&&i+j+k+l<=f;l+=d){
                    if(anss==0)anss=k+l,ansz=i+j+k+l;
                    else if((double)anss/ansz<(double)(k+l)/(i+j+k+l))anss=k+l,ansz=i+j+k+l;
                }
            }        
        }
    }
    cout<<ansz<<" "<<anss<<endl;
    return 0;
}

Measured memory_bytes: 256
S = input()
n = len(S)

if S != S[::-1]:
    print("No")
    exit()

tmp = S[:(n-1)//2]
if tmp != tmp[::-1]:
    print("No")
    exit() 

tmp = S[((n+3)//2)-1:]
if tmp != tmp[::-1]:
    print("No")
    exit()    
print("Yes")

Measured memory_bytes: 3064
r,c=[int(x) for x in input().split()]
s_row=[0 for x in range(c+1)]
for i in range(r):
    row=[int(x) for x in input().split()]
    row.append(sum(row))
    print(" ".join([str(x) for x in row]))
    s_row=[x+y for x,y in zip(s_row,row)]
print(" ".join([str(x) for x in s_row]))

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

int main()
{
    int M, D;
    cin >> M >> D;
    int d1 = 0;
    int d10 = 0;
    int ans = 0;
    for (int i = 1; i <= M; ++i)
    {
        for (int j = 1; j <= D; ++j)
        {
            if (j >= 10)
            {
                d1 = j % 10;
                d10 = j / 10;
            }
            else
            {
                d1 = j;
                d10 = 0;
            }
            if ((d1 >= 2) && (d10 >= 2) && (d1 * d10) == i)
            {
                ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
///Astalavista Code........~CodeSlayer007
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define Br cout<<endl
#define pb push_back
#define mp make_pair
#define fe first
#define se second
#define int long long
#define double long double
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define PT(x) cout << (x) << endl
#define PTT(x) cout << (#x) << " is " << (x) << endl
#define lets_go ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int M = 1e9 + 7;
const int N = 1e6 + 10;
const int IM = 1e15 + 37;
const double PI = 3.1415926535897932384;
void PV(vi v) { for (int i = 0 ; i < v.size() ; i++) cout << v[i] << " " ; cout << endl;}
void PVV(vii v) {for (int i = 0 ; i < v.size() ; i++) cout << v[i].fe << " " << v[i].se << endl;}
void PA(int v[], int n, int x = 0) { for (int i = x ; i < n + x; i++)cout << v[i] << ' ' ; cout << endl;}
void IN(int a[], int n, int x = 0) {for (int i = x; i < n + x; i++)cin >> a[i];}
inline void PP(int n) { cout << n << " ";}
inline void PP(int n, int m) { cout << n << " " << m << endl;}
inline void PP(int n, int m, int q) {  cout << n << " " << m << " " << q << endl;}
inline void PP(int n, int m, int q, int u) {  cout << n << " " << m << " " << q << " " << u << endl;}
inline void op() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
// <=================================================================================================================================
// <=================================================================================================================================


signed  main() {
    //op();
    lets_go
    int i, j, x, y, u, l;
    //int t; cin >> t; while (t--)
    {
        i = j = x = y = u = l = 0;


        char c;
        cin >> c;
        if(isupper(c))
            PT("A");
        else
            PT("a");


        /* */

    }
    return 0;

}


Measured memory_bytes: 3576
N = gets.to_i
puts 111 if 100<=N && N<=111
puts 222 if 112<=N && N<=222
puts 333 if 223<=N && N<=333
puts 444 if 334<=N && N<=444
puts 555 if 445<=N && N<=555
puts 666 if 556<=N && N<=666
puts 777 if 667<=N && N<=777
puts 888 if 778<=N && N<=888
puts 999 if 889<=N && N<=999


Measured memory_bytes: 3836
import sys

A, B = map(int, input().split())
S = input()

if '-' in S[:A]:
    print('No')
    sys.exit()

if S[A] != '-':
    print('No')
    sys.exit()

if '-' in S[A + 1:]:
    print('No')
    sys.exit()

print('Yes')


Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

#define chmax(a, b) (a) = max(a, b)
#define chmin(a, b) (a) = min(a, b)

int D;
vector<int> c(26);
vector<vector<int>> s;

int64_t calc_score(const vector<int>& t) {
  int64_t result = 0;
  vector<int> last(26, -1);
  rep(i, D) {
    const int j = t[i];
    result += s[i][j];
    last[j] = i;
    rep(k, 26) { result -= c[k] * (i - last[k]); }
  }
  return result;
}

int main() {
  cin >> D;

  rep(i, 26) { cin >> c[i]; }

  s.resize(D, vector<int>(26));
  rep(i, D) rep(j, 26) { cin >> s[i][j]; }

  mt19937 rng(111);
  uniform_int_distribution<int> select_day(0, D - 1);
  uniform_int_distribution<int> select_kind(0, 25);

  int64_t score = 0;
  vector<int> sln(D);

  vector<int> last(26, -1);
  rep(i, D) {
    int next;
    int64_t point = numeric_limits<int64_t>::min();
    int64_t penalty = 0;
    rep(j, 26) { penalty += c[j] * (i - last[j]); }
    rep(j, 26) {
      int z = s[i][j] - penalty + c[j] * (i - last[j]);
      if (point < z) {
        point = z;
        next = j;
      }
    }

    last[next] = i;
    sln[i] = next;
    score += point;
  }

  rep(i, D) { cout << sln[i] + 1 << "\n"; }
  cerr << "score = " << score << "\n";

  return 0;
}

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

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

#define LL long long
#define FI ios_base::sync_with_stdio(false); cin.tie(NULL);
#define PREC cout << setprecision(10) << fixed;

const int MOD = 1e9 + 7;
const int INF = 1e9 + 9;
const int MX = 1e5 + 5;

int n,m;
vector<int> G[MX];
int vis[MX];

void dfs(int u) {
	vis[u] = 1;
	for(int i=0;i<G[u].size();i++) {
		int v = G[u][i];
		if(vis[v] != 1) {
			dfs(v);
		}
	}
}

int main()
{
	cin >> n >> m;
	int x,y;
	for(int i=0;i<m;i++) {
		cin >> x >> y;
		G[x].push_back(y);
		G[y].push_back(x);
	}

	int cnt = 0;
	for(int i=1;i<=n;i++) {
		if(vis[i] != 1) {
			cnt++;
			dfs(i);
		}
	}

	cout << cnt - 1 << endl;
	
	return 0;
}


Measured memory_bytes: 9964
import java.io.*;
import java.util.Map;
import java.util.StringTokenizer;

public class Main {
  private static PrintWriter out;

  public static void main(String[] args) {
    Main main = new Main();
    Runtime.getRuntime().addShutdownHook(new Thread(() -> out.close()));
    try {
      main.run(args);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }

  private void run(String[] arguments) throws Exception {
    MyScanner sc = new MyScanner();
    out = new PrintWriter(new BufferedOutputStream(System.out));

    int K = sc.nextInt();
    int ans = 0;
    for (int i = 1; i <= K; i++) {
      for (int j = 1; j <= K; j++) {
        for (int k = 1; k <= K ; k++) {
          int ij = dpf(i, j);
          int ijk = dpf(ij, k);
          ans += ijk;
        }
      }
    }

    out.println(ans);
    out.close();
  }

  int dpf(int i, int j){
    if (j>i){
      int k = i;
      i = j;
      j = k;
    }
    int rest = i%j;
    if (rest==0){
      return j;
    }
    return dpf(j, rest);
  }


  /*          
   * Form: http://codeforces.com/blog/entry/7018
   */
  private class MyScanner {
    BufferedReader br;
    StringTokenizer st;

    MyScanner() {
      br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

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

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

    double nextDouble() {
      return Double.parseDouble(next());
    }

    String nextLine() {
      String str = "";
      try {
        str = br.readLine();
      } catch (IOException e) {
        e.printStackTrace();
      }
      return str;
    }
  }
}


Measured memory_bytes: 34008
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
	char a,b;
	bool aa,bb;
	cin>>a>>b;
	aa=a=='H';
	bb=b=='D';
	if(aa^bb) cout<<'H'<<endl;
	else cout<<'D'<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<stack>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
#define inf 0X3f3f3f3f
#define ll long long
#define N 1011
int a[5];
int main()
{
    int n,m;
    while(~scanf("%d %d",&n,&m))
    {
        memset(a,0,sizeof a);
        int flag=0;
        while(m--)
        {
            int x,y;
            scanf("%d %d",&x,&y);
            if((a[x]!=0&&a[x]!=y)||(x==1&&y==0&&n!=1))
            {
                flag=1;
                continue;
            }
             a[x]=y;
        }
        if(n!=1&&a[1]==0)
            a[1]=1;
        if(flag)
            printf("-1\n");
        else
        {
            for(int i=1; i<=n; i++)
                if(a[i]!=inf)
                    printf("%d",a[i]);
                else
                    printf("0");
            printf("\n");
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  string s; cin >> s;
  int ans=700;
  for(char c: s) if (c == 'o') ans+=100;
  COUT(ans);
  return 0;
}


Measured memory_bytes: 256
n=input()
list=[int(x) for x in input().split()]
count=0
newlist=[int(x) for x in list if x%2==0]
s=[int(x) for x in newlist if x%3==0 or x%5==0]
if len(s)==len(newlist):
  print("APPROVED")
else:
  print("DENIED")

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

int main() {
	int h, w;
	cin >> h >> w;
	vector<vector<vector<int>>>grid(h + 2, vector<vector<int>>(w + 2, vector<int>(2, 0)));
	vector<vector<int>>blacks(0, vector<int>(2));
	for (int i = 1; i < h + 1; i++) {
		for (int j = 1; j < w + 1; j++) {
			char s; cin >> s;
			if (s == '.')grid.at(i).at(j).at(0) = 1;
			else {
				grid.at(i).at(j).at(0) = 2;
				blacks.push_back({ i,j });
			}
			grid.at(i).at(j).at(1) = -1;
		}
	}
	int ct = 1;
	vector<vector<int>>bw(0, vector<int>(2,0));
	int btmp = 0;
	int wtmp = 0;
	for (int i = 0; i < blacks.size(); i++) {
		int x = blacks.at(i).at(0);
		int y = blacks.at(i).at(1);
		if (grid.at(x).at(y).at(1) != -1)continue;
		queue<pair<int, int>>sq;
		sq.push({ x,y });
		while (sq.size() > 0) {
			int xq = sq.front().first;
			int yq = sq.front().second;
			grid.at(xq).at(yq).at(1) = ct;
			int cl = grid.at(xq).at(yq).at(0);
			if (cl == 1) {
				cl++;
				wtmp++;
			}
			else {
				cl--;
				btmp++;
			}
			vector<int>xqa = { xq,xq,xq - 1,xq + 1 };
			vector<int>yqa = { yq - 1,yq + 1,yq,yq };
			for (int i = 0; i < 4; i++) {
				if (grid.at(xqa.at(i)).at(yqa.at(i)).at(0) == cl&& grid.at(xqa.at(i)).at(yqa.at(i)).at(1)== -1) {
					grid.at(xqa.at(i)).at(yqa.at(i)).at(1) = ct;
					sq.push({ xqa.at(i),yqa.at(i) });
				}
			}
			sq.pop();
		}
		bw.push_back({ btmp, wtmp });
		btmp = 0;
		wtmp = 0;
		ct++;
	}
	ll ans = 0;
	for (int i = 0; i < bw.size(); i++)ans += (ll)bw.at(i).at(0) * bw.at(i).at(1);
	cout << ans << endl;
}

Measured memory_bytes: 28972
import java.util.*;
public class Main{
    private static int gcd(int m, int n) {
    if(m < n) return gcd(n, m);
    if(n == 0) return m;
    return gcd(n, m % n);
}
    public static void main(String args[]){
        Scanner sc= new Scanner(System.in);
        int n = sc.nextInt();
        int ans = 0;
        sc.close();
        for(int i=1;i<n+1;i++){
            for(int j=1;j<n+1;j++){
                for(int k=1;k<n+1;k++){
                    ans += gcd(gcd(i,j),k);
                }
            }
        }
        System.out.println(ans);
    }
}

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

class UnionFind{
    public:
    //親の番号を格納する。親だった場合は-(その集合のサイズ)
    vector<int> parent;

    //-1で初期化。最初はすべてバラバラ
    UnionFind(int N){
        parent = vector<int>(N,-1);
    }

    //Aがどのグループに属しているか(Aの根)を調べる
    int root(int A){
        if(parent[A] < 0) return A;
        return parent[A]=root(parent[A]);
    }

    //自分のいるグループの頂点数を調べる
    int size(int A){
        return -parent[root(A)];
    }

    //AとBをくっつける
    bool unite(int A, int B) {
    //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        //既にくっついているからくっつけない
        if(A == B) return false; 

        //大きいほう(A)に小さいほう(B)をくっつける
        //大小が逆ならひっくり返す
        if(size(A) < size(B)) swap(A,B);

        //Aのサイズを更新する
        parent[A] += parent[B];
        //Bの親をAに変更する
        parent[B] = A;

        return true;
    }

    //AとBが同じグループならtrueを返す
    bool same(int A, int B){
        return root(A)==root(B);
    } 
};

vector<vector<array<ll,2>>> v(4444);
ll sum = 0;
bool used[4444];
ll ans[4040][4040];

void dfs(int r,int p, ll dist){
    used[p]=1;
    ans[r][p] = dist;
    for(auto i:v[p]){
        if(!used[i[0]]){
            dfs(r,i[0],max(dist,i[1]));
        }
    }
}


signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    
    ll n,m;
    cin>>n>>m;
    UnionFind uni(n);
    array<ll,3> a[m];
    for(int i=0;i<m;i++){
        ll e,b,c;
        cin>>e>>b>>c;
        e--,b--;
        a[i] = {c,e,b};
    }
    sort(a,a+m);

    for(int i=0;i<m;i++){
        if(!uni.same(a[i][1],a[i][2])){
            sum += a[i][0];
            uni.unite(a[i][1],a[i][2]);
            v[a[i][1]].push_back({a[i][2],a[i][0]});
            v[a[i][2]].push_back({a[i][1],a[i][0]});
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++) used[j]=0;
        dfs(i,i,0);
    }
    int q;
    cin>>q;
    while(q--){
        int s,t;
        cin>>s>>t;
        s--,t--;
        cout << sum - ans[s][t] << "\n";
    }
    
}

Measured memory_bytes: 138240
// Math = ♥️

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

/*-------------------------------------------------------------------------------------------------------------------------*/
#define ll long long                  // Short form for long long
#define ld long double                // Short form for long double
typedef pair<ll, ll> ii;              // Pair of long long
typedef vector<ll> vi;                // Vector of long long
typedef vector<vi> vvi;               // Vector of vector of long long
typedef vector<ii> vii;               // Vector of pairs
typedef vector<vii> vvii;             // Vector of vector of pairs
#define pq priority_queue             // Max heap (To convert to min heap, use negative sign before every value)
#define ff first                      // For pairs
#define ss second                     // For pairs
#define pb push_back                  // Pushback to vector
#define mp make_pair                  // Makes pairs to be stored as pair
#define all(c) (c).begin(), (c).end() // Mainly used by me in sorting
// ordered_set adds two new functions to set - (set).find_by_order([kth element based on zero indexing]) and order_of_key()
// order_of_key returns number of elements less that parameter. If element exists, that order is its index
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
/*-------------------------------------------------------------------------------------------------------------------------*/

int main(void)
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n, k;
    cin >> n >> k;

    vi arr(n);
    for (int i = 0; i < n; i++)
        cin >> arr[i];

    ll dp[n];
    dp[0] = 0;
    for (int i = 1; i < n; i++)
    {
        dp[i] = dp[i - 1] + llabs(arr[i] - arr[i - 1]);
        for (int j = 2; i - j >= 0 && j <= k; j++)
            dp[i] = min(dp[i], dp[i - j] + llabs(arr[i] - arr[i - j]));
    }

    cout << dp[n - 1] << "\n";
}


Measured memory_bytes: 1792
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.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;
}

vector<int> as;
vector<int> bs;

vector<int> s_as;
vector<int> s_bs;

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

    as.resize(N);
    bs.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> as[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> bs[i];
    }

    s_as.resize(N + 1, 0);
    for (int i = 0; i < N; i++) {
        s_as[i + 1] = s_as[i] + as[i];
    }

    s_bs.resize(N + 1, 0);
    for (int i = 0; i < N; i++) {
        s_bs[i + 1] = s_bs[i] + bs[i];
    }

    int ans = 0;
    for (int i = 1; i <= N; i++) {
        int cand = s_as[i] + (s_bs[N] - s_bs[i - 1]);
        // printf("%d: %d\n", i, cand);
        chmax(ans, cand);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3644
from math import sqrt
def factorint(n):
    d = {}
    for i in range(2, int(sqrt(n))+1):
        c = 0
        q, r = divmod(n, i)
        while not r:
            c += 1
            n = q
            q, r = divmod(n, i)
        if c:
            d[i] = c
    if n != 1:
        d[n] = 1
    return d

n = int(input())
if n == 1:
    print(0)
else:
    d = factorint(n)
    s = 0
    for v in d.values():
        s += int((sqrt(8*v+1)-1)/2)
    print(s)

Measured memory_bytes: 9228
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func main() {
	sc := NewScanner()
	S := sc.nextStr()
	max := 0
	count := 0
	for _, r := range S {
		if r == 'A' || r == 'C' || r == 'G' || r == 'T' {
			count++
		} else {
			if max < count {
				max = count
			}
			count = 0
		}
	}
	if max < count {
		max = count
	}
	fmt.Println(max)
}


Measured memory_bytes: 640
#include<stdio.h>

int main()
{
	char S[15];
	int i, temp, count = 0,nokori;
	for (i = 0; ; i++) {
		scanf("%c", &S[i]);
		if (S[i] == '\n' || S[i] == '\0') {
			break;
		}
		if (S[i] == 'o') {
			count++;
		}
	}

	nokori = 15 - i;

		if (count + nokori>= 8) {
			puts("YES");
		}
		else {
			puts("NO");
		}
		return 0;
	}



Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;typedef long long ll;
#define inf 0x3f3f3f3f
#define read(x) scanf("%d",&x)
#define lowbit(x) (x&-x)
const int N=3e5+7;
int T;
int n,m;
int a[N],p[N],tot;
struct node{
    int mx,l,r;
}t[N<<2];
inline void build(int p,int l,int r)
{
    t[p].l=l,t[p].r=r;
    if(l==r){t[p].mx=0;return;}
    int mid=l+r>>1;
    build(p<<1,l,mid);
    build(p<<1|1,mid+1,r);
    t[p].mx=0;
}
inline void update(int p,int x,int v)
{
    if(t[p].l==t[p].r){t[p].mx=v;return;}
    int mid=(t[p].l+t[p].r)>>1;
    if(x<=mid) update(p<<1,x,v);
    else update(p<<1|1,x,v);
    t[p].mx=max(t[p<<1].mx,t[p<<1|1].mx);
}
inline int ask(int p,int l,int r)
{
    if(l<=t[p].l&&t[p].r<=r) return t[p].mx;
    int mid=(t[p].l+t[p].r)>>1;
    int ret=0;
    if(l<=mid) ret=max(ret,ask(p<<1,l,r));
    if(r>mid) ret=max(ret,ask(p<<1|1,l,r));
    return ret;
}
int main()
{
    read(n),read(m);
    int ans=0;
    for(int i=1;i<=n;i++) read(a[i]),a[i]++;
    build(1,1,N-1);
    for(int i=1,t;i<=n;i++){
        t=ask(1,max(1,a[i]-m),min(N-1,a[i]+m));
        update(1,a[i],t+1);
        ans=max(ans,t+1);
    }
    printf("%d\n",ans);

    return 0;
}
/**


**/


Measured memory_bytes: 17232
N, M = map(int, input().split())
a = set(int(input()) for i in range(M)) 

A = [1] + [0] * (N)

for i in range(1, N+1):
  if i in a:
    A[i] = 0
  else:
    A[i] = (A[i-1] + A[i-2]) % (10 ** 9 + 7)

print (A[-1])  

Measured memory_bytes: 11884
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
#include<bitset>
using namespace std;

int main() {

	int N, M;
	cin >> N >> M;

	vector<int> X(M, 0);

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

	sort(X.begin(), X.end());

	vector<long long> diff(M - 1, 0);
	for (int i = 0; i < M - 1; i++) {
		diff[i] = (long long)X[i + 1] -(long long) X[i];
	}

	sort(diff.begin(), diff.end());
	
	int v = M - N;
	if (v < 0) {
		v = 0;
	}
	long long ans = accumulate(diff.begin(), diff.begin() + v, (long long)0);

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 1408
#include<stdio.h>
#define N 101

int d[N],f[N],color[N],list[N][N];

void dfp(int);
void visit(int,int);

int main(){
  int num,i,j,k,v;
  
  scanf("%d",&num);
  
  for(i=1; i<=num; i++){
    for(j=1; j<=num; j++){
      list[i][j] = 0;
    }
  }
  
  for(i=1; i<=num; i++){
    scanf("%d%d",&k,&j);
    for(j; j>0; j--){
      scanf("%d",&v);
      list[k][v] = 1;
    } 
  }
  
    dfp(num);
    
     for(i=1; i<=num; i++) printf("%d %d %d\n",i,d[i],f[i]);
    
  return 0;
}


void dfp(int num){
  int i;
  for(i=1; i<=num; i++) color[i]=0;
  for(i=1; i<=num; i++){
    if(color[i] == 0)  visit(i,num);
  }
}

void visit(int r,int num){
  int k=1,S[N],i,u,v,j;
  static int time=0;
  S[k]=r;
  color[r] = 1;
  d[r] = ++time;
  v = r;
  while(&S[k] != &S[0]){
    u = S[k];
    j=v;
    v=0;
    for(i=1; i<=num; i++){
      if(list[j][i] == 1 && color[i] == 0){
	v = i;
	break;
      }
    }
    
    if(v!=0){
      if(color[v] == 0){
	k++;
	S[k] = v;
	color[v] = 1;
	d[v] = ++time;
      }
    }
      else {
	k--;
	color[u] = 2;
	f[u] = ++time;
	v = S[k];
      }  
  } 
}

Measured memory_bytes: 632
h,w = map(int,input().split())
hw = [list(input()) for j in range(h)]
tf = [True for i in range(w)]
ans = []
for i in hw:
  if i.count(".") != w:
    ans.append(i)
  for j in range(len(i)):
    if i[j]=="#":
      tf[j] = False
for i in range(len(ans)):
  for j in range(len(tf)):
    if not tf[j]:
      print(ans[i][j],end='')
  print('')

Measured memory_bytes: 4596
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n, m := scanInt(), scanInt()
	sum := 0
	for i := 0; i < m; i++ {
		a := scanInt()
		sum += a
	}

	if sum > n {
		fmt.Println(-1)
	} else {
		fmt.Println(n - sum)
	}
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() 
{
    int A,B;
    cin >> A >> B;
    string S;
    cin >> S;
    
    string str1, str2;
    for (int i = 0; i < S.size(); i++) {
        if (S[i] == '-') {
            str2 = S.substr(i+1, S.size());
            break;
        }
        str1 += S[i];
    }
    
    if (A != str1.size() || B != str2.size()) {
        cout << "No" << endl;
        return 0;
    }
    for (int i = 0; i < str1.size(); i++) {
        if (!('0' <= str1[i] && str1[i] <= '9')){
            cout << "No" << endl;
            return 0;
        }
    }
    for (int i = 0; i < str2.size(); i++) {
        if (!('0' <= str2[i] && str2[i] <= '9')){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Inf 0x3f3f3f3f
#define int long long 
#define ios std::ios::sync_with_stdio(false);std::cin.tie(0);std::cout.tie(0);
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,n,a) for (int i=n;i>=a;i--)
const int N = 3e5 + 10;
using namespace std;
typedef long long ll;
int x , y , q , w , e ;
int a[N] , b[N] , c[N] ;
queue<int> q1 , q2 , q3 ;
ll quick_power_mod(ll a,ll b,ll m)//pow(a,b)%m
{
    a%=m;
    ll result = 1;
    while(b>0)
    {
        if(b&1)
        result=(result*a)%m;
        a=(a*a)%m;
        b>>=1;
    }
    return result;
}
//计算组合数取模
ll comp(ll a,ll b,int p)//composite num C(a,b)%p
{
    if(a<b)return 0;
    if(a==b)return 1;
    if(b>a-b)b=a-b;
    ll ans=1,ca=1,cb=1;
    for(ll i=0;i<b;i++)
    {
        ca=(ca*(a-i))%p;
        cb=(cb*(b-i))%p;
    }
    ans=(ca*quick_power_mod(cb,p-2,p))%p;
    return ans;
}
ll lucas(ll n,ll m,ll p)
{
    ll ans=1;
    while(n&&m&&ans)
    {
        ans=(ans*comp(n%p,m%p,p))%p;//also can be recusive
        n/=p;
        m/=p;
    }
    return ans;
}
signed main()
{
    lucas(1000,100,1007);
    int ans = 0 ;
    cin >> x >> y >> q >> w >> e;
    rep(i , 1 , q) cin >> a[i];
    rep(i , 1 , w) cin >> b[i];
    rep(i , 1 , e) cin >> c[i];
    sort(a + 1 , a + q + 1 , greater<int>()) ;
    sort(b + 1 , b + w + 1 , greater<int>()) ;
    sort(c + 1 , c + e + 1 , greater<int>()) ;
    for(int i = x ; i >= 1 ; i --)  q1.push(a[i]) ;
    for(int i = y ; i >= 1 ; i --)  q2.push(b[i]) ;
    for(int i = 1 ; i <= e ; i ++)  q3.push(c[i]) ;
    while(!q1.empty() && !q2.empty() && !q3.empty())
    {
        int r = q1.front() ;
        int t = q2.front() ;
        int u = q3.front() ;
        if(r < t)
        {
            q1.pop() ;
            if(r < u)
            {
                ans += u ;
                q3.pop() ;
            }
            else  ans += r ;
        }
        else
        {
            q2.pop() ;
            if(t < u)
            {
                ans += u ;
                q3.pop() ;
            }
            else  ans += t ;
        }
    }
    while(!q1.empty() && !q3.empty())
    {
        int r = q1.front() ;
        int u = q3.front() ;
        q1.pop() ;
        if(r < u)
        {
            ans += u ;
            q3.pop() ;
        }
        else  ans += r ;
    }
    while(!q2.empty() && !q3.empty())
    {
        int t = q2.front() ;
        int u = q3.front() ;
        q2.pop() ;
        if(t < u)
        {
            ans += u ;
            q3.pop() ;
        }
        else  ans += t ;
    }
    while(!q1.empty())
    {
        int r = q1.front() ;
        q1.pop() ;
        ans += r ;
    }
    while(!q2.empty())
    {
        int t = q2.front() ;
        q2.pop() ;
        ans += t ;
    }
    cout << ans << '\n';
    return 0 ;
}

Measured memory_bytes: 7424
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  ui N; cin >> N;
  ui res{N};
  for(ui k = 0; k <= N; ++k){
    // k     =6^p + x円に対してp+x回引き下ろす
    ui s = k;
    ui p{};
    while(s){
      p += s % 6;
      s /= 6;
    }

    // N - k =9^q + y円に対してq+y回引き下ろす 
    ui t = N - k;
    ui q{};
    while(t){
      q += t % 9;
      t /= 9;
    }
    chmin(res, p + q);
  } 

  cout << res << CRLF;
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Measured memory_bytes: 256