akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

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


signed main(void) {
    int v[8][8] = {};
    rep(i,8)rep(j,8){
        if(i%2 || j%2 == 0)v[i][j]++;
    }
    int n;
    cin >> n;
    while(n--){
        int a,b,c,d;
        scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
        int ans = 0;
        a--,b--;
        loop(i,a,c)loop(j,b,d)ans += v[i][j];
        printf("%lld\n",ans);
    }

}



Measured memory_bytes: 3224
N = int(input())
ans = float("inf")
a = 1
b = 1
for i in range(1, int(N**0.5)+1):
    a = i
    b = N/i
    if N%i==0:
        ans = min(ans, max(len(str(a)),len(str(int(b)))))
print(ans)

Measured memory_bytes: 9376
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        sc.close();

        int ans = Math.min(b / a, c);
        System.out.println(ans);
    }

}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
#define ci const int&
using namespace std;
struct edge{
	int t,nxt;
}e[20010];
int n,u,v,cnt,be[10010],c[10010],nw,mx,sum,prt[10010];
void add(ci x,ci y){
	e[++cnt].t=y,e[cnt].nxt=be[x],be[x]=cnt;
}
void dfs(ci x){
	prt[x]=c[--nw];
	for(int i=be[x];i;i=e[i].nxt)!prt[e[i].t]?dfs(e[i].t),0:0;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<n;++i)scanf("%d%d",&u,&v),add(u,v),add(v,u);
	for(int i=1;i<=n;++i)scanf("%d",&c[i]),mx=max(mx,c[i]),sum+=c[i];
	sort(c+1,c+n+1),nw=n+1,dfs(1),printf("%d\n",sum-mx);
	for(int i=1;i<=n;++i)printf("%d%c",prt[i]," \n"[i==n]);
	return 0;
}

Measured memory_bytes: 768
#include <iostream>

int abs(int a) {
    if (a < 0)
        return  -a;
    return a;
}

int main() {
    unsigned int n, x, y;

    std::cin >> n;
    std::cin >> x;
    std::cin >> y;



    if (n == 1) {
        std::cin >> x;
        std::cout << abs(y - x);
    } else {
        for (int i = 0; i < n - 2; i++) std::cin >> x;
    
        std::cin >> x;

        unsigned int tmp;
        std::cin >> tmp;

        if (abs(tmp - x) > abs(tmp - y))
            std::cout << abs(tmp - x);
        else
            std::cout << abs(tmp - y);
    }

    return 0;
}

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

int main(){
  string s;
  cin >> s;
  //cout << s << endl;
  int count = 0;
  for (int i=0; i<s.size(); i++){
    //cout << s.at(i);
    if (s.at(i) == '1'){
      count++;
    }
  }
  cout << count <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>

#define roop(i, n) for(int i=0;i<n;i++)

using namespace std;
using ll = long long int;
using ull = unsigned long long;

float myPower(int a, int n) { // aのn乗の計算
	float x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

int main() {
	int a, b;
	cin >> a >> b;
	int ans = a + b;
	if (ans == 3) {
		cout << "3";
	} else if (ans == 4) {
		cout << "2";
	} else if (ans == 5) {
		cout << "1";
	}
	return 0;
}

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

const int INF = 1 << 28;

int to_hex (char a) {
    if ('0' <= a && a <= '9') return a - '0';
    else return a - 'a' + 10;
}

int main ()
{
    int R[] = {0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff};
    int G[] = {0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff};
    int B[] = {0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff};
    string color[] = {"black", "blue", "lime", "aqua", "red", "fuchsia", "yellow", "white"};

    string str;
    while (cin >> str, str != "0") {
        int r = to_hex(str[1]) * 16 + to_hex(str[2]);
        int g = to_hex(str[3]) * 16 + to_hex(str[4]);
        int b = to_hex(str[5]) * 16 + to_hex(str[6]);

        int D = INF;
        string res;
        for (int i = 0; i < 8; i++) {
            int d = ((R[i] - r) * (R[i] - r) + (G[i] - g) * (G[i] - g) + (B[i] - b) * (B[i] - b));
            if (d < D) {
                res = color[i];
                D = d;
            }
        }
        cout << res << endl;
    }

    return 0;
}

Measured memory_bytes: 1188
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String input = sc.next();
        int cnt = 0, ans = 0;
        String acgt = "ACGT";

        for(int i = 0; i < input.length(); i++){
            String str = String.valueOf(input.charAt(i));
            if(acgt.indexOf(str) > -1) cnt++;
            else{
                ans = ans > cnt ? ans : cnt;
                cnt = 0;
            }
        }
        ans = ans > cnt ? ans : cnt;
        System.out.println(ans);
    }
}

Measured memory_bytes: 22736
#include <bits/stdc++.h>
#include <string>
#include <vector>
/* 変数i を n回繰り返すマクロ */
#define rep(i,n) for (int i = 0;i < (n);i++)
using namespace std;
int main()
{
    cout << fixed << setprecision(10);//小数点以下10桁出力
    int l;
    cin >> l;
    long double hen = (long double)l / 3;
    //cout << hen << endl;
    long double ans = hen * hen * hen;
    cout << ans << endl;
    return 0;
}

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

struct P
{
	int value;
	int cnt;
	int total;
};
const int maxn = 100000 + 5;
int n;
int mem[maxn];
map<int, int> M1;
map<int, int> M2;
P mem1[maxn];
P mem2[maxn];

bool cmp(P & a, P &b)
{
	return a.cnt > b.cnt;
}

