akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
typedef long long ll;
const int INF=1001001001;
int main(){
  int N;
  cin>>N;
  vector<int>H(N);
  rep(i,N)cin>>H[i];
  int tmp=0;
  int ans=0;
  rep(i,N-1){
    if(H[i]>=H[i+1])tmp++;
    else tmp=0;
    ans=max(tmp,ans);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<math.h>
#include<string.h>
#include<algorithm>


using namespace std;
#define int long long
#define ld long double
#define all(x) x.begin(),x.end()
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define vi vector<int>
#define vstr vector<string>
#define vbool vector<bool>
#define vvi vector<vector<int> >
#define mii map<int,int>
#define pb push_back
#define pii pair<int,int>
#define vpair vector<pii > 
#define mkp make_pair
#define scan(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) {cout<<a[i]<<' ';}cout<<'\n'
#define mem(a,v) memset(a,v,sizeof(a))
#define loop(i,a,b) for (int i = a; i < b; i++)
#define loope(i,a,b) for (int i = a; i <= b; i++)
#define FastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PRECISION std::cout.unsetf ( std::ios::fixed );std::cout.precision(9)
#define PI 3.14159265
#define S second
#define F first
#define CHECK cout<<"CHEDEDWB"<<endl
#define br '\n'
int mod = 1e9+7;
int inf = 1e18;
int m_inf = INT_MIN;

void solve()
{
	vi arr(5);
	scan(arr,5);
	int k;
	cin>>k;
	bool ok = true;
	loop(i,0,4)
	{
		loop(j,i+1,5)
		{
			int d = abs(arr[j]-arr[i]);
			if(d>k)
			{
				cout<<":("<<endl;
				ok = false;
				break;
			}
		}
		if(!ok)
			break;
	}
	if(ok)
		cout<<"Yay!"<<endl;
}

int32_t main()
{
	FastIO; PRECISION;
	int t = 1;
	//cin>>t;
	while(t--)
		solve();
	return 0;
} 

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int i,n,yen=100000;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    yen=yen+yen*0.05;
    yen=yen+999;
    yen=yen/1000;
    yen=yen*1000;
  }
  printf("%d\n",yen);
  return(0);
}

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

