akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		String s = fs.next();
		
		int ans = 700;
		for(int i = 0; i< 3; i++) {
			if(s.charAt(i) == 'o') {
				ans += 100;
			}
		}
		
		System.out.println(ans);
	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

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

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

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


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

#define PI 3.141592653589

int main(void)
{
	double x,y, a,b,c,s,l,h;
	scanf("%lf %lf %lf", &a, &b, &c);
	x = PI*c / 180.0;
	s =  (a*b*sin(x))/2;
	h = b*sin(x);
	y = (a*a) + (b*b) - (2*a*b*cos(x));
	l = a + b + sqrt(y);
	printf("%lf %lf %lf\n", s, l, h);

	return 0;

}


Measured memory_bytes: 2100
#include<stdio.h>

int bubbleSort(int [], int n);

int main(){
  int n,a[100],i,c;
  scanf("%d",&n);
  
  for(i = 0; i < n; i++){
    scanf("%d",&a[i]);
    }

  c = bubbleSort(a, n);

  for(i = 0; i < n; i++){
    if(i != n-1) printf("%d ",a[i]);
    else printf("%d",a[i]);
  }
  printf("\n");
  printf("%d\n",c);

  return 0;
}

int bubbleSort(int a[], int n){
  int flag = 1,j,tmp,c=0;

  while(flag){
    flag = 0;
    for(j = n-1; j >= 1; j--){
      if(a[j] < a[j-1]){
	tmp = a[j];
	a[j] = a[j-1];
	a[j-1] = tmp;
	flag = 1;
	c++;
      }
    }
  }
  return c;
}



Measured memory_bytes: 2140
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	
	int N, X, T, res;
	cin >> N >> X >> T;

	if(N%X == 0){
		res = (N/X)*T;
	}else{
		res = (N/X + 1)*T;
	}
 

	
	cout << res;
 
	return 0;
}

Measured memory_bytes: 3620
import java.util.*;
 
public class Main {
    //最小公倍数lcm
    static long lcm (int a, int b) {
    	int temp;
    	long c = a;
    	c *= b;
    	while((temp = a%b)!=0) {
    		a = b;
    		b = temp;
    	}
    	return c/b;
    }
    //最大公約数
    static int gcd (int a, int b) {
    	int temp;
    	while((temp = a%b)!=0) {
    		a = b;
    		b = temp;
    	}
    	return b;
    }

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        long LCM = lcm(N,M);//N,Mの最小公倍数
        String S = sc.next();
        String T = sc.next();
        int g = gcd(N,M);
        for(int i = 0; i < g; i++){
            if(!(S.substring(N/g*i,N/g*i+1).equals(T.substring(M/g*i,M/g*i+1)))){
                LCM = -1;
            }
        }
        System.out.println(LCM);
    }
}

Measured memory_bytes: 26400
n=int(input())
A=list(map(int,input().split()))

ans1=0
ans2=0

#最初の符号が正の場合
sign=1
total=0
for i in range(n):
  total+= A[i]
  if total*sign<=0:   #符号が正しいかを判定（正が欲しい時に正とかけたら正、逆も然り）
    k=abs(total-sign)
    ans1+=k           #理想の値との差分
    total=sign        #暫定累積値を理想の値に変更
  sign*=-1            #一回ごとに符号を変更

#最初の符号が負の場合
sign=-1
total=0
for i in range(n):
  total+=A[i]
  if total*sign<=0:
    k=abs(total-sign)
    ans2+=k
    total=sign
  sign*=-1
print(min(ans1,ans2))


Measured memory_bytes: 14332
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cctype>
#include<cmath>
#include<cstring>
#include<sstream>
#include<set>
#include<map>
#define maxn 100000
using namespace std;
int main()
{
    char a,s;
    cin>>a;
    if(a=='A')
        s='T';
    else if(a=='T')
        s='A';
    else if(a=='C')
        s='G';
    else
        s='C';
    cout<<s;
    return 0;
}


Measured memory_bytes: 256
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
 
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
 
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
 
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
 
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
 
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
 
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
 
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
  input!{
    a: i32,
    b: i32,
    c: i32
  }
  println!("{} {} {}", c, a, b);  
}

Measured memory_bytes: 4352
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define print(x) cout<<(x)<<endl
#define INF10 1001001001 
#define INF5 100000
#define EPS 1e-10


vector<ll> A;

vector<ll> res;