int solve()
{	
	for(int i = 0; i < n; i+=2) M1[mem[i]]++; 
	int i = 0;
	for(auto iter = M1.begin(); iter != M1.end(); iter++)
	{
		mem1[i].value = iter->first;
		mem1[i++].cnt = iter->second;
	}
	sort(mem1, mem1+n/2, cmp); 
	P p1 = mem1[0]; p1.total = n/2 - mem1[0].cnt;
	P p2 = mem1[1]; p2.total = n/2 - mem1[1].cnt;
	//for(int i = 0; i < n; i++) printf("%d ", mem1[i].value); printf("\n");

	for(int i = 1; i < n; i+=2) M2[mem[i]]++;
	i = 0;
	for(auto iter = M2.begin(); iter != M2.end(); iter++)
	{
		mem2[i].value = iter->first;
		mem2[i++].cnt = iter->second;
	}
	sort(mem2, mem2+n/2, cmp);
	P p3 = mem2[0]; p3.total = n/2 - mem2[0].cnt;
	P p4 = mem2[1]; p4.total = n/2 - mem2[1].cnt;
	//for(int i = 0; i < n/2; i++) printf("%d ", mem2[i].cnt); printf("\n");
	
	int res1 = maxn;
	if(p1.value != p3.value) 
		res1 = p1.total + p3.total;
	
	int res2 = maxn;
	if(p1.value != p4.value) 
		res2 = p1.total + p4.total;

	int res3 = maxn;
	if(p2.value != p3.value)
		res3 = p2.total + p3.total;

	int res4 = maxn;
	if(p2.value != p4.value)
		res4 = p2.total + p4.total;

	return min({res1, res2, res3, res4});
}

int main()
{
	cin >> n;
	for(int i = 0; i < n; i++) cin >> mem[i];
	printf("%d\n", solve());
}

Measured memory_bytes: 6528
N=int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

def test(n,x):
    while n%x==0:
        n//=x
    n%=x
    return n==1

l=make_divisors(N)
la=make_divisors(N-1)
l.extend(la)
l=set(l)

c=0
for i in l:
    if i==1 or i==N:
        continue
    if test(N,i):
        c+=1

print(c+1)


Measured memory_bytes: 3828
#include<stdio.h>
int main()
{
    int n;
    scanf("%d",&n);
    int a=n%10;
    if(a==2||a==4||a==5||a==7||a==9)
        printf("hon\n");
    else if(a==0||a==1||a==6||a==8)
        printf("pon\n");
    else
        printf("bon\n");
   return 0;
}


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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int a[200000];
ll cnt[200000];

int main(){
	int n;cin>>n;
	ll sum=0;
	rep(i,n){
		scanf("%d",&a[i]);
		cnt[a[i]]++;
		sum+=a[i];
	}
	int q;cin>>q;
	rep(i,q){
		int b,c;scanf("%d%d",&b,&c);
		sum-=cnt[b]*b;
		sum-=cnt[c]*c;
		cnt[c]+=cnt[b];
		cnt[b]=0;
		sum+=cnt[c]*c;
		printf("%lld\n",sum);
	}
}

Measured memory_bytes: 4996
N = int(input())
Ai = list(map(int, input().split()))

add_sum = 0
xor_sum = 0
count = 0

left = 0
right = 0
while True:
    while right < N:
        add_sum = add_sum + Ai[right]
        xor_sum = xor_sum ^ Ai[right]
        if add_sum != xor_sum:
            add_sum = add_sum - Ai[right]
            xor_sum = xor_sum ^ Ai[right]
            break
        right += 1
        count += (right - left)
    add_sum = add_sum - Ai[left]
    xor_sum = xor_sum ^ Ai[left]
    left += 1
    if left >= N:
        break

print(count)


Measured memory_bytes: 24712
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <bitset>
#include <time.h>
#include <set>
#include <algorithm>
#define ll long long
#define MODD 1000000007
#define Inf 1000000000
using namespace std;
int N,C,K;

int T[111111];
ll dp[111111];

int main() {
    cin>>N>>C>>K;
    for(int i=0;i<N;i++) {
        cin>>T[i];
    }
    
    sort(T,T+N);
    
    
    
    dp[N]=0;
    for(int i=N-1;i>=0;i--) {
        // T[i] to T[i]+K.
        int low=i;
        int high=min(N-1,i+C-1);
        while(low < high) {
            int mid = (low+high+1)/2;
            if (T[mid] > T[i]+K) {
                high = mid-1;
            } else {
                low = mid;
            }
        }
        
        // T[i] to T[low]
        dp[i]=1+dp[low+1];
        
    }
    
    cout << dp[0] << endl;
}

Measured memory_bytes: 1408
n = int(input())
w = [""] * n 
result = "Yes"

for i in range(n):
    tmp = input()
    if tmp in w:
        result = "No"
    w[i] = tmp 
for i in range(n-1):
    if w[i][-1] == w[i+1][0]:
        pass
    else:
        result = "No"
print(result)


Measured memory_bytes: 2940
N, M, K = list(map(int, input().split()))
A = [0] + [int(i) for i in input().split() ]
B = [0] + [int(i) for i in input().split() ]

best = 0
a_time = 0
b_time = sum(B)
b_i = len(B)-1
end_flag = False
for a_i in range(N+1):
    a_time += A[a_i]
    while a_time + b_time > K:
        if b_i == 0:
            end_flag = True
            break
        b_time -= B[b_i]
        b_i -= 1

    if end_flag == True:
        break
    if a_i + b_i > best:
        best = a_i + b_i

print(best)

Measured memory_bytes: 39788
#include<iostream>
#include<vector>
#include<string>

using namespace std;

