akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>
#include <random>
#include <list>
#include <numeric>
#include <chrono>


#define rep(i,p,q) for(ll i = p;i < q;i++)
#define ll long long

using namespace std;

vector<vector<ll>> graph;
vector<ll> query;
vector<ll> ans;
vector<ll> visited;


const long long MAX_N = 1 << 17;

long long dat[2 * MAX_N - 1];

//141 C
int main(void) {
	ll n,k,q;
	cin >> n >> k >> q;
	vector<ll> ans = vector<ll>(n, 0);
	rep(i, 0, q) {
		ll a;
		cin >> a;
		ans[a - 1]++;
	}
	rep(i, 0, n) {
		if (q - ans[i] >= k)cout << "No" << endl;
		else cout << "Yes" << endl;
	}
}


Measured memory_bytes: 1408
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<map>
#include<numeric>
//#include <bits/stdc++.h>
#include<cstring>
#include<iostream>
#include<functional>
using namespace std;
int main() {
	int X, t;
	cin >> X >> t;
	if (X < t)
		cout << 0 << endl;
	else
		cout << (X - t) << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
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 main(){
    cout << fixed << setprecision(10);
    ll n,a,b;
    cin >> n >> a >> b;
    if(n == 1){
        if(a != b){
            cout << 0 << endl;
            return 0;
        }else{
            cout << 1 << endl;
            return 0;
        }
    }
    if(a > b){
        cout << 0 << endl;
        return 0;
    }
    if(a == b){
        cout << 1 << endl;
        return 0;
    }

    cout << b * (n - 1) + a - (a * (n - 1) + b) + 1 << endl;

    return 0;
}

Measured memory_bytes: 3608
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 1LL << 61;
const ll mod = 1000000007LL;
//const ll mod = 998244353LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok;
ll dx[9] = { 0,1,0,-1,0,1,1,-1,-1 }, dy[9] = { 0,0,1,0,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222





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


  cin >> n;
  vpll v;
  rep(i, n) {
    ll a, b;
    cin >> a >> b;
    v.pb(make_pair(b, a));
  }
  sort(all(v));
  ok = true;
  ll cur = 0;
  rep(i, n) {
    cur += v[i].second;
    if (cur > v[i].first) {
      ok = false;
      break;
    }
  }

  if (ok) cout << "Yes" << endl;
  else cout << "No" << endl;
  

  return 0;
}

Measured memory_bytes: 6512
#include <bits/stdc++.h>
 
using namespace std;
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
 
const long long INF = 1LL << 60;
#define PI 3.14159265359 
bool dp[100100];


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

    vector<int>A(N);
    rep(i,N){
        cin >> A[i];
    }

    vector<int>kyori(N);
    rep(i,N-1){
        kyori[i]=A[i+1]-A[i];
    }
    kyori[N-1]=K-A[N-1]+A[0];

    long long ans = 0;
    int m =kyori[0];
    rep(i,N){
        ans += kyori[i];
        m =max(m,kyori[i]);
    }

    cout << ans-m << endl;
}

Measured memory_bytes: 1792
program sequence_sum;
var
  n, x, m, num: int64;
  i, offset, period, rem: integer;
  a: array[0..100000] of int64;
  b: array[0..100000] of integer;
begin
  read(n, x, m);
  if n = 1 then
  begin
    writeln(x);
    halt(0);
  end;
  a[1] := x;
  b[x] := 1;
  for i := 2 to m + 1 do
  begin
    x := (x * x) mod m;
    a[i] := a[i - 1] + x;
    if i = n then
    begin
      writeln(a[i]);
      halt(0);
    end;
    if b[x] > 0 then
    begin
      offset := b[x] - 1;
      period := i - offset - 1;
      break;
    end;
    b[x] := i;
  end;
  num := (n - offset) div period;
  rem := n - offset - num * period;
  writeln((a[offset + period] - a[offset]) * num + a[offset + rem]);
end.

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

int main(){
    int h,w;
    cin >> h >> w;
    char a[h][w];
    int counth=0,countw=0;
    int counthw[h][w];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            counthw[i][j]=0;
        }
    }
    for(int i=0;i<h;i++){
        countw=0;
        for(int j=0;j<w;j++){
            cin >> a[i][j];
            if(a[i][j]=='.'){
                countw++;
            }
            if(a[i][j]=='#'){
                for(int k=1;k<countw+1;k++){
                    counthw[i][j-k]+=countw;
                }
                countw=0;
            }
            else if(j==w-1){
                for(int k=0;k<countw;k++){
                    counthw[i][j-k]+=countw;
                }
                countw=0;
            }
        }
    }
    for(int i=0;i<w;i++){
       counth=0;
        for(int j=0;j<h;j++){
            if(a[j][i]=='.'){counth++;}
            if(a[j][i]=='#'){
                for(int k=1;k<counth+1;k++){
                    counthw[j-k][i]+=counth;
                }
                counth=0;
            }
            if(j==h-1&&a[j][i]=='.'){
                for(int k=0;k<counth;k++){
                    counthw[j-k][i]+=counth;
                }
                counth=0;
            }
        }
    }
    int ans =0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            ans=max(ans,counthw[i][j]-1);
        }
    }
    cout << ans << endl;
}

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

int compare_int(int *a, int *b){
	return *a - *b;
}

