akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC target ("avx2,tune=native")
#include<bits/stdc++.h>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define __V vector
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define oit ostream_iterator
#define mod 1000000007ll
using namespace std;
using namespace __gnu_pbds;
void doin() {
	cin.tie();
	cout.tie();
	ios::sync_with_stdio(0);
#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif
}
template<typename X, typename Y>
istream& operator>>(istream& in, pair<X, Y> &a) {
	in >> a.first >> a.second;
	return in;
}
template<typename T>
void getv(T& i) {
	cin >> i;
}
template<typename T, typename ... Ns>
void getv(vector<T>& v, int n, Ns ... ns) {
	v.resize(n);
	for (auto& i : v)
		getv(i, ns...);
}
template<typename T>
void getv1(T& i) {
	cin >> i;
}
template<typename T, typename ... Ns>
void getv1(vector<T>& v, int n, Ns ... ns) {
	v.resize(n + 1);
	for (int i = 1; i <= n; i++)
		getv1(v[i], ns...);
}
#ifdef _WIN32
#define getchar_unlocked() _getchar_nolock()
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
inline void getch(char &x) {
	while (x = getchar_unlocked(), x < 33) {
		;
	}
}
inline void getstr(string &str) {
	str.clear();
	char cur;
	while (cur = getchar_unlocked(), cur < 33) {
		;
	}
	while (cur > 32) {
		str += cur;
		cur = getchar_unlocked();
	}
}
template<typename T> inline bool sc(T &num) {
	bool neg = 0;
	int c;
	num = 0;
	while (c = getchar_unlocked(), c < 33) {
		if (c == EOF)
			return false;
	}
	if (c == '-') {
		neg = 1;
		c = getchar_unlocked();
	}
	for (; c > 47; c = getchar_unlocked())
		num = num * 10 + c - 48;
	if (neg)
		num *= -1;
	return true;
}
template<typename a, typename b>
void minq(a& x, b y) {
	if (x > y)
		x = y;
}
template<typename a, typename b>
void maxq(a& x, b y) {
	if (x < y)
		x = y;
}
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef ll _I;
typedef pair<_I, _I> pi;
typedef pair<ld, ld> pd;
typedef map<_I, _I> mii;
typedef __V <_I> vi;
typedef __V <char> vc;
typedef __V <string> vs;
typedef __V <ld> vd;
typedef __V <vd> vvd;
typedef __V <pi> vpi;
typedef __V <__V<_I>> vvi;
typedef __V <__V<char>> vvc;
typedef __V <__V<pi>> vvpi;
using AntonTsypko = void;
using arsijo = AntonTsypko;
using god = arsijo;
//store differences, not the elements for rsq in fenwick or array(for write-only)
//Sum Over Subsets + inclusion-exclusion is a thing! (Solved div1E (383E) using it!)
//SQRT-heuristic divide items into groups: >sqrt and <=sqrt and do something according to group(eg. trie for one, z-func for other) - 1202E
uniform_real_distribution<double> double_dist(0, 1);
//WHEN DOING MODULAR SUBTRACTION ALWAYS **ALWAYS** ADD MOD
//don't use AVX at AtCoder(=RE)
//Trie: MAXDEPTH!=MAXSIZE
//suspiciously big numbers? use python, seriosly you don't wanna waste your time if it overflows
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
	doin();
	ll k, x;
	cin >> k >> x;
	for(int i = x-k+1; i <= x+k-1; i++) {
		cout << i << " ";
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
int m,d; 
int ans;
int main() { 
    //freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>m>>d;
	for(int i=2;i<=9;i++){
		for(int j=2;j<=9;j++){
			int nw=i*10+j;
			if(nw<=d && i*j<=m)ans++;
		}
	}
	cout<<ans<<endl;
    return 0; 
}

Measured memory_bytes: 256
n, k = map(int, input().split())

a = list(map(int, input().split( )))

dp = [0]*(k+1)
#0は先手負け、1が先手勝ち

for i in range(a[0],k+1):
    for p in a:#負かす手があれば勝ち
        if i-p >= 0 and dp[i-p] == 0:
            dp[i] = 1
            break
if dp[k] == 1:
    print("First")
else:
    print("Second")


Measured memory_bytes: 41964
x, n = map(int, input().split())
if n == 0:
    print(x)
    exit()

p = list(map(int, input().split()))

#p.sort()

for i in range(101):
    if x -i not in p:
        print(x-i)
        exit()
    elif x +i not in p:
        print(x+i)
        exit()

Measured memory_bytes: 9184
N, M = gets.split.map(&:to_i)
A = Array.new(N)
N.times do |i|
    A[i]=gets.to_i
end
[*1..M].each do |k|
    N.times do |i|
        break if i == N-1
        p1 = A[i]%k
        p2 = A[i+1]%k
        if p1 > p2 then
            tmp = A[i]
            A[i] = A[i+1]
            A[i+1] = tmp
        end
    end
end
A.each{|a| p a}


Measured memory_bytes: 6876
#include <stdio.h>

int exchange1And9(int n)
{
if(n == 9)
{
return 1;
}
else if(n == 1)
{
return 9;
}
return n;
}

int main()
{
int n;
scanf("%d",&n);

int low= n % 10;
int middle = ((n % 100) - low) / 10;
int high= (n - (middle + low)) / 100;

high = exchange1And9(high);
middle = exchange1And9(middle);
low = exchange1And9(low);

printf("%d", high*100+middle*10+low);
return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
#ifdef _WIN32
#include "debug.hpp"
#endif
using namespace std;

#define rep(i, N)  for(int i = 0; i < (N); i++)
#define reps(i, N) for(int i = 1; i <= (N); i++)
#define repr(i, N) for(int i = (N) - 1; i >= 0; i--)
#define pub push_back

template<typename T> 
void chmax(T &a, T b){ a = max(a, b); };
template<typename T> 
void chmin(T &a, T b){ a = min(a, b); };

typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;
const ll LINF = 10000000000000000;
const int MOD = 1000000007;
const int dx[9] = { 0, 1,  0, -1, 1,  1, -1, -1, 0};
const int dy[9] = { 1, 0, -1,  0, 1, -1, -1,  1, 0};
//--------------------------------------//
int n, m;
ll x[100000], y[100000];

ll xs[100000], ys[100000];
ll sy;
void solve(){
	ll ans = 0;

	rep(i, n - 1){
		xs[i] = (x[i + 1] - x[i]) * (i + 1) * (n - i - 1);
		xs[i] %= MOD;
	}
	rep(i, m - 1){
		ys[i] = (y[i + 1] - y[i]) * (i + 1) * (m - i - 1);
		ys[i] %= MOD;
		sy += ys[i];
		sy %= MOD;
	}
	rep(i, n - 1){
		ans += xs[i] * sy;
		ans %= MOD;
	}
	cout<<ans<<endl;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n >> m;
	rep(i, n) {
		cin >> x[i];
	}
	rep(i, m) {
		cin >> y[i];
	}
		solve();
	return 0;
}


Measured memory_bytes: 3328
N, M = map(int,input().split())
L = [list(map(int,input().split())) for k in range(M)]

for k in range(M):
    L[k].append(k)
L = sorted(L)

A = [[L[0][0],1,L[0][2]]]
t = 1

for k in range(1,M):
    if L[k-1][0] != L[k][0]:
        t = 1
    else:
        t += 1
    A.append([L[k][0],t,L[k][2]])

A = sorted(A, key = lambda x: x[2])

for a in A:
    print(str(a[0]).zfill(6) + str(a[1]).zfill(6))

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

int main(){
	string N;
  cin >> N;
  for(int i=0;i<3;i++){
    if(N.at(i)=='7'){
      cout<< "Yes"<<endl;
      break;
    }else if(i==2){
      cout<<"No" <<endl;
    }
  }
}

Measured memory_bytes: 3628
n=int(input())
a=list(map(int,input().split()))

def solve(parity):
  wa=0
  ans=0
  for i in range(n):
    wa+=a[i]
    if i%2==parity:
      if wa>=0:
        ans+=wa+1
        wa-=wa+1
    else:
      if wa<=0:
        ans+=-wa+1
        wa+=-wa+1
  return ans

print(min(solve(0),solve(1)))

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

// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>

vector <ll> v;

ll fep(ll x, ll y, ll mod)
{ll res=1;while(y>0){if(y&1)res=(res*x)%mod;
    y=y>>1;x=(x*x)%mod;}return res%mod;}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	
	//freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

	ll n,i,m,j,k,x,y,a,b,t;
	string s;
	
	cin >> n;
	k=m=0;
	for(i=0;i<n;i++)
	{
		cin >> x;
		if(x<m)
			k+=m-x;
		else
			m=x;
	}
	cout << k;
	
	return 0;
}


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

#define range 524289
#define mod 1000000007
#define eps 1e-9
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define _ <<" "<<

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef pair <int, int> ii;
typedef pair<int, pair<int,int> > iii;
typedef vector<ii> vii;
typedef vector<iii> viii;

bool compareInterval(ii i1, ii i2)
{
	return i1.se>i2.se;
}


int find_empty(int x, vi &a){
	if(x==0) return 0;
	if(a[x]==x){
		return x;
	}
	else{
		return a[x] =  find_empty(a[x], a);
	}
}

int main(int argc, char const *argv[])
{
	// #ifndef ONLINE_JUDGE
 //    	freopen("input.txt", "r", stdin);
 //    	freopen("output.txt", "w", stdout);
 //    	freopen("error.txt", "w", stderr);
	// #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, m;
    cin>>n>>m;
    vii p(n);
    vi a(m+1);
    for (int i = 0; i < m+1; ++i)
    {
    	a[i] = i;
    }

    for(int i=0;i<n;i++){
       int x, y;
       cin>>x>>y;
       p[i] = {x, y};
    }
    sort(p.begin(), p.end(), compareInterval);
    ll profit = 0;
    for (int i = 0; i < p.size(); ++i)
    {
    	if(p[i].fi<=m){
    		int ava =  find_empty(m-p[i].fi+1, a);
    		if(ava!=0){
    			 profit += p[i].second;
    			 a[ava] = find_empty(ava-1, a);
    		}
    	}
    }

    cout<<profit<<endl;





    return 0;
}



Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD=1000000007;
const ll INF=1000000000;

int main(){
    ll N, M;
    cin>>N>>M;
    int a[1010];
    int b[1010];
    int c[1010][20];
    for(int i=1; i<=M; i++){
        cin>>a[i]>>b[i];
        for(int j=1; j<=b[i]; j++){
            cin>>c[i][j];
        }
    }

    vector<int> dp(5000, INF);
    dp[0]=0;
    for(int i=1; i<=M; i++){
        int now=0;
        for(int j=1; j<=b[i]; j++){
            now|=(1<<(c[i][j]-1));//nowにc[i][j]-1番目のフラグを立てる>>c[i]のフラグが全てたつ
        }
        for(int j=0; j<(1<<N); j++){
            dp[j|now]=min(dp[j|now], dp[j]+a[i]);
        }
    }
    if(dp[(1<<N)-1]==INF){
        cout<<-1<<endl;
    }
    else{
        cout<<dp[(1<<N)-1]<<endl;
    }
    return 0;
}

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

using namespace std;

#define int64 long long 
#define fi first
#define se second
const int mod = (int) 1e9 + 7;

const int nax = 2e5 + 5;

void add_self(int &a, int b){
	a = a + b;
	if(a >= mod)a -= mod;	
}


void test_case(){
	int s;
	cin >> s;
	vector<int> dp(s+1);
	dp[0] = 1;
	for(int i=0; i<=s; i++){
		if(dp[i] > 0){
			for(int j=3; j + i <= s; j++){
				add_self(dp[j+i], dp[i]);
			}
		}
	}
	cout << dp[s];
}

int main(){
	int t=1;
	//cin>>t;
	while(t--){
		test_case();
	}
}


Measured memory_bytes: 3568
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String T = sc.next();
        boolean ok = false;
        for (int i = 0; i < S.length(); i++) {
            String p1 = S.substring(0, i);
            String p2 = S.substring(i);
            if (T.equals(p2 + p1)) {
                ok = true;
                break;
            }
        }
        if (ok) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        sc.close();
    }
}