typedef long long ll;

string S, T;
vector<vector<ll>> pos;

int main() {
	cin >> S >> T;
	int cnt1[26] = {}, cnt2[26] = {};
	for (int i = 0; i < S.size(); i++)cnt1[S[i] - 'a']++;
	for (int i = 0; i < T.size(); i++)cnt2[T[i] - 'a']++;
	for (int i = 0; i < 26; i++) {
		if ((cnt1[i] == 0 && cnt2[i] > 0)) {
			cout << -1 << endl;
			return 0;
		}
	}
	pos.resize(26);
	for (int i = 0; i < S.size(); i++) {
		int c = S[i] - 'a';
		pos[c].push_back(i);
	}

	ll ans = 0;

	int pointer = 0;
	ll beforepos = -1;
	int before_c = -1;
	ans += pos[T[0] - 'a'][0];
	beforepos = pos[T[0] - 'a'][0];
	before_c = T[0] - 'a';

	for (int i = 1; i < T.size(); i++) {

		int c = T[i] - 'a';
		if (before_c == c) {
			if (pos[c].size() - 1 > pointer) {
				ans += (pos[c][pointer + 1] - pos[c][pointer]);
				pointer++;
				beforepos = pos[c][pointer];
			}
			else {
				ans += (S.size() - pos[c][pointer]) + pos[c][0];
				pointer = 0;
				before_c = c;
				beforepos = pos[c][0];
			}
		}
		else {

			int yoteipos = -1;
			int memo_pointer = -1;
			for (int j = 0; j < pos[c].size(); j++) {
				if (pos[c][j] > beforepos) {
					memo_pointer = j;
					yoteipos = pos[c][j];
					break;
				}
			}
			
			if (yoteipos == -1) {
				ans += (S.size() - beforepos);
				ans += (pos[c][0]);
				beforepos = pos[c][0];
				before_c = c;
				pointer = 0;
			}
			else {
				ans += (yoteipos - beforepos);
				beforepos = yoteipos;
				before_c = c;
				pointer = memo_pointer;
			}
		}
	}

	cout << ans + 1 << endl;

	return 0;
}

Measured memory_bytes: 1724
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int,int> pii;
const int maxn=1e5+7;
const ll modn=1e9+7;
const int inf=2e9+7;
const double PI = acos(-1.0);
const double eps=1e-8;
inline int lowbit(int x){return x&-x;}
inline ll lowbit(ll x) {return x&-x;}
inline int CountOneBinary(ll num){int ans=0;while(num){if(num&1) ans+=1;num>>=1;}return ans;}
inline void read(int &x){char c;x=0;for(c=getchar();c>'9'||c<'0';c=getchar());for(;c>='0'&&c<='9';c=getchar()) x=x*10+c-'0';}
inline void read(ll &x){char c;x=0;for(c=getchar();c>'9'||c<'0';c=getchar());for(;c>='0'&&c<='9';c=getchar()) x=x*10+c-'0';}
inline ll qpow(ll x,ll y){ll ans=1;while(y){if(y&1) ans=ans*x%modn;x=x*x%modn;y>>=1;}return ans;}
inline double qpow(double x,ll y){double ans=1;while(y){if(y&1) ans=ans*x;x=x*x;y>>=1;}return ans;}
ll n,k;
int main()
{
    while(scanf("%lld%lld",&n,&k)==2)
    {
        ll cur=n/k;
        ll ans=cur*cur*cur;
        if(k%2==0)
        {
            cur=n/(k/2)-cur;
            ans+=cur*cur*cur;
        }
        printf("%lld\n",ans);
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1000000000;
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MAX_N = (int)1e5;

template <size_t N>
class unionFindTree{
	private:
		int par[N];
		int rank[N];
		int united[N];
	public:
		unionFindTree(){
			for(int i = 0; i < (int) N; i++){
				par[i] = i; rank[i] = 0; united[i] = 1;
			}
		}
		void init(){
			for(int i = 0; i < (int) N; i++){
				par[i] = i; rank[i] = 0; united[i] = 1;
			}
		}
		int find(int x){
			if(par[x] == x) return x;
			else return par[x] = find(par[x]);
		}
		void unite(int x, int y){
			x = find(x); y = find(y);
			if(x == y) return;

			if(rank[x] < rank[y]){
				par[x] = y;
				united[y] += united[x];
			}else{
				par[y] = x;
				united[x] += united[y];
				if(rank[x] == rank[y]) rank[x]++;
			}
		}
		bool same(int x, int y){
			return find(x) == find(y);
		}
		int count(int x){
			return united[find(x)];
		}
};


int main(void){
	int N, M; cin >> N >> M;
	int p[MAX_N];
	unionFindTree<MAX_N> uf;
	for(int i = 0; i < N; i++){
		cin >> p[i];
		p[i]--;
	}
	for(int i = 0; i < M; i++){
		int x, y; cin >> x >> y;
		uf.unite(--x, --y);
	}

	int res = 0;
	for(int i = 0; i < N; i++){
		if(uf.same(i, p[i])) res++;
		// debug(i);
		// debug(p[i]);
		// debug(uf.same(i, p[i]));
	}

	cout << res << '\n';

	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
 
int main() {
  int w,h,n;
  vector<int> a(n);
  vector<int> x(n);
  vector<int> y(n);
  cin >> w >>h>>n;
  vector<vector <int>> g(h,vector<int> (w,1));
  for(int i=0;i<n;i++){
    cin >> x[i] >>y[i] >>a[i];
    if(a[i]==1){
      for(int j=0;j<h;j++){
        for(int k=0;k<x[i];k++){
          g[j][k]=0;
        }
      }
    }else if(a[i]==2){
      for(int j=0;j<h;j++){
        for(int k=x[i];k<w;k++){
          g[j][k]=0;
        }
      }
    }else if(a[i]==3){
      for(int j=0;j<y[i];j++){
        for(int k=0;k<w;k++){
          g[j][k]=0;
        }
      }
    }else{
      for(int j=y[i];j<h;j++){
        for(int k=0;k<w;k++){
          g[j][k]=0;
        }
      }
    }
  }
  int ss=0;
  for(int j=0;j<h;j++){
    for(int k=0;k<w;k++){
      ss += g[j][k];
    }
  }
  cout << ss <<endl;
}


Measured memory_bytes: 640
#include <stdio.h>

int main(void) {
	int gusu = 0, kisu = 0;
	int N, A, i;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &A) != 1) return 1;
		if (A % 2 == 0) gusu++; else kisu++;
	}
	puts(kisu % 2 == 0 || (gusu == 0 && kisu == 1) ? "YES" : "NO");
	return 0;
}