int main() {
	ll N; cin >> N;
	A.assign(N, 0);
	ll sum = 0;
	ll zero_sup = 0;
	for (ll i = 0; i < N; i++) {
		cin >> A[i];
		sum += A[i];
		if (i % 2 != 0)zero_sup += A[i];
	}
	sum /= 2;
	res.assign(N, 0);
	res[0] = 2*(sum - zero_sup);
	for (int i = 1; i < N; i++) {
		res[i] = 2*A[i-1] - res[i - 1];
	}
	for (int i = 0; i < N; i++) {
		cout << res[i];
		if (i != N - 1)cout << " ";
	}
	cout << endl;


	return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

int main() {
	double a, b, x;
	cin >> a >> b >> x;

	x /= a;
	cout << fixed << setprecision(10);
	if (x > a * b / 2) cout << atan2((a * b - x) * 2, a * a) * 180 / PI << endl;
	else cout << atan2(b * b, x * 2) * 180 / PI << endl;
}

Measured memory_bytes: 4164
from fractions import gcd

def lcm(x, y):
  ret = (x*y)//gcd(x,y)
  return ret
  
def f(n, c, d):
  x = n
  x -= n//c
  x -= n//d
  x += n//lcm(c,d)
  return x

A, B, C, D = map(int, input().split())
ans = f(B, C, D) - f(A-1, C, D)
print(ans)

Measured memory_bytes: 5076
N,W=map(int,input().split())
wv=[[0,0]]+[list(map(int,input().split()))for _ in range(N)]
v_max=sum(wv[i][1]for i in range(N+1))

dp=[[0]*(N+1)]+[[float('inf')]*(N+1)for _ in range(v_max)]
for v in range(1,v_max+1):
    for n in range(1,N+1):
        dp[v][n]=min((dp[v][n-1],dp[v-wv[n][1]][n-1]+wv[n][0]))

print(max(v for v in range(v_max+1) if dp[v][N]<=W))

Measured memory_bytes: 255588
import scala.io.StdIn._
object Main extends App {
  val n = readInt
  val s = readLine
  val array = new Array[Int](n)
  (0 until n).foldLeft(0) { (acc, i) =>
    array(i) = acc + (if ('W' == s(i)) 1 else 0)
    array(i)
  }

  (n - 1 to 0 by -1).foldLeft(0) { (acc, i) =>
    array(i) = array(i) + acc + (if ('E' == s(i)) 1 else 0)
    acc + (if ('E' == s(i)) 1 else 0)
  }

  println(array.min - 1)
}


Measured memory_bytes: 39980
// Author -- xyr2005

#include<bits/stdc++.h>

#define lowbit(x) ((x)&(-(x)))
#define Finline __inline__ __attribute__ ((always_inline))
#define DEBUG fprintf(stderr,"Running on Line %d in Function %s\n",__LINE__,__FUNCTION__)
#define SZ(x) ((int)x.size())
#define mkpr std::make_pair
#define pb push_back

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef std::pair<int,int> pi;
typedef std::pair<ll,ll> pl;
using std::min;
using std::max;

const int inf=0x3f3f3f3f,Inf=0x7fffffff;
const ll INF=0x3f3f3f3f3f3f3f3f;

Finline uint rnd(){static uint seed=416;return seed+=0x71dad4bfu,seed^=seed>>5,seed+=0xc6f74d88u,seed^=seed<<17,seed+=0x25e6561u,seed^=seed>>13;}
template <typename _Tp>_Tp gcd(const _Tp &a,const _Tp &b){return (!b)?a:gcd(b,a%b);}
template <typename _Tp>Finline _Tp abs(const _Tp &a){return a>=0?a:-a;}
template <typename _Tp>Finline void chmax(_Tp &a,const _Tp &b){(a<b)&&(a=b);}
template <typename _Tp>Finline void chmin(_Tp &a,const _Tp &b){(b<a)&&(a=b);}
template <typename _Tp>Finline void read(_Tp &x)
{
	char ch(getchar());bool f(false);while(!isdigit(ch)) f|=ch==45,ch=getchar();
	x=ch&15,ch=getchar();while(isdigit(ch)) x=(((x<<2)+x)<<1)+(ch&15),ch=getchar();
	f&&(x=-x);
}
template <typename _Tp,typename... Args>Finline void read(_Tp &t,Args &...args){read(t);read(args...);}
template <typename _Tp,typename... Args>Finline _Tp min(const _Tp &a,const _Tp &b,const Args &...args){return a<b?min(a,args...):min(b,args...);}
template <typename _Tp,typename... Args>Finline _Tp max(const _Tp &a,const _Tp &b,const Args &...args){return a<b?max(b,args...):max(a,args...);}
Finline int read_str(char *s)
{
	char ch(getchar());while(ch==' '||ch=='\r'||ch=='\n') ch=getchar();
	char *tar=s;*tar=ch,ch=getchar();while(ch!=' '&&ch!='\r'&&ch!='\n'&&ch!=EOF) *(++tar)=ch,ch=getchar();
	return tar-s+1;
}

const int N=100005;
int k;
int f(int x)
{
	if(!(x%k)) return x/k;
	int val=(x+k-1)/k;
	int cnt=(x%k+val-1)/val;
	return f(x-cnt*val);
}
int main()
{
	int n;read(n);
	int ans=0,x;
	for(int i=1;i<=n;++i) read(x,k),ans^=f(x);
	if(ans) puts("Takahashi");
	else puts("Aoki");
	return 0;
}


Measured memory_bytes: 3612
ans_word = "keyence"

s = input()
flag = False
if s == ans_word:
    flag = True
else:
    for i in range(len(s)-1):
        for j in range(i+1, len(s)):
            if s[:i] + s[j:] == ans_word:
                flag = True
                break
        if flag:
            break

if flag:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 38512
#include <iostream>

int main()
{
  const int end_input = 0;
  int case_count = 1;

  while (1) {
    int input;
    std::cin >> input;
    if (input == end_input) break;

    std::cout 
      << "Case " << case_count << ": " 
      << input << std::endl;

    ++case_count;
  }

  return 0;
}

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

using namespace std;

int main()
{
	string s;
	int ma = 0, x = 0, n;
	cin >> n >> s;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'I') {
			x++;
			ma = max(ma, x);
		}
		else {
			x--;
		}
	}
	cout << ma << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

typedef long long ll;

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

// const int C ;
// const int M = 1000000007;

int ans(int n, int d) {
  if (n%2 == 0) {
    return (127-d) + (n-1) * 127;
  } else {
    return d + (n-1) * 127;    
  }
}

int T;
int N[1010];
int D[1010];