int main() {
	int N, K;
	scanf("%d %d", &N, &K);
	int H[N];
	long long ans = 0;
	for(int i = 0;i < N;i++){
		scanf("%d", &H[i]);
	}
	qsort(H, N, sizeof(int), compare_int);
	for(int i = 0;i < N - K;i++){
		ans += H[i];
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1788
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while(true) {
			int H = scan.nextInt();
			int W = scan.nextInt();
			if (H == 0 && W == 0) break;
			for (int i = 0; i < H; i++) {
				for(int k = 0; k < W; k++) {
					if(i == 0 || i == H-1) {
						System.out.print("#");
					}
					else if (i != 0 && (k != 0 && k != W-1)) {
						System.out.print(".");
					}
					else {
						System.out.print("#");
					}
				}
				System.out.println();
			}
			System.out.println();
		}
	}

}


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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = 1e9 + 100;
const long long LLINF = 2e18 + 129;
const long long MOD = 1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

lint solve(void){
    lint k, a, b;
    cin >> k >> a >> b;

    if(a + 1LL >= b || 1LL + k <= a){
        return 1LL + k;
    }

    k -= (a - 1LL);
    lint res = a;
    res += (b - a) * (k / 2LL);
    res += k % 2LL;
    return res;
}

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

    lint ans = solve();
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 2e5 + 7;
const int INF = 1e18 + 7;
const int MOD = 1000 * 1000 * 1000 + 7;
int mod(int n) {
    return (n % MOD + MOD) % MOD;
}   
int n, m;
int S, T;
struct Edge {
    int v, c;
};  
int dist[2][N];
int dp[2][N];
vector <Edge> g[N];
void work(int S, int *dist, int *dp) {
    set <pair <int, int> > ms;
    for (int i = 1; i <= n; ++i) {
        dist[i] = INF;
    }   
    dist[S] = 0;
    dp[S] = 1;
    ms.insert({0, S});
    while (ms.size()) {
        int u = ms.begin()->second; ms.erase(ms.begin());
        for (auto e : g[u]) {
            if (dist[u] + e.c < dist[e.v]) {
                ms.erase({dist[e.v], e.v});
                dist[e.v] = dist[u] + e.c;
                dp[e.v] = dp[u];
                ms.insert({dist[e.v], e.v});
            }   
            else if (dist[u] + e.c == dist[e.v]) {
                dp[e.v] = mod(dp[e.v] + dp[u]);
            }   
        }   
    }   
}   
struct Ed {
    int u, v, c;
};  
vector <Ed> ed;
bool check(int x, int y, int c) {
    if (y < x) swap(x, y);
    return y < x + c;
}   
int D;
bool mem(int t, int u, int v, int c) {
    return dist[t][u] + c == dist[t][v] && dist[t][v] + dist[t ^ 1][v] == D;
}
int f(int n) {
    n = mod(n);
    return mod(n * n);
}   
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    cin >> n >> m >> S >> T;
    for (int i = 0; i < m; ++i) {
        int u, v, c;
        cin >> u >> v >> c;
        g[u].push_back({v, c});
        g[v].push_back({u, c});
        ed.push_back({u, v, c});
    }   
    work(S, dist[0], dp[0]); work(T, dist[1], dp[1]);
    D = dist[0][T];
    int ans = mod(dp[0][T] * dp[0][T]);
    for (int i = 1; i <= n; ++i) {
        if (dist[0][i] + dist[1][i] == D && dist[0][i] == dist[1][i]) {
            ans = mod(ans - f(dp[0][i] * dp[1][i]));
        }   
    }   
    for (auto e : ed) {
        if (mem(0, e.u, e.v, e.c) && mem(1, e.v, e.u, e.c)) {
            if (check(dist[0][e.u], dist[1][e.v], e.c)) {
                ans = mod(ans - f(dp[0][e.u] * dp[1][e.v]));
            }   
        }
        else if (mem(1, e.u, e.v, e.c) && mem(0, e.v, e.u, e.c)) {
            if (check(dist[1][e.u], dist[0][e.v], e.c)) {
                ans = mod(ans - f(dp[1][e.u] * dp[0][e.v]));
            }   
        }   
    }   
    cout << ans << '\n';
}   

Measured memory_bytes: 32164
import numpy as np
import sys
sys.setrecursionlimit(100000)



def acinput():
    return list(map(int, input().split(" ")))



directions=np.array([[1,0],[0,1],[-1,0],[0,-1]])
directions = list(map(np.array, directions))

mod = 10**9+7


def factorial(n):
    fact = 1
    for integer in range(1, n + 1):
        fact *= integer
    return fact



def serch(x, count):
    #print("top", x, count)
            

    for d in directions:
        nx = d+x
        #print(nx)
        if np.all(0 <= nx) and np.all(nx < (H, W)):
            if field[nx[0]][nx[1]] == "E":
                count += 1 
                field[nx[0]][nx[1]] = "V"
                count = serch(nx, count)  
                continue
            if field[nx[0]][nx[1]] == "#":
                field[nx[0]][nx[1]] = "V"
                count = serch(nx, count)    
                 
    return count

N=int(input())
A=np.array(acinput())
s=A-range(1,N+1)

s=sorted(s)
m=round(np.median(s))

res=0
for i in range(N):
    res+=np.abs(A[i]-m-(i+1))

print(int(res))


Measured memory_bytes: 34188
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

#define N 100
void trace(int *A, int n);
void insertionSort(int *A, int n);

int main(void){
	int n, i = 0, A[N] = {0};

	scanf("%d", &n);
	while(i < n) scanf("%d", &A[i++]);

	trace(A, n);
	insertionSort(A, n);

	return 0;
}

void trace(int *A, int n){
	int i = 0;

	while(i < n){
		if(i > 0) printf(" ");
		printf("%d", A[i++]);
	}

	putchar('\n');
}

void insertionSort(int *A, int n){
	int v, i, j;

	for(i = 1; i < n; i++){
		v = A[i];
		j = i - 1;
		while(j >= 0 && A[j] > v){
			A[j + 1] = A[j];
			j--;
		} 
		A[j + 1] = v;
		trace(A, n);
	}
}