/*
gusu + gusu = gusu
kisu + kisu = gusu
gusu + kisu = kisu <- tukaenai
kisu + gusu = kisu <- tukaenai

偶奇が等しい数を選択する->奇数が奇数個だと1個取り残される
偶数はいくらでもたせる
奇数が1個 -> 自明にOK (2<=Nなので無いけど)
奇数が3個 -> 偶数1個と奇数1個に鳴るのでNG
*/


Measured memory_bytes: 128
# input
N = int(input())
K = int(input())

# processing
## definition of function
def opeA(num):
    return num*2

def opeB(num, K = K):
    return num + K

## initial
num = 1

for i in range(N):
    if opeA(num) < opeB(num):
        num = opeA(num)
    else:
        num = opeB(num)

# output
print(num)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

int main() {
  Cin(int, a, b);

  int ans = 0;
  ans += a >= b ? a-- : b--;
  ans += a >= b ? a-- : b--;

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<string>
#include <queue>
#include <stack>
#include <cstring>
#include <map>
using namespace std;
typedef long long ll;

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

	string s; cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '7') {
			cout << "Yes" << '\n'; return 0;
		}
	}

	cout <<"No"<<'\n';


}

Measured memory_bytes: 3648
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int descending_compare(const void *a, const void *b){
    if (*(int*)a > *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}

int ascending_compare(const void *a, const void *b){
    if (*(int*)a < *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}


int lower_bound(int *a, int n, int key){
    int left, mid, right;
    left = 0, right = n;
    mid = (left + right)/2;
    while ((left+1 != mid || mid+1 != right) && mid != left){
        if (key > a[mid]){
            left = mid;
        }else{
            right = mid+1;
        }
        mid = (left + right)/2;
    }
    if (a[left] >= key)return left;
    if (a[mid] >= key)return mid;
    if (a[right] >= key)return right;
    return n;
}

//greatest common divisor
unsigned long  gcd(unsigned long x, unsigned long y){
    if (y == 0){ 
        return x;
    }else if (x > y){
        return gcd(y, x % y);
    }else{
        return gcd(x, y % x);
    }
}



long long factorial(int x){
    long long rtn = 1;
    int i;
    for (i = x; i > 1; i--){
        rtn = (rtn*i);
    }
    return rtn;
}

int d[10];

int main(void){
    int n, k;
    int price;
    int flag;
    scanf("%d %d", &n, &k);
    for (int i = 0; i < k; i++){
        scanf("%d", &d[i]);
    }
    for (int i = n; i < 1000000000; i++){
        price = i;
        flag = 1;
        while (price != 0){
            for (int j = 0; j < k; j++){
                if (price%10 == d[j]){
                    flag = 0;
                    break;
                }
            }
            price /= 10;
        }
        if (flag == 1){
            printf("%d\n", i);
            return 0;
        }
    }

}


Measured memory_bytes: 128
N = int(input())
st = set()
s = []

for i in range(N):
    tmp = input()
    st.add(tmp)
    s.append(tmp)

M = int(input())
t = []

for i in range(M):
    t.append(input())

ans = -100
tmp = 0

for x in st:
    tmp = s.count(x)
    tmp -= t.count(x)
    ans = max(ans, tmp)

print(ans if 0 <= ans else 0)


Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<utility>
#include<queue>
#include<tuple>
#include<stdio.h>
#define rep(i, n) for(int i=0;i<n;i++)
using namespace std;

int main(){
	int n, m;
	cin>>n>>m;
	int a[m], b=0;
	rep(i, m){
		cin>>a[i];
		b+=a[i];
	}
	if(b>n)
		cout<<-1<<endl;
	else
		cout<<n-b<<endl;
	return 0;
}

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

const ll INF = 1e9+7;
const int MAXN = 1e5;
int N,M;
bool a[MAXN+2]={}; // broken
ll dp[MAXN+2]={};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> N >> M;
  REP(i,M) {
    int idx;
    cin >> idx;
    a[idx+1] = true;  // 1段目->idx=2
  }
  dp[0] = 0;
  dp[1] = 1; // 0段目
  REP(i,N) {
    if (!a[i+1]) dp[i+2] += dp[i+1];
    if (!a[i]) dp[i+2] += dp[i];
    dp[i+2] %= INF;
  }
  cout << dp[N+1] << endl;
}


Measured memory_bytes: 1152
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;

typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
typedef long long ll;

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

int main(){
	ios::sync_with_stdio(false);

	int n, count;
	int a, b, c, d;

	while (cin >> n){
		count = 0; 
		for (a = 0; a < 10; a++){
				for (b = 0; b < 10; b++){
					for (c = 0; c < 10; c++){
						for (d = 0; d < 10; d++){
							if ((a + b + c + d) == n)
								count++;
						}
					}
				}
			}
		
		cout << count << endl;
	}
}

Measured memory_bytes: 3132
#include<stdio.h>
int main(void){
  int n,t;
  int min=1001;
  scanf("%d %d",&n,&t);
  for(int i=0;i<n;i++){
    int a,b;
    scanf("%d %d",&a,&b);
    if(b<=t && a<min){
      min=a;
    }
  }
  if(min>1000){
    printf("TLE\n");
  }else{
    printf("%d\n",min);
  }
  return 0;
}

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

//宣言
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

//数値
#define MOD 1000000007
#define INF (1<<20)
const double EPS = 1e-10;
const double PI = acos(-1.0);

//操作
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define REP(i,n) FOR(i,0,n)
#define REPB(i,n) for(int i=n;i>=0;--i)
#define SORT(A) sort(A,A+sizeof(A)/sizeof(A[0]))
#define VSORT(A) sort(A.begin(),A.end())
#define EXIST(s,e) (s.find(e)!=s.end())
#define PB push_back
#define MP make_pair
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);