Measured memory_bytes: 22736
#include <stdio.h>

int main() {
    
    int l, m, n, i;
    
    while (1) {
        
        if(scanf("%d %d", &l, &m) == EOF) break;
        
        n = l + m;
        
        for (i = 1; n > 9; i++) {
            n /= 10;
        }
        
        
        printf("%d\n", i);
        
    }
    return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
vector<long long>num;
long long n,a[10000];
int main(){
	for(int i=1;i<=9;i++){
		for(int j=i;j<=9;j++){
			string S="";
			for(int k=i;k<=j;k++)S+=(char)('0'+k);
			num.push_back(stoll(S));
		}
	}
	cin>>n;for(int i=0;i<n;i++)cin>>a[i];
	long long maxn=-1;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			long long B=a[i]*a[j];
			bool flag=false;
			for(int k=0;k<num.size();k++){
				if(num[k]==B)flag=true;
			}
			if(flag==true)maxn=max(maxn,B);
		}
	}
	cout<<maxn<<endl;
	return 0;
}

Measured memory_bytes: 3196
import Control.Applicative
import Control.Monad
import Data.List
import Data.Char
import Data.Maybe
strToInt s = (read :: String -> Int) s
strToInteger s = (read :: String -> Integer) s
strToDouble s = (read :: String -> Double) s