Measured memory_bytes: 1960
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    string s;
    cin >> s;

    int n = s.size();
    int count = 0;

    for (int i = 0; i < n / 2; i++) {
        if (s[i] != s[n - i - 1]) {
            count++;
        }
    }

    cout << count << "\n";
    return 0;
}

Measured memory_bytes: 256
use std::io::prelude;
use std::{io};
use std::collections::{HashMap, HashSet, VecDeque};
use std::cmp::Ordering;

fn string_to_nums(s: String) -> Vec<isize> {
    let mut v = Vec::new();
    for part in s.split_whitespace() {
        v.push(part.parse::<isize>().unwrap())
    }
    v
}

fn read_a_line() -> String {
    let mut s = String::new();
    assert!(io::stdin().read_line(&mut s).is_ok());
    s.trim().to_string()
}

fn read_nums() -> Vec<isize> {
    string_to_nums(read_a_line())
}

fn main() {
    let abc = read_nums();
    for n in 1..100 {
        if abc[0] * n % abc[1] == abc[2] { println!("YES"); return }
    }
    println!("NO");
}


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = INT_MAX / 2;
const ll  inf = LLONG_MAX / 2;
const int mod = 1000000007;
const int MAX_N = 101010;
const double PI = acos(-1);

int n;

void dfs(string A, char ma) {
	if (sz(A) == n) {
		out(A);
		return;
	}

	for (char c = 'a'; c <= ma; c++) {
		dfs(A + c, (c == ma) ? (char)(ma + 1) : ma);
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	cin >> n;

	dfs("", 'a');

	return 0;
}

Measured memory_bytes: 1536
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
public class Main {
	static final long C =  1000000007;
	static final int CY = 1000000000;
	StringBuilder sb;
	public void calc() {
		sb = new StringBuilder();


		FastScanner sc = new FastScanner();

		String s = sc.next();


		String ans = s.substring(0,4) + " " + s.substring(4);

		System.out.println(ans);
	}



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

	}
	static class FastScanner {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;
		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			}else{
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}
		private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
		private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
		private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
		public boolean hasNext() { skipUnprintable(); return hasNextByte();}
		public String next() {
			if (!hasNext()) throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while(isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
		public long nextLong() {
			if (!hasNext()) throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while(true){
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				}else if(b == -1 || !isPrintableChar(b)){
					return minus ? -n : n;
				}else{
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}
		public int nextInt() {
			if (!hasNext()) throw new NoSuchElementException();
			int n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while(true){
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				}else if(b == -1 || !isPrintableChar(b)){
					return minus ? -n : n;
				}else{
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}
	}
}


Measured memory_bytes: 8148
N = int(input()) 
A = list(map(int, input().split())) 
cnt = 0

for j in range(N): 
    for i in range(N-1,j,-1): 
        v = A[i] 
        if A[i-1] > A[i]: 
            A[i] = A[i-1] 
            A[i-1] = v 
            cnt += 1
        else:
            continue

print(*A)
print(cnt)


Measured memory_bytes: 5600
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <cstring>
#include <vector>
#include <map>
#include <cmath>
#include <climits>

//find out the use of the below
#include <list>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <memory.h>
#include <cassert>

using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> set_t;
#define mp(a,b) make_pair((a),(b))
#define LL long long
#define pii pair<int,int>
#define pll pair<LL,LL>
#define pdd pair<double,double>
#define pb push_back
#define x first
#define y second
#define sqr(x) ((x)*(x))
#define EPS 1e-6
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
#define pi acos(-1)
vector<int> g[(int)1e5+5];
int pr[(int)1e5+5];
int dfs(int u, vector<int>* g){
    if (pr[u] != 0)
        return pr[u];
    int ans = 0;
    for (int v: g[u]){
        ans = max(dfs(v, g), ans);
    }
    return pr[u] = ans+1;
}

int main(){
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt","w", stdout);
    int n, m;
    scanf("%d %d", &n, &m);
    for (int i = 0; i < m; ++i){
        int x, y;
        scanf("%d%d", &x, &y);
        g[x].pb(y);
    }
    int ans = 0;
    for (int i = 0; i < n; ++i){
        if (pr[i+1] == 0){
            ans = max(ans, dfs(i+1, g));
        }
    }
    cout << ans-1; 
    return 0;
}
/* BEFORE submitting, check for:
 *  1. Integer overflow
 *  2. Float/Double precision errors
 *  3. Array index out of bounds
 *  4. Edge cases.(n=1, n=max, etc.)
 *  5. Time complexity. No TLEs
 */


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

using namespace std;

const int MAX_N = 22;

vector<vector<int>> F[MAX_N];

vector<bool> exist[MAX_N];

int N, K;

void calc(int len, int val, int split) {
    int &res = F[len][val][split];
    if (split == 0) {
        res += exist[len][val];
        if (len < N) {
            res += F[len + 1][val][split];
            res += F[len + 1][val + (1 << len)][split];
        }
    } else {
        int pre = val & (1 << split) - 1, suf = val >> split;
        res += F[len][(pre >> 1) + (suf << split - 1) + ((pre & 1) << len - 1)][split - 1];
        if (len < N) {
            res += F[len + 1][val + (((pre & 1) ^ 1) << len)][split];
        }
    }
}

int main() {
    scanf("%d%d", &N, &K);
    for (int i = 0; i <= N; i++) {
        char buf[1 << MAX_N]; scanf("%s", buf);
        exist[i].resize(1 << i);
        for (int j = 0; j < 1 << i; j++) exist[i][j] = buf[j] == '1';
    }
    for (int i = 0; i <= N; i++) {
        F[i].resize(1 << i, vector<int>(i + 1));
    }
    for (int len = N; len >= 0; len--) {
        for (int split = 0; split <= len; split++) {
            for (int val = 0; val < 1 << len; val++) {
                calc(len, val, split);
            }
        }
    }
    for (int i = N; i >= 0; i--) {
        for (int j = 0; j < 1 << i; j++) {
            if (F[i][j][i] >= K) {
                for (int k = i - 1; k >= 0; k--)
                    printf("%d", j >> k & 1);
                printf("\n");
                return 0;
            }
        }
    }
}


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

int main()
{
  int n;
  cin >> n;
  int ans = 0, p = 1;
  for (int i = 1; i <= 5; i++)
  {
    p *= 10;
    if (i % 2)
      ans += max(0, min(n, p - 1) - p / 10 + 1);
  }
  cout << ans << endl;
}


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

int main(void){
	int p,n,sum=0;
	double num=0,kind=0;
	while(scanf("%d,%d",&p,&n)!=EOF){
		sum+=p*n;num+=n;kind++;
	}
	printf("%d\n%d\n",sum,(int)floor(num/kind+0.5));
	return 0;
}

Measured memory_bytes: 592
#include <iostream>

using namespace std;

const long MOD = 1000000007;

long pow2[100002];
long pow3[100002];

void init(){
    pow2[0] = 1;
    pow3[0] = 1;
    for(int i = 1; i <= 100001; i++){
        pow2[i] = pow2[i-1]*2;
        pow2[i] %= MOD;
        pow3[i] = pow3[i-1]*3;
        pow3[i] %= MOD;
    }
}

int main(){
    init();
    string L;
    cin >> L;
    int N = L.size();
    long ans = 0;
    
    int cnt = 0;
    for(int i = 0; i < N; i++){
        if(L[i] == '1'){
            cnt++;
            ans += pow2[cnt-1]*pow3[N-(i+1)];
            ans %= MOD;
        }
    }
    
    ans += pow2[cnt];
    ans %= MOD;
    cout << ans << endl;
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-12, PI = acos(-1);
const int N = 1e6 + 9, M = 3e3 + 9, OO = 1e9 + 7, MOD = 1e9 + 7;
const ll inf = 1e18;

int tree[5*N], lazy[5*N];

void propagate(int node, int start, int end) {
  if(lazy[node] == 1061109567)
    return;
  tree[node] = min(lazy[node], tree[node]);
  if(start != end) {
    lazy[node * 2] = min(lazy[node*2], lazy[node]);
    lazy[node * 2 + 1] = min(lazy[node*2 + 1], lazy[node]);
  }
  lazy[node] = 1061109567;
}

void update(int node, int start, int end, int l, int r, int val) {
  propagate(node, start, end);
  if(start > r || end < l)
    return;
  if(start >= l && end <= r) {
    if(!lazy[node])
      lazy[node] = val;
    else
      lazy[node] = min(lazy[node], val);
    propagate(node, start, end);
    return;
  }
  int mid = (start + end) / 2;
  update(node * 2, start, mid, l, r, val);
  update(node * 2 + 1, mid + 1, end, l, r, val);
  tree[node] = min(tree[node * 2], tree[node * 2 + 1]);
}

int query(int node, int start, int end, int idx) {
  propagate(node, start, end);
  if(start == end)
    return tree[node];
  int mid = (start + end) / 2;
  if(idx <= mid)
    return query(node * 2, start, mid, idx);
  else
    return query(node * 2 + 1, mid + 1, end, idx);
}

int main() {
  fastIO;
#ifdef LOCAL
  freopen("input.in", "rt", stdin);
#endif
  int n, m, start, end, x, d;
  cin >> n >> m;
  memset(tree, '?', sizeof tree);
  memset(lazy, '?', sizeof lazy);
//  cout << tree[0] << endl;
//  return 0;
  map<int, int> mp;
  vector<pair<pair<int, int>, int>> vec;
  vector<int> q;
  for (int i = 0; i < n; ++i) {
    cin >> start >> end >> x;
    int startTime = max(0, start - x);
    int endTime = end - x - 1;
    if(endTime < startTime) continue;
    mp[endTime];
    mp[startTime];
    vec.push_back({{startTime, endTime}, x});
//    update(1, 0, 25, startTime, endTime, x);
  }
  for (int i = 0; i < m; ++i) {
    cin >> d;
    q.push_back(d);
    mp[d];
//    int val = query(1, 0, 25, d);
//    if(val == 1061109567)
//      val = -1;
//    cout << val << '\n';
  }
  int idx = 1;
  for(auto it: mp)
    mp[it.first] = idx++;
  for (int i = 0; i < (int)vec.size(); ++i) {
    int startTime = vec[i].first.first;
    int endTime = vec[i].first.second;
    int VAL = vec[i].second;
    startTime = mp[startTime];
    endTime = mp[endTime];
    update(1, 1, idx, startTime, endTime, VAL);
  }
  for (int i = 0; i < m; ++i) {
    d = mp[q[i]];
    int val = query(1, 1, idx, d);
    if(val == 1061109567)
      val = -1;
    cout << val << '\n';
  }
  return 0;
}


Measured memory_bytes: 71984
def solve(N, A):
    rmax = 0
    for i in range(N):
        r = sum(A[0][0:i + 1]) + sum(A[1][i:])
        rmax = max(rmax, r)
    return rmax

N = int(input())
A = [[int(x) for x in input().split()] for i in range(2)]
print(solve(N, A))


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

using namespace std;
#define int long long
int inf = 1e9 + 2;
signed main()
{
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];

    vector<int> dp;
    dp.resize(n,inf);

    dp[0] = 0;

    for (int i = 0; i < n; i++)
    {
        for (int j = 1; j <= k; j++)
        {   if(i+j < n)
                dp[i + j] = min(dp[i+j], dp[i] + abs(a[i+j] - a[i]));
        }
    }

    cout << dp[n - 1] << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>

using namespace std;

int main() {
    long long int N;
    vector<long long int> cap(5);
    
    cin >> N;
    for(auto& c : cap)
        cin >> c;
    
    if(N == 0) {
        cout << 0 << endl;
        return 0;
    }

    long long int minimum = *min_element(cap.begin(), cap.end());

    cout << 5 + (N-1) / minimum << endl;;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <deque>
#include <numeric>
#include <sstream>
#include <iomanip>
using lint = long long;

int main()
{
    lint sx, sy, tx, ty;
    scanf("%lld", &sx);
    scanf("%lld", &sy);
    scanf("%lld", &tx);
    scanf("%lld", &ty);

    lint dist_x = abs(tx - sx);
    lint dist_y = abs(ty - sy);

    std::string ans = "";
    ans += std::string(dist_x, 'R') + std::string(dist_y, 'U');
    ans += std::string(dist_x, 'L') + std::string(dist_y, 'D');
    ans += std::string(1, 'D') + std::string(dist_x + 1, 'R') + std::string(dist_y + 1, 'U') + std::string(1, 'L');
    ans += std::string(1, 'U') + std::string(dist_x + 1, 'L') + std::string(dist_y + 1, 'D') + std::string(1, 'R');

    std::cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int a, b, c; cin >> a >> b >> c;
    if (b >= c - 1) { cout << b + c << endl; return 0; }
    int ans = 0;
    ans += 2*b;
    if (a >= c - b - 1) ans += c - b;
    else ans += a + 1;
    cout << ans << endl;
}


Measured memory_bytes: 256
fun main(args : Array<String>) {
    val (a, b, c, d) = readLine()!!.map { it.toString().toInt() }

    for (i in 0..1) {
        for (j in 0..1) {
            for (k in 0..1) {
                var ans = if (i == 0) a + b else a - b
                ans += if (j == 0) c else -c
                ans += if (k == 0) d else -d

                if (ans == 7) {
                    println("$a${if (i == 0) '+' else '-'}$b${if (j == 0) '+' else '-'}$c${if (k == 0) '+' else '-'}$d=7")
                    return
                }
            }
        }
    }
}

Measured memory_bytes: 33688
# dp[c1][c2][c3]=
# 		(1個の皿がc1枚、2個の皿がc2枚、3個の皿がc3枚あるとき、全て食べるまでの操作回数の期待値)

N = int(input())
A = list(map(int, input().split()))
cnt1 = A.count(1)
cnt2 = A.count(2)
cnt3 = A.count(3)

dp = [[[-1] * (N + 1) for _ in range(N + 1)] for _ in range(N + 1)]
dp[0][0][0] = 0

# dp[c1][c2][c3]=
# 	1
# 	+dp[c1−1][c2][c3]∗(1個の皿が選ばれる確率)
# 	+dp[c1+1][c2−1][c3]∗(2個の皿が選ばれる確率)
# 	+dp[c1][c2+1][c3−1]∗(3個の皿が選ばれる確率)
# 	+dp[c1][c2][c3]∗(0個の皿が選ばれる確率)
# ↓式変形↓
# dp[c1][c2][c3]=
# 	1/(1−(0個の皿が選ばれる確率))
# 	+ dp[c1−1][c2][c3]*(1個の皿が選ばれる確率)/(1−(0個の皿が選ばれる確率))
# 	+ dp[c1+1][c2−1][c3]*(2個の皿が選ばれる確率)/(1−(0個の皿が選ばれる確率))
# 	+ dp[c1][c2+1][c3−1]*(3個の皿が選ばれる確率)/(1−(0個の皿が選ばれる確率))


def func(c1, c2, c3):
    if dp[c1][c2][c3] != -1:
        return dp[c1][c2][c3]

    #　1-(0個の皿が選ばれる確率), 繰り返し登場するので先に計算しておく
    prob = 1 - (N - c1 - c2 - c3) / N

    temp = 1 / prob
    if c1 > 0:
        temp += func(c1 - 1, c2, c3) * (c1 / N) / prob
    if c2 > 0:
        temp += func(c1 + 1, c2 - 1, c3) * (c2 / N) / prob
    if c3 > 0:
        temp += func(c1, c2 + 1, c3 - 1) * (c3 / N) / prob

    dp[c1][c2][c3] = temp
    return temp


print(func(cnt1, cnt2, cnt3))


Measured memory_bytes: 400876
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <sstream>
#include <climits>
#include <cfloat>
#include <complex>

using namespace std;

static int c;
int gcd(int x, int y)
{
	if (y == 0)
		return x;
	++c;
	return gcd(y, x % y);
}	
int main()
{
	int x, y;
	while (scanf("%d %d", &x, &y), x | y)
	{
		if (x < y)
			swap(x, y);
		c = 0;
		int ans = gcd(x, y);
		printf("%d %d\n", ans, c);
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;



#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

ll debugFlag = false;
template<typename T> void debug(T&);
template<typename T> void debug(T&, bool);
template<typename T> void debug(vector<T>&);
template<typename T> void debug(vector<T>&, bool);
template<typename T, typename U> void debug(pair<T, U>&);
template<typename T, typename U> void debug(pair<T, U>&, bool);

template<typename T>
void debug(T& obj) {
	debug(obj, true);
}

template<typename T>
void debug(T& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << obj;
	if (lnFlag) cout << endl;
}

template<typename T>
void debug(vector<T>& obj) {
	debug(obj, true);
}

template<typename T>
void debug(vector<T>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "[";
	rep(i, obj.size()) {
		if (i != 0) cout << ",";
		debug(obj[i], false);
	}
	cout << "]";
	if (lnFlag) cout << endl;
}

template<typename T, typename U>
void debug(pair<T, U>& obj) {
	debug(obj, true);
}

template<typename T, typename U>
void debug(pair<T, U>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "(";
	debug(obj.first, false);
	cout << ",";
	debug(obj.second, false);
	cout << ")";
	if (lnFlag) cout << endl;
}

void solve() {

	ll N;
	cin >> N;

	vector<vector<ll>> vec(N, vector<ll>(N - 1));

	rep(i, N) rep(j, N - 1) {
		cin >> vec[i][j];
		vec[i][j]--;
	}

	vector<ll> num(N, 0);

	vector<vector<ll>> days(N, vector<ll>(N - 1,0));

	ll ans = 0;
	ll end = 0;

	vector<bool> def(N, false);

	set<ll> SET;
	rep(i, N) SET.insert(i);

	while (1) {

		ll but = 0;

		set<ll> nextSET;

		for (auto itr = SET.begin(); itr != SET.end();itr++) {

			ll i = *itr;

			if (def[i] == true) continue;
			if (num[i] == N - 1) continue;

			ll opp = vec[i][num[i]];
			if (def[opp] == true) continue;

			if (vec[opp][num[opp]] == i) {
				def[i] = true;
				def[opp] = true;
				num[i]++;
				if (num[i] == N - 1) end++;
				num[opp]++;
				if (num[opp] == N - 1) end++;
				but++;
				nextSET.insert(i);
				nextSET.insert(opp);
			}
			else {
			}
		}

		SET = nextSET;

		if (but == 0) {
			break;
		}

		ans++;
		rep(i, N) def[i] = false;
	}

	if (end == N) cout << ans;
	else cout << -1;

}


int main(int argc, char* argv[]) {
	if (argc == 2 && string(argv[1]) == "debug") debugFlag = true;
	solve();
	return 0;
}


Measured memory_bytes: 16000
#include<bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cstdlib>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;

int main()
{
    int N,K;
    scanf("%d%d",&N,&K);
    if(N%K!=0)
        printf("1\n");
    else
        printf("0\n");
    return 0;
}


Measured memory_bytes: 256
s,t=input(),input()
ans=1e9
for si in range(len(s)):
    if (si+len(t) > len(s)):break
    cnt=0
    for i in range(len(t)):
        if(s[si+i]!=t[i]):
            cnt+=1
    ans=min(ans,cnt)
print(ans)

Measured memory_bytes: 9060
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
ll MOD=1e9+7;
#define INF 2*1e9
#define N 1000010
#define MAX_V 900010
#define vec vector<int>
using namespace std;

bool check(vec v,int x){
    bitset<40000> b;
    b[20000]=1;
    rep(i,v.size()){
        int t=v[i];
        b=(b<<t)|(b>>t);
    }
    return b[20000+x];
}
main(){
    string s;
    int x,y;
    cin>>s>>x>>y;
    vector<int> v1,v2;
    int count=0,pos=0;
    while(s[pos]=='F'&&pos<s.size()){
        x--;pos++;
    }
    count++;
    pos++;
    while(pos<s.size()){
        int t=0;
        while(s[pos]=='F'){
            t++;pos++;
        }
        if(count%2){
            v2.pb(t);
        }
        else v1.pb(t);
        count++;pos++;
    }
    cout<<(check(v1,x)&&check(v2,y)?"Yes":"No");
}

Measured memory_bytes: 384
n = int(input())
p = list(map(int,input().split()))

a = 0
for i in range(1,n-1,1):
  if p[i-1]<p[i]:
    if p[i]<=p[i+1]:
      a +=1
  if p[i+1]<p[i]:
    if p[i]<=p[i-1]:
      a +=1

print(a)
  

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

int main(){
    string s;
    cin >> s;
    int l = s.length();
    ll ans = 0;
    int p = 0;
    ll a = 0;
    while(p < l-2){
        if(s[p] == 'A' && s[p+1] == 'B' && s[p+2] == 'C'){
            ans += a+1;
            s[p] = 'B'; s[p+1] = 'C'; s[p+2] = 'A';
            p += 2;
        } else if(s[p] == 'A' && !(s[p+1] == 'B' && s[p+2] == 'C')) {
            a++; p++;
        } else {
            a = 0; p++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
A, B = map(int,input().split())
ans = 0
flag = False;
for i in range(1,10000):
	a = int(i*0.08)
	b = int(i*0.1)
	if((a==A) and (b==B)):
		ans = i
		flag =True
		break
if(flag == False):
	print(-1)
else:
	print(ans)

Measured memory_bytes: 3064
let partition (a : int array) p r =
  let x = a.(r) in
  let swap i j = let t = a.(i) in a.(i) <- a.(j); a.(j) <- t
  in
  let rec doit i j =
    if j >= r then i
    else begin
      if a.(j) <= x then (swap (i + 1) j; doit (i + 1) (j + 1))
      else doit i (j + 1)
    end
  in
  let i = doit (p - 1) p in
  swap (i + 1) r;
  i + 1

let () =
  let n = read_int () in
  let a = Array.init n (fun _ -> Scanf.scanf "%d " (fun i -> i)) in
  let k = partition a 0 (n - 1) in
  Array.iteri (fun i e ->
    Printf.printf (if i = 0 then "%d" else if i = k then " [%d]" else " %d") e) a;
  print_newline ()

Measured memory_bytes: 5440
#include <cstdio>
#include <cmath>
using namespace std;
int main() 
{
    int t,n,h,oldh;
    scanf("%d",&t);
    for (int ix=0; ix<t; ix++) {
        int max=0,min=0;
        scanf("%d",&n);
        scanf("%d",&oldh);
        for (int i=0; i<n-1; i++) {
            scanf("%d",&h);
            int diff=h-oldh;
            oldh=h;
            if (max<diff) max=diff;
            else if (min>diff) min=diff;
        }
        printf("%d %d\n",max,min*-1);
    }
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<map>
#define MN 200000
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;
}
map<int,int>mp;
int now=0,n,a[MN+5],b[MN+5],cnt,head[MN+5],in[MN+5],out[MN+5],num=0,size[MN+5],s[MN+5];
inline int getfa(int x){return s[x]?s[x]=getfa(s[x]):x;}
inline void ins(int f,int t)
{
	if(getfa(f)!=getfa(t))
		size[getfa(t)]+=size[getfa(f)],s[getfa(f)]=getfa(t);
	++in[t];++out[f];++cnt;
}
int main()
{
	n=read();
	for(int i=1;i<=n;++i) 
	{
		a[i]=read(),now^=a[i];
		if(!mp[a[i]]) mp[a[i]]=++num;
	}
	for(int i=1;i<=n;++i)
	{
		b[i]=read();
		if(!mp[b[i]]) mp[b[i]]=++num;	
	}
	if(!mp[now]) mp[now]=++num;++in[mp[now]];
	for(int i=1;i<=num;++i) size[i]=1;
	for(int i=1;i<=n;++i) if(a[i]!=b[i]) ins(mp[b[i]],mp[a[i]]);
	int difnum=0;
	for(int i=1;i<=num;++i) 
		if(out[i]>in[i]||in[i]+1<out[i]) return 0*puts("-1");
		else if(out[i]!=in[i]) ++difnum;
	if(difnum>1) return 0*puts("-1");
	for(int i=1;i<=num;++i) if(getfa(i)==i)
	{	
		if(size[i]==1) cnt+=(mp[now]==i);
		else ++cnt;
	}
	printf("%d",cnt-1);
	return 0;
}



Measured memory_bytes: 8832
#include<stdio.h>

int main(void){
  int a[3];
  int i, j;
  int temp;
  for(i = 0; i < 3; ++i)
    scanf("%d", &a[i]);
  for(i = 0; i < 3 - 1; ++i){
    for(j = i + 1; j < 3; ++j){
      if(a[i] > a[j]){
        temp = a[i];
        a[i] = a[j];
        a[j] = temp;
      }
    }
  }
  printf("%d %d %d\n", a[0], a[1], a[2]);

  return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pii pair<int,int>
#define pll pair<lli, lli>
#define vi  vector<int>
#define vii vector<pair<int,int>>
#define vll vector<lli>
#define pb  push_back
#define mpr  make_pair
#define ss  second
#define ff  first
#define INF 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846264338327950L
#define all(x) x.begin(),x.end()
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define testcase() int tc;cin>>tc;while(tc--)
#define clean(x) memset(x,0,sizeof(x))
const lli maxn = 1e5+9;
vector<lli> catlan(int n) {
    vector<lli> dp(n + 1, 0);
    dp[0] = 1;
    dp[1] = 1;
    for (int i = 2; i <= n; i ++) {
        for (int j = 0; j < i; ++ j) {
            dp[i] += dp[j] * dp[i - j - 1];
        }
    }
    return dp;
}
lli digit(lli n){int res=(int)log10(n)+1;return res;}
lli lcm(lli a,lli b){lli ans=(a*b)/(__gcd(a,b));return ans;}
lli b_ex(lli n,lli a){lli res=1;while(n){if(n%2==1)res*=a;n>>=1;a=a*a;}return res;}
lli ncr(lli n,lli k){lli ans=1;if(k>n-k)k=n-k;for(lli i=1;i<=k;i++){ans*=(n-i+1),ans=ans/i;}return ans;}
lli power(lli a , lli n){lli ans = 1;while(n){if(n % 2)ans = (ans * a) % mod;n /= 2;a = (a * a) % mod;}return ans;}
lli set_bits(lli n)
{
    int c=0;
    if(n==0)return 0;
    while(n)
    {
        if((n&1)==1)
        {
           cout<<c<<" ";
        }
        c++;
        n=n>>1;
    }
    return c;
}
///=================== ALWAYS CHECK 1 or 0 base case=================================================================================///
///------------------ALWAYS lli-----TEMP TSF99--------------------------------------------------------------------------------------///
string a,b;
int res(int m,int x)
{
    int ans=0;
    int j=0;
    for(int i=x;i<x+m;i++)
    {
        if(a[i]!=b[j])ans++;
        j++;
    }
    return ans;
}
void solve()
{
    cin>>a>>b;
    int n=a.size();
    int m=b.size();
    int ans=INT_MAX;
    for(int i=0;i<n;i++)
    {
        if(i+m <= n)
        {
            ans=min(ans,res(m,i));
        }
    }
    cout<<ans<<endl;
}
int main()
{
    solve();
}


Measured memory_bytes: 3620
S = input()

T = list(S)
k = 0
g = 0

i = 0
while i < len(T):
    if (i + 1) % 2 == 1 and T[i] == 'L':
        k = 1
    elif (i + 1) % 2 == 0 and T[i] == 'R':
        g = 1
    i += 1

if k == 0 and g == 0:
    print("Yes")
else:
    print("No")

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

using namespace std;

const int MAX = 10e9;

int main(){
  int d, g;
  cin >> d >> g;
  
  int p[d];
  int c[d];
  for(int i = 0; i < d; i++) cin >> p[i] >> c[i];
  
  int min_cost = MAX;
  for(int b = 0; b < (1 << d); b++){
    int cost = 0;
    int score = 0;
    for(int i = 0; i < d; i++){
      if((1 << i) & b){
        score += 100 * (i + 1) * p[i] + c[i];
        cost += p[i];
      }
    }
    
    for(int i = d - 1; i >= 0; i--){
      if(score >= g){
        min_cost = cost < min_cost ? cost : min_cost;
        break;
      }
      
      if((1 << i) & b) continue;
      
      if(score + 100 * (i + 1) * (p[i] - 1) < g){
        score += 100 * (i + 1) * (p[i] - 1);
        cost += p[i] - 1;
      }else{
        cost += (g - score - 1) / (100 * (i + 1)) + 1;
        score = g;
      }
    }
    
    if(score >= g){
      min_cost = cost < min_cost ? cost : min_cost;
    }
  }
  
  cout << min_cost << endl;
  
  return 0;
}

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

int main(){

	vector<int> height(10,0);

	for(int i=0; i<10; i++)
		cin >> height[i];
	sort(height.begin(), height.end());

	for(int i=9; i>6; i--)
		cout << height[i] << endl;

	return 0;
}

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

using namespace std;
 
int main(){

    int n;
    vector<int> v;
    vector<int> c;

    cin >> n;

    for(int i = 0; i < n; i++){
        int tmp;
        cin >> tmp;
        v.push_back(tmp);
    }

    for(int i = 0; i < n; i++){
        int tmp;
        cin >> tmp;
        c.push_back(tmp);
    }

    int sum = 0;

    for(int i = 0; i < n; i++){
        sum = sum + max(0, v[i] - c[i]);
    }
    
    cout << sum << endl;
 
    return 0;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d%d%d", $N, $K, $C);
$S = trim(fgets(STDIN));
$rest = 10**10;
$c = 1;
for($i = 0; $i < $N; $i++){
    if($S[$i] == "o" && $rest > $C){
        $work[$i] = $c++;
        $rest = 0;
    }else{
        $work[$i] = 0;
    }
    $rest++;
}
$rest = 10**10;
$c = $K;
for($i = $N-1; $i >= 0; $i--){
    if($S[$i] == "o" && $rest > $C){
        $work2[$i] = $c--;
        $rest = 0;
    }else{
        $work2[$i] = 0;
    }
    $rest++;
}
for($i = 0; $i < $N; $i++){
    if($work[$i] > 0 && $work[$i] == $work2[$i])echo $i+1,"\n";
}


Measured memory_bytes: 25588
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int S3[1024];

int main()
{
	rep (S, 1024 ){
		int stat = 0;
		rep (j, 10 ) if (S & (1<<j) ) {
			stat ^= 1<<j;
			if (j > 0 ) stat ^= 1<<(j-1);
			if (j < 9 ) stat ^= 1<<(j+1);
		} // end rep
		S3[S] = stat;
	} // end rep
	int T; scanf ("%d", &T );
	while (T--){
		int org[10] = {};
		rep (i, 10 ) rep (j, 10 ){
			int tmp; scanf ("%d", &tmp );
			org[i] |= tmp<<j;
		} // end rep
		
		int ans = -1;
		rep (S, 1024 ){
			int grid[10];
			rep (i, 10 ) grid[i] = org[i];
		
			grid[0] ^= S3[S];
			grid[1] ^= S;
			for (int i = 1; i < 10; i++ ){
				int pttn = grid[i-1];
				grid[i-1] = 0;
				grid[i] ^= S3[pttn];
				if (i < 9 ) grid[i+1]^=pttn;
			} // end if
			if (grid[9] == 0 ){
				ans = S; break;
			} // end if
		} // end rep
		if (ans == -1 ) while (1 );
	
		rep (j, 10 ) printf ("%d%c", !!(ans&(1<<j)), j<9 ? ' ' :'\n' );
		org[0] ^= S3[ans];
		org[1] ^= ans;
		for (int i = 1; i < 10; i++ ){
			int pttn = org[i-1];
			org[i-1] = 0;
			org[i] ^= S3[pttn];
			if (i < 10 ) org[i+1]^=pttn;
			rep (j, 10 ) printf ("%d%c", !!(pttn&(1<<j)), j<9 ? ' ' : '\n' ); 
		} // end for
	} // end while

	return 0;
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	long long  x,y;
	cin>>x>>y;
	if(x == 1)
	{
		cout<<1<<endl;return 0;
	}
	if(y == 1)
	{
		cout<<1<<endl;return 0;
	}
	cout<<(x*y+1)/2<<endl;
}  

Measured memory_bytes: 256
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << 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 solve() {
	string g;
    while(cin >> g) {
        if(g == "#") break;
        int y, m, d; cin >> y >> m >> d;
        if(y <= 30 || (y == 31 && m <= 4)) {
            cout << g << " " << y << " " << m << " " << d << endl;
        } else {
            cout << "? " << y - 30 << " " << m << " " << d << endl;
        }
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}


Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	bool ans=true;
	int cnt=0;
	if(s.front()!='A')
		ans=false;
	for(unsigned int i=1;i<s.length();i++){
		if(isupper(s[i])){
			if(i==1||i==(s.length()-1)||s[i]!='C'){
				ans=false;
			}
			if(s[i]=='C'){
				cnt++;
			
			}
		}
	}
	if(cnt!=1){
		ans=false;
	}
	if(ans){
		cout<<"AC"<<endl;
	}
	else{
		cout<<"WA"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256