//DEBUG
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int p[100001];
int imo[100001] = { 0 };
void isPrime( ) {
	FOR(i, 0, 100001) p[i] = 1;
	p[0] = p[1] = 0;
	int i;
	for (i = 4;i <= 100000;i += 2) p[i] = 0;
	for (i = 3;i*i <= 100000;i += 2) {
		if (p[i]) {
			int j = i + i;
			while (j <= 100000) {
				p[j] = 0;
				j += i;
			}
		}
	}
}

int main() {
	isPrime();
	imo[0] = 0;
	imo[1] = 0;
	imo[2] = 0;
	for (int i = 3;i <= 100000;i ++)
	{
		int x=0;
		if(p[i]&&p[(i + 1) / 2]) x=1;
		imo[i] = imo[i - 1] + x;
	}
	int q;
	cin >> q;
	
	for (int i = 0; i < q;i++) {
		int l, r;
		cin >> l >> r;
		cout << imo[r] - imo[l - 1]<< endl;
	}

}

Measured memory_bytes: 1408
#include <iostream>
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main ()
{
    ll n;
    cin>>n;
    vector<ll>v(n);
    for(ll i=0;i<n;i++)
    cin>>v[i];
    vector<ll>pf(n,v[0]);
    for(ll i=1;i<n;i++)
    {
        pf[i]=max(pf[i-1],v[i]);
    }
    ll sum=0;
    for(ll i=0;i<n;i++)
    sum+=pf[i]-v[i];
    cout<<sum<<endl;
}

Measured memory_bytes: 6392
def root(x):
    path = []
    while P[x] != x:
        path.append(x)
        x = P[x]
    for node in path:
        P[node] = x
    return x
def check(x,y):
    if root(x) == root(y):
        return 1
    else:
        return 0
def unite(x,y):
    P[root(x)] = root(y)        
 
n,q = map(int,input().split())
P = [i for i in range(n)]
for j in range(q):
    s = list(map(int,input().split()))
    if s[0] == 0:
        unite(s[1],s[2])
    else:
        print(check(s[1],s[2]))
    #print(P)    


Measured memory_bytes: 5996
#include"bits/stdc++.h"
using namespace std;
struct _ { ios_base::Init i; _() { cin.sync_with_stdio(0); cin.tie(0); } } _;

#define pii pair<int,int>
#define ff first
#define ss second
#define endll '\n'

using ll = long long int;

ll gcd(ll a,ll b){while(b){ll x=a%b;a=b;b=x;}return a;}

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

    ll sum=0;

    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            for(int k=1;k<=n;k++)
            {
                sum+=gcd(i,__gcd(j,k));
            }
        }
    }

    cout<<sum;

}



Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
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 (a>b) { a=b; return 1; } return 0; }

struct Edge
{
    int d;
    int hight;
    int wide;
    Edge(int d, int h, int w): d(d), hight(h), wide(w) {};
};

bool operator< (const Edge &e1, const Edge &e2){
    return e1.d > e2.d;
}


int main(){
    int h, w;
    cin >> h >> w;
    int ch, cw;
    cin >> ch >> cw;
    ch--; cw--;
    int gh, gw;
    cin >> gh >> gw;
    gh--; gw--;

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

    vector<string> s(h);
    rep(i,h) cin >> s[i];
    
    int INF = 1001001001;
    vector<vector<int>> dist(h, vector<int>(w, INF));

    priority_queue<Edge> q;

    q.push(Edge(0,ch,cw));

    while (!q.empty())
    {
        Edge e = q.top();
        q.pop();
        int nd = e.d;
        int nh = e.hight;
        int nw = e.wide;
        if(dist[nh][nw]!=INF) continue;
        dist[nh][nw] = nd;
        rep(i,4){
            int dh = nh + dy[i];
            int dw = nw + dx[i]; 
            if(dh<0 || dh>=h) continue;
            if(dw<0 || dw>=w) continue;
            if(dist[dh][dw]!=INF) continue;
            if(s[dh][dw]=='.') {
                //dist[dh][dw] = nd;
                q.push(Edge(nd,dh,dw));
            }            
        }

        nd++;
        for(int i=-2; i<=2; i++){
            for(int j=-2; j<=2; j++){
                int dh = nh + i;
                int dw = nw + j;
                if(dh<0 || dh>=h) continue;
                if(dw<0 || dw>=w) continue;
                if(dist[dh][dw]!=INF) continue;
                if(s[dh][dw]=='.') {
                    //dist[dh][dw] = nd;
                    q.push(Edge(nd,dh,dw));
                }     
            }
        }
    }   
    if(dist[gh][gw]==INF) cout << -1 << endl;
    else cout << dist[gh][gw] << endl;

    return 0;
}