int main(){
    int n,cnt=0,num=0,ans=0;
    cin>>n;
    REP(i,n+1){
        num=i;
        while (true)
        {
            /* code */
            if (num%2==0&&num!=0)
            {
                /* code */
                cnt++;
                num/=2;
            }
            else
            {
                break;
            }
         
        }
                    ans=max(cnt,ans);
            cnt=0;
        
    }
    if (n==1)
    {
        /* code */
        cout<<1<<endl;
    }
    else
    {
        cout<<pow(2,ans)<<endl;

    }
    
    
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main(){
 input!{
    a:i64,
 }
 let ans = a * a * 3;
 println!("{}",ans);
}


fn is_prime(x:i64) -> bool {
    if x == 2 {return true;}
    if x < 2 || x % 2 == 0 {return false;}
    let mut j = 3;
    while j <= (x as f64).sqrt() as i64 {
        if x % j == 0 {
            return false;
        }
        j += 2;
    }
    true
}


Measured memory_bytes: 4352
import java.util.*;

public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        int[] s = new int[n];
        Arrays.fill(s, 20);

        for(int i = 0; i < m; ++i) {
            int sIndex = Integer.parseInt(sc.next()) - 1;
            int sNumber = Integer.parseInt(sc.next());
            if(s[sIndex] == 20) {
                s[sIndex] = sNumber;
            } else if(s[sIndex] >= 0 && sNumber != s[sIndex]) {
                s[sIndex] = -1;
            }
        }

        // System.out.println("s = " + Arrays.toString(s));
        
        if((s[0] == 0 && s.length > 1) || hasNegative(s)) {
            System.out.println(-1);
            return;
        }

        for(int i = 0; i < 1000; ++i) {
            String iStr = String.valueOf(i);
            if(iStr.length() < n) {
                continue;
            }

            if(iStr.length() > n) {
                break;
            }

            if(isValidNumber(iStr, s)) {
                System.out.println(i);
                return;
            }
        }

        System.out.println(-1);

    }

    static boolean hasNegative(int[] s) {
        for(int i = 0, f = s.length; i < f; ++i) {
            if(s[i] < 0) {
                return true;
            }
        }
        return false;
    }

    static boolean isValidNumber(String iStr, int[] s) {
        for(int j = 0, f = s.length; j < f; ++j) {
            if(s[j] == 20) {
                continue;
            }

            if((iStr.charAt(j) - '0') != s[j]) {
                // System.out.println("j = " + j);
                // System.out.println("istr = " + iStr + ", s = " + Arrays.toString(s));
                return false;
            }
        }
        return true;
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll INF = 1ll<<30;
const ll longINF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

int N;
int P[212345], pos[212345];

int main() {
	cin >> N;
	REP(i, N) scanf("%d", P + i);
	REP(i, N) pos[P[i]-1] = i;
	
	int mx = 0;
	REP(i, N) {
		int cur = 0, lp = -1;
		while (i < N && lp < pos[i]) {
			cur++;
			lp = pos[i++];
		}
		
		chmax(mx, cur);
		if (i == N) break;
		i--;
	}
	
	cout << N - mx << endl;
	
	return 0;
}


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

int main()
{
  int N;
  cin >> N;
  bool OK = false;
  for (int i = 0; i <= N / 4; i++)
  {
    for (int j= 0; j <= N / 7; j++)
    {
      if (4 * i + 7 * j == N)
        OK = true;
    }
  }
  if (OK == true)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

int main()
{
  int N,T,A;
  cin >>N >>T >>A ;
  float x=999;
  int bangou;
  for(int i=1;i<=N;i++)
  {
    int H; cin >>H;
    float sa=T-H*0.006;
    sa=A-sa; if(sa<0)sa*=-1;
    if(sa<=x){x=sa;bangou=i;}
  }
cout <<bangou <<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){
  int W, H, x, y, r;
  cin >> W >> H >> x >> y >> r;
  if(x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H){
    cout << "Yes\n";
  } else cout << "No\n";
  return 0;
}


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

int main(){

    string s;
    cin >> s;

    int i=0;
    for(i=0;i<s.size();i++){
        if(s[i]=='A'){
            break;
        }
    }
    for(int j=s.size()-1;j>=0;j--){
        if(s[j]=='Z'){
            cout << j-i+1 << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;
import java.util.Arrays; 
public class Main {
	public static void main(String[] args){
	Scanner scan = new Scanner(System.in);
	int a = scan.nextInt();
	int b = scan.nextInt();
	int c = scan.nextInt();
	int[] intArr = new int[3];
	intArr[0] = a;
	intArr[1] = b;
	intArr[2] = c;
	
	Arrays.sort(intArr);
	System.out.println("" + intArr[0] + " " + intArr[1]
	+ " " + intArr[2]);
}

}



Measured memory_bytes: 26160
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include <string.h>
using namespace std;
int a[2][105];
int dp[2][105];
int n;
int t, x, y, pt, px, py;


int main() {
	int y;
	cin >> n >> y;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n - i; j++) {
			if (y == i * 10000 + j * 5000 + (n -i-j) * 1000) {
				cout << i << " " << j << " " << (n - i - j) << endl;
				return 0;
			}
		}
	}

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

Measured memory_bytes: 256
import std.stdio, std.string, std.algorithm, std.array, std.range, std.conv,
    std.typecons, std.math, std.container, std.format;

// from https://ei1333.github.io/luzhiled/snippets/structure/union-find.html
class UnionFind
{
public:
    long[] par;

    this(long size)
    {
        par = new long[](size);
        foreach (i; 0 .. size)
        {
            par[i] = -1;
        }
    }

    long size(long x)
    {
        return -(par[find(x)]);
    }

    long find(long x)
    {
        if (par[x] < 0)
        {
            return x;
        }
        par[x] = find(par[x]);
        return par[x];
    }

    bool is_same(long x, long y)
    {
        return find(x) == find(y);
    }

    bool unite(long x, long y)
    {
        x = find(x);
        y = find(y);

        if (x == y)
        {
            return false;
        }
        if (par[x] > par[y])
        {
            par[y] += par[x];
            par[x] = y;
        }
        else
        {
            par[x] += par[y];
            par[y] = x;
        }
        return true;
    }
}

void main(string[] args)
{
    alias T = Tuple!(int, int);
    T[][] xss = [];
    long n = readln.strip.to!long;
    foreach (i; 0 .. n)
    {
        long m = readln.strip.to!long;
        T[] xs = [];
        foreach (j; 0 .. m)
        {
            int x, y;
            readf("%d %d\n", &x, &y);
            xs ~= T(x - 1, y);
        }
        xss ~= xs;
    }

    long ans = 0;
    // 下から i bit目 が1 -> i番は正直者としてみる
    foreach (i; 0 .. (2 ^^ n))
    {
        // 矛盾している人がいたらだめ
        bool ok = true;
        check: foreach (j; 0 .. n)
        {
            if (((1 << j) & i) == 0)
            {
                continue;
            }

            foreach (xs; xss[j])
            {
                if (xs[1] == 0 && ((1 << xs[0]) & i) != 0)
                {
                    ok = false;
                    break check;
                }
                if (xs[1] == 1 && ((1 << xs[0]) & i) == 0)
                {
                    ok = false;
                    break check;
                }
            }
        }
        if (ok)
        {
            long cnt = 0;
            while (i > 0)
            {
                if ((i & 1) == 1)
                {
                    cnt++;
                }
                i = i >> 1;
            }
            ans = max(cnt, ans);
        }
    }
    writeln(ans);
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int S,h,m,s;
    cin >> S;
    h = S / 3600;
    m = (S % 3600) / 60;
    s = (S % 3600) % 60;
    cout << h << ":" << m << ":" << s <<endl;
    return 0;
}


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

using namespace std;
#define int long long
#define double long double
#define rep(i, n) for(int i=0;i<(n);++i)
#define INF (1ll<<60)
#define FI first
#define SE second
typedef pair<int, int> pii;
#define l_b lower_bound
#define u_b upper_bound


int A, B, C;

signed main() {
    cin >> A >> B >> C;
    int ans = 0;
    if (A > B)swap(A, B);
    if (A > C)swap(A, C);
    if (B > C)swap(B, C);
    ans += C - B;
    A += C - B;
    if ((C - A) % 2 == 0)ans += (C - A) / 2;
    else ans += 1 + (C + 1 - A) / 2;
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int point1 = 0, point2 = 0;
		String animal1, animal2;
		for (int i = 0; i < n; i++) {
			animal1 = sc.next();
			animal2 = sc.next();
			char[] array1 = animal1.toCharArray();
			char[] array2 = animal2.toCharArray();
			int arrayLength = Math.min(array1.length, array2.length);
			top: for (int j = 0; j < arrayLength; j++) {
				if (array1[j] > array2[j]) {
					point1 += 3;
					break top;
				} else if (array1[j] < array2[j]) {
					point2 += 3;
					break top;
				} else if (j == arrayLength - 1) {
					if (array1.length == array2.length) {
						point1 += 1;
						point2 += 1;
						break top;
					} else if (array1.length > array2.length) {
						point1 += 3;
						break top;
					} else {
						point2 += 3;
						break top;
					}
				}
			}
		}
		System.out.println(point1 + " " + point2);
		sc.close();
	}
}


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

int main(){
  int n; cin>>n;
  int h=n/100, d=n%100;

  int num=0;
  num+=d/5; d%=5;
  num+=d/4; d%=4;
  num+=d/3; d%=3;
  num+=d/2; d%=2;
  num+=d;
  
  if(h>=num)cout<<1<<endl;
  else cout<<0<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  string s;
  cin >> s;
  ll n = s.size();
  ll ans = n;
  rep(i, n - 1) if(s[i] != s[i + 1]) ans = min(ans, max(i + 1, n - i - 1));
  cout << ans << endl;
}

Measured memory_bytes: 3724
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = list(input())

if S[0] == "A" and "C" in S[2:-1]:
	S.remove("A")
	S.remove("C")
else:
	print("WA")
	exit()

for x in S:
	if not x in ascii_lowercase:
		print("WA")
		exit()
else:
	print("AC")

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


int main(){
 
 ll a,b,n;
 cin>>a>>b>>n;
 ll ok=0,num;/*
 rep(i,n+1){
     if(ok<(a*i)/b-a*(i/b)){
     num=i;}
     ok = max(ok,(a*i)/b-a*(i/b));
 }
 cout<<"ok"<<ok<<endl;*/
 if(n<b){
     cout<<(a*n)/b-a*(n/b)<<endl;
     return 0;
 }
 /*
ll x=b-1,mx=0;
while(x<=n){
    mx = max(mx,(a*x)/b-a*(x/b));
    x += b;
    cout<<mx<<endl;
}*/
if(a-a/b-1<=0)cout<<0<<endl; 
else cout<<a-a/b-1<<endl;
return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
	int x,y;
	scanf("%d%d",&x,&y);
	for(int i = 0;i <= x;i++){
		if(2 * i + (x - i) * 4 == y){
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 3768
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}

int dx[] = {0, 1, -1, 0, 1, -1, 1, -1}; // i<4:4way i<8:8way
int dy[] = {1, 0, 0, -1, 1, -1, -1, 1};

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int dp[4005][3]; // dp[i][j] := 右からi番目までの

// 0:Rの数
// 1:Gの数
// 2:Bの数

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n;
    cin >> n;
    string s;
    cin >> s;
    ll ans = 0;
    for (int i = n - 1; i >= 0; i--)
    {
        if (s[i] == 'R')
            dp[i][0]++;
        else if (s[i] == 'G')
            dp[i][1]++;
        else
            dp[i][2]++;
        rep(j, 3) dp[i][j] += dp[i + 1][j];
    }

    for (int i = 0; i < n; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            if (s[i] == s[j])
                continue;
            int dis = j - i;
            if (dis + j >= n)
                dis = 0;
            if (s[i] == 'R')
            {
                if (s[j] == 'G')
                {
                    ans += dp[j + 1][2];
                    if (s[j + dis] == 'B')
                        ans--;
                }
                else if (s[j] == 'B')
                {
                    ans += dp[j + 1][1];
                    if (s[j + dis] == 'G')
                        ans--;
                }
            }
            else if (s[i] == 'G')
            {
                if (s[j] == 'R')
                {
                    ans += dp[j + 1][2];
                    if (s[j + dis] == 'B')
                        ans--;
                }
                else if (s[j] == 'B')
                {
                    ans += dp[j + 1][0];
                    if (s[j + dis] == 'R')
                        ans--;
                }
            }
            else if (s[i] == 'B')
            {
                if (s[j] == 'R')
                {
                    ans += dp[j + 1][1];
                    if (s[j + dis] == 'G')
                        ans--;
                }
                else if (s[j] == 'G')
                {
                    ans += dp[j + 1][0];
                    if (s[j + dis] == 'R')
                        ans--;
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3688
#include <iostream>
#include <string>
#include <algorithm>

int main()
{
  std::string s;
  std::cin >> s;
  std::sort(s.begin(), s.end());
  if(s[0]==s[1] && s[2]==s[3] && s[0]!=s[2])
    std::cout << "Yes" << std::endl;
  else
    std::cout << "No" << std::endl;
  return 0;
}

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

using namespace std;

#define LL long long
#define _rep(i,j,N) for(int i = (j);i <=(N);i++)
#define _for(i,j,N) for(int i = (j);i <(N);i++)
#define ALL(x) x.begin(),x.end()

const int mod = 998244353;
const int maxn = 305;
int N,M;
string G[maxn];

void xors(string &a,string &b){
    _for(i,0,M){
        if(a[i] == b[i]) b[i] = '0';
        else b[i] = '1';
    }
}

int pow_mod(int a,int n,int m){
    if(n == 0) return 1;
    int x = pow_mod(a,n/2,m);
    LL ans = ((LL)x * x) % m;
    if(n & 1) ans = ans * a % m;
    return (int) ans;

}

int main()
{
    cin >> N >> M;
    _for(i,0,N){
        _for(j,0,M){
            string s;
            cin >> s;
            G[i].push_back(s[0]);
        }
    }

    int r = -1;
    _for(i,0,N){
        sort(G+i,G+N,greater<string>());
        int index = -1;
        _for(j,0,M) if(G[i][j] == '1'){index = j;break;}
        if(index == -1){r = i;break;}
        _for(j,i+1,N){
            if(G[j][index] == '1'){
                xors(G[i],G[j]);
            }
        }
    }
    if(r == -1) r = N;
    int a = pow_mod(2,M+N-1,mod);
    int b = pow_mod(2,M+N-r-1,mod);
    int ans = ((LL)a - b + mod)%mod;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
int main ()
{
    int a,b,c;
    scanf ("%d",&a );
    scanf ("%d",&b );
    if ((a==1||b==1) && (a==2||b==2))
    {
       printf("3\n");
    }
    else if ((a==1||b==1) && (a==3||b==3))
    {
        printf("2\n");
    }
    else
    {
        printf("1\n");
    }
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<string> S;
  for(int i = 0; i < N; i++) {
    string s;
    cin >> s;
    S.push_back(s);
  }
  set<string> st;
  for(int i = 0; i < N; i++) {
    string s = S[i];
    for(int j = 1; j <= 4; j++) {
      for(int k = 0; k+j <= s.size(); k++) {
	st.insert(s.substr(k, j));
      }
    }
  }
  vector<int> vec(5, -1);
  while(1) {
    bool carry = true;
    for(int i = 0; carry; i++) {
      carry = false;
      vec[i]++;
      if(vec[i] >= 26) {
	vec[i] = 0;
	carry = true;
      }
    }
    if(~vec[4]) break;
    string ans = "";
    for(int i = 0; vec[i] != -1; i++) ans += 'a' + vec[i];
    reverse(ans.begin(), ans.end());
    if(st.count(ans)) continue;
    else {
      cout << ans << endl;
      return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 42472
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
    return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
int main()
{
    //freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	int n=read(),m=read(),b=read(),a=read();
	for(int i=1;i<=a;i++)
	{
		for(int j=1;j<=b;j++)write(1);
		for(int j=b+1;j<=m;j++)write(0);
		puts("");
	}
	for(int i=a+1;i<=n;i++)
	{
		for(int j=1;j<=b;j++)write(0);
		for(int j=b+1;j<=m;j++)write(1);
		puts("");
	}
    return 0;
}

Measured memory_bytes: 1152
#include <stdio.h>
#include <stdlib.h>

int main(){
    int N,M,C,i,j;
    int A[20][20],B[20];
    int sum,count=0;

    scanf("%d %d %d", &N,&M,&C);
    for(i=0;i<M;i++){
      scanf("%d ", &B[i]);
    }

    for(i=0;i<N;i++){
      for(j=0;j<M;j++){
        scanf("%d", &A[i][j]);
      }
    }

    for(i=0;i<N;i++){
      sum=C;
      for(j=0;j<M;j++){
        sum=sum+A[i][j]*B[j];
      }
      if(sum>0){
        count++;
      }

    }

    printf("%d\n", count);

    return 0;
}


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

using namespace std;

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


Measured memory_bytes: 256
#include <cstdio>
#include <string>

using namespace std;

int a[300000];
int b[300000];
char str[300001];

int main(){
  int n;
  int ans;
  int l,r;
  scanf("%d\n%s", &n, str);
  l=r=0;
  for (int i=0; i<n; i++) {
    if (str[i] == 'W') l++;
    a[i] = l;
    if (str[n-i-1] == 'E') r++;
    b[n-i-1] = r;
  }
  ans = 300000;
  for (int i=0; i<n; i++) {
    ans = ans > a[i]+b[i]-1? a[i]+b[i]-1: ans;
  }
  printf("%d\n", ans);
}




Measured memory_bytes: 2816
#include<stdio.h>

int main(void)
{
  int x[4],y[4];
  scanf("%d%d%d%d",&x[0],&y[0],&x[1],&y[1]);

  x[2] = x[1]+(y[0]-y[1]); 
  y[2] = y[1]+(x[1]-x[0]);
  x[3] = x[2]+(y[1]-y[2]);
  y[3] = y[2]+(x[2]-x[1]);

  printf("%d %d %d %d\n",x[2],y[2],x[3],y[3]);
  return 0;
}

Measured memory_bytes: 1696
n,m=map(int, input().split())

def combination(n,r):
    r=min(r,n-r)
    result=1
    for i in range(n-r+1,n+1):
        result*=i
    for i in range(1,r+1):
        result//=i
    return result

def factorize(n):
    i=2
    result={}
    while True:
        if i**2>n:
            break
        count=0
        while n%i==0:
            n//=i
            count+= 1
        if count!=0:
            result[i]=count
        i+=1
    if n>1:
        result[n]=1
    return result

ans=1
mod=10**9+7
f=factorize(m)
for i in f.values():
    ci=combination(i+n-1,i)%mod
    ans=ans*ci%mod
print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
		//List<Integer> list_gold=new ArrayList<Integer>();
		//Integer[] Republican = new Integer[m];
		int r = sc.nextInt();
		int d = sc.nextInt();
		int x = sc.nextInt();
		for(int i=0;10>i;i++) {
			int a = r*x-d;
			System.out.println(a);
			x=a;
		}
	}

}



Measured memory_bytes: 21588
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.math.*;

public class Main {

	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		String[] str = br.readLine().split(" ");
		int n = Integer.parseInt(str[0]);
		int l = Integer.parseInt(str[1]);
		String[] s = new String[n];
		for(int i = 0; i < n; i++){
			s[i] = br.readLine();
		}
		Arrays.sort(s);
		for(int i = 0; i < n; i++){
			sb.append(s[i]);
		}
		System.out.println(sb);
	}
}

Measured memory_bytes: 8020
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
using namespace std;

int l,n;
char s[100][100];

int comp(char *a,char *b){//a<b:res=1
    int res =0;
    for (int i=0;i<l;i++) {
        if (a[i]<b[i]) {res =1; break;}
        else if (a[i]>b[i]) {res=0; break;}
    }
    
    return res;
}

int swap (char *a,char *b){
    char c[100];
    for (int i=0;i<l;i++) {
        c[i]=a[i];
        a[i]=b[i];
        b[i]=c[i];
    }
    return 0;
}


int main() {
    cin >>n>>l;
    
    
    
    for (int i=0;i<n;i++) {
        for (int j=0;j<l;j++) cin >>s[i][j];
        int k=i;
        while (comp(&s[k][0],&s[k-1][0])&&k>0) {swap(&s[k][0],&s[k-1][0]); k--;}
        
        
    }
    for (int i=0;i<n;i++) for (int j=0;j<l;j++) cout <<s[i][j];
    cout <<endl;
  }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
// const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    int f = 0;
    string s = to_string(N);
    for (int i = 0; i < (int)s.size(); i++) {
        f += (int)(s[i] - '0');
    }
    if (N % f == 0) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


struct Precision{
  Precision(){
    cout<<fixed<<setprecision(12);
  }
}precision_beet;

//INSERT ABOVE HERE
signed main(){
  Int w,h,x,y;
  cin>>w>>h>>x>>y;
  cout<<(double)w*h/2.0<<" "<<(x*2==w&&y*2==h)<<endl;
  return 0;
}


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

int main(){
  int N;
  cin >> N;
  char c[N];
  int p = 0,w = 0,g = 0,y = 0;
  for(int i = 0; i < N; i++){
    cin >> c[i];
    if(c[i] == 'P')
      p++;
      if(c[i] == 'W')
        w++;
        if(c[i] == 'G')
          g++;
          if(c[i] == 'Y')
            y++;
  }
  if(p > 0 && w > 0 && g > 0 && y > 0)
    cout << "Four" << endl;
    else
      cout << "Three" << endl;

  return 0;
}
 



Measured memory_bytes: 256
n=int(input())
s=[input() for i in range(n)]
m=int(input())
t=[input() for i in range(m)]
ans=0
for i in range(len(s)):
    if s.count(s[i])-t.count(s[i])>ans:
        ans=s.count(s[i])-t.count(s[i])
print(ans)

Measured memory_bytes: 9108
#include <iostream>

using namespace std;

int main()
{
	int a[3][2];

	cin >> a[0][0] >> a[0][1];
	cin >> a[1][0] >> a[1][1];
	cin >> a[2][0] >> a[2][1];

	if (a[0][0] == a[1][0] || a[0][0] == a[1][1]) {
		if (a[0][0] == a[2][0] || a[0][0] == a[2][1]) {
			cout << "NO" << endl;
			return 0;
		}
	}
	else if (a[0][1] == a[1][0] || a[0][1] == a[1][1]) {
		if (a[0][1] == a[2][0] || a[0][1] == a[2][1]) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}

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

class Cube {
public:
	int f[6];
	Cube() {}
		void roll_z() { roll(1, 2, 4, 3); }
		void roll_y() { roll(0, 2, 5, 3); }
		void roll_x() { roll(0, 1, 5, 4); }
		void roll(int i, int j, int k, int l) {
			int t = f[i]; f[i] = f[j]; f[j] = f[k]; f[k] = f[l]; f[l] = t;
		}
};

int getRight(Cube c1, int f1, int f2) {
	for (int i = 0; i < 6; i++) {
		for (int j = 0; j < 4; j++) {
			if (c1.f[0] == f1&&c1.f[1] == f2)return c1.f[2];
			c1.roll_z();
		}
		if (i % 2 == 0)c1.roll_y();
		else c1.roll_x();
	}
	return -1;
}

int main()
{
	Cube c;
	int f1, f2;

	for (int i = 0; i < 6; i++)cin >> c.f[i];
	int q; cin >> q;

	for (int i = 0; i < q; i++) {
		cin >> f1 >> f2;
		cout<<getRight(c, f1, f2) << endl;
	}
	return 0;
}

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

int main(){
    string ans = "";
    string a, b, c;
    cin >> a >> b >> c;
    transform (a.begin(),a.end(),a.begin(),::toupper);
    transform (b.begin(),b.end(),b.begin(),::toupper);
    transform (c.begin(),c.end(),c.begin(),::toupper);
    
    cout << a[0] << b[0] << c[0] << endl;
}


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

bool f(int n) {
	if (n % 2 == 0) return true;
	return false;
}

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (f(a) && a == b && b == c) {
		cout << "-1" << endl;
		return 0;
	}
	int count = 0;
	int ac, bc, cc;
	while (1) {
		if (!(f(a) && f(b) && f(c))) {
			break;
		}
		count++;
		ac = a;
		bc = b;
		cc = c;
		a = (bc + cc) / 2;
		b = (ac + cc) / 2;
		c = (bc + ac) / 2;
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>
using namespace std;

long long int gcd(long long int x, long long int y)
{
	if (y == 0) { return x; }
	return gcd(y, x % y);
}

int main(void)
{
	int p[60],n,i,count = 0;
	cin >> n;
	for (i = 0; i < n; i++) { cin >> p[i]; }
	i = 1;
	for (int j = 0; j < n; j++)
		{
			if (p[j] != i) { count++; }
			i++;
		}
	if (count <= 2) { cout << "YES" << endl; }
	else { cout << "NO" << endl; }
	return 0;
}

Measured memory_bytes: 256
H,N=map(int,input().split())
L=[tuple(map(int,input().split())) for i in range(N)]
dp=[[-1]*(H+1) for i in range(N+1)]
for d in dp:
    d[0]=0
dp[0]=[10**9]*(H+1)
i=1
for a,b in L:
    for j in range(H+1):
        if j<a:
            dp[i][j]=min(dp[i-1][j],b)
        else:
            dp[i][j]=min(dp[i-1][j],dp[i][j-a]+b)
    i+=1
print(dp[N][H-1])

Measured memory_bytes: 146616
#include<cstdio>
#include<vector>
#include<map>
#include<climits>
#include<algorithm>
#include<iostream>
using namespace std;
typedef pair<int,int> Pt;
#define MAX 1000001
#define fr first
#define sc second
int n,dat[MAX * 2 - 1];
void update(int i,int x){
  i += n - 1;
  dat[i] = x;

  while(i > 0){
    i = (i - 1)/2;
    dat[i] = min(dat[i*2+1],dat[i*2+2]);
  }
}
int query(int a,int b,int k,int l,int r){
  if( r<=a || b <= l ) return INT_MAX;
  if( a<=l && r <= b ) return dat[k];
  return min(query(a,b,k*2+1,l,(l+r)/2),query(a,b,k*2+2,(l+r)/2,r));
}
int main(){
  int q,a,b,c,N;
  for(int i=0;i<MAX*2-1;i++) dat[i] = INT_MAX;
  scanf("%d %d",&N,&q);
  n=1;
  while(n < N) n *= 2;
  while(q--){
    scanf("%d %d %d",&a,&b,&c);
    if(!a) update(b,c);
    else printf("%d\n",query(b,c+1,0,0,n));
  }
}

Measured memory_bytes: 9004
#include <bits/stdc++.h>
#define rep(i, l, r) for(register int i = l; i < r; i++)
#define hrp(i, l, r) for(register int i = l; i <= r; i++)
#define rev(i, r, l) for(register int i = r; i >= l; i--)
#define ms(n, t) memset(n, t, sizeof(n))
#define U 10050
#define pb push_back
#define int unsigned long long
#ifndef JOEON
#define D(...)
#define R(x, l)
#define sp
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
template<typename tn> inline tn next(void);
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v);
const double eps = 1e-5;
signed main(void)
{
	#ifdef JOEON
//		freopen("C:\\Users\\Joeon\\Desktop\\IN.txt", "r", stdin);
//		freopen("C:\\Users\\Joeon\\Desktop\\OUT.txt", "w", stdout);
	#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a;
	float b;
	cin>>a>>b;
	int c = (int)((b+eps)*100);
	cout<<a*c/100<<endl;
	return 0;
}
template<typename tn> inline tn next(void)
{
	tn k;
	cin>>k;
	return k;
}
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v)
{
	rep(i, 0, v.size()) os<<v[i]<<' ';
	return os;
}


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

int main() {
    int s;
    cin >> s;
    const ll mod = 1000000007;

    vector<ll> dp(s + 1);
    dp.at(0) = 1;
    for (int i = 1; i < s + 1; i++) {
        for (int j = 0; j < i - 2; j++) {
            dp.at(i) += dp.at(j);
            dp.at(i) %= mod;
        }
    }
    cout << dp.at(s) << endl;
    return 0;
}

Measured memory_bytes: 3636
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  s=list(S())
  s=set(s)

  if len(s)==1:
    return 'No'
  return 'Yes'

# main()
print(main())


Measured memory_bytes: 5972
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
adj = [[] for i in range(N)]

for _ in range(M):
    a, b = map(int, input().split())
    adj[a-1].append(b-1)
    adj[b-1].append(a-1)

from collections import deque
q = deque()
q.append(0)

parents = [-1] * N
parents[0] = 0
while q:
    nex = q.popleft()
    for v in adj[nex]:
        if parents[v] == -1:
            parents[v] = nex
            q.append(v)

out = ['Yes']
for i in range(1, N):
    out.append(str(parents[i] + 1))
print(*out, sep='\n')
    



Measured memory_bytes: 101960
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
using namespace std;
int N,A,B,C;
int l[8];
int dfs(int cur, int a, int b, int c)
{
    if(cur==N){
        if(a*b*c!=0){
            return abs(a-A)+abs(b-B)+abs(c-C)-30;
        }else{
            return 1000000000;
        }
    }
    int tmp0=dfs(cur+1, a, b, c);
    int tmp1=dfs(cur+1, a+l[cur], b, c)+10;
    int tmp2=dfs(cur+1, a, b+l[cur], c)+10;
    int tmp3=dfs(cur+1, a, b, c+l[cur])+10;
    int t0=min(tmp0, tmp1);
    int t1=min(tmp2, tmp3);

    return min(t0, t1);
}

int main()
{
    cin >> N >> A >> B >> C;
    for(int i=0; i<N; i++){
        cin >> l[i];
    }
    //数え上げる
    //それぞれが使わない,A,B,Cの４通りの使い方がある。順に0,1,2,3とする
    int ans = dfs(0, 0, 0, 0);
    cout << ans << '\n';

    return 0;
}

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

int main()
{
    int i,N;
    string city;
    int point;
    cin >> N;
    pair<pair<string,int>,int> p[N];
    for(i=0;i<N;i++){
        cin >> city >> point;
        p[i] = make_pair(make_pair(city,-1*point),i);
    }
    sort(p,p+N);
    
    for(i=0;i<N;i++){
        printf("%d\n",p[i].second+1);
    }
}


Measured memory_bytes: 3736
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

namespace
{
	void DFS(int n, int N, const vi& src, int i)
	{
		if (n == N)
		{
			string s(src.begin(), src.end());

			cout << s << endl;
			return;
		}

		for (int j = 0; j <= i + 1; ++j)
		{
			vi cpy(src);
			cpy.push_back(j + 'a');
			DFS(n + 1, N, cpy, max(i,j));
		}
	}
}
void PANA2020D()
{
	int N;
	cin >> N;
	vi x(1,'a');
	DFS(1, N, x, 0);
}

int main()
{
	PANA2020D();
	return 0;
}

Measured memory_bytes: 1536
#include <iostream>

using namespace std;
constexpr int infty = 1000000000;

int main() {
  int N, K, S;
  cin >> N >> K >> S;
  if (S < infty) {
    for (int i = 0; i != N; ++i) {
      cout << (i ? " " : "") << S+(i>=K);
    }
  } else {
    for (int i = 0; i != N; ++i) {
      cout << (i ? " " : "") << (i<K ? S : 1);
    }
  }
}


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

using namespace std;

vector<vector<int>> E;
vector<bool> used;
const int INF = 1e9;

bool check(const set<int> &V, const set<int> &U){
    for (const auto &v: V){
        for (const auto &e: E[v]){
            if (used[e] and U.count(e) != 1)
                return true;
        }
    }
    return false;
}

int dfs(const set<int> &U){
    if (U.empty())
        return 0;
    set<int> V;
    for (const auto &u: U){
        used[u] = true;
        for (const auto &e: E[u]){
            if (!used[e]) V.insert(e);
            used[e] = true;
        }
    }
    if (check(V, U))
        return -INF;
    return dfs(V) + 1;
}

int main(){
    int n;
    cin >> n;
    E.resize(n);
    used.resize(n);
    for (int i = 0; i < n; i++){
        for (int j = 0; j < n; j++){
            char c;
            cin >> c;
            if (c == '1')
                E[i].push_back(j);
        }
    }

    int ans = 0;
    for (int i = 0; i < n; i++){
        fill(used.begin(), used.end(), false);
        ans = max(ans, dfs({i}));
    }

    cout << (ans > 0 ? ans : -1) << endl;

}


Measured memory_bytes: 512
#pragma comment (linker, "/STACK:256000000")
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define BUGAVOID(x) x
#define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define sz(c) (int)(c.size())
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T, class U>using vp = vector<pair<T, U>>;
template<class T>using vv = vector<vector<T>>; template<class T, class U>using vvp = vv<pair<T, U>>;
template<class T>vv<T> vvec(const size_t n, const size_t m, const T v) { return vv<T>(n, vector<T>(m, v)); }
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; }
constexpr ll pow2(const int n) { return 1ll << n; }
constexpr int INF = 1 << 28; constexpr ll LINF = 1ll << 60;
constexpr int MAX = 1e5 + 5; constexpr int MOD = 1e9 + 7; constexpr double EPS = 1e-6;
constexpr int dy[4] = { 0,1,0,-1 }; constexpr int dx[4] = { 1,0,-1,0 };
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

int H, W, N;
vll cnt(10);

int main() {
    cin >> H >> W >> N;
    multiset<pair<int, int>> ms;
    rep(i, N) {
        int a, b;
        cin >> a >> b;
        
        rep(h, -2, 1) {
            rep(w, -2, 1) {
                if (a + h < 1 || a + h > H - 2 || b + w < 1 || b + w > W - 2) continue;
                ms.insert(mp(a + h, b + w));
            }
        }
    }

    while (!ms.empty()) {
        const auto it = ms.begin();
        int c = ms.count(*it);
        cnt[c]++;
        ms.erase(*it);
    }

    ll sum = accumulate(all(cnt), 0);

    write((ll)(H - 2) * (W - 2) - sum);
    rep(i, 1, 10) write(cnt[i]);
}

Measured memory_bytes: 42496
#include<stdio.h>
int main(void){
	int i, j, H, W;
	while(1){
		//縦と横の長さを入力
		scanf("%d %d", &H, &W);
		//数値が2つとも0なら終了
		if(H == 0 && W == 0){
			break;
		}
		//四角形を出力
		for(i = 0; i < H; i++){
			for(j = 0; j < W; j++){
				if(i == 0 || i == (H - 1)){
					if(j == (W - 1)){
						printf("#\n");
					}else{
						printf("#");
					}
				}else{
					if(j == 0){
						printf("#");
					}else if(j == (W - 1)){
						printf("#\n");
					}else{
						printf(".");
					}
				}
			}
		}
		printf("\n");
	}
	return 0;
}

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

LL x, y, m;
int main() {
	cin >> x >> y >> m;
	x--;
	LL a=0, b=0;
	a=x/m;
	if(x<0) a=-1;
	b=y/m;
	cout << b-a << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
     
    public class Main {
    	public static void main(String[] args) {
    		Scanner scan = new Scanner(System.in);
    		int n = scan.nextInt();
			String str=scan.next();
			char t = ' ';
			int count=0;
			for(int i=0;i<n;i++)
			{
				char a = str.charAt(i);
				if(a!=t){
					count++;
				}
				t=a;
			}
			System.out.println(count);
    	}
    }

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
struct grid{
	long long a[50][50];
};
const int mod=1e9+7;
int n;
long long k;
inline grid mul(grid x,grid y){
	grid ans;
	memset(ans.a,0,sizeof(ans.a));
	for(int i=0;i<n;++i){
		for(int k=0;k<n;++k){
			for(int j=0;j<n;++j){
				ans.a[i][j]=(ans.a[i][j]+x.a[i][k]*y.a[k][j]+mod)%mod;
			}
		}
	}
	return ans;
}
inline int solve(long long d,grid ini){
	grid res;
	for(int i=0;i<n;++i){
		res.a[i][i]=1;
	}
	while(d){
		if((d&1)){
			res=mul(res,ini);
		}
		d>>=1;
		ini=mul(ini,ini);
	}
	long long ans=0;
	for(int i=0;i<n;++i){
		for(int j=0;j<n;++j){
			ans+=res.a[i][j];
			if(ans>=mod){
				ans-=mod;
			}
		}
	}
	return ans;
}
int main(){
	cin>>n>>k;
	grid ini;
	for(int i=0;i<n;++i){
		for(int j=0;j<n;++j){
			cin>>ini.a[i][j];
		}
	}
	cout<<solve(k,ini)<<'\n';
	return 0;
}

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

int digitSum(int num){
    int sum=0;

    while(true){
        int r=num%10;
        num/=10;
        sum+=r;
        if (num==0) break;
    }
    return sum;
}

int main(){
    int N,A,B;
    cin >> N >> A >> B;

    int ans=0;

    for (int i=1; i<=N; i++){
        if (A<=digitSum(i) & digitSum(i)<=B) ans+=i;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://atcoder.jp/contests/abc103/tasks/abc103_d

int main() {
    int N, M; cin >> N >> M;
    vector<P> ab;
    REP(i, M) {
        int a, b; cin >> a >> b;
        ab.push_back({b,a});
    }

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

    int now = 0;
    int ans = 0;
    for (P p : ab) {
        int right = p.first;
        int left = p.second;
        if (left >= now) {
            now = right;
            ans++;
        }
    }

    cout << ans << "\n";


    return 0;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<10;i++)
		for(int j=1;j<10;j++){
			if(i*j==n){
				printf("Yes\n");
				return 0;
			}
		}
	printf("No\n");
	return 0;
}

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

typedef pair<int, int> P;

int par[16][16];
int rank[16][16];
char map[16][16];
int cnt;

void init();
void unite(int y1, int x1, int y2, int x2);
int find(int y, int x);

int main()
{
	while (scanf("%s", &map[1][1]) != EOF){
		for (int i = 2; i <= 12; i++) scanf("%s", &map[i][1]);
		init();
		for (int i = 1; i <= 12; i++){
			for (int j = 1; j <= 12; j++){
				if (map[i][j] == '1'){
					cnt++;
					unite(i, j, i - 1, j);
					unite(i, j, i + 1, j);
					unite(i, j, i, j - 1);
					unite(i, j, i, j + 1);
				}
			}
		}
		printf("%d\n", cnt);
	}
	
	return 0;
}

void init()
{
	for (int i = 0; i < 16; i++){
		for (int j = 0; j < 16; j++){
			par[i][j] = i * 16 + j;
			rank[i][j] = 1;
		}
	}
	cnt = 0;
}

void unite(int y1, int x1, int y2, int x2)
{
	if (map[y2][x2] == '1' && find(y1, x1) != find(y2, x2)){
		if (rank[y1][x1] < rank[y2][x2]){
			par[y1][x1] = y2 * 16 + x2;
			rank[y1][x1]++;
		}
		else {
			par[y2][x2] = y1 * 16 + x1;
			rank[y2][x1]++;
		}
		cnt--;
	}
}

int find(int y, int x)
{
	if (par[y][x] != y * 16 + x){
		par[y][x] = find(par[y][x] / 16, par[y][x] % 16);
	}
	return par[y][x];
}

Measured memory_bytes: 968
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN

x, k, d = map(int, input().split())

m = Decimal(str(x/d)).quantize(Decimal('0'), rounding=ROUND_HALF_UP)
m = abs(m)
if k < m:
    m = k

if x >= 0:
    x = x - m * d
else:
    x = x + m * d
k = k - m

#print("m=",m," k=",k, "x=",x)

if k % 2 == 0:
    print(abs(x))
else:
    print(min(abs(x-d), abs(x+d)))

Measured memory_bytes: 10008
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m1(x) memset(x,-1,sizeof(x))
const int INF = 1e9 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793;

int n;
int main(){
  cin >> n;
  cout << int(sqrt(n)) * int(sqrt(n)) <<endl;
}

Measured memory_bytes: 256