akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define pb           push_back
#define pf           push_front
#define in           insert
#define ff           first
#define ss           second
#define mp           make_pair
#define int          long long
#define uint         unsigned long long
#define rep(i,x,m)   for(int i=x;i<m;i++)
#define repr(i,x,m)  for(int i=x;i>=m;i--)
#define MOD          1000000007
#define endl         "\n"
#define all(v)       v.begin(),v.end()
#define rall(v)      v.rbegin(),v.rend()
#define vi           vector<int>
#define vs           vector<string>
#define pi           pair<int,int>
#define di           deque<int>
#define sz(x)       (int)x.size()
#define pq           priority_queue<int>
#define pqs          priority_queue<int,vi,greater<int> >
#define fix(y)       fixed<<setprecision(y)
#define print(v)     for(int i=0;i<v.size();i++) cout<<v[i]<<" ";cout<<endl
#define noob         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

int fac[2000005]={0};
void factorial(){ fac[0]=1; fac[1]=1; for(int i=2;i<200005;i++) fac[i]=((i%MOD)*(fac[i-1]%MOD))%MOD;}
int power(int n,int m)
{int p=1;if(m==0)return 1;p=(power(n,m/2)%MOD);p=(p%MOD*p%MOD)%MOD;
return(m&1?((p%MOD*n%MOD)%MOD):(p%MOD));}
int ncr(int n,int r){return ((fac[n]*power(fac[r],MOD-2))%MOD*power(fac[n-r],MOD-2))%MOD;}

void ram5564()
{
    int n,k;
    cin>>n>>k;
    int a[n];
    int dp[n];
    rep(i,0,n)
    dp[i]=1e15;
    rep(i,0,n)
    {
        cin>>a[i];
    }
    dp[0]=0;
    rep(i,0,n)
    {
      if(i==0)
        continue;
      if(i==1)
      {
        dp[i]=abs(a[i]-a[i-1]);
        continue;
      }
      for(int j=1;j<=k&&i-j>=0;++j)
      dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
    }
   cout<<dp[n-1];
}

signed main()
{
        noob
        // #ifndef ONLINE_JUDGE
        //  freopen("input.txt","r",stdin);
        //  freopen("output.txt","w",stdout);
        //  #endif   
        
        int t=1;
        //cin>>t;
        while(t--)
        ram5564();
        return 0;
}

Measured memory_bytes: 5128
n = int(input())
list = []
for i in range(3, n + 1):
    if i % 3 == 0:
        list.append(i)
    else:
        x = i
        while x:
            if x % 10 == 3:
                list.append(i)
                break
            else:
                x = x // 10
print("", *list)


Measured memory_bytes: 5984
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-12;
const double PI = acos(-1.0);
const int INF = INT_MAX/10;

string add(string a, string b) {
	reverse(ALL(a));
	reverse(ALL(b));
	int al = a.length();
	int bl = b.length();
	string res;
	int tmp, carry = 0;
	REP(i, max(al, bl)) {
		if(i < al && i < bl) {
			tmp = (a[i]-'0')+(b[i]-'0');
		} else if(i < al) {
			tmp = (a[i]-'0');
		} else if(i < bl) {
			tmp = (b[i]-'0');
		}
		tmp += carry;
		res.push_back(tmp%10+'0');
		carry = tmp/10;
	}
	if(carry) {
		res.push_back('1');
	}

	reverse(ALL(res));
	return res;
}