Measured memory_bytes: 10672
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int a, b, c,sum=0;
	scanf("%d %d %d", &a, &b, &c);
	if (b >= c)sum += (b + c);
	else {
		sum += (2*b);
		c -= b;
		if (a >= c)sum += c;
		else sum += (a+1);
	}
	printf("%d", sum);
	return 0;
}

Measured memory_bytes: 256
n = int(input())
X = list(map(int,input().split()))
Y = list(map(int,input().split()))

x_y = []
for x, y in zip(X,Y):
    x_y.append(abs(x-y))

d1 = sum(x_y)
d2 = 0
for xy in x_y:
    d2 += xy ** 2
d2 = d2 ** (1/2)
d3 = 0
for xy in x_y:
    d3 += xy ** 3
d3 = d3 ** (1/3)
d4 = max(x_y)

print(d1)
print(d2)
print(d3)
print(d4)


Measured memory_bytes: 5640
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

int parse(string& formula){
    int idx = 0;
    int ret = 0;

    int len = formula.size();
    while(idx < len){
        int diff = formula[idx] - '0';
        idx++;

        if(idx >= len){
            ret += diff;
            break;
        }

        char op = formula[idx];
        idx++;
        while(op == '*'){
            int cur = formula[idx] - '0';
            idx++;
            diff *= cur;

            if(idx >= len) break;
            op = formula[idx];
            idx++;
        }

        ret += diff;
    }

    return ret;
}

int main(void){
    string in; cin >> in;
    int bob_res; cin >> bob_res;

    int l_res = in[0] - '0';
    int len = in.size();
    rep(i, 1, len){
        char op = in[i];
        i++;

        int cur = in[i] - '0';
        switch(op){
            case '*': { l_res *= cur; break; }
            case '+': { l_res += cur; break; }
        }
    }
    int f_res = parse(in);

    char res = 'I';
    if(l_res == bob_res and f_res == bob_res){
        res = 'U';
    }
    else if(l_res == bob_res){
        res = 'L';
    }
    else if(f_res == bob_res){
        res = 'M';
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3196
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
//#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vl = vector<ll>;
using vi = vector<int>;
using Graph = vector<vi>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(15); //"for float-base
  // problem"
  int D;
  cin >> D;
  vi C(26), Last(26, -1);
  vector<vi> S(D, vi(26));
  vi T(D);
  REP(i, 26) cin >> C.at(i);
  REP(i, D) REP(j, 26) cin >> S.at(i).at(j);
  REP(i, D) cin >> T.at(i);

  ll ans = 0;

  for (int i = 0; i < D; i++) {
    ll count = 0;
    T.at(i)--;

    REP(j, 26) {
      if (j == T.at(i))
        Last.at(j) = i;
      else
        count -= C.at(j) * (i - Last.at(j));
    }
    // cout << count << endl;

    // cout << "T = " << T.at(i) << " S = " << S.at(i).at(T.at(i)) << endl;
    count += S.at(i).at(T.at(i));
    ans += count;
    cout << ans << endl;
  }

  // cout << ans << endl;
}

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

int n, m;
vector<int> a, b;
map<tuple<int,int,int64_t,int64_t,bool,bool>, int64_t> checked;

int64_t solve(int x, int y, int64_t px, int64_t py, bool k, bool passed){
    tuple<int,int,int64_t,int64_t,bool,bool> key = tuple<int,int,int64_t,int64_t,bool,bool>{x, y, px, py, k, passed};
    if(checked.count(key)) return checked[key];

    int64_t cand[2];
    if(k == 0){
        if(passed)   cand[1] = 0;
        else         cand[1] = solve(x, y, 0, 0, !k, px == 0 && py == 0) + px - py;
        if(x >= n) return checked[key] = cand[1];
        if(a[x] > 0) cand[0] = solve(x + 1, y, px + a[x], py, !k, 0);
        else         cand[0] = solve(x + 1, y, px,        0,  !k, 0);
        return checked[key] = max(cand[0], cand[1]);
    }else{
        if(passed)   cand[1] = 0;
        else         cand[1] = solve(x, y, 0, 0, !k, px == 0 && py == 0) + px - py;
        if(y >= m) return checked[key] = cand[1];
        if(b[y] > 0) cand[0] = solve(x, y + 1, px, py + b[y], !k, 0);
        else         cand[0] = solve(x, y + 1, 0,  py       , !k, 0);
        return checked[key] = min(cand[0], cand[1]);
    }
}

int main(){
    cin >> n >> m;
    a.reserve(n);
    b.reserve(m);
    for(int i=0;i<n;++i){ int x; cin >> x; a.emplace_back(x); }
    for(int j=0;j<m;++j){ int y; cin >> y; b.emplace_back(y); }
    cout << solve(0, 0, 0, 0, 0, 0) << endl;
    
    return 0;
}


Measured memory_bytes: 17552
from scipy.sparse import*
(n,m,s,*D),*t=[map(int,t.split())for t in open(0)]
x=51
r=range(0,x**3,x)
for u,v,a,b in t[:m]:
 for i in r:D+=i+a*x+u,i+v,b,i+a*x+v,i+u,b
i=0
for c,d in t[m:]:
 i+=1
 for j in r:D+=j+i,j+c*x+i,d
d=csgraph.dijkstra(csr_matrix((D[2::3],(D[::3],D[1::3])),[j*2]*2),1,min(j,s*x)+1)
for i in range(2,n+1):print(int(min(d[i::x])))

Measured memory_bytes: 126748
#include <bits/stdc++.h>
using namespace std; inline void fileio(const char* in, const char* out) { freopen(in, "r", stdin); freopen(out, "w", stdout); } 
#define TD typedef
#define forx(i,n) for(int i = 0; i < (n); ++i)
TD long long ll; TD long double ld; TD pair<int,int> pii; TD pair<ll, ll> pll; TD vector<int> VI; TD vector<bool> VB; TD vector<ll> VL;
const char nl = '\n'; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fll; const ld EPS = 1e-9, PI = acos(-1);
#define ff first
#define ss second

int main() {
  atexit([](){ cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << nl; });
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  // Emily <3
  
  int n;
  cin >> n;
  VI balls(n);
  forx(i, n) {
    cin >> balls[i];
  }
  sort(balls.begin(), balls.end());

  vector<pii> ops;
  int x = balls[n-1];
  int y = balls[0];
  for (int i = 1; i < n-1; i++) {
    int b = balls[i];
    if (b < 0) {
      //sub from big
      ops.push_back({x, b});
      x -= b;
    } else {
      //sub from small
      ops.push_back({y, b});
      y -= b;
    }
  }
  cout << x-y << nl;
  for (auto a : ops) {
    cout << a.ff << " " << a.ss << nl;
  }
  cout << x << " " << y << nl;

  return 0;
}


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

int main() {
  string s;
  cin >> s;
  if (s == "SUN"){
    cout << 7 << endl;
  }
  else if (s == "MON"){
    cout << 6 << endl;
  }
  else if (s == "TUE"){
    cout << 5 << endl;
  }
  else if (s == "WED"){
    cout << 4 << endl;
  }
  else if (s == "THU"){
    cout << 3 << endl;
  }
  else if (s == "FRI"){
    cout << 2 << endl;
  }
  else if (s == "SAT"){
    cout << 1 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> P;
 
constexpr int INF = 1e9;
constexpr int MOD = 1e9+7;

int main() {
    ll n,d;
    cin >> n >> d;
    int cnt = 0;
    rep(i,n){
        ll x,y;
        cin >> x >> y;
        if(x*x+y*y<=d*d) cnt++;
    }
    cout << cnt << endl;
 
	return 0;
}

Measured memory_bytes: 3532
/*																													   
 Templatka c++ Kacper Fis																							   																											   //
*/																													  
																								   
#include <bits/stdc++.h>																							   
																													   
using namespace std; 																								   
																													   
const int INF = 1000000001;																						   
const float PI = 3.14;																								   
typedef long long LL;																								   
																													   
typedef vector<int> vi;																								   
typedef list<int> li;																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii; 																							   
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'															   
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford			   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra	   
																													   																				   
vector<ii>::iterator iter;																							   
																													   																				   
#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}							   
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}						   
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)													   
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);											   
#define pb(x) push_back(x) 																							   
#define pf(x) push_front(x)																							   
#define mp(x, y) make_pair(x, y)                                                                                       
///////////////////////////////////////////////GLOBAL DEFINITIONS////////////////////////////////////////////////////////