int main () {
  cin >> T;
  for (auto i = 0; i < T; i++) {
    cin >> N[i] >> D[i];
  }
  for (auto i = 0; i < T; i++) {
    cout << ans(N[i], D[i]) << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map>
#include <map>
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
#include <bitset>
#include <memory>
#include <complex>
#include<fstream>
using namespace std;
typedef long long LL;

int main(void)
{
	LL n;
	cin >>n;
	vector<LL> a(n+1,0);
	vector<LL> ans;
	for (int i = 1; i <= n; i++) {
		cin >>a[i];
	}

	for (LL i = n; i >= 1; i--) {
		LL count =0;
		for (LL j = i; j < n+1; j+=i) {
			if (a[j]>=1&&j!=i) {
				count+=a[j];
			}
		}
		if (count % 2 != a[i]%2) {
			a[i]=1;
		}
		else{
			a[i] = 0;
		}
		if (a[i] >= 1) {
			ans.push_back(i);
		}
	}

	cout << ans.size()<<endl;
	for (LL i = 0; i < ans.size(); i++) {
		if (i == 0) {
			cout << ans[i];
		}
		else if(i==ans.size()-1) {
			cout <<" "<< ans[i]<<endl;
		}
		else {
			cout << " " << ans[i];
		}
		
	}

	return 0;
}

Measured memory_bytes: 3572
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority_queue
#include<deque>//double_ended queue
using namespace std;
typedef pair<int,int> P;//Pでpair<-,->を表す。
typedef long long LL; 
LL MOD=1000000007;

int main()
{ 
    LL l,r;
    cin>>l>>r;
    while(r>l+4038){r=r-2019;}
    LL min=2019;
    for(LL i=l;i<r;i++){
        for(LL j=i+1;j<=r;j++){
            if(((i*j)%2019)<min){min=((i*j)%2019);}
        }
    }
    cout<<min<<endl;
    return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int h, w, o = 0, c[10][10];
  cin >> h >> w;
  for(int i = 0; i < 10; i++)
    for(int j = 0; j < 10; j++) cin >> c[i][j];
  for(int k = 0; k < 10; k++)
    for(int i = 0; i < 10; i++)
      for(int j = 0; j < 10; j++) c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
  for(int i = 0; i < h; i++) {
    for(int j = 0; j < w; j++) {
      int a;
      cin >> a;
      if(a != -1) o += c[a][1];
    }
  }
  cout << o << '\n';
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;
import java.util.Deque;
import java.util.ArrayDeque;
import java.io.BufferedReader;
import java.io.InputStreamReader;


class Main{
	public static void main(String[] args)throws Exception{
		Scanner scanner = new Scanner(System.in);
		Deque<String> name_stack = new ArrayDeque<>();
		Deque<Integer> time_stack = new ArrayDeque<>();
		int n = scanner.nextInt();
		int q = scanner.nextInt();
		String nothing = scanner.nextLine();
		int all_time = 0;

		for(int i = 0; i < n-1; i++){
			name_stack.offer(scanner.next());
			time_stack.offer(scanner.nextInt());
			nothing = scanner.nextLine();
		}
		
		name_stack.offer(scanner.next());
		time_stack.offer(scanner.nextInt());

		while(!(name_stack.isEmpty())){
			String name = name_stack.poll();
			int time = time_stack.poll();

			if(time <= q){
				all_time += time;
				System.out.println(name + " " + all_time);
			}else{
				all_time += q;
				time -= q;
				name_stack.offer(name);
				time_stack.offer(time);
			}
		}

	}
}

Measured memory_bytes: 106552
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <limits>
#include <string>
#include <algorithm>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include "math.h"
#include "assert.h"

using namespace std;

#define ll long long

#define BUFF ios::sync_with_stdio(false)
#define epsilon 1e-07
#define pi 2 * acos(0.0);
#define mod 1000000007   // 1e9+7
#define cerr if(false)cerr
#define watch(x) cerr << #x << " = " << x << endl;

#define inf std::numeric_limits<int>().max();

/*
	Busca por x em v utilizando pesquisa binária. 
	pre-condições: 
		 - v ordenado.
		 - [l, r] é um intervalo válido para os índices de v: [0, n-1], [1, n], [2, 4], etc.

	Saída:
		- i = min { i : x ≤ v(i), l ≤ i ≤ r} ou -1 se todos os números de v forem menores que x.
 */
int f(int x, vector<int> & v, int l, int r) {
	int ans, i;
	while (l < r) {
		i = (l + r) / 2;
		if (v[i] < x) l = i+1;
		else r = i;
	}
	if (v[l] >= x) ans = l;  // v[l] == x (igualdade)
	else ans = -1;
	return ans;
}

/*
	Busca por x em v utilizando pesquisa binária. 
	pre-condições: 
		 - v ordenado.
		 - [l, r] é um intervalo válido para os índices de v: [0, n-1], [1, n], [2, 4], etc.

	Saída:
		- i = max { i : v(i) ≤ x, l ≤ i ≤ r} ou -1 se todos os números de v forem maiores que x.
 */
int g(int x, vector<int> & v, int l, int r) {
	int ans, i;
	while (l < r) {
		i = (l + r) / 2 + (l+r) % 2;
		if (v[i] > x) r = i-1;
		else l = i;
	}
	if (r < v.size() and v[r] <= x) ans = r;
	else ans = -1;
	return ans;
}



int main() {
	int n;
	cin >> n;
	vector<int> v(n); 
	for(int i=0; i<n; i++) {
		cin >> v[i];
	}
	sort(v.begin(), v.end());
	for(int i=0; i<n; i++) {
//		cout <<"*"<< v[i] << endl;
	}

	int ans = 0;
	for(int i=0; i<n; i++) {
		for(int j=i+2; j<n; j++) {
			int a = v[i];
			int b = v[j];
			int l = abs(a-b)+1;
			int r = a + b - 1;
			int fx = f(l, v, i+1, j-1);
			int gx = g(r, v, i+1, j-1);
			if (fx != -1 and gx != -1) {
				ans += max(0, gx - fx + 1);
			}
			//cout << a << " " << b << " gx: " << gx << "\t fx:  "  << fx << " asn " << ans << endl;
		}
	}
	cout << ans << endl;
}


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

class Node {
    public:
        int id;
        int left_id;
        int right_id;
        int parent_id;
        Node();
};

Node::Node()
{
    id = -1;
    left_id = -1;
    right_id = -1;
    parent_id = -1;
}

int search_root(std::vector<Node>& data, int id)
{
    if(data[id].parent_id == -1) {
        return id;
    } else {
        return search_root(data, data[id].parent_id);
    }
}

void walk_preorder(std::vector<Node>& data, int id)
{
    printf(" %d", id);
    if(data[id].left_id != -1) {
        walk_preorder(data, data[id].left_id);
    }
    if(data[id].right_id != -1) {
        walk_preorder(data, data[id].right_id);
    }
}

void walk_inorder(std::vector<Node>& data, int id)
{
    if(data[id].left_id != -1) {
        walk_inorder(data, data[id].left_id);
    }
    printf(" %d", id);
    if(data[id].right_id != -1) {
        walk_inorder(data, data[id].right_id);
    }
}

void walk_postorder(std::vector<Node>& data, int id)
{
    if(data[id].left_id != -1) {
        walk_postorder(data, data[id].left_id);
    }
    if(data[id].right_id != -1) {
        walk_postorder(data, data[id].right_id);
    }
    printf(" %d", id);
}

int main()
{
    int input_size;
    scanf("%d", &input_size);
    std::vector<Node> data(input_size);
    for(int i = 0; i < data.size(); i++) {
        int id, left, right;
        scanf("%d %d %d", &id, &left, &right);
        data[id].id = id;
        if(left != -1) {
            data[id].left_id = left;
            data[left].parent_id = id;
        }
        if(right != -1) {
            data[id].right_id = right;
            data[right].parent_id = id;
        }
    }

    int root_id = search_root(data, 0);

    puts("Preorder");
    walk_preorder(data, root_id);
    putchar('\n');

    puts("Inorder");
    walk_inorder(data, root_id);
    putchar('\n');

    puts("Postorder");
    walk_postorder(data, root_id);
    putchar('\n');

    return 0;
}

Measured memory_bytes: 2724
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cassert>
#include <map>
#include <set>
#include <cctype>
using namespace std;

int main() {

  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int h, w, a, b;
  cin >> h >> w >> a >> b;

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (i < h - b && j < a) {
        cout << "1";
      } else if (i >= h - b && j >= a) {
        cout << "1";
      } else {
        cout << "0";
      }
    }
    std::cout << "\n";
  }
}

Measured memory_bytes: 1280
n, m = map(int, input().split())
e = [[int(x) for x in input().split()] for _ in range(m)]

u = [-1]*(n+1)

def find(x):
  return x if u[x] < 0 else find(u[x])

t = n*(n-1)// 2
s = [t]

for i in range(m-1,0,-1):
  a = find(e[i][0])
  b = find(e[i][1])
  if a > b:
    a, b = b, a
  if a != b:
    t -= u[a]*u[b]
    u[a] += u[b]
    u[b] = a
  s.append(t)

for i in reversed(s):
  print(i)


Measured memory_bytes: 27204
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        int k = stdIn.nextInt();
        char s[] = stdIn.next().toCharArray();
        long ans = 0;
        for(int i= 0; i+1 < n; i++){
            if(s[i] == s[i+1])
                ans++;
        }
        System.out.println((int)Math.min(k*2 + ans ,n-1  ));

    }
}