int main() {
	string s;
	while(cin >> s) {
		string a, b, c;
		int ppos = s.find_first_of('+');
		int epos = s.find_first_of('=');
		a = s.substr(0, ppos);
		b = s.substr(ppos+1, epos-a.length()-1);
		c = s.substr(epos+1);

		int ans = -1;
		REP(i, 10) {
			string na = a, nb = b, nc = c;
			REP(j, na.size()) {
				if(na[j] == 'X') {
					na[j] = i+'0';
				}
			}
			REP(j, nb.size()) {
				if(nb[j] == 'X') {
					nb[j] = i+'0';
				}
			}
			REP(j, nc.size()) {
				if(nc[j] == 'X') {
					nc[j] = i+'0';
				}
			}

			if(na[0] == '0' && na.length() != 1) {
				continue;
			}
			if(nb[0] == '0' && nb.length() != 1) {
				continue;
			}
			if(nc[0] == '0' && nc.length() != 1) {
				continue;
			}

			if(add(na, nb) == nc) {
				ans = i;
				break;
			}
		}

		if(ans == -1) {
			cout << "NA" << endl;
		} else {
			cout << ans << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1196
#[allow(unused_macros)]
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty ;; $n:expr) => {
        (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! get_chars {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().chars().collect::<Vec<_>>()
        }
    };
    ($n:expr) => {
        {
            (0..$n)
                .map(|_| get_chars!())
                .collect::<Vec<_>>()
        }
    };
}

fn main() {
    let (n, m, q) = get!(i64, i64, i64);
    let sets = get!(i64, i64, i64, i64; q);

    println!("{}", dfs(&sets, vec!(), n, m));
}

fn dfs(sets: &Vec<(i64,i64,i64,i64)>, vec: Vec<i64>, n: i64, m: i64) -> i64 {
    if vec.len() == n as usize {
        return sets.iter().map(|(a, b, c, d)| {
            let b = (*b as usize) - 1;
            let a = (*a as usize) - 1;
            if vec[b] - vec[a] == *c { *d } else { 0 }
        }).sum();
    }

    let mut ans = 0;
    let last = if vec.is_empty() { 1 } else { vec[vec.len() - 1] };
    for nn in last..=m {
        let mut nvec = vec.clone();
        nvec.push(nn);
        ans = ans.max(dfs(&sets, nvec, n, m));
    }
    ans
}

Measured memory_bytes: 2180
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

using namespace std;

#define MAX 100000
#define INF 2140000000
#define MOD 1000000007

int main() {
	int n, l;
	cin >> n >> l;
	int flavor = 0;

	for (int i = 0; i < n; ++i) {
		flavor += l + i;
	}

	int maxx = INF, ans = 0;

	for (int i = 0; i < n; ++i) {
		int temp = flavor;
		temp -= l + i;

		if (abs(temp - flavor) < maxx) {
			maxx = abs(temp - flavor);
			ans = temp;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 6)
N=int(input())
g = [[] for i in range(N)]
for i in range(N-1):
	a,b=map(int,input().split())
	a -= 1
	b -= 1
	g[a].append(b)
	g[b].append(a)

nim = [-1 for i in range(N)]

def dfs(cur,par):
	val = 0
	for dst in g[cur]:
		if dst == par:
			continue
		val ^= dfs(dst,cur) + 1
	nim[cur] = val
	return val

dfs(0 , -1)
#print(nim)
if nim[0] == 0:
	print('Bob')
else:
	print('Alice')


Measured memory_bytes: 110420
#include <iostream>

using namespace std;

int main()
{
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(b <= c || d <= a)
    {
        cout << "0" << endl;
    }
    else
    {
        int l = 0,r = 0;
        if(a <= c) l = c;
        else if(c < a) l = a;
        if(b <= d) r = b;
        else if(d < b) r = d;
        cout << r-l << endl;
    }
    return 0;
}


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

int main()
{
  int n;
  int save;
  int fx;
  
  fx = 0;
  cin >> n;
  save = n;
  while (n > 0)
  {
    fx += n % 10;
    n /= 10;
  }
  if (save % fx == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
s = input()

if ((int(s[0])==0 and 1<=int(s[1])<=9)  or (int(s[0]) == 1 and 0<=int(s[1])<=2)) and ((int(s[2])==0 and 1<=int(s[3])<=9)  or (int(s[2]) == 1 and 0<=int(s[3])<=2) ):
  print("AMBIGUOUS")
elif (int(s[0])==0 and 1 <=int(s[1])<=9)  or (int(s[0]) == 1 and 0<=int(s[1])<=2):
  print("MMYY")
elif (int(s[2])==0 and 1 <=int(s[3])<=9)  or (int(s[2]) == 1 and 0<=int(s[3])<=2):
  print("YYMM")
else:
  print("NA")


Measured memory_bytes: 9124
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    std::ios::sync_with_stdio(false); cin.tie(nullptr);
    int n, k, q, p;
    cin >> n >> k >> q;

    vector<int> a(n, k-q);
    for(int i=0;i<q;++i) {
        cin >> p;
        ++a[p-1];
    }

    for(int i=0;i<n;++i) {
        cout << ((a[i] > 0) ? "Yes" : "No") << endl;
    }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define ld long double
#define pb push_back
#define all(x) (x).begin(), (x).end()
template <typename T> using ord_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 2e5 + 123, inf = 1e9 + 123;
int n, a[N], b[N];

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	cin >> n;
	ll s = 0;
	int mn = inf;
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i], s += a[i];
		if (a[i] > b[i]) mn = min(mn, b[i]);
	}
	if (mn == inf) cout << 0;
	else cout << s - mn;
}


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

cnt = [0] * ((10 ** 6) + 1)

for elem in a:
    cnt[elem] += 1

unique = []

for i in range((10 ** 6) + 1):
    if cnt[i] == 1:
        unique.append(i)

cnt = [0] * ((10 ** 6) + 1)

a = list(set(a))

for elem in a:
    for m in range(elem * 2, (10 ** 6) + 1, elem):
        cnt[m] = 1

ans = 0
        
for elem in unique:
    if cnt[elem] == 0:
        ans += 1

print(ans)
         
         

Measured memory_bytes: 48272
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int c = Integer.parseInt(sc.next());
		
		if(a == b && b == c) {
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 21204
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin >> n;
  char c[n][n];
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      cin >> c[i][j];
    }
  }
  int ans=0;
  char d[n][n];
  for(int i=0;i<n;i++){
    bool f=true;
    for(int j=0;j<n;j++){
      for(int k=0;k<n;k++){
        d[j][k]=c[(j+i)%n][k];
      }
    }
    for(int j=0;j<n;j++){
      for(int k=j;k<n;k++){
        if(d[j][k]!=d[k][j]){
          f=false;
        }
      }
    }
    if(f){
      ans+=(n-i);
    }
  }
  for(int i=1;i<n;i++){
    bool f=true;
    for(int j=0;j<n;j++){
      for(int k=0;k<n;k++){
        d[j][k]=c[j][(k+i)%n];
      }
    }
    for(int j=0;j<n;j++){
      for(int k=j;k<n;k++){
        if(d[j][k]!=d[k][j]){
          f=false;
        }
      }
    }
    if(f){
      ans+=(n-i);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{

        int a,b;
        string s,t,u;
        cin>>s>>t;
        cin>>a>>b;
        cin>>u;
          if(u==s)
        {
            cout<<(a-1)<<" "<<b<<endl;
        }
        else
             cout<<a<<" "<<(b-1)<<endl;
return 0;
}










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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

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

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

int main(void){
    VI a(3,0);
    REP(i,3){
        char c; cin >> c;
        a[c-'a'] = 1;
    }
    cout << (a[0]+a[1]+a[2]==3 ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cassert>
#include <cstring>
using namespace std;

#define GET_ARG(a,b,c,F,...) F
#define REP3(i,s,e) for (i = s; i <= e; i++)
#define REP2(i,n) REP3 (i,0,(int)(n)-1)
#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)
#define RREP3(i,s,e) for (i = s; i >= e; i--)
#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)
#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)
#define DEBUG(x) cerr << #x ": " << x << endl

vector<int> pos[128];

int main(void) {
    string s;
    cin >> s;

    char c;
    int i, j, n = s.size();
    set<char> st;
    REP (c,'a','z') st.insert(c);
    vector<int> bound;
    bound.push_back(n);
    RREP (i,n) {
        st.erase(s[i]);
        if (st.empty()) {
            REP (c,'a','z') st.insert(c);
            bound.push_back(i);
        }
    }
    bound.push_back(0);
    reverse(bound.begin(),bound.end());

    REP (i,n) {
        pos[s[i]].push_back(i);
    }
    REP (c,'a','z') pos[c].push_back(n);

    string ans;
    int now = 0;
    REP (i,bound.size()-1) {
        REP (c,'a','z') {
            int p = *lower_bound(pos[c].begin(),pos[c].end(),now);
            if (p >= bound[i+1]) {
                ans += c;
                now = p+1;
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1412
h,n=input().split()
h=int(h)
n=int(n)
#print(h,n)
arr=list(map(int,input("\r").strip().split()))[:n] 
sum=0;
for i in range(0,n):
  #  print(arr[i])
    sum+=arr[i]
  
if sum>=h:
    print("Yes")
else:
    print("No")
    
   

Measured memory_bytes: 20460
#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin, exit


def main():
    for line in stdin:
        p, q = (int(s) for s in line.split())

        div_list = []
        mod_list = []

        d, m = divmod(p, q)
        p = m * 10
        mod_list.append(m)

        while m:
            d, m = divmod(p, q)
            div_list.append(d)
            p = m * 10
            if m in mod_list:
                break
            mod_list.append(m)

        print(*div_list, sep='')

        if m:
            space = mod_list.index(m)
            circum = len(mod_list) - space
            print(' ' * space + '^' * circum)


if __name__ == '__main__':
    main()

Measured memory_bytes: 4252
#include<queue>
#include<cmath>
#include<ctime>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define mem(a,b) memset(a,b,sizeof a)
#define  For(i,a,b) for(int i=a,i##end=b;i<=i##end;++i)
#define rFor(i,a,b) for(int i=a,i##end=b;i>=i##end;--i)
using namespace std;
typedef long long LL;
template<typename T>inline T chkmax(T _A,T _B){return _A>_B?_A:_B;}
template<typename T>inline T chkmin(T _A,T _B){return _A<_B?_A:_B;}
template<typename T>void read(T&x)
{
    x=0;int _f(0);char ch=getchar();
    while(!isdigit(ch))_f|=(ch=='-'),ch=getchar();
    while( isdigit(ch))x=x*10+ch-'0',ch=getchar();
    x=_f?-x:x;
}
inline void file()
{
#ifndef ONLINE_JUDGE
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
#endif
}
int dp[10010],a[110],n,ans;
int main()
{
	read(n);
	For(i,1,n)read(a[i]);
	dp[0]=1;
	For(i,1,n)
		rFor(j,10000-a[i],0)
			if(dp[j])
				dp[j+a[i]]=1;
	rFor(i,10000,0)
		if(dp[i]&&i%10!=0)
		{
			ans=i;
			break;
		}
	printf("%d\n",ans);
	return 0;
}


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

using ll = long long;
const int INF = 1001001001;
const ll LLINF = 1001001001001001001;
const int MOD = 1000000007;

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

int main()
{
  int n;
  cin >> n;
  vector<pair<int, int>> a;
  for (int i = 1; i <= n; i++) {
    int tmp;
    cin >> tmp;

    a.push_back(make_pair(tmp, i));
  }
  sort(a.begin(), a.end());

  rep(i,n) {
    cout << a[i].second << " ";
  }
  cout << endl;
}


Measured memory_bytes: 1780
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll t=0,n,m=0,f=0;
    cin>>n;
    ll a[n+10];
    for(int i = 0;i < n;i++)
    {
        cin>>a[i];
        t += a[i];
    }
    sort(a,a+n);
    a[n-1] = a[n-1]/2;
    t -= a[n-1];
    cout<<t<<endl;

}


Measured memory_bytes: 256
t = list(str(input()).split(" "))
n = int(t[0])
m = int(t[1])

a = list()
for i in range(n):
    a.append(str(input()))

b = list()
for i in range(m):
    b.append(str(input()))

c = n-m+1
for i in range(c):
    for j in range(c):
        fg = False
        for k in range(m):
            if(fg == True):break
            for l in range(m):
                if(fg == True):break
                if(a[i+k][j+l] != b[k][l]):
                    fg = True
                    break

        if(fg == False):
            print("Yes")
            exit()

print("No")


Measured memory_bytes: 3064
import sys
import re
input = sys.stdin.readline

N = int(input())

alpha = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
ans = []
for i in range(N):
    if not i:
        ans.append(['a'])
    else:
        l = []
        p = []
        for x in ans[-1]:
            m = max([alpha.index(a) for a in x])
            l.extend([x + a for a in alpha[:m + 2]])

        ans.append(l)

for x in ans[N - 1]:
    print(x)


Measured memory_bytes: 14848
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;

int main()
{
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    int x = tx-sx, y = ty-sy;
    for(int i = 1; i <= y; i++) cout << "U";
    for(int i = 1; i <= x; i++) cout << "R";
    for(int i = 1; i <= y; i++) cout << "D";
    for(int i = 1; i <= x+1; i++) cout << "L";
    for(int i = 1; i <= y+1; i++) cout << "U";
    for(int i = 1; i <= x+1; i++) cout << "R";
    cout << "DR";
    for(int i = 1; i <= y+1; i++) cout << "D";
    for(int i = 1; i <= x+1; i++) cout << "L";
    cout << "U" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;
typedef std::string str;
#define sei set<int>
#define sell set<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pld pair<ld,ld>
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define vvll vector<vll>
#define vld vector<ld>
#define vstr vector<str>
#define vpii vector<pii>
#define vpll vector<pll>
#define all(v) v.begin(),v.end()
#define foa(i,v) for(auto i : v)
#define fo(i,a,b) for(int i=a;i<b;i++)
#define fo_(i,a,b) for(int i=a;i>b;i--)
#define M(a) memset(a,0,sizeof a)
#define M_(a) memset(a ,-1,sizeof a)
#define deb(x)  cerr << #x << " = " << x << endl
#define pb push_back
#define pob pop_back
#define F first
#define S second
#define OK order_of_key
#define FO find_by_order
#define nmax 1000100
const ld PI = 3.141592653589793238462643383279;
const ll inf = std::numeric_limits<ll>::max();
const int infint = std::numeric_limits<int>::max();
const ll mod = 1e9+7;
using namespace __gnu_pbds;
using namespace std;
/*#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")*/
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
int main(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n,a,b;
    cin >> n>> a >> b;
    if((b-a)%2 == 0) return cout << (b-a)/2,0;
 	a--,b--;
    ll ans = min(b,n-a);
  	ans = min(ans,a+1+(b-a)/2);
    ll sa = a;
    a = n-1-b;
    b = n-1-sa;
    ans = min(ans,a+1+(b-a)/2);
    cout << ans;
 
    return 0;
}
 

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

using namespace std;

void doc() {
    freopen("OB.inp", "r", stdin);
    freopen("OB.out", "w", stdout);
}

void solve(){
    int n, k;
    cin >> n >> k;
    int f[n], a[n];
    for(int i = 0; i < n; i++)
        cin >> a[i];
    for(int i = 0; i < n; i++)
        f[i] = 2* 1e9;
    f[0] = 0;
    for(int i = 1; i < n; i++)
        for(int j = 1; j <= k; j++) {
            if (i >= j)
                f[i] = min(f[i], f[i - j] + abs(a[i] - a[i - j]));
        //cout << f[i] << " " << i << " " << j << '\n';
        }
    cout << f[n - 1];
}

int main()
{
//    ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
    ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
   // doc();
    solve();
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
     
#define int long long
#define hell 1000000007  
#define endl "\n"
#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define MAX_SIZE 10000000000
 
int32_t main()
{   
    io
    
    int n;
    cin>>n;

    for(int i=1;i<=9;i++)
    {
        for(int j=1;j<=9;j++)
        {
            if(i*j==n)
            {
                cout<<"Yes";
                return 0;
            }

        }
    }

    cout<<"No";
    

return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
class Main{
  public static void main(String[] args){
    Scanner scan=new Scanner(System.in);
    String in=scan.next();
    String input[]=in.split("");
    boolean flag=true;
    if(input[2].equals(input[3]) && input[4].equals(input[5])){
      flag=false;
    }
    if(flag){
      System.out.println("No");
    }else{
      System.out.println("Yes");
    }
  }
}

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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pf printf
#define sc scanf
#define sf(n) scanf("%d",&n)
#define sff(n1,n2) scanf("%d %d",&n1,&n2)
#define sfff(n1,n2,n3) scanf("%d %d %d",&n1,&n2,&n3)
#define sl(n) scanf("%lld",&n)
#define sll(n1,n2) scanf("%lld %lld",&n1,&n2)
#define slll(n1,n2,n3) scanf("%lld %lld %lld",&n1,&n2,&n3)
#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,n) for(i=1;i<=n;i++)
#define reps(i,a,n) for(i=a;i<=n;i++)
#define nl puts("");
#define pb push_back
#define MOD 1000000007
#define fi first
#define se second
#define N 100005
#define mem(ara,n) memset(ara,n,sizeof(ara))
#define memb(ara) memset(ara,false,sizeof(ara))
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define sz(x) x.size()
#define pi pair<int,int>
#define pii pair<pair<int,int>,pair<int,int> >
#define line puts("-------");
#define db(x) cout<<#x<<" :: "<<x<<"\n";
#define dbb(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define fr freopen("input.txt","r",stdin);
#define fw freopen("output.txt","w",stdout);
typedef long long int ll;
using namespace std;
int main()
{
    int i;
    string a;
    cin>>a;
    rep0(i,sz(a))
        cout<<"x";
}


Measured memory_bytes: 256
from collections import deque

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

G = {k: [] for k in range(N+1)}
for _ in range(M):
    a, b = map(int, input().split())
    # 無向グラフ
    G[a-1].append(b-1)
    G[b-1].append(a-1)

visited = [-1] * N
visited[0] = 0
que = deque([(0, -1)])

while que:
    ci, p = que.popleft()

    for ni in G[ci]:
        if visited[ni] == -1:
            que.append((ni, ci))
            visited[ni] = ci+1

if -1 in visited:
    print('No')
else:
    print('Yes')
    print(*visited[1:], sep='\n')


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

#define ff              first
#define ss              second
#define ll            long long

#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
//mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void sb()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
vector<int> dp(100001,-1);
vector<vector<int>> graph(100001,vector<int> (0));
int dfs(int source){

    if(dp[source]!=-1)
    return dp[source];
if(graph[source].size()==0)
return dp[source]=0;
int maxr =0;
    
    for(auto child:graph[source]){
        
       
           maxr = max(maxr,1+dfs(child));
      
      
    }

dp[source] = maxr;
return dp[source];
}
int main()
{
	//sb();
    int n,m;
    cin>>n>>m;
    
    for(int i=0;i<m;i++){
        int u,v;
        cin>>u>>v;
        graph[u].pb(v);
    }
    int ans =0;
   for(int i=1;i<n+1;i++){
   
   ans = max(ans,dfs(i));
   
   }
    cout<<ans;




return 0;
}



Measured memory_bytes: 8192
N = int(input())
S = {"AC" : 0,"WA" : 0,"TLE" : 0,"RE" : 0}
     
for i in range(N):
  x = input()
  S[x] += 1
  
for i in S.keys():
  ans = " ".join([i,"x",str(S[i])])
  print(ans)

Measured memory_bytes: 9196
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define Int int32_t
#define all(c) c.begin(), c.end()
#define FAST ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define pii pair<int,int>
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define bitcnt(n) __builtin_popcountll(n)
#define setpre(n) cout << fixed << setprecision(n)
#define tr(c) for(const auto& x : c )cout << x << " "; cout << "\n";
#define ol(c, s, e) for(int pos=s; pos<e; pos++)cout << c[pos] << " ";cout <<"\n";
#define PI acos(-1LL)

const int M = 1000000007;
const int N = 2e5 + 5;
const long long INF = 1e9 + 12;

vector<vector<int>> v;
vector<int> dp;
//dp[i] store maximum distance we can go from i'th vertex
int dfs(int i){
    int ans = 0;
    if(dp[i]!=-1)
        return dp[i];
    for(auto x: v[i]){
        ans = max(ans, 1+dfs(x));
    }
    return dp[i] = ans;
}
void solve(){
    int n, m;
    cin >> n >> m;
    v.resize(n+1);
    dp.resize(n+1,-1);
    for(int i=0; i<m; i++){
        int a,b;
        cin >> a >> b;
        v[a].pb(b);
    }
    int ans = 0;
    for(int i=1; i<=n; i++){
        ans = max(ans, dfs(i));
    }
    cout << ans;
}

signed main(){
    FAST
    int tc = 1;
//    TODO: check for tc
//    cin >> tc;
    for (int t = 1; t <= tc; t++) {
        solve();
    }
}


Measured memory_bytes: 11464
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define lli long long int
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF 9223372036854775807+1
#define sosuu 1000000007

int main(){
  lli N, R1,R;
  cin >> N >> R1;
  R=R1;
  lli keep;
  
  lli ans=1;
  while(R1<=N){
  R1*=R;
    ans++;
  }
  cout << ans << endl;
}


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

#define rep(i,n) for(ll i = 0; i < n; i++)
#define per(i,n) for(ll i = n-1; i >= 0; i--)
#define REP(i,n) for(ll i = 1; i < n; i++)
#define PER(i,n) for(ll i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPP = vector<vP>;
using vPl = vector<Pl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



int main(){
  int n;
  cin >> n;
  vi a(n);
  rep(i,n) cin >> a[i];
  sort(all(a));
  vi b;
  rep(i,n) {
    if(i != 0) if(a[i] == a[i-1]) continue;
    if(i != n-1) if(a[i] == a[i+1]) continue;
    b.push_back(a[i]);
  }
  int m = sz(b);
  vii factor(m);
  rep(i,m) {
    for(int j = 1; j*j <= b[i]; j++) {
      if(b[i] % j == 0) {
        if(j != b[i]) factor[i].push_back(j);
        if(b[i]/j != b[i]) factor[i].push_back(b[i]/j);
      }
    }
  }
  int ans = 0;
  rep(i,m) {
    bool ok = true;
    for(int v : factor[i]) {
      if(binary_search(all(a), v)) ok = false;
    }
    ans += ok;
  }
  cout << ans << endl;
}

Measured memory_bytes: 26864
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define sol (k+k)
#define sag (k+k+1)
#define orta ((bas+son)/2)
#define coc g[node][i]
#define mod 1000000007
#define inf 1000000000000009
#define N 1000005

using namespace std;

long long n, a[N], yer[N],kuck = inf;

int main(){
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	cin >> n;

	for(long long i = 1; i*i <= n; i++){
		long long j = n / i;
		if(i * j != n)
			continue;
		if ((i + j) < kuck) {
			kuck = i + j;
		}
	}
	cout << kuck - 2 << endl;
	return 0;
}


Measured memory_bytes: 256
X,K,D=map(int,input().split(' '))
if X>=0:
    time=X//D
    if time>K:
        print(X-K*D)
    elif (K-time)%2==0:
        print(X%D)
    else:
        print(abs((X%D)-D))
else:
    time=-(X//D)
    if time>K:
        print(abs(X+K*D))
    elif (K-time)%2==0:
        print(X%D)
    else:
        print(abs((X%D)-D))

Measured memory_bytes: 9132
M=pow(10,5)

prime_sieve=[-1 for i in range(M+1)]
prime_sieve[0]=1
prime_sieve[1]=1

primes=[]
for i in range(M+1):
  if prime_sieve[i]==-1:
    primes.append(i)
    for j in range(2,(M)//i+1):
      prime_sieve[i*j]=1
#print(prime_sieve)
rangesum=[0,0,0]
sum=0
for i in range(3,M+1):
  if prime_sieve[i]==-1:
    if prime_sieve[(i+1)//2]==-1:
       sum+=1
       #print(i,sum)
  rangesum.append(sum)

Q=int(input())
for i in range(Q):
  l,r=[int(x) for x in str(input()).split()]
  print(rangesum[r]-rangesum[l-1])












Measured memory_bytes: 53924
#include <stdio.h>
#include <string.h>

int main(){
    int n;
    char stT[110], stH[110];
    int result;
    int ptT=0, ptH=0;
    
    scanf("%d", &n);
    for (int i=0; i<n; i++){
        scanf("%s %s", stT, stH);
        result = strcmp(stT, stH);
        if (result > 0) ptT+=3;
        else if (result <0) ptH += 3;
        else ptT++, ptH++;
    }
    printf("%d %d\n", ptT, ptH);
    return 0;
}

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

using namespace std;

int R,C;
int cnt;
int s = 0;
bool sen[11][10001];
bool flg[11];

int fnc(){
	int ret = 0;
	int senc[R+1][C+1];

	for(int i = 1;i <= R;i++){
		for(int j = 1;j <= C;j++){
			senc[i][j] = sen[i][j];
			if(flg[i] == 1){
				if(senc[i][j] == 1){
					senc[i][j] = 0;
				}else if(senc[i][j] == 0){
					senc[i][j] = 1;
				}
			}
		}
	}

	// for(int i = 1;i <= R;i++){
	// 	for(int j = 1;j <= C;j++){
	// 		cout << senc[i][j] <<" ";
	// 	}
	// 	printf("\n");
	// }

	int sum1;
	int sum0;
	int sum;

	for(int i = 1;i <= C;i++){
		sum1 = 0;
		sum0 = 0;
		for(int j = 1;j <= R;j++){
			if(senc[j][i] == 1)sum1++;
			if(senc[j][i] == 0)sum0++;
		}
		sum = max(sum1,sum0);
		//cout << sum << endl;
		ret += sum;
	}
	//cout << ret <<" "<< ++s << endl ;
	return ret;
}

int solve(int d){
	int ret = 0;

	if(d == R)return fnc();

	ret = max(ret,solve(d+1));
	flg[d+1] = 1;
	ret = max(ret,solve(d+1));
	flg[d+1] = 0;
	//cout << ret << endl;
	return ret;
}

int main(){
	while(cin >> R >> C,R){
		fill_n(flg,11,0);
		fill_n(*sen,11*10001,0);

		for(int i = 1;i <= R;i++){
			for(int j = 1;j <= C;j++){
				cin >> sen[i][j];
			}
		}
		cout << solve(0) << endl;
	} 
	return 0;
}

Measured memory_bytes: 3580
N=int(input())
s=input()

count=0
if N%2!=0 or N==1:
    print('No')
else:
    for i in range(int(N/2)):
        if s[i] != s[i+int(N/2)]:
            count+=1
        else:
            count=count

    if count==0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
 #include <ext/pb_ds/tree_policy.hpp>
 #include <ext/pb_ds/assoc_container.hpp>
 #include<chrono>
 using namespace std;
 using namespace std::chrono;      
 using namespace __gnu_pbds; 
 #define fastio     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 #define fi         first
 #define se         second
 #define int         long long 
 #define pb         push_back
 #define emp        emplace_back
 #define vv(x)      vector<x>
 #define mp(x,y)    map<x,y>
 #define dq(x)      deque<x>
 #define pql(x)     priority_queue<x>
 #define pqs(x)     priority_queue<x,vv(x),greater<x> >
 #define M          1000000007
 #define forf(i,a,b) for(int i=a;i<b;i++)
 #define it(x)      x::iterator
 #define ll         long long 
 #define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
 #define time__(d)  for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
 #define vii        vector<int>
 #define big        3e18
 #define sm         -2e9
 #define mkr        make_pair
 #define vpi        vector<pair<int,int> >
 #define pii        pair<int,int>
 #define rng        500005
 #define sz(x)      (int)x.size()
 #define rv(x)      reverse(x.begin(),x.end())
 #define out(x)     cout<<x.fi<<" "<<x.se<<endl;

//#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update> 
  
void pr_init()
{
   
    #ifndef ONLINE_JUDGE
    freopen("gin.txt", "r", stdin);
    freopen("gout.txt", "w", stdout);
   
    #endif
}




int dp[100005][4];
void solve()
{
 
 int n;
 cin >> n; 
 
 forf(i,1,n+1)
 {
  cin >> dp[i][1] >> dp[i][2] >> dp[i][3];
  dp[i][1] += max(dp[i-1][2] , dp[i-1][3]);
  dp[i][2] += max(dp[i-1][3] , dp[i-1][1]);
  dp[i][3] += max(dp[i-1][2] , dp[i-1][1]);
 }
 
 
  cout<<max(dp[n][1],max(dp[n][2],dp[n][3]));
}


int32_t main()
{
  pr_init();
  //fastio;
  
  auto start = high_resolution_clock::now(); 
 
  solve();
  auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start); 
   // cout << "Time taken by function: "
   //       << duration.count() << " microseconds" << endl; 

 }
      
      

Measured memory_bytes: 6704
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

ll l,r;
ll bit[2][65];
ll dp[66][2][2];
ll ans;

void solve(ll l,ll r){
	if(l>r)return;
	//printf("%lld %lld\n",l,r);
	int v=0;
	ll tl=l,tr=r;
	while(l>0){
		bit[0][v]=l%2LL;
		v++;
		l/=2LL;
	}
	v=0;
	while(r>0){
		bit[1][v]=r%2LL;
		v++;
		r/=2LL;
	}
	memset(dp,0,sizeof(dp));
	if(bit[0][v-1]==0){
		dp[v-1][1][0]=1;
	}else{
		dp[v-1][0][0]=1;
	}
	for(int i=v-2;i>=0;i--){
		for(int j=0;j<2;j++){
			for(int k=0;k<2;k++){
				for(int a=0;a<2;a++){
					if(j==0 && a==0 && bit[0][i]==1)continue;
					int nj=j;
					if(a==1 && bit[0][i]==0)nj=1;
					for(int b=0;b<2;b++){
						if(k==0 && b==1 && bit[1][i]==0)continue;
						if(a==1 && b==0)continue;
						int nk=k;
						if(b==0 && bit[1][i]==1)nk=1;
						dp[i][nj][nk]+=dp[i+1][j][k];
						dp[i][nj][nk]%=MOD;
					}
				}
			}
		}
	}
	for(int i=0;i<2;i++){
		for(int j=0;j<2;j++){
			ans+=dp[0][i][j];
			ans%=MOD;
		}
	}
	l=tl;
	r=tr;
	ll ig=1;
	for(int i=0;i<v-1;i++){
		ig*=2LL;
	}
	ig--;
	solve(l,ig);
}

int main(void){
	scanf("%lld%lld",&l,&r);
	if(r==1LL){
		printf("1\n");
		return 0;
	}
	solve(l,r);
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	l := n % 10
	if l == 3 {
		fmt.Println("bon")
	} else if l == 0 || l == 1 || l == 6 || l == 8 {
		fmt.Println("pon")
	} else {
		fmt.Println("hon")
	}
}

Measured memory_bytes: 1756
import sys
S = input()

if S[0] != "A":
    print("WA")
    sys.exit()
if S[1].isupper() or S[-1].isupper():
    print("WA")
    sys.exit()
T = S[2:len(S)-1]
if list(T).count("C") == 0 or list(T).count("C") > 1:
    print("WA")
    sys.exit()
for i in range(len(T)):
    if T[i].isupper() and T[i] != "C":
        print("WA")
        sys.exit()
print("AC")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	int n;cin>>n;
	string s;cin>>s;
	int ans=1;
	for(int i=1;i<n;i++){
		if(s[i]!=s[i-1])	ans++;
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 3720
#include <algorithm>
#include <iostream>
#include <vector>
#include <string> 

typedef long long ll;
using namespace std;
const ll m = 1e9 + 7;
ll solve(ll x, ll y) {
	ll X = x * x;
	ll Y = y * y;
	return X + Y;
	
}
int main() {
	ll n, d; cin >> n >> d;
	ll cnt = 0;
	while (n--) {
		ll x, y; cin >> x >> y;
		ll res = solve(x, y);
		if (res <= d * d) 
		{
			
			cnt++;
		}

	}
	cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3584
#include <stdio.h>
     
    int main(){
        int n;
        int a = 1000;
        scanf("%d", &n);
        
        if (n <= 1000){
            printf("%d\n", 1000 - n);
        }
        
        else{
            while (1){
                a += 1000;
                if (n <= a){
                    printf("%d\n", a - n);
                    break;
                }
            }
        }
        
     
        return 0;
    }

Measured memory_bytes: 1728
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int n = a % 10;

        if((n==2) || (n==4) || (n==5) || (n==7) || (n==9)){
            System.out.println("hon");
        }else if((n==0) || (n==1) || (n==6) || (n==8)){
            System.out.println("pon");
        }else{
            System.out.println("bon");
        }

    }
}


Measured memory_bytes: 35788
S = input()
A = int(S[:2])
B = int(S[2:])

if 1 <= A <= 12 and 1 <= B <= 12:
  print("AMBIGUOUS")
elif 1 <= A <= 12:
  print("MMYY")
elif 1 <= B <= 12:
  print("YYMM")
else:
  print("NA")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i, n) for(int i = 0; i < n; i++){
const int INF = 1 << 25;
 
stack<int> cars;
int numbar;
 
int main(){
    while(scanf("%d", &numbar) != EOF){
        if(numbar == 0){
            printf("%d\n", cars.top());
            cars.pop();
            continue;
        }
        cars.push(numbar);
    }
    return 0;
}

Measured memory_bytes: 1192
import scala.io.Source.stdin

object Main {
  def main(args: Array[String]) = {
    var min: Double = 1000000 + 1
    var max: Double = -1
    val input = stdin.getLines.map(_.toDouble)

    for (y <- input) {
      if (y < min) min = y
      if (y > max) max = y
    }

    println(max - min)
  }
}

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

int main(){
    string S; cin >> S;
    int n = S.size();
    for (int i= 0; i <n ; i++){
        if (S[i] == '?'){
            S[i] = 'D';
        }
    }
    cout << S << '\n';
    return 0;
}

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

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<pii> vpii;

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    string s;
    cin >> s;

    rep(i, s.size()) {
        if (i % 2 == 0 and s[i] == 'L') {
            cout << "No" << endl;
            return 0;
        } else if (i % 2 == 1 and s[i] == 'R') {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/ruby
#encoding: utf-8

#input
n = gets.to_i
a = Array.new(n)
(0..n-1).each do |i|
  a[i] = gets.to_i
end

# compute
a2 = a.sort.reverse

(0..n-1).each do |i|
  if a[i] != a2[0] then
    puts a2[0]
  else
    puts a2[1]
  end
end

Measured memory_bytes: 8168
#!/usr/bin/env python3
# ????????????????????°???????????°????????????????????\??????????????¢?????´???????????¨??????????§???????
# ?????????http://www.prefield.com/algorithm/geometry/convex_hull.html

import enum


EPS = 1e-10


class PointsRelation(enum.Enum):
    counter_clockwise = 1
    clockwise = 2
    online_back = 3
    on_segment = 4
    online_front = 5


def inner_product(v1, v2):
    return v1.real * v2.real + v1.imag * v2.imag


def outer_product(v1, v2):
    return v1.real * v2.imag - v1.imag * v2.real


def project(a, b):
    return a * inner_product(a, b) / (abs(a) ** 2)


def points_relation(p0, p1, p2):
    v1 = p1 - p0
    v2 = p2 - p0
    op = outer_product(v1, v2)
    if op > EPS:
        return PointsRelation.counter_clockwise
    elif op < -EPS:
        return PointsRelation.clockwise
    elif inner_product(v1, v2) < -EPS:
        return PointsRelation.online_back
    elif abs(v1) < abs(v2):
        return PointsRelation.online_front
    else:
        return PointsRelation.on_segment


def in_place_convex_hull_andrew(ps):
    def judge(p0, p1, p2):
        b = points_relation(p0, p1, p2) != PointsRelation.counter_clockwise
        b &= points_relation(p0, p1, p2) != PointsRelation.online_front
        return b
    if len(ps) < 3:
        return ps
    ps.sort(key=lambda p: p.imag)
    n = len(ps)
    k = 0
    ch = [None for _ in range(2 * n)]
    for i in range(n):
        while k >= 2 and judge(ch[k - 2], ch[k - 1], ps[i]):
            k -= 1
        ch[k] = ps[i]
        k += 1
    t = k + 1
    for i in range(n - 1)[::-1]:
        while k >= t and judge(ch[k - 2], ch[k - 1], ps[i]):
            k -= 1
        ch[k] = ps[i]
        k += 1
    ch = ch[:k - 1]
    return ch


def main():
    n = int(input())
    ps = [complex(*map(int, input().split())) for _ in range(n)]
    ch = in_place_convex_hull_andrew(ps)
    print(len(ch))
    print(*("{:d} {:d}".format(int(p.real), int(p.imag))
            for p in ch), sep="\n")


if __name__ == '__main__':
    main()

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

#define ll   long long int
#define rep(i,n)    for(int i=0;i<(int)n;i++)

int main() {

    int N;
    cin >> N;

    int w = N;
    int ans = 0;

    for(int i=0; i<5; i++){
        w /= 10;
        if(w!=0){
            if((i%2)==0){
                ans+=(9*pow(10,i));
            }
        }else{
            if((i%2)==0){
                ans+=(N-pow(10,i)+1);
            }
            break;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as B
import Data.List
import Data.Maybe
import Control.Applicative

main = do
 [n,_] <- map read . words <$> getLine
 cxys <- map (map (fst . fromJust . B.readInt) . B.words) . B.lines <$> B.getContents
 let seg = fromList n (replicate n 0)
 mapM_ print (rsq n seg cxys)

rsq n seg = reverse . fst . foldl' process ([],seg)
 where
  process (lg,seg) [c,x,y]
   | c==0 = (lg, update n seg x y)
   | c==1 = (query n seg x y : lg, seg)


data SegTree a = Leaf a | Node a (SegTree a) (SegTree a) deriving (Eq, Show)

val :: SegTree a -> a
val (Leaf v) = v
val (Node v _ _) = v

fromList :: (Num a) => Int -> [a] -> SegTree a
fromList 1 [x] = Leaf x
fromList n xs  = Node (val left + val right) left right
 where
  n' = div n 2
  (xs1,xs2) = splitAt n' xs
  left = fromList n' xs1
  right = fromList (n-n') xs2

update :: (Num a) => Int -> SegTree a -> Int -> a -> SegTree a
update 1 (Leaf v) 1 x = Leaf (v+x)
update n (Node v l r) i x
 | i <= n' = Node (val left + val r) left r
 | otherwise = Node (val l + val right) l right
 where
  n' = div n 2
  left = update n' l i x
  right = update (n-n') r (i-n') x

query :: (Num a) => Int -> SegTree a -> Int -> Int -> a
query 1 (Leaf v) 1 1 = v
query n (Node v l r) i j
 | (i,j) == (1,n) = v
 | j <= n' = query n' l i j
 | i > n' = query (n-n') r (i-n') (j-n')
 | otherwise = query n' l i n' + query (n-n') r 1 (j-n')
 where n' = div n 2

Measured memory_bytes: 73128
dp[1<<27];i;a;c;b;j;
main()
{
	memset(dp+1,9,1<<28);
	for(;c=getchar()-10;)
	{
		a=dp[b^=1<<c-87]+1;
		for(j=1;j<1<<26;j<<=1)a=fmin(a,dp[b^j]+1);
		dp[b]=fmin(dp[b],a);
	}
	//aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
	//aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
	//aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
	//aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
	//aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
	//aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
	//aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
	//aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
	printf("%d",a);
}

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

int main(){
  string s;
  cin >> s;
  ll n,i,b,r;
  n=s.size();
  r=0;
  b=0;
  for(i=0;i<n;i++){
    if(s.at(i)=='B'){
      r += i;
      b++;
    }
  }
  cout << (n*2-b-1)*b/2-r << endl;
}

Measured memory_bytes: 3732