bool tab[1000005];
int w;

/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])																					 
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);                  												       
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	fill(tab, tab+1000005, true);
	
	int x;
	int n = 100002;
	
	cin >> x;
	
	for(int i = 2; i <= n; i++){
		w = i + i;
		while(w <= n){
			tab[w] = false;
			w += i;
		}
	}
	
	while(1){
		if(tab[x]){
			cout << x << endl;
			return 0;
		}
		else x++;		
	}
	
	
	
	
	
	return 0;
}


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

int main(){
    int n;
    cin >> n;
    ll z, w;
    cin >> z >> w;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    if ( n == 1 ) {
        cout << abs(a[0] - w) << endl;
        return 0;
    }
    cout << max(abs(a[n-1]-w), abs(a[n-1]-a[n-2])) << endl;
//    cout << abs(a[n-1]-w) << " "<< abs(a[n-1]-a[n-2]) << endl;
    return 0;
}


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

class Point {
public:
  double x, y;
  Point(double x = 0, double y = 0):x(x), y(y){}
  Point operator +(Point p) { return Point(x+p.x, y+p.y);}
  Point operator -(Point p) { return Point(x-p.x, y-p.y);}
  Point operator *(double t) { return Point(x*t, y*t);}
};

typedef Point Vector;

double naiseki(Vector a, Vector b);

int isTyokko(Point a1, Point a2, Point b1, Point b2) {
  if(naiseki(Vector(a1.x-a2.x, a1.y-a2.y), Vector(b1.x-b2.x, b1.y-b2.y)) == 0) {
    return 1;
  } else {
    return 0;
  }
}

double naiseki(Vector a, Vector b) {
  return a.x*b.x + a.y*b.y;
}