Measured memory_bytes: 27304
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;

ll count(ll n){
    ll p = 1;
    ll d = 1;
    ll sd = 0;
    while(p * 10 <= n){
        ll np = p * 10 - 1;
        ll div3 = np / 3 - (p-1) / 3;
        ll div5 = np / 5 - (p-1) / 5;
        ll div15 = np / 15 - (p-1) / 15;
        sd += 9 * p * d + div3 * (4 - d) + div5 * (4 - d) + div15 * d;
        p *= 10;
        d++;
    }

    ll div3 = n / 3 - (p-1) / 3;
    ll div5 = n / 5 - (p-1) / 5;
    ll div15 = n / 15 - (p-1) / 15;
    sd += (n - p + 1) * d + div3 * (4 - d) + div5 * (4 - d) + div15 * d;
    return sd;
}

int main(){
    ll s;
    cin >> s;
    if(s == 1){
        cout << "12Fizz4BuzzFizz78Fiz" << endl;
    }else{
        ll l = 1, r = 1000000000000000000LL;
        while(r - l > 1){
            ll n = (l + r) / 2;
            if(count(n) < s){
                l = n;
            }else{
                r = n;
            }
        }

        stringstream ss;
        for(ll i=r;i<r+20;i++){
            if(i % 15 == 0){
                ss << "FizzBuzz";
            }else if(i % 3 == 0){
                ss << "Fizz";
            }else if(i % 5 == 0){
                ss << "Buzz";
            }else{
                ss << i;
            }
        }
        string str;
        ss >> str;
        cout << str.substr(s - count(l) - 1, 20) << endl;
    }
    return 0;
}

Measured memory_bytes: 3228
n,m,x=map(int,input().split())
a=[]
d=[]
for i in range(n):
    a.append(list(map(int,input().split())))
for i in range(2**n):
    b='0'*(n-len(bin(i))+2)+bin(i)[2:]
    s=[0]*m
    c=0
    f=1
    for j in range(n):
        if b[j]=='1':
            for k in range(m):
                s[k]+=a[j][k+1]
            c+=a[j][0]
    for j in range(m):
        if s[j]<x:
            f=0
    if f==1:
        d.append(c)