main :: IO ()
main = do
	n <- readLn
	putStrLn . show $ if even n then n else n * 2


Measured memory_bytes: 508
#include <math.h>
#include <time.h>
#include <ctype.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include<iomanip>

#define mod 1000000007
#define ll long long int
#define pb(x) push_back(x)
#define MP(x,y) make_pair(x,y)

using namespace std;

ll power(ll a, ll b, ll m)
{
	if (b == 0)
		return(1);
	ll sol = power(a, b / 2, m);
	sol = (sol * sol) % m;
	if (b % 2 == 1)
		sol = (sol * a) % m;
	return(sol);
}
ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	else
	{
		return gcd(b, a % b);
	}
}
int p[21];
void solve()
{
	int n,sol=0;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> p[i];
	for (int i = 1; i < n - 1; i++)
	{
		if (p[i] < max(p[i-1], p[i + 1]) && (p[i] > min(p[i-1], p[i + 1])))
		{
			sol++;
		}
	}
	cout << sol;
}
int main()
{
	int t = 1;
	//cin>>t;
	while (t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (x, y) = readLine()!!.split(" ").map{it.toLong()}

    var res = 1e18.toLong()

    for (a in -1 .. 1 step 2) for (b in -1 .. 1 step 2) {
        val s = x * a
        val t = y * b

        if (s > t) {
            continue
        }
        var u = t - s
        if (a < 0) u++
        if (b < 0) u++
        res = Math.min(u, res)
    }

    println(res)
}


Measured memory_bytes: 36148
# コンプリートボーナスをとる問題をbinで全列挙
# その条件でgreedyすればよい
# O(D*P * 2^D):100*10*1024~10^6

D,G = map(int,input().split())
PC = [tuple(map(int,input().split())) for i in range(D)]
ans = 10**3+19
for i in range(2**D):
    score = 0
    solved = 0
    ps = [PC[j][0] for j in range(D)]
    s = bin(i)[::-1][:-2] # なおしたい
    for j in range(len(s)):
        if s[j] == '1':
            score += PC[j][1]
            score += PC[j][0]*100*(j+1)
            solved += ps[j]
            ps[j] = 0
    i = -1
    while G > score:
        if i < -D:
            solved = 10**3+19
            break
        if ps[i] == 0:
            i -= 1
        else:
            ps[i] -= 1
            score += (D+i+1)*100
            solved += 1
    ans = min(ans,solved)
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string.h>
#include<cmath>
#include<vector>
#include<queue>

using namespace std;

#define INF 2<<29

int main(){
  int n,ans=0;
  int v[100];
  int c[100];

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

  for(int i=0;i<n;i++){
    if(v[i]>c[i]){
      ans+=v[i]-c[i];
    }
  }

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



Measured memory_bytes: 256
import java.lang.Math

fun main(args: Array<String>) {
    val (H, N) = readInputLine().split(" ").map { it.toInt() }
    val magic = Array(N) { val (A, B) = readInputLine().split(" ").map { it.toInt() }; Pair(A, B)}

    // ダメージを与えるために必要な最低のMP
    val dp = IntArray(H + 1) { Int.MAX_VALUE }
    dp[0] = 0

    for (i in 0 until H) {
        if (dp[i] == Int.MAX_VALUE) {
            continue
        }
        for (m in magic) {
            val next = Math.min(H, i + m.first)
            dp[next] = Math.min(dp[next], dp[i] + m.second)
        }
    }

    println(dp[H])
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 40540
from collections import deque

N,Q = map(int,input().split())

graph, parents, values, visited = [],[],[],[]
for _ in range(N):
  graph.append([])
  parents.append(-1)
  values.append(0)
  visited.append(False)

for i in range(N-1):
  a,b = map(int,input().split())
  graph[a-1].append(b-1)
  graph[b-1].append(a-1)

for i in range(Q):
  p,x = map(int,input().split())
  values[p-1] += x

bfs_queue = deque()
bfs_queue.append(0)
bfs_queue_len = 1
while bfs_queue_len:
  cur = bfs_queue.popleft()
  bfs_queue_len -= 1
  visited[cur] = True

  for other in graph[cur]:
    if not visited[other]:
      parents[other] = cur
      values[other] += values[cur]
      bfs_queue_len += 1
      bfs_queue.append(other)

print(*values)



Measured memory_bytes: 57700
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
func exponentiate(_ lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
    func uppercased() -> String {
        return self.uppercaseString
    }
    func lowercased() -> String {
        return self.lowercaseString
    }
}
//extension Array where Element == String {
//    func joined(separator separator: String) -> String {
//        return self.joinWithSeparator(separator)
//    }
//}
extension Array where Element: Comparable {
    func max() -> Element {
        return self.maxElement()!
    }
    func min() -> Element {
        return self.minElement()!
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
func exponentiate(lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/



/*************** メインプログラム ***************/

let N = readInt()!
let S = readLine()!.toArray()
var x = 0
var ans = 0
for c in S {
    if c == "I" {
        x += 1
    } else {
        x -= 1
    }
    ans = max(x, ans)
}
print(ans)


Measured memory_bytes: 6888
//============================================================================
// Name        : AOJ.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <string>
#include <cctype>
using namespace std;

int main() {
	int n,s;
	int T[10];
	while(1){
		for(int i=0;i<10;i++){
			T[i]=0;
		}
		cin>>n;
		if(n==0)break;
		for(int i=0;i<n;i++){
			cin>>s;
			T[s]+=1;

		}
		for(int i=0;i<10;i++){
			if(T[i]==0){
				cout<<"-";
			}else{
				for(int j=0;j<T[i];j++){
					cout<<"*";
				}
			}
			cout<<endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3060
#include <stdio.h>
                        #include <math.h>
                		#include <stdlib.h>
                         
                        int main(void){
                          int n,d;
                          scanf("%d %d",&n,&d);
                          int ar[10][10];
                          for(int r=0; r<n;r++){
                            for(int c=0; c<d;c++){
                              scanf("%d",&ar[r][c]);
                            }
                          }
                          double distance;
                          int correctCount = 0;
                          for(int i=0; i<n; i++){
                            for(int j=i+1; j<n; j++){
                              distance = 0;
                          		for(int k=0; k<d;k++){
                            		distance = distance + pow((double)abs(ar[i][k] - ar[j][k]),2.0);
                                }
			      
                              distance = pow(distance,0.5);
                              if(ceil(distance) == floor(distance)){
                                correctCount++;
                              }
                        	
                            }
                          }
                          printf("%d",correctCount);
                        }

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

int main() {
  string s; cin>>s;
  int c=0, count=0;
  for(int i=0; i<s.size(); i++) {
    if(i>1 && i<s.size()-1 && s[i]=='C') c++;
    if(isupper(s[i])) count++;;
  }
  if(s[0]=='A' && c==1 && count==2) cout<<"AC";
  else cout<<"WA";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define ll long long
#define mod (1000000007)
#define pf(x) cout << (x) << endl;
#define all(x) (x).begin(),(x).end()

ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll t = 1;
    rep1(i, n)t *= i;
    return t;
}

ll combinations(ll n, ll k) {
    ll r = 1;
    rep1(i, k)r = r * n-- / i;
    return r;
}

int main()
{
    int n,m;
    cin >> n >> m;
    if(n == m)pf("Yes")
        else pf("No")
    return 0;
}


Measured memory_bytes: 256
/*package whatever //do not write package name here */

import java.io.*;
import java.lang.Math; 
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
	    Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int w = scan.nextInt();
		int[] val = new int[n];
		int[] wt = new int[n];
		
		for(int i = 0; i < n; i++){
		    wt[i] = scan.nextInt();
		    val[i] = scan.nextInt();
		}
		
		long[][] dp = new long[n+1][w+1];
		
		for(int i = 1; i <= n; i++){
		    for(int j = 0; j <= w; j++){
		        if(j>=wt[i-1]){
		            dp[i][j] = val[i-1]+dp[i-1][j-wt[i-1]];
		        }
		        dp[i][j] = Math.max(dp[i][j],dp[i-1][j]);
		        //System.out.println(i+" "+j+" "+dp[i][j]);
		    }
		}
		System.out.println(dp[n][w]);
		
	}
}

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

using namespace std;
using LL = long long;
const int N = 1024;
const int INF = 1E9;
const double EPS = 1E-9;

int a[N];
int n, m;

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

#ifdef CF_DEBUG
    freopen("../cf/input.txt","r",stdin);
#endif
    cin>>n;
    string s = to_string(n);
    for(auto c :s){
        if(c=='7'){
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  ll a;
  cin>>a;
  if(a==25){
    cout<<"Christmas"<<endl;
    return 0;
  }
  if(a==24){
    cout<<"Christmas Eve"<<endl;
    return 0;
  }
  if(a==23){
    cout<<"Christmas Eve Eve"<<endl;
    return 0;
  }
  if(a==22){
    cout<<"Christmas Eve Eve Eve"<<endl;
  }
}
    
    
  


Measured memory_bytes: 3548
#include<bits/stdc++.h>
#define V vector
#define VI vector<int>
#define VVI vector<vector<int>>
#define rep(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(void){
    int x;
    cin>>x;
    cout<<int(pow(x,3))<<endl;
}





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

int g[13] = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};

int main() {
	int x, y;
	cin >> x >> y;
	if (g[x] == g[y]) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

#define HEAP priority_queue
#define rep(i, n) for(int i = 0, _end_ = (n); i < _end_; ++i)
#define per(i, n) for(int i = (n) - 1; i >= 0 ; --i)
#define forn(i, l, r) for(int i = (l), _end_ = (r); i <= _end_; ++i)
#define nrof(i, r, l) for(int i = (r), _end_ = (l); i >= _end_; --i)
#define FOR(a, b) for(auto (a): (b))
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define X first
#define Y second
#define eps 1e-6
#define pi 3.1415926535897932384626433832795
#define SZ(x) (int)x.size()
#define ALL(x) x.begin(), x.end()
#define FILL(a, b) memset((a), (b), sizeof((a)))
#define MCPY(a, b) memcpy((a), (b), sizeof((b)))

using namespace std;

typedef long long LL;
typedef double flt;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef pair<int,int> pii;
typedef pair<int,LL> pil;
typedef pair<LL,int> pli;
typedef pair<LL,LL> pll;
typedef vector<pil> vil;
typedef vector<pii> vii;
typedef vector<pli> vli;
typedef vector<pll> vll;

const int iinf = 1e9 + 7;
const int oo = 0x3f3f3f3f;
const LL linf = 1ll << 60;
const flt dinf = 1e60;

template <typename T>
inline void scf(T &x)
{
	bool f = 0; x = 0; char c = getchar();
	while((c < '0' || c > '9') && c != '-') c = getchar();
	if(c == '-') { f = 1; c = getchar(); }
	while(c >= '0' && c <= '9') { x = x * 10 + c - '0'; c = getchar(); }
	if(f) x = -x; return;
}
template <typename T1, typename T2>
void scf(T1 &x, T2 &y) { scf(x); return scf(y); }
template <typename T1, typename T2, typename T3>
void scf(T1 &x, T2 &y, T3 &z) { scf(x); scf(y); return scf(z); }
template <typename T1, typename T2, typename T3, typename T4>
void scf(T1 &x, T2 &y, T3 &z, T4 &w) { scf(x); scf(y); scf(z); return scf(w); }

inline char mygetchar(){ char c = getchar(); while(c == ' ' || c == '\n') c = getchar(); return c; }

template <typename T> inline bool chkmax(T &x, const T &y){ return y > x ? x = y, 1 : 0; }
template <typename T> inline bool chkmin(T &x, const T &y){ return y < x ? x = y, 1 : 0; }

#ifdef ONLINE_JUDGE
#define debug(...) ;
#else
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define DEBUG
#endif

//---------------------------------------------------------head----------------------------------------------------

const int maxn = 2e5 + 100;

int n, K, m;
LL ans, sum[maxn], a[maxn];
map<LL, int> M;

namespace BIT
{
	LL num[maxn];

	int lowbit(int i){ return i & (-i); }
	void M(int i, int x){ for(; i; i ^= lowbit(i)) num[i] += x; return; }
	LL Q(int i){ LL R = 0; for(; i <= m; i += lowbit(i)) R += num[i]; return R; }
}

int main()
{
	scf(n, K);
	forn(i, 1, n) scf(a[i]), a[i] -= K, sum[i] = sum[i - 1] + a[i], M[sum[i]];
	M[0];
	for(auto it = M.begin(); it != M.end(); ++it) it->Y = (++m);
	forn(i, 1, n) BIT::M(M[sum[i]], 1);
	rep(i, n)
	{
		ans += BIT::Q(M[sum[i]]);
		BIT::M(M[sum[i + 1]], -1);
	}
	printf("%lld\n", ans);
	return 0;
}

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

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

    int h, w, n;
    cin >> h >> w >> n;

    map<pair<int, int>, int> p;
    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        for (int i = max(a - 2, 1); i <= min(a, h - 2); i++) {
            for (int j = max(b - 2, 1); j <= min(b, w - 2); j++) {
                auto it = p.find({ i, j });
                if (it == p.end()) {
                    p.insert({ { i, j }, 1 });
                } else {
                    it->second++;
                }
            }
        }
    }

    int64_t r[10] = {};
    int k = 0;
    for (const auto& o : p) {
        r[o.second]++;
    }

    r[0] = (int64_t)(h - 2) * (w - 2);
    for (int i = 1; i < 10; i++) {
        r[0] -= r[i];
    }
    for (int i = 0; i < 10; i++) {
        cout << r[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 56576
//include <bits/stdc++.h>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <cstring> 
#define db double 
#define LL long long
#define int LL
#define rep(i,x,y) for (int i=x;i<=y;++i)

using namespace std;
const int N  =  1e5+233;
const int INF =1ll<<60;
const int M=1e15;
//const int mod = ;
void read(int &x)
{
	int f=1;
	x=0;
	char ch=getchar();
	while (!isdigit(ch)) (ch=='-'?f=-1:0),ch=getchar();
	while ( isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	x*=f;
	return ;
}
struct xx
{
	int V,next,q[2];
}b[N<<1];
int G,head[N];
void add(int x,int y,int p,int q)
{
	b[++G]=(xx){y,head[x],p,q};
	head[x]=G;
}
int vis[N],d[N][2];
queue <int > Q;
int n,m,s,t;
void SPFA(int S,int k)
{
	Q.push(S);
	rep(i,1,n) d[i][k]=INF;
	d[S][k]=0;
	while (!Q.empty())
	{
		int u=Q.front();Q.pop();
		for (int i=head[u];i;i=b[i].next)
		{
			#define v b[i].V
			if (d[u][k]+b[i].q[k]<d[v][k]) 
			{
				d[v][k]=d[u][k]+b[i].q[k];
				if (!vis[v]) vis[v]=1,Q.push(v);
			}
			#undef v
		}
		vis[u]=0;
	}
	return ;
}
int cmp(int x,int y)
{
	return d[x][0]+d[x][1]<d[y][0]+d[y][1];
}
int id[N],S,T,x,y,p,q;
signed main()
{
	read(n);read(m);read(S);read(T);
	rep(i,1,m) read(x),read(y),read(p),read(q),add(x,y,p,q),add(y,x,p,q);
	SPFA(S,0);
	SPFA(T,1);
	rep(i,1,n) id[i]=i;  
	sort(id+1,id+1+n,cmp);
	int pos=1;
	for (int i=1;i<=n;++i)
	{
		while (id[pos]<i) ++pos;
	//	if (gg[id[i]]) //continue;
	//	{
//			++i;
	//		continue;
	//	}
		printf("%lld\n",M-d[id[pos]][0]-d[id[pos]][1]);
		//++i;
		//gg[i]=1;
	}
	return 0;	
}


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n;
    cin >> n;
    int64 ans = 0;
    REP(i,n){
        int32 a;
        cin >> a;
        ans += a;
    }
    ans -= n;
    ANS(ans);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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

	
	int H, W;
	cin >> H >> W;
	string S[100];
	rep(i, H) cin >> S[i];

	rep(i, H) {
		co(S[i]);
		co(S[i]);
	}
	Would you please return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010


int main(){
  int n;
  int dp[SIZE];

  dp[0] = 0;

  cin >> n;
  
  for(int i=1;i<=n;i++){
    dp[i] = INF;
  }

  for(int i=9;i<=n;i*=9){
    for(int j=0;j+i<=n;j++){
      dp[j+i] = min(dp[j+i], dp[j]+1);
    }
  }
  
  for(int i=6;i<=n;i*=6){
    for(int j=0;j+i<=n;j++){
      dp[j+i] = min(dp[j+i], dp[j] + 1);
    }
  }
  
  int ans = INF;
  
  for(int i=0;i<=n;i++){
    ans = min(ans, dp[i] + n-i);
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 640
n = input()
cnt = 1
m = 0
for i in range(3):
    if n[i] == n[i+1]:
        cnt += 1
    else:
        m = max(m, cnt)
        cnt = 1
m = max(m, cnt)
if m >= 3:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
#include <iostream>
#include <cstring>

using namespace std;

int main(){
    int N;
    int a[100000];
    int s = 0;
    bool used[100000];
    int ans = 0;
    cin >> N;
    memset(used, false, N);
    for(int i = 0; i < N; i++){
        cin >> a[i];
        s ^= a[i];
    }
    for(int i = 30; i >= 0; i--){
        int n = 1<<i;
        if(s&n){
            for(int i = 0; i < N; i++){
                if(a[i]%n == 0 && a[i]%(2*n) != 0 && !used[i]){
                    s ^= (2*n-1);
                    used[i] = true;
                    ans++;
                    break;
                }
                if(i == N-1){
                    cout << -1 << endl;
                    return 0;
                }
            }
        }
    }
    cout << ans << endl;
}

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

#include <limits.h>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

// O(N * logN)
int main(void) {
    int N;
    cin >> N;

    ll ans = 0;
    ll cnt = 0;
    for (int i = 1; i <= N; i++) {
        for (int j = i; j <= N; j += i) {
            ans += j;
            cnt++;
        }
    }

    // printf("ans: %lld, cnt: %lld\n", ans, cnt);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3616
using System;

namespace ABC084
{
    class B
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int A = int.Parse(input[0]);
            int B = int.Parse(input[1]);

            string S = Console.ReadLine();

            bool res;
            for (int i = 0; i < A; i++)
            {
                res = Char.IsDigit(S[i]);
                if (!res)
                {
                    Console.WriteLine("No");
                    return;
                }
            }

            if (S[A] != '-')
            {
                Console.WriteLine("No");
                return;
            }

            for (int i = A + 1; i < A + 1 + B; i++)
            {
                res = Char.IsDigit(S[i]);
                if (!res)
                {
                    Console.WriteLine("No");
                    return;
                }
            }
            Console.WriteLine("Yes");
        }
    }
}


Measured memory_bytes: 13140
x,y=map(int,input().split())
ans=0
if x==1:
  ans+=300000
if x==2:
  ans+=200000
if x==3:
  ans+=100000
if y==1:
  ans+=300000
if y==2:
  ans+=200000
if y==3:
  ans+=100000
  
if x==1 and y==1:
  ans+=400000
print(ans)
 

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

using namespace std;

#define ll long long

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

    vector<int> w, v;
    for(int i = 0; i < N; i++)
    {
        int weight, value;
        cin >> weight >> value;
        w.push_back(weight);
        v.push_back(value);
    }

    // dp[i][j] - maximum value using i items with weight at most j
    vector<vector<ll>> dp(N+1, vector<ll>(W+1, 0));
    dp[0][0] = 0;

    for(int i = 1; i <= N; i++)
    {
        for(int j = 0; j <= W; j++)
        {
            if(j-w[i-1] >= 0)
                dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i-1]] + v[i-1]);
            else
                dp[i][j] = dp[i-1][j];
        }
    }

    cout << dp[N][W] << endl;

    return 0;
}


Measured memory_bytes: 80256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
typedef long long ll;
using namespace std;
#define int long long

//素数判定
inline bool IsPrime(int p) {
	if (p == 1) return false;
	for (int i = 2; i <= sqrt(p); i++) {
		if (p%i == 0) return false;
	}
	return true;
}

//10進数の自然数の桁数を返す
inline int GetDigit(int num) {
	return (int)log10(num) + 1;
}

//各位の和を返す
int GetDigitsSum(int num) {
	int N = 0;
	while (num > 0) {
		N += num % 10;
		num /= 10;
	}
	return N;
}

//互除法
ll gcd(ll a, ll b) {
	if (a < b) {
		return gcd(b, a);
	}
	else if (a%b) {
		return gcd(b, a%b);
	}
	else {
		return b;
	}
}

//異なるn個からr個の整数を取り出す組合せの数を求める
int combination(int n, int r) {
	if (r == 0 || n == r) {
		return 1;
	}
	else if (r == 1) {
		return n;
	}
	else {
		return combination(n - 1, r - 1) + combination(n - 1, r);
	}

}

//Ｏ(√n)
//素因数分解
map<int, int> prime_factor(int n) {
	map<int, int> res; // map[i]:=ｎを素因数分解したときiは何乗か。
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0) {
			while (n % i == 0) {
				res[i]++;
				n /= i;
			}
		}
	}
	if (n != 1)
		res[n] = 1;
	return res;
}

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

	int M, N;
	cin >> M >> N;
	bool flg = false;
	int ans;

	if (abs(M - N) <= 1) {
		flg = true;

		int a = max(M, N);
		int b = min(M, N);
		

		if (a == b) {
			int tmp = 1;
			for (int i = 1; i <= a; i++)
			{
				tmp *= i;
				tmp %= 1000000007;
			}
			ans = tmp * tmp;
			ans %= 1000000007;
			ans *= 2;
			ans %= 1000000007;
		}
		else {
			int tmp1 = 1;
			for (int i = 1; i <= a; i++)
			{
				tmp1 *= i;
				tmp1 %= 1000000007;
			}
			int tmp2 = 1;
			for (int i = 1; i <= b; i++)
			{
				tmp2 *= i;
				tmp2 %= 1000000007;
			}
			ans = tmp1 * tmp2;
			ans %= 1000000007;
		}

		
	}
	if (flg) {
		cout << ans << endl;
	}
	else {
		cout << 0 << endl;
	}
	return 0;
}

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

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

  int64_t mod = 1e9+7;
  int64_t p = 1;
  for (int i = 1; i <= N; i++) p = p * i % mod;
  cout << p << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static int K;
	static int A;
	static int B;
	static int a;
	static int b;
	public static void main(String[]args) {
		Scanner sc=new Scanner(System.in);
		K=sc.nextInt();
		A=sc.nextInt();
		B=sc.nextInt();
		a=A/K;
		b=B/K;
		if(a!=b) {
			System.out.println("OK");
		}
		else if(a==b&&A%K==0) {
			System.out.println("OK");
		}
		else if(a==b&&B%K==0) {
			System.out.println("OK");
		}
		else {
			System.out.println("NG");
		}
	}
}


Measured memory_bytes: 35816
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
// #define LOCAL
const int MAXN=1;
const ll MOD=1;
ll _gcd(ll a,ll b){if(b==0)return a;return _gcd(b,a%b);}
ll gcd(ll a,ll b){a=abs(a),b=abs(b);if(a<b)swap(a,b);return _gcd(a,b);}
ll qpow(ll a,ll n){ll rt=1;while(n){if(n&1)rt=(rt*a)%MOD;a=a*a%MOD;n>>=1;}return rt;}
ll factor[MAXN];
void cal_factor(){factor[0]=1;for(int u=1;u<MAXN;u++){factor[u]=(factor[u-1]*u)%MOD;}}
ll C(ll n,ll k){return factor[n]*qpow(factor[n-k],MOD-2)%MOD*qpow(factor[k],MOD-2)%MOD;}
int N;
void solve()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>N;
    int c0=0,c1=0,c2=0;
    for(int u=0;u<N;u++){
        int cnt=0;
        int a;
        cin>>a;
        while(a%2==0){
            a/=2;
            cnt++;
        }
        if(cnt==0)c0++;
        else if(cnt==1)c1++;
        else c2++;
    }
    if(c1==0){
        if(c0-c2<=1)cout<<"Yes\n";
        else cout<<"No\n";
    }
    else {
        if(c0<=c2)cout<<"Yes\n";
        else cout<<"No\n";
    }
}
int main()
{
#ifdef LOCAL
    freopen("in.txt","r",stdin);
#endif
    solve();
}

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

int main() {
    int a,b,c,d;
    cin >> a >> b >> c >> d;

    if(abs(a-c)<=d || (abs(a-b)<=d && abs(b-c)<=d))
        cout << "Yes";
    else
        cout << "No";
    cout << endl;
}

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

typedef long long ll;
const int N = 666, mod = 1000000007;
int n, m, f[N][N], g[N][N];
bool fix[N], banned[N];
int main() {
  scanf("%d", &n);
  int t = 1;
  for (int i = 1, x, y; i <= n; i++) {
    scanf("%d%d", &x, &y);
    if (~x && ~y) {
      fix[x] = fix[y] = true;
    } else if (~x || ~y) {
      banned[x + y + 1] = true;
    } else {
      t = (ll) t * (++m) % mod;
    }
  }
  f[0][0] = 1;
  for (int x = n * 2; x; x--) if (!fix[x]) {
    memset(g, 0, sizeof g);
    for (int i = 0; i <= n; i++) {
      for (int j = 0; j <= n; j++) if (f[i][j]) {
        if (banned[x]) {
          g[i][j + 1] = (g[i][j + 1] + f[i][j]) % mod;
          if (i) g[i - 1][j] = (g[i - 1][j] + f[i][j]) % mod;
        } else {
          g[i + 1][j] = (g[i + 1][j] + f[i][j]) % mod;
          if (i) g[i - 1][j] = (g[i - 1][j] + f[i][j]) % mod;
          if (j) g[i][j - 1] = (g[i][j - 1] + (ll) f[i][j] * j) % mod;
        }
      }
    }
    memcpy(f, g, sizeof g);
  }
  int ans = (ll) f[0][0] * t % mod;
  printf("%d\n", ans);
}


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

int main(){
    string s;
    cin >> s;
    string t = s.substr(0,3);
    cout << t << endl;
}

Measured memory_bytes: 3628
#include<iostream>
#include<bits/stdc++.h>
#include<string>
#include<time.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define fi first    
#define se second
void solve()
{
    ll n,i,j,k;
    cin>>n>>k;
    vector<ll> a(n);
    for(i=0;i<n;i++)
        cin>>a[i];
    ll dp[n];
    dp[0]=0;
    dp[1]=abs(a[0]-a[1]);
    ll m=INT_MAX;
    for(i=2;i<n;i++)
    {
        for(j=i-1;j>=(i-k>0?i-k:0);j--){
            m=min(m,abs(a[i]-a[j])+dp[j]);
            // if(i==n-1)
            // cout<<abs(a[i]-a[j])<<" "<<dp[i-j]<<" "<<i<<" "<<j<<"\n";
        }
        dp[i]=m;
        m=INT_MAX;
    }
    cout<<dp[n-1];
    // for(i=0;i<n;i++)
        // cout<<dp[i]<<" ";
}
int main(){ 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //#endif  
    clock_t tStart = clock();
    ll t,k;
    // cin>>t;
    // while(t--)
        solve();
    // printf("\nTime taken: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
    return 0;
}       

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

using namespace std;

int main() {

    int N, H;
    cin >> N >> H;

    vector<int> throw_dmg;
    int max_at = 0, at_throw = 0;
    int at, th;
    for (int i = 0; i < N; i++) {
        cin >> at >> th;
        if (at > max_at) {
            max_at = at;
            throw_dmg.push_back(at_throw);
            at_throw = th;
        }
        else if (at == max_at) {
            if (at_throw > th) {
                throw_dmg.push_back(at_throw);
                at_throw = th;
            }
            else {
                throw_dmg.push_back(th);
            }
        }
        else {
            throw_dmg.push_back(th);
        }
    }

    sort(throw_dmg.begin(), throw_dmg.end(), greater<int>());
    /*
    cout << max_at << ' ' << at_throw << '\n';
    for (int i = 0; i < N; i++) {
        cout << throw_dmg[i] << '\n';
    }
    */

    long long ans = 0;
    for (int i = 0; i < throw_dmg.size(); i++) {
        if (throw_dmg[i] > max_at) {
            H -= throw_dmg[i];
            ans++;
        }
        else break;
        if (H <= 0) {
            break;
        }
    }

    if (H <= 0) {
        cout << ans << '\n';
        return 0;
    }
    
    H -= at_throw;
    ans++;
    if (H <= 0) {
        cout << ans << '\n';
        return 0;
    }
    
    ans += (H + (max_at - 1)) / max_at;
    cout << ans << '\n';


}


Measured memory_bytes: 892
ALPHA = 'abcdefghij'
N = int(input())
ans = [('', 0)]
for _ in range(N):
    temp = []
    for s, num in ans:
        for a in ALPHA[:num]:
            t = s + a
            temp.append((t, num))
        temp.append((s + ALPHA[num], num + 1))
    ans = temp
for a, _ in ans: print(a)

Measured memory_bytes: 21592
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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

int A,B,K,temp;


int main(){
    cin>>A>>B>>K;
    temp=min(A,B)+1;
    while(K){
        temp--;
        if(A%temp==0&&B%temp==0){
            K--;
        }
    }
    out(temp);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,y,ans,ic,uc,hc;
int main(){
    cin>>n>>y;


    for(int i=0;i<n+1;i++){
        if(1000*i>y||i>n)break;
        for(int u=0;u<n+1;u++){
            if(1000*i+5000*u>y||i+u>n)break;
            for(int h=0;h<n+1;h++){
                if(1000*i+5000*u+10000*h>y||i+u+h>n)break;
                if(1000*i+5000*u+10000*h==y&&i+u+h==n){
                    ic=h;
                    uc=u;
                    hc=i;
                    ans=1;
                    break;
                }
            }if(ans)break;
        }if(ans)break;
    }

    for(int i=0;i<1000000000*10;i++){
        int aho;
    }








    if(ans==1){
        cout<<ic<<" "<<uc<<" "<<hc<<endl;
    }else{
        cout<<"-1 -1 -1"<<endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#include<set>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) std::cout<<arg<<"\n"
#define prin2(arg1,arg2) std::cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) std::memset(arg,n,sizeof(arg))
#define mp std::make_pair
#define pb push_back
using std::cin;
typedef long long ll;
typedef std::pair<int,int> pi;
typedef std::vector<int> vi;
typedef std::set<int> si;
typedef std::string str;
const int INF=1e+9;
const ll INFLL=1e+17;
const ll MOD=1e+9+7;
int N;
ll A[100010];
int main(){
  cin>>N;
  rep(i,N) cin>>A[i];
  ll res=0;
  rep(i,N){
    if(A[i]%2==0&&A[i]>=2){
      res+=(A[i]-1)/2;
      A[i]=2;
    }
    else if(A[i]%2==1){
      res+=A[i]/2;
      A[i]=1;
    }
    else continue;
  }
  rep(i,N-1){
    if(A[i]==1&&A[i+1]!=0){
      res++;
      A[i]=0;
      A[i+1]--;
    }
    else if(A[i]==2){
      res++;
      A[i]=0;
    }
    else continue;
  }
  if(A[N-1]==2) res++;
  prin(res);
  
  return 0;
}


Measured memory_bytes: 1024
x1, y1, x2, y2 = map(int, input().split())
dx = x2 - x1
dy = y2 - y1
x3 = x2 - dy
y3 = y2 + dx
x4 = x1 - dy
y4 = y1 + dx
print(f"{x3} {y3} {x4} {y4}")

Measured memory_bytes: 9060