int main() {
  Point a, b, c, d;
  while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &a.x, &a.y, &b.x, &b.y, &c.x, &c.y, &d.x, &d.y) != EOF) {
    if(isTyokko(a, b, c, d)) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <string.h>
int main(void){


  
     char S[1010] ;
       char T[1009] ;
      int lengthS;
        int lengthT;
      
    int r ;
    int p ;
    
     scanf("%s",S);
      scanf("%s",T);
    
  

    
    
      lengthS = strlen(S);
        lengthT =strlen(T);
    
    int answer = lengthT;
    
    for(r=0;r<=lengthS -lengthT ;r++){
        int total =lengthT;
     for(p=0;p<=lengthT -1;p++){
        
         if(S[p+r]==T[p]){--total;}
    }
        
        if(answer>total) {answer = total ;}
     }
       
     printf("%d",answer);
  
      return 0;
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define N (long long)(1e5)
using namespace std;

long long q;
vector<long long> sum;

void prepair();
void solve();

int main() {
  cin >> q;
  prepair();
  solve();
  return 0;
}

void prepair() {
  sum.assign(N + 1, 0);
  for(int i = 2; i <= N; ++i) {
    sum[i] = sum[i - 1];
    long long cnt = 0;
    for(long long j = 2; j * j <= i; ++j)
      if(i % j == 0) ++cnt;
    if(cnt >= 2) ++sum[i];
  }
}
void solve() {
  for(int i = 0; i < q; ++i) {
    int n;
    cin >> n;
    cout << sum[n] << endl;
  }
}


Measured memory_bytes: 3632
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

void solve() {
  while (true) {
    ll H, W;
    cin >> H >> W;
    if (H == 0 and W == 0) return;
    rep (h, H) {
      rep (w, W) cout << "#";
      cout << endl;
    }
    cout << endl;
  }
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  cout << fixed;
  solve();
  return 0;
}



Measured memory_bytes: 3168
import java.io.IOException;
import java.math.BigDecimal;
import java.math.BigInteger;

public class Main {
    private static final StringBuilder builder = new StringBuilder();
    public static void main(String[] args) {
        if (readInt() >= 30) {
            System.out.print("Yes");
        } else {
            System.out.print("No");
        }
    }

    private static void read() {
        builder.setLength(0);
        while (true) {
            try {
                int b = System.in.read();
                if (b == ' ' || b == '\n' || b == -1) {
                    break;
                } else {
                    builder.appendCodePoint(b);
                }
            } catch (IOException e) {
                break;
            }
        }
    }

    private static int readInt() {
        read();
        return Integer.parseInt(builder.toString());
    }

    private static int readInt(int radix) {
        read();
        return Integer.parseInt(builder.toString(), radix);
    }

    private static long readLong() {
        read();
        return Long.parseLong(builder.toString());
    }

    private static long readLong(int radix) {
        read();
        return Long.parseLong(builder.toString(), radix);
    }

    private static BigInteger readBigInteger() {
        read();
        return new BigInteger(builder.toString());
    }

    private static BigInteger readBigInteger(int radix) {
        read();
        return new BigInteger(builder.toString(), radix);
    }

    private static double readDouble() {
        read();
        return Double.parseDouble(builder.toString());
    }

    private static BigDecimal readBigDecimal() {
        read();
        return new BigDecimal(builder.toString());
    }

    private static float readFloat() {
        read();
        return Float.parseFloat(builder.toString());
    }

    private static void skipLine() {
        while (true) {
            try {
                int b = System.in.read();
                if (b == '\n' || b == -1) {
                    break;
                }
            } catch (IOException e) {
                break;
            }
        }
    }

    private static void skip() {
        while (true) {
            try {
                int b = System.in.read();
                if (b == ' ' || b == '\n' || b == -1) break;
            } catch (IOException e) {
                break;
            }
        }
    }

}


Measured memory_bytes: 32352
# 頭から探して見つかったら適当に次のやつと入れ替えりゃいいのでは
# ->なんか4ケースでダメになるのでなんかを見逃してるっぽい
# 無限にわからん

n = int(input())
arr = list(map(int, input().split()))

count = 0
for i in range(0, n):
    if arr[i] == i + 1:
        if i == n - 1:
            arr[i], arr[0] = arr[i], arr[0]
        else:
            arr[i], arr[i + 1] = arr[i + 1], arr[i]
        count += 1


print(count)



Measured memory_bytes: 14004
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int k=sc.nextInt();
		int h[]=new int[n];
		for(int i=0; i<n; i++) {
			h[i]=sc.nextInt();
		}
		Arrays.sort(h);
		int ans = 1001001001;
		for(int i=0; i<n-k+1; i++) {
			ans=Math.min(ans, Math.abs(h[i] - h[i+k-1]));
		}
		System.out.println(ans);
		sc.close();
	}

}


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

#define all(x) begin(x), end(x)

using i64 = int_fast64_t;
using f64 = double;
using p64 = pair<i64, i64>;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

void solve() {
    i64 n;
    cin >> n;
    i64 cnt = 0;
    for (i64 i = 0; i < n; i++) {
        i64 a;
        cin >> a;
        if (a % 2) cnt++;
    }

    cout << (cnt % 2 ? "NO" : "YES") << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    string s,t; cin>>s>>t;
    cout << t<<s << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
int h, w, i, j;
scanf("%d %d", &h, &w);
while( h != 0 && w != 0 ) {
for(i = 0; i < h; ++i ) {
for(j = 0; j < w; ++j ) {
if((i%2==0&&j%2==0)||(i%2==1&&j%2==1) ) {
putchar('#');
} else {
putchar('.');
}
}
putchar('\n');
}
putchar('\n');
scanf("%d %d", &h, &w);
}
return 0;
}

Measured memory_bytes: 1004
<?php
fscanf(STDIN,"%d\n",$n);
$pos=0;
for($i=2;$pos<$n;$i++){
    if($i%5==1){
        $ng=0;
        for($j=2;$j<$i;$j++){
            if($i%$j==0){
              $ng=1;
              break;
            }
        }
        if($ng==0){
            $pos++;
            echo $i," ";
        }
    }
    echo "\n";
}
?>

Measured memory_bytes: 3576