if len(d)==0:
    print(-1)
else:
    print(min(d))

Measured memory_bytes: 9244
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	static Scanner sc;

	public static void main(String[] args) throws Exception {
		InputStream in = System.in;

		sc = new Scanner(in);

		int N = sc.nextInt();
		int K = sc.nextInt();
		//long[] A = new long[N];
		TreeMap<Integer, Integer> m = new TreeMap<Integer, Integer>();

		int answer = 0;
		boolean run = true;

		for(int i = 0; i < N; i++){
			//A[i] = sc.nextLong();
			int a = sc.nextInt();
			if(m.get(a) == null){
				m.put(a, 0);
			}
			m.put(a, m.get(a)+1);
		}

		ArrayList<Integer> l = new ArrayList<>();
		for(int v : m.values()){
			l.add(v);
		}
		Collections.sort(l);

		for(int i = 0; i < m.size() - K; i++){
			answer += l.get(i);
		}

		System.out.println(answer);
	}
}

Measured memory_bytes: 100980
N,M = map(int, input().split())
H = list(map(int, input().split()))
A = [ list(map(int,input().split(" "))) for i in range(M)]
C = []
for i in range(N):
	C.append(0)
for i in range(M):
	x = A[i][0]
	y = A[i][1]
	if H[x-1] > H[y-1]: 
		C[y-1] += -1
	elif H[x-1] < H[y-1]:
		C[x-1] += -1
	elif H[x-1] == H[y-1]:
		C[x-1] += -1
		C[y-1] += -1
print(C.count(0))

Measured memory_bytes: 31892
#include <iostream>
#include <cstdio>
#define ll long long
#define mod 1000000007
using namespace std;
int n;
ll f(int n)
{
	if(n == 1) return 1;
	return (n*(f(n-1)%mod))%mod;
}
int main()
{
	scanf("%d",&n);
	printf("%lld",f(n));
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N,X;
    cin >> N;
    X=N%10;
    if(X==3){
        cout <<"bon"<<endl;
    }
    else if (X==0||X==1||X==6||X==8){
         cout <<"pon"<<endl;
    }
    else{
         cout <<"hon"<<endl;
    }
}

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

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	long long x, k, d;
	cin >> x >> k >> d;
	if (x < 0) x = -x;
	long long ans;
	if (x / d < k) {
		long long rest = k - x / d;
		if (rest % 2 == 0) ans = x % d;
		else ans = d - x % d;
	} else {
		ans = x - d * k;
	}
	cout << ans << '\n';
	return 0;
}

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

using namespace std;

#define int long long

signed main(){
	
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    
    string s1,s2;
    cin >> s1 >> s2;
    int n,m;
    cin >> n >> m;
    string s;
    cin >> s;
    if(s==s1){
    	cout << n-1 << " " << m;
	}
	else{
		cout << n << " " << m-1;
	}
    
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
 
	Scanner sc = new Scanner(System.in);
    String S = sc.next();
	char[]ss = S.toCharArray();
      
      if(ss[2]==ss[3] && ss[4]==ss[5]){
        System.out.println("Yes");
      }else{
        System.out.println("No");
      }
    }
}

Measured memory_bytes: 22868
n,d = gets.chomp.split(" ").map(&:to_i)
x_arr = n.times.map{gets.chomp.split(" ").map(&:to_i)}

count = 0
# i < j
(0..n-2).each do |i|
  (i+1..n-1).each do |j|
    dist = 0
    x_arr[i].zip(x_arr[j]).each do |y, z|
      dist += (y - z) ** 2
    end
    # integer?
    count += 1 if Math.sqrt(dist).to_i == Math.sqrt(dist)
  end
end

puts count


Measured memory_bytes: 1788
#include<cstdio>
#include<algorithm>
using namespace std;
long long a123[4];
int main(){
	scanf("%lld%lld%lld",&a123[1],&a123[2],&a123[3]);
	sort(a123+1,a123+3+1);
	long long ans=a123[1]+a123[2];
	int k;
	scanf("%d",&k);
	while (k--) a123[3]*=2;
	ans+=a123[3];
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 128
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author AEroui
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int[] cnt = new int[9];
            int n = in.nextInt();
            int min = 0;
            for (int i = 0; i < n; i++) {
                int tmp = in.nextInt();
                int col = getColor(tmp);
                ++cnt[col];
                if (cnt[col] <= 1 && col < 8) ++min;
            }

            if (min == 0) {
                out.println(1 + " " + cnt[8]);
                return;
            }
            out.println(min + " " + (min + cnt[8]));

        }

        public int getColor(int a) {
            int ret = a / 400;
            return Math.min(8, ret);
        }

    }
}



Measured memory_bytes: 21844
#include <bits/stdc++.h> // Include every standard library
using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;

typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpl;
double EPS = 1e-9;
int INF = 1000000005;
long long INFF = 1000000000000000005LL;
double PI = acos(-1.0);
int dirx[8] = { -1, 0, 0, 1, -1, -1, 1, 1 };
int diry[8] = { 0, 1, -1, 0, -1, 1, -1, 1 };

#ifdef TESTING
#define DEBUG fprintf(stderr, "====TESTING====\n")
#define VALUE(x) cerr << "The value of " << #x << " is " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define DEBUG
#define VALUE(x)
#define debug(...)
#endif
#define REP(i,a,b) for (ll i = a; i <= b; i++)
#define sqr(x) ((ll)(x) * (x))
#define reset(a,b) memset(a, b, sizeof(a))
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define all(v) v.begin(), v.end()
#define len(v) (ll)v.size()
#define srt(v) sort( v.begin(), v.end())
#define rsrt(v) sort( v.rbegin(), v.rend())
#define rvrs(v) reverse( v.begin(), v.end())
#define PERMUTE next_permutation
#define tc(t) while (t--)
#define sc1(a) scanf("%lld",&a)
#define sc2(a,b) scanf("%lld %lld",&a,&b)
#define sc4(a,b,c,d) scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define yes printf("YES\n")
#define no printf("NO\n")
#define minus1  printf("-1\n")
#define space printf(" ")
#define pf1(a) printf("%lld",a)
#define pf2(a,b) printf("%lld %lld",a,b)
#define case(a) printf("Case %lld: ",a)
#define ses printf("\n")
bool odd(ll n){if(n&1)return true;return false;}
//ll xor(ll a,ll b)return a^b;
ll power(ll x, ll y,ll M){ll res=1;while(y>0){ if(y&1)res=(res*x)%M;y=(y>>1)%M;x=(x*x)%M;}return res;}
ll mx(ll a,ll b){if(a>=b)return a;return b;}
ll mn(ll a,ll b){if(a<=b)return a;return b;}
int main()
{
    string s,t;
    cin>>s>>t;
    int cnt=0;
    for(ll i=0;i<max(len(s),len(t));i++)
    {
        if(s[i]!=t[i])cnt++;
    }
    cout<<cnt<<endl;
}




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

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define MOD 1000000007
#define MAX 100000
#define INF 1410065408

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
struct edge{int from, to; ll cost;};

priority_queue<P, vector<P>, greater<P> > que;
bool used[MAX];

signed main(){
  int n;
  ll a, b;
  scanf("%d %lld %lld", &n, &a, &b);
  
  ll before, after, cost = 0;
  scanf("%lld", &after);
  rep(n-1){
	before = after;
	scanf("%lld", &after);
	cost += min(b, a*(after-before));
  }

  printf("%lld", cost);
}


Measured memory_bytes: 384
def getStart(field):
    search_field = field[1:]     # cut the first [H,W,N] for min_path matrix
    for y in range(len(search_field)):
        for x in range(len(search_field[0])):
            if search_field[y][x] == "S":
                return x,y+1


def bfs(field,start_x,start_y,goal_N):
    direction = [[-1,0],[1,0],[0,-1],[0,1]]
    gotten_cheese = 1
    distance = 0
    que = []
    que.append([start_x,start_y,gotten_cheese,distance])
    INF = 1
    min_path = [[INF for j in range(field[0][1])] for i in range(field[0][0])]
    while len(que) != 0:
        current = que.pop(0)
        for d in direction:
            nx = current[0] + d[0]
            ny = current[1] + d[1]
            if 0 <= nx < field[0][1] and 1 <= ny < field[0][0]+1 and field[ny][nx] != "X" and min_path[ny-1][nx] == INF:
                if field[ny][nx] == current[2]: # at the same cheese-power number
                    if field[ny][nx] == goal_N: # goal
                        print(current[3]+1)
                        return
                    else: # not goal, but could eat cheese
                        que = []
                        que.append([nx,ny,current[2]+1,current[3]+1])
                        min_path = [[INF for j in range(field[0][1])] for i in range(field[0][0])]
                        break
                else:
                    que.append([nx,ny,current[2],current[3]+1])
                    min_path[ny-1][nx] = 0


def main(field):

    # field = [[10,10,9],
    # [".","X",".",".",".","X",".","S",".","X"],
    # [6,".",".",5,"X",".",".","X",1,"X"],
    # [".",".",".","X","X","X","X",".",".","X"],
    # ["X",".",".",9,"X",".",".",".","X","."],
    # [8,".","X",2,"X",".",".","X",3,"X"],
    # [".",".",".","X","X",".","X",4,".","."],
    # ["X","X",".",".",".",".",7,"X",".","."],
    # ["X",".",".","X",".",".","X","X",".","."],
    # ["X",".",".",".","X",".","X","X",".","."],
    # [".",".","X",".",".",".",".",".",".","."]]

    sx,sy = getStart(field)
    bfs(field,sx,sy,field[0][2])

matrix = []
while True:
    row = input().rstrip().split()
    if len(row) == 3:
        re_row = []
        for i in row:
            re_row.append(int(i))
        matrix.append(re_row)
    else:
        re_row = []
        for char in row[0]:
            if char.isdigit():
                re_row.append(int(char))
            else:
                re_row.append(char)
        matrix.append(re_row)
    if len(matrix) == int(matrix[0][0]) + 1:
        main(matrix)
        break

Measured memory_bytes: 34104
#include <stdio.h>

int main()
{
	char str[21];
	int i;
	scanf("%s",&str);
	for (i=0 ; i<20 ; i++){
		if(str[i]==0)break;
	}
	for (i=i-1 ; i>=0 ; i--){
		printf("%c",str[i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 1812
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
const lint MOD = pow(10, 9) + 7;

int main() {
	int N;
	cin >> N;
	vector<int>A(N);
	rep(i, N) {
		cin >> A[i];
	}
	deque<int>ans;
	if (N % 2 != 0) {
		rep(i, N) {
			if (i % 2 == 0) {
				ans.push_front(A[i]);
			}
			else {
				ans.push_back(A[i]);
			}
		}
	}
	else {
		rep(i, N) {
			if (i % 2 == 0) {
				ans.push_back(A[i]);
			}
			else {
				ans.push_front(A[i]);
			}
		}
	}

	rep(i, N) {
		cout << ans[i];
		if (i != N) {
			cout << ' ';
		}
	}
	cout << endl;
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define ll long long
#define endl "\n"
#define print_array(name,n) for(ll o=0;o<n;o++) cout<<name[o]<<" "
#define fr(i,f,t) for(ll i=(f);i<t;i++)
#define fb(i,f,t) for(ll i=(f);i>=t;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 2e18
bool sortbysecond(const pair<int,int> &a,const pair<int,int> &b){
	return (a.ss>b.ss);
}
template <typename T>
string NumberTostring(T Number )
{
	ostringstream ss;
	ss<<Number;
	return ss.str();
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    int c1 = 0;
    int c2 = 0;
    c1 = n/500;
    n = n - 500*c1;
    c2 = n/5;
    int ans = c1*1000 + c2*5;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

int N,M;
int monster[100000];

int calc(int X){

	int left = 0,right = 0,ret = 0;
	int calc_left = 0,calc_right = N-1,m = (calc_left+calc_right)/2;
	int LEVEL = 1;

	while(right < N-1){
		ret++;

		while(calc_left <= calc_right){

			if(monster[m] < LEVEL+X){
				right = m;
				calc_left = m+1;
			}else{
				calc_right = m-1;
			}
			m = (calc_left+calc_right)/2;
		}

		while(left < right && abs(LEVEL-monster[left+1]) < abs(LEVEL-monster[left]))left++;
		LEVEL += max(1,X-abs(LEVEL-monster[left]));

		calc_left = right;
		calc_right = N-1;
		m = (calc_left+calc_right)/2;
	}
	return ret;
}

void func(){

	for(int i = 0; i < N; i++)scanf("%d",&monster[i]);

	int ans = -1;

	int left,right,m;

	left = monster[0],right = monster[N-1],m = (left+right)/2;

	while(left <= right){

		if(calc(m) >= M){
			ans = m;
			left = m+1;
		}else{
			right = m-1;
		}
		m = (left+right)/2;
	}

	printf("%d\n",ans);
}

int main(){

	while(true){
		scanf("%d %d",&N,&M);
		if(N == 0 && M == 0)break;

		func();
	}

	return 0;
}

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

ll N,Q,x,y,z;
P s,t;
char str[20];

P a[300005];
ll b[300005];
ll C;

P find(ll x){
  if(a[x].first==-1)return P(x,0);
  P res=find(a[x].first);
  res.second+=a[x].second;
  return a[x]=res;
}

void init(){
  for(int i=0;i<300005;i++){
    a[i]=P(-1,0);
    b[i]=i;
  }
  C=100001;
}

int main(){
  init();
  cin>>N>>Q;
  for(int i=0;i<Q;i++){
    scanf("%s",str);
    
    if(str[0]=='C'){
      scanf("%lld %lld",&x,&y);
      x=b[x];y=b[y];
      s=find(x);t=find(y);
      if(s.first!=t.first)printf("WARNING\n");
      else {
        printf("%lld\n",s.second-t.second);
      }
    }else{
      scanf("%lld %lld %lld",&x,&y,&z);
      a[C]=a[b[x]];
      if(a[C].first!=-1)a[C].second-=z;
      a[b[x]]=P(C,z);
      b[x]=C++;
      
      a[C]=a[b[y]];
      if(a[C].first!=-1)a[C].second-=z;
      a[b[y]]=P(C,z);
      b[y]=C++;
      
      x=b[x];y=b[y];
      s=find(x);t=find(y);
      if(s.first!=t.first){
        a[s.first].first=t.first;
        a[s.first].second=z+t.second-s.second;
      }
      
    }
  }
  return 0;
}

Measured memory_bytes: 16068
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        a: usize, b: usize,
        s: chars
    }

    let mut is_ok = true;
    for i in 0..a+b+1 {
        if i != a {
            if !(b'0' <= s[i] as u8 && s[i] as u8 <= b'9') {
                is_ok = false;
            }
        } else {
            if s[i] != '-' {
                is_ok = false;
            }
        }
    }
    println!("{}", if is_ok {"Yes"} else {"No"});
}


Measured memory_bytes: 4352
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from math import sqrt

ND = input().split(' ')
N = int(ND[0])
D = int(ND[1])
X = [list(map(int, input().split(' '))) for i in range(N)]

result = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        sum = 0
        for d in range(D):
            sum += (X[i][d] - X[j][d]) * (X[i][d] - X[j][d])
        s = int(sqrt(sum))
        if s * s == sum:
            result += 1

print(result)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>

#define mp make_pair
#define pb push_back
#define ppb pop_back

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<pll> vpl;
typedef vector<vl> vvl;

#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define fors(i, n, s) for (int i = 0; i < (int)(n); i += s)
#define forn1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define forn11(i, n) for (int i = 1; i < (int)(n); ++i)
#define forr(i, n) for (int i = (int)(n) - 1; i >= 0; --i)

#define prOk(ok) cout << ((ok) ? "Yes" : "No")
#define in insert
#define rem remove

int main()
{

	ll n, top, bot;
	cin >> n >> top >> bot;

	//vl t(n);


	ll sum = 0;

	forn(i, n)
	{
		ll tmp;
		cin >> tmp;
		if(tmp >= top && tmp < bot)
			sum++;
	}


	cout << n - sum << endl;

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define pb push_back
typedef long long ll;
typedef long double la;
using namespace std;

int main(){
  ll a,b,k;
  cin >> a >> b >> k;
  if(k >= a+b){
    a = 0;
    b = 0;
  }else if(k >= a){
    b -= k-a;
    a = 0;
  }else{
    a -= k;
  }
  cout << a << ' ' << b << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <cstdio>

using namespace std;

int main()
{
    int n, t, a[105], b[105], ans=999999999;
    bool ok=false;
    cin>>n>>t;
    for (int i=0; i<n; i++) cin>>a[i]>>b[i];
    for (int i=0; i<n; i++)
    {
        if (b[i]<=t)
        {
            ok=true;
            ans=min(ans, a[i]);
        }
    }
    if (ok) cout<<ans<<endl;
    else cout<<"TLE\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int len,dp[300005][3][3],f[300005],ans;
char s[300005];

int main(){
	scanf("%s",s+1);
	len=strlen(s+1);
	dp[0][0][0]=1;
	f[len+1]=1;
	for(int i=len;i>=1;i--) f[i]=(s[i]=='?')?2*f[i+1]%mod:f[i+1];
	for(int i=1;i<=len;i++){
		if(s[i]!='1'){
			(dp[i][1][0]+=dp[i-1][0][0])%=mod;
			(dp[i][1][1]+=dp[i-1][0][1])%=mod;
			(dp[i][1][2]+=dp[i-1][0][2])%=mod;
			(dp[i][2][0]+=dp[i-1][1][0])%=mod;
			(dp[i][2][1]+=dp[i-1][1][1])%=mod;
			(dp[i][2][2]+=dp[i-1][1][2])%=mod;
			(dp[i][1][0]+=dp[i-1][2][0])%=mod;
			(dp[i][1][1]+=dp[i-1][2][1])%=mod;
			(dp[i][1][2]+=dp[i-1][2][2])%=mod;
		}
		if(s[i]!='0'){
			(dp[i][0][1]+=dp[i-1][0][0])%=mod;
			(dp[i][0][2]+=dp[i-1][0][1])%=mod;
			(ans+=1ll*dp[i-1][0][2]*f[i+1]%mod)%=mod;
			(dp[i][0][0]+=dp[i-1][1][0])%=mod;
			(dp[i][0][1]+=dp[i-1][1][1])%=mod;
			(dp[i][0][2]+=dp[i-1][1][2])%=mod;
			(dp[i][1][0]+=dp[i-1][2][0])%=mod;
			(dp[i][1][1]+=dp[i-1][2][1])%=mod;
			(dp[i][1][2]+=dp[i-1][2][2])%=mod;
		}
	}
	(ans+=dp[len][0][1])%=mod;
	(ans+=dp[len][1][2])%=mod;
	printf("%d\n",ans);

	return 0;
}

Measured memory_bytes: 12288
n,m = map(int,input().split())
dp = [[10**10 for i in range(m+1)] for j in range(1<<n)]

for i in range(m+1):
    dp[(1<<n)-1][i] = 0
#print(dp)

for i in range(m):
    a,b = map(int,input().split())
    c = list(map(int,input().split()))
    S_c = 0
    for x in c:
        S_c += 1<<(x-1)
    #print(S_c)
    for s in range(1<<n):
        dp[s][i+1] = min(dp[s][i],a+dp[s | S_c][i],dp[s][i+1])

    #print(dp)

if dp[0][m] == 10**10:
    print(-1)
else:
    print(dp[0][m])

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

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  rep(i,100){
    c -=b;
    if(c<=0){
      cout << "Yes" << endl;
      return 0;
    }
    a -=d;
    if(a<=0){
      cout << "No" << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 3640
n = int(input().rstrip())

line = input().rstrip().split(' ')

a = {}
ans = 0
for i in range(n):
    n = int(line[i])
    ans += n
    if n in a:
        a[n] += 1
    else:
        a[n] = 1

q = int(input().rstrip())

for i in range(q):
    line = input().rstrip().split(' ')
    b = int(line[0])
    c = int(line[1])

    if b in a:
        ab = a[b]
        a[b] = 0
        if c in a:
            ac = a[c]
            a[c] += ab
        else:
            a[c] = ab
    else:
        ab = 0

    ans -= ab * b
    ans += ab * c

    print(ans)



Measured memory_bytes: 21928
#include<bits/stdc++.h>                          
using namespace std;
int a,b,c,ans,x,y,s,d;
int main(){
	cin>>a>>b>>c;
	x=min(a,min(b,c));
	s=max(a,max(b,c));
	y=a+b+c-x-s;
	ans+=s-y;
	x+=ans;
	d=s-x;
	if(d%2==0) ans+=d/2;
	else ans+=(d+1)/2+1;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int a,b,c,d,p,x,y;
	scanf("%d %d %d %d %d",&a,&b,&c,&d,&p);
	x=a*p;
	if(p<=c){
		y=b;
	}else{
		y=b;
		p=p-c;
		while(p>0){
			y=y+d;
			p--;
		}
	}
	if(x>y){
		printf("%d\n",y);
	}else{
		printf("%d\n",x);
	}
	return 0;
}

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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loop2(num) for (lli j = 0 ; j < num ; j ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }
#define looppu(num , ar) for (lli i = 0 ; i < num ;  i++) {lli x ; cin >> x ; ar . push_back (x) ;}
#define loopin(num , ar) for (lli i = 0 ; i < num ;  i++) {lli x ; cin >> x ; ar . insert (x) ;}

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define F first
#define S second
#define pb push_back
#define pf push_front
#define pob pop_back ()
#define pof pop_front ()

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

void fillPrefixSum(ll[]) ;
signed main ()
{
    fastio
    ll a = 0 , b = 0 ;
    cin >> a >> b ;
    ll pref [999] ;
    fillPrefixSum(pref) ;
    cout << pref[b - a - 1 ] - b << endl ;
    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/

void fillPrefixSum(ll prefixSum[])
{
    ll arr[999] ;
    for(int i = 0 , j = 1 ; i < 999 ; i++ , j++)
        arr[i] = j ;

    prefixSum[0] = arr[0] ;
    forr(1 , 999){
        prefixSum[i] = prefixSum [i - 1] + arr [i] ;
    }
}


Measured memory_bytes: 256