akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int a,b; cin >> a >> b;
    int ans = a+b;
    if (ans >= 24)
    {
        ans -= 24;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import deque

k = int(input())
lst = deque([1,2,3,4,5,6,7,8,9])

for i in range(k-1):
    num = lst.popleft()
    judge = num % 10
    if judge != 0:
        lst.append(num*10+judge-1)
    lst.append(num*10+judge)
    if judge != 9:
        lst.append(num*10+judge+1)

print(lst.popleft())

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

int main (void){

  int x,y,W,H,r,a,b;
  scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);
  if(x-r>=0 && x+r<=W && y-r>=0 && y+r <=H){
    printf("Yes\n");
  }
  else{
    printf("No\n");
    }
   
  return(0);
}



Measured memory_bytes: 2116
#include<bits/stdc++.h>
using namespace std;
using ull=unsigned long long;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define setbits(x)  __builtin_popcount(x)
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;

//int divr[maxn];
/**/
/*void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
/*ll modexpo(ll a,ll b)
{
     ll ans=1LL;
     while(b>0)
     {
          if(b&1)ans=(ans*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return ans;
}
*/
int main(){
     int n,k;
     cin>>n>>k;
     int a[n];rep(i,n)cin>>a[i];
     vector<ll> vec;
     for(int i=0;i<n;i++){
          ll sm=0;
          for(int j=i;j<n;j++){
               sm+=a[j];
               vec.pb(sm);
          }
     }
     ll cur=0;
     for(int i=40;i>=0;i--){
          int ct=0;
          ll ncur=cur+(1LL<<i);
          for(int j=0;j<vec.size();j++){
               if((ncur&vec[j])==ncur)ct++;
          }
          if(ct>=k)cur=ncur;
     }
     cout<<cur;
}
 
 
 
 
 

























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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int getRand(int l, int r)
{
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}
  
#define int long long 
#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define precise(x) fixed << setprecision(x) 

const int MOD = 1e9+7;

int mod_pow(int a,int b,int M = MOD)
{
    int res = 1;
    
    while(b)
    {
        if(b&1) res=(res*a)%M;
        a=(a*a)%M;
        b>>=1;
    }
    
    return res;
}


void solve()
{
   int l,r,d;
    cin >> l >> r >> d;
    
    cout << ((r/d) - (l-1)/d);
    
    
}

signed main()
{
    fast;
    
    int t = 1;
    
//    cin >> t;
    
    while(t--)
        
    solve();
}

Measured memory_bytes: 3652
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<map>
#include<string>
#define all(x) (x).begin(),(x).end()
typedef long long ll;
 
using namespace std;

int main(){
    string s;   cin >> s;
    int K;  cin >> K;
    int i, j, k, l, nmax, tmp;
    l = s.length();
    vector<int> v(l);
    nmax = min(K, l*25);
    for(int i=0; i<l; i++){
        char c = s[i];
        int x = (26 - (c - 'a'))%26;
        v[i] = x;
    }
    i = 0;
    j = 0;
    tmp = K;
    while(i < K){
        if(v[j] <= tmp){
            s[j] = 'a';
            i += v[j];
            j++;
        }else{
            for(int k=j+1; k<l; k++){
                if(v[k] <= tmp){
                    s[k] = 'a';
                    tmp -= v[k];
                }
            }
            char c = s[l-1];
            c = c + tmp;
            s[l-1] = c;
            break;
        }
        tmp = K-i;
        if(j==l){
            char c = s[l-1];
            tmp %= 26;
            c += tmp;
            s[l-1] = c;
            break;
        }
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3832
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
//    return *(long long*)a - *(long long*)b;
}
//  qsort(A, b, sizeof(int), compare_int);

int main()
{
 
  int a, b, c, d, e, X, Y;
  //  double  c;
  int  A[3]={};
//  int  B[100003]={};
  int  L[1003]={};

  int  flag[103]={};

//  long long  a, b, c, d, X, Y;
char s[101][101]={};
  long long JPY;
  double BTC;
char t[101][101]={};
//  int N, M;
//  int A[1000000001]={};
//  long long  C[101]={};
  int i,j,k;
//  int flag=0;
  double tmp=0;
//  int min=1000000;
  long long min=100000001;
  int len=0;
  int cnt=0;
  int num=0;
//  double ans=0.0;
  int ans=0.0;
  int max=0;
  int sum=0;
//  char alp[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

  //  a=0;
//  scanf("%lld %lld", &a, &b);
  scanf("%d%d%d", &a, &b, &c);

  
  if((b/a)>c) printf("%d\n",c);
  else printf("%d\n",b/a);
//    if(max < cnt - max)  printf("Yes\n");
//    else  printf("No\n");
  
return 0;
}


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

int main()
{
  string s;
  cin >> s;
  int n = s.size();

  int cnt0 = 0;
  int cnt1 = 0;
  for (int i = 0; i < n; i++)
  {
    if (s.at(i) == '0')
      cnt0++;
    if (s.at(i) == '1')
      cnt1++;
  }

  cout << 2*min(cnt0, cnt1) << endl;

  return 0;
}


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

using namespace std;

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

  int n;
  cin >> n;
  vector<int> S(n);
  int sum = 0;
  for (auto &s: S) {
    cin >> s;
    sum += s;
  }
  sort(S.begin(), S.end());
  int res = 0;
  if (sum % 10 > 0) res = sum; 
  else {
    for (int i = 0; i < n; ++i) {
      if ((sum-S[i])%10 > 0) {
        res = sum-S[i];
        break;
      }
    }
  }
  cout << res << endl;

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define INF = numeric_limits<long long>::max();
#define intf int_fast64_t
int main(){
    string s;
    cin >>s;
    if(s[1]=='R'){
        cout << "ABC" <<endl;
    }else if(s[1]=='B'){
        cout << "ARC" <<endl;
    }
}

Measured memory_bytes: 3624
use std::io;

fn main() {
    let mut a = read::<isize>();
    a.sort();
    println!("{}", (a[1] - a[2]).abs() + (a[0] - a[1]).abs());
}

#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define LL long long
#define mp make_pair
#define pb push_back
#define INF (1<<29)
using namespace std;
typedef pair<int,int>pii;
int n,m;
vector<pii>G[200010];
int col[200010];
int vis[200010];
bool dfs(int x,int co){
//	cout<<"In:"<<x<<' '<<co<<endl;
	if(vis[x]!=-1)return col[x]==co;
	vis[x]=1;
	col[x]=co;
	for(pii i:G[x]){
		if(dfs(i.first,co+i.second)==0)return false;
//		else{
//			if(vis[i.first]!=co+i.second)return false;
//		}
	}
	return true;
}
int main(){
//	freopen("produce/People.txt","r",stdin);
	cin>>n>>m;
	memset(vis,-1,sizeof(vis));
	if(m==0){
		cout<<"Yes\n";
		return 0;
	}
	for(int i=1;i<=m;i++){
		int l,r,d;
		cin>>l>>r>>d;
		G[l].pb(mp(r,d));
		G[r].pb(mp(l,-d));
	}
	for(int i=1;i<=n;i++){
		if(vis[i]!=-1)continue;
		memset(col,0,sizeof(col));
		if(dfs(i,0)==0){
			cout<<"No\n";
			return 0;
		}
//		cout<<"-----------------------\n";
	}
	cout<<"Yes\n";
	return 0;
}


Measured memory_bytes: 14592
n = gets.to_i
str = []
n.times { str.push(gets.chars.sort.join) }

values = str.group_by{ |item| item }.values

values.reject { |v| v.length <= 1 }

puts values.map { |v| v.length * (v.length - 1) / 2 }.inject(&:+)

Measured memory_bytes: 38396
/* ＵＴＦ－８ */
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}

	int A, B, C;
	std::cin >> A >> B >> C;
	std::cout << std::min(B / A, C) << "\n";
}


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

#define ll long long
#define ull unsigned long long

using namespace std;

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

	if (N == 1){
		cout << "Hello World" << "\n";
	} else {
		int A, B;
		cin >> A >> B;
		cout << A + B << "\n";

	}


	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long INF=1e13;
int main(){
int N,W;
  cin>>N>>W;
  long long dp[100001];
  dp[0]=0;
  for(int i=1;i<=100000;i++){
  dp[i]=INF;
  }
  int wi[N],vi[N];
  int V=0;
  for(int i=0;i<N;i++){
  cin>>wi[i]>>vi[i];
    V+=vi[i];
  }
  for(int i=0;i<N;i++){
  for(int j=V;j>=vi[i];j--){
  dp[j]=min(dp[j],dp[j-vi[i]]+(long long)wi[i]);
  }
  }
  for(int i=V;i>=0;i--){
  if(dp[i]<=W)
  {cout<<i;
  break;
  }
  }
return 0;
}

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

int main(){
    int a,b;
    cin >> a >> b;
    if(b>=a) cout << a << endl;
    else cout << a-1 << endl;
    return 0;
}


Measured memory_bytes: 256
n, k = [int(_) for _ in input().split(' ')]
a = [int(_) for _ in input().split(' ')]

for _ in range(k):
    diff = [0 for _ in range(n + 1)]
    for i in range(n):
        diff[max(i - a[i], 0)] += 1
        diff[min(i + 1 + a[i], n)] -= 1

    for i in range(n):
        if i == 0:
            a[i] = diff[0]
        else:
            a[i] = a[i - 1] + diff[i]
    
    if all([d == n for d in a]):
        break

print(' '.join([str(d) for d in a]))

Measured memory_bytes: 182200
#include <bits/stdc++.h>
    using namespace std;
    
    typedef double dd;
    typedef long long ll;

    #define ff first
    #define ss second
    #define mp make_pair
    #define eb emplace_back
    #define trav(i,a) for(auto i: a)
    #define all(v) (v.begin(),v.end())
    #define rall(v) (v.rbegin(),v.rend())
    #define tc(t) ll t; cin>>t; while(t--)
    #define prec(n) fixed<<setprecission(n)
    #define mst(arr,value) memset(arr,value,sizeof(arr)) /* -1 or 0 */
    
    const long long sz = (long long)1e4+5;
    const long long mx = (long long)2e5+5;
    const long long inf = (long long)1e18;
    const long long mod = (long long)1e9+7;
    
    #define f(i,n)     for(ll i=0;   i<n;  i++)
    #define fab(i,a,b) for(ll i=a;   i<b;  i++)
    #define fr(i,n)    for(ll i=n-1; i>=0; i--)
    #define fba(i,b,a) for(ll i=b-1; i>=a; i--)

    long long pw(long long x,unsigned long long y) 
    { 
        if (y==0) return 1; 
        else if (y%2==0)  return pw(x,y/2)*pw(x,y/2); 
        else return x*pw(x,y/2)*pw(x,y/2);
    }

    int main() 
    {
        ios_base::sync_with_stdio(0);
        cin.tie(NULL);
        cout.tie(NULL);
        ll h,n,k,ans=0;
        cin>>h;
        k=0;
        while(h)
        {
            if(h>1)
                ans+=pw(2,k);
            else ans+=pw(2,k);
            k++;
            h/=2;
        }
        cout<<ans;
        return 0;
    }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int 
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define vi vector<int>
#define pi pair<int,int>
#define all(v) v.begin(),v.end()
#define zeros(arr) memset(arr,0,sizeof(arr))
#define precise(num)  cout<<fixed; cout << std::setprecision(num)
#define nl cout<<"\n";
#define test int t;cin>>t;while(t--) 
int32_t main(){
        int a,b,c;
        cin>>a>>b>>c;
        cout<<c<<" "<<a<<" "<<b<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{

    int n[3], i, max = 0;
    int x[3] = {1, 0, -1};
    long k;

    for (i = 0; i < 4; i++)
    {
        if (i == 3)
        {
            scanf("%ld", &k);
        }
        else
            scanf("%d", &n[i]);
        max += n[i];
    }

    if (n[0] >= k)
        printf("%d", k);

    else if (n[0] + n[1] >= k)
    {
        printf("%d", n[0]);
    }
    else
    {
        printf("%d", n[0] - (k - n[0] - n[1]));
    }
    return 0;
}

Measured memory_bytes: 1732
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

std::string S;
int32_t N;
int32_t count = 0;
bool existed[11][11][11] = {};
bool used[40000][11][11];
void func(int i, int a, int b) {
	if (i == N) {
		return;
	}
	if (used[i][a][b]) {
		return;
	}
	used[i][a][b] = true;

	if (a == 10) {
		func(i + 1, a, b);
		func(i + 1, S[i]-'0', b);
	}
	else if (b == 10) {
		func(i + 1, a, b);
		func(i + 1, a, S[i] - '0');
	}
	else {
		func(i + 1, a, b);
		auto& memo = existed[a][b][S[i] - '0'];
		if (memo == false) {
			memo = true;
			++count;
		}
	}
}

template<typename T, typename U>
std::enable_if_t<std::rank<T>::value == 0> fill_all(T& arr, const U& v) {
	arr = v;
}
template<typename ARR, typename U>
std::enable_if_t<std::rank<ARR>::value != 0> fill_all(ARR& arr, const U& v) {
	for (auto& i : arr) {
		fill_all(i, v);
	}
}

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N >> S;
	func(0, 10, 10);
	out << count << endl;

	return 0;
}
#endif


Measured memory_bytes: 6784
let m1, d1 = Scanf.sscanf (read_line ()) "%d %d" (fun a b -> a, b) in
let m2, d2 = Scanf.sscanf (read_line ()) "%d %d" (fun a b -> a, b) in
Printf.printf "%d\n" (if m1 = m2 then 0 else 1)

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

int main(){
  int N; cin >> N;
  vector<int> v(N);
  for (int i=0;i<N;i++){
    cin >> v.at(i);
  }
  sort(v.begin(),v.end());
  cout << v.at(N/2)-v.at(N/2-1) << endl;
    
  
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <queue>
using namespace std;

int main(void){
	bool time[10001];
	queue<int> q;
	int n,m,t;
	int x;
	cin>>n>>m>>t;
	for(int i=0;i<=t;i++){
		time[i]=true;
	}
	for(int i=0;i<n;i++){
		cin>>x;
		q.push(x);
	}
	for(int i=0;i<=t;i++){
		if(q.front()+m<i)q.pop();
			if(q.empty())break;
		if(q.front()-m<i&&i<=q.front()+m){
			time[i]=false;
		}
	}
	int c=0;
	for(int i=1;i<=t;i++){
		if(time[i])c++;
//		cout<<time[i]<<" ";
	}
//	cout<<endl;
	cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 3132
#include <iostream>
#include <string>
#include <unordered_map>

using namespace std;
typedef long long LL;

unordered_map<LL, int> mapLevel_Count;

int main()
{
	int N, M;
	
	cin >> N;
	LL inputD;
	for (int i = 0; i < N; i++)
	{
		cin >> inputD;
		mapLevel_Count[inputD]++;
	}

	cin >> M;
	LL inputT;
	int flag;
	for (flag = M; flag > 0; flag--)
	{
		cin >> inputT;
		if (mapLevel_Count[inputT] == 0)
			break;
		mapLevel_Count[inputT]--;
	}

	if (flag == 0)
		cout << "YES";
	else
		cout << "NO";

	return 0;
}

Measured memory_bytes: 8520
N = int(input())
dishs = list(map(int, input().split()))
points = list(map(int, input().split()))
add_points = list(map(int, input().split()))

res = 0
for i in range(0,len(dishs)-1):
    res += points[dishs[i]-1]
    if dishs[i]+1 == dishs[i+1]:
        res += add_points[dishs[i]-1]
res += points[dishs[len(dishs)-1]-1]
print(res)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;

namespace ABC084A
{
    class Program
    {
        static void Main(string[] args)
        {
            var M = ReadInt;
            int ans = 48 - M;

            Console.WriteLine(ans);

        }


    }


}

namespace Assistant
{
    static class Input
    {
        static List<string> line = new List<string>();
        static int index = 0;
        static String ReadNext()
        {
            if (line.Count <= index) line.AddRange(Console.ReadLine().Split());
            return line[index++];
        }
        public static int ReadInt => int.Parse(ReadNext());
        public static long ReadLong => long.Parse(ReadNext());
        public static int[] ReadInts => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static long[] ReadLongs => Console.ReadLine().Split().Select(long.Parse).ToArray();
    }

    static class Debug
    {
        static public void Draw2D(int[,] map, int mode = 1)
        {
#if DEBUG
            int W = map.GetLength(0);
            int H = map.GetLength(1);

            int[,] map2 = new int[W + 1, H + 1];
            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (i == 0 && j == 0) map2[i, j] = 0;
                    else if (i == 0) map2[i, j] = j - 1;
                    else if (j == 0) map2[i, j] = i - 1;
                    else map2[i, j] = map[i - 1, j - 1];
                }
            }

            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (mode == 0) Console.Write(map2[i, j] % 10);
                    if (mode == 1) Console.Write(map2[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
#endif
        }

        public static void Draw1D(int[] array, int mode = 0)
        {
#if DEBUG
            Console.WriteLine(string.Join(" ", array));
#endif
        }
    }
}


Measured memory_bytes: 13268
import java.util.Scanner;

public class Main {

    static Scanner sc = new Scanner(System.in);


    public static void main(String[] args) {
        int d = sc.nextInt();
        int n = sc.nextInt();

        if (d == 0) {
            if (n == 100) {
                n++;
            }
            System.out.println(n);
        } else {
            if (n == 100) {
                n++;
            }
            System.out.println((long) Math.pow(100, d) * n);
        }
    }
}


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

int N, M, Q;
vector<vector<int>> sum;
void func1(vector<int> L, vector<int> R)
{
    sum = vector<vector<int>>(N + 1, vector<int>(N + 1, 0));
    for(int i = 0; i < M; i++)
    {
        sum[L[i]][R[i]]++;
    }
    for(int i = 1; i <= N; i++)
    {
        for(int j = 1; j <= N; j++)
        {
            sum[i][j] += sum[i - 1][j];
            sum[i][j] += sum[i][j - 1];
            sum[i][j] -= sum[i - 1][j - 1];
        }
    }
}

int func2(int p, int q)
{
    int ans = sum[q][q] - sum[q][p - 1] - sum[p - 1][q] + sum[p - 1][p - 1];    
    return ans;
}

int main()
{
    cin >> N >> M >> Q;
    vector<int> L(M, 0);
    vector<int> R(M, 0);
    for(int i = 0; i < M; i++)
    {
        cin >> L[i] >> R[i];
    }
    vector<int> p(Q, 0);
    vector<int> q(Q, 0);
    for(int i = 0; i < Q; i++)
    {
        cin >> p[i] >> q[i];
    }
    
    func1(L, R);
    for(int i = 0; i < Q; i++)
    {
        int ans = func2(p[i], q[i]);
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 5120
N = int(input())
works = list()
safe = True
for _ in range(N):
    works.append(list(map(int, input().split())))

works.sort(key=lambda x: x[1])
cumsum = 0

for work in works:
    cumsum += work[0]
    if cumsum > work[1]:
        safe = False
        break

if safe:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 53660
N,K,Q = list(map(int,input().split()))
A = []
LIST = [K]*N
for i in range(Q):
    LIST[int(input())-1] +=1
#     A.append(int(input()))
for i in LIST:
    if(i-Q<=0):
        print('No')
    else:
        print('Yes')


Measured memory_bytes: 50648
n,m=map(int,input().split())
dp=[0]*(n+1)
for i in range(m):dp[int(input())]=-1
dp[0]=1
if dp[1]!=-1:dp[1]=1
for i in range(2,n+1):
    if dp[i]==0:dp[i]=(max(dp[i-2],0)+max(dp[i-1],0))%(10**9+7)
print(dp[-1])

Measured memory_bytes: 6900
tmp=input().split()
n=int(tmp[0])
d=int(tmp[1])
xn = [0]*n
num = 0

for i in range(n):
  xn[i] = input().split()
    
for i in range(n):
  for j in range(i+1, n):
    dist = 0
    for k in range(d):
      dist = dist + pow(int(xn[i][k])-int(xn[j][k]), 2)
#    print("test",dist)
#    print(int(pow(int(pow(dist,0.5)), 2)))
    if dist == int(pow(int(pow(dist,0.5)), 2)):
      num += 1
print(num)
                
    

Measured memory_bytes: 3188
MOD = 10 ** 9 + 7
N, K = map(int, input().split())
d = [0] * (K + 1)
for i in range(1, K + 1):
    d[i] = pow(K // i, N, MOD)
for i in reversed(range(1, K + 1)):
    for j in range(2 * i, K + 1, i):
        d[i] -= d[j]
        d[i] %= MOD
ans = 0
for i in range(1, K + 1):
    ans += d[i] * i
    ans %= MOD
print(ans)


Measured memory_bytes: 11108
s=input()

temp=0
ans=0
check=0
for i in range(len(s)):
    if s[i]=='<':
        if temp>0 and s[i-1]=='>':
            ans=ans-(temp*check)
            temp=0
        
        check=0
        temp+=1
        ans+=temp
        i+=1
    else:
        check+=1
        temp-=1
        if temp<0:
            temp=0
            ans+=check
        else:
            ans+=temp
print(ans)
    

Measured memory_bytes: 4108
from collections import Counter

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

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

def f(): 
    for i, a in enumerate(A, 1):
        if i < a:
            yield i, a
        else:
            yield a, i

c = Counter(f())
print(len([k for k, v in c.items() if v == 2]))

Measured memory_bytes: 26592
from math import factorial
N = int(input())
A = list(map(int, input().split()))
n = {}
s = 0
for i in range(N):
    if A[i] not in n:
        n[A[i]] = 1
    else:
        n[A[i]] += 1
for j in n:
    if n[j] > 1:
        s += factorial(n[j]) // 2 // factorial(n[j]-2)
for i in range(N):
    print(s-n[A[i]]+1)


Measured memory_bytes: 116912
import Control.Applicative
import Control.Monad
import Control.Monad.ST
-- import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
--import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import GHC.ST
-- import System.IO.Unsafe
 
-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
getDoubles = map readDouble . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
tjoin :: (Show a, Show b) => (a, b) -> String
tjoin (x, y) = show x ++ (' ' : show y)
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
ibsearch :: (Int -> Bool) -> (Int,Int) -> Int
ibsearch f (ok,ng) = if abs (ok-ng) <= 1 then ok else let mid = (ok + ng) `div` 2 in ibsearch f (if f mid then (mid,ng) else (ok,mid))
-- templete

bitCount n = bsub 0 n
  where
    bsub r 0 = r
    bsub r x = case divMod x 2 of (y, b) -> bsub (b+r) y

lsb x = x .&. (-x)

f x y
  | signum x /= signum y = bitCount (abs x) + bitCount (abs y)
  | otherwise = g ax ay
  where
    [ax, ay] = sort $ map abs [x, y]
    g n m
      | n==m = 0
      | n + lsb n <= m = 1 + g (n + lsb n) m
      | otherwise = bitCount m - bitCount n
 
main = getInt >>= flip replicateM getIntegers >>= mapM_ (print . apply2 f)


Measured memory_bytes: 4208
#include <cstdio>
#include <iostream>
#include <cstring>
#include <cmath>

int main()
{
	int numR=0, numB=0, ans;
	std::string S;
	std::cin >> S;
	for(int i=0; i<S.length(); i++){
		if(S[i] == '0'){
			numR++;
		}
		else if(S[i] == '1'){
			numB++;
		}
	}
	ans = S.length()-abs((numB-numR));
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define NIL NULL

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};

typedef struct node * Node;


Node root;

Node mini(Node x){
  if(x->left==NIL){
    return x;
  }
  return mini(x->left);
}

Node max(Node x){
  if(x->right==NIL){
    return x;
  }
  return max(x->right);
}


Node search(Node u, int k){
  if(u->key==k){
    return u;
  }
  else if(u->key>k){
    return search(u->right, k);
  }
  else{
    return search(u->left, k);
  }
}


Node successor(Node x){
  Node ans;
  if(x->right==NIL){
    ans=x->parent;
    while(1){
      if(ans->parent==NIL || ans->parent<ans){
	break;
      }
      ans=x->parent;
    }
  }

  else {
    ans=x->right;
    while(1){
      if(ans->left==NIL){
	break;
      }
      ans=ans->left;
    }
  }
  return ans;
}
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }
    else{
      x = x->right;
    }
  }
  z->parent = y;
  if(y == NIL){
    root = z;
  }
  else{
    if(z->key < y->key){
      y->left = z;
    }
    else{
      y->right = z;
    }
  }
}

void inorder(Node u){
  if(u == NIL){
    return;
  }
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if(u == NIL){
    return;
  }
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}




int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = search(root, x);
      if ( t != NIL ){
	printf("yes\n");
      }
      else{
	printf("no\n");
      }
    }
    else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    }
    else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}



Measured memory_bytes: 25300
//#include <bits/stdc++.h>
#include<iostream>
#include<vector>
#include<map>
#include<math.h>

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)

#define fi first
#define se second

using namespace std;

using ll = long long;
using v_int = vector<int>;
using v2_int = vector<v_int>;
using v_ll = vector<ll>;
using v2_ll = vector<v_ll>;
using v_string = vector<string>;
using v_bool = vector<bool>;
using v2_bool = vector<v_bool>;
using pii = pair<int, int>;
using mii = map<int, int>;

const double PI = 3.1415926535897932;
const int INF = (int)2e9;
const ll LINF = (ll)2e18;
const ll MOD = 1000000007;
const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p) {
    return o << "{" << p.first << "," << p.second << "}";
}
template<typename T> inline
istream& operator>>(istream &is, vector<T> &vec) {
    for(auto &v : vec) { is >> v; }
    return is;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &vec) {
    for(auto &v : vec) { os << v << ",";}
    return os;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<vector<T> > &mat) {
    for(auto &row : mat) { os << row << endl; }
    return os;
}
template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }
template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

int main(void)
{
    int w, h, x, y;
    cin >> w >> h >> x >> y;
    
    double s = ((double)w * h)/2.0;

    int ans = 0;
    if(w == 2 * x && h == 2 * y) {
        ans = 1;
    }

    printf("%.10f %d\n", s, ans);
    
    return 0;
} /*atcoder*/


Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define rrep(i,m,n) for(int i = m; i >= n; i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
typedef struct{
    ll to;
    ll cost;
} edge;
typedef pair<ll, ll> lpair;
ll dp[3010][3010] = {};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s,t;
    cin >> s >> t;
    ll ns = s.size();
    ll nt = t.size();
    rep(i,0,ns){
        if(s[i] == t[0]){
            dp[i][0] = 1;
        }else{
            dp[i][0] = 0;
        }
        if(i != 0){
            dp[i][0] = max(dp[i-1][0], dp[i][0]);
        }
    }
    rep(j,0,nt){
        if(s[0] == t[j]){
            dp[0][j] = 1;
        }else{
            dp[0][j] = 0;
        }
        if(j != 0){
            dp[0][j] = max(dp[0][j], dp[0][j-1]);
        }
    }
    rep(i,1,ns){
        rep(j,1,nt){
            if(s[i] == t[j]){
                // ll max_val = max(dp[i-1][j-1], max(dp[i-1][j], dp[i][j-1]));
                dp[i][j] = dp[i-1][j-1] + 1;
            }else{
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
                dp[i][j] = max(dp[i][j], dp[i-1][j-1]);
            }
        }
    }
    // print(dp[ns-1][nt-1]);
    // rep(i,0,ns){
    //     rep(j,0,nt){
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    // ll idx = dp[ns-1][nt-1];
    // ll px = ns-1, py = nt-1;
    // while(idx > 0){
    //     while()

    // }
    // cout << endl;
    string ans = "";
    ll px = ns-1, py = nt-1;
    while(px >= 0 && py >= 0){
        if(s[px] == t[py]){
            ans += s[px];
            px--;
            py--;
        }else{
            if(px == 0){
                py--;
            }else if(py == 0){
                px--;
            }else if(dp[px-1][py] > dp[px][py-1]){
                px--;
            }else{
                py--;
            }
        }
    }
    reverse(ans.begin(), ans.end());
    print(ans);


}


Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
int main() {
  int s;
  cin >> s;
  // cout << fixed << setprecision(0);
  cout << s / 3600 << ":" << (s % 3600) / 60 << ":" << (s % 60) << endl;
  return 0;
}



Measured memory_bytes: 3120
base' = concat $ replicate 151 "#."
base  = [base'] ++ [tail base'] ++ base

chessBoard [h,w] = unlines $ take h $ map (take w) base

main = do
  s <- getLine
  let [h,w] = map read $ words s

  if [h,w] == [0,0] then return ()
  else do
    putStrLn $ chessBoard [h,w]
    main

Measured memory_bytes: 3944
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
int num[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
bool uru(int checkyear){if(checkyear%4==0){if(checkyear%100!=0||checkyear%400==0)return true;}return false;}
int gcd( int x, int y ){return y ? gcd(y, x%y) : x;}
bool pairCompare(const pairint& firstElof, const pairint& secondElof)
{
  if(firstElof.second!= secondElof.second)    return firstElof.second> secondElof.second;
  else return firstElof.first< secondElof.first;
}
signed main()
{
int x=0,y=0,z=0,w=0,n=0,m=0;
std::cin >> x;
std::cout << x*800-x/15*200 << '\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LEN 100005
#define MAX 100000

typedef struct pp{
  char name[100];
  int t;
}P;

void enqueue(P);
P dequeue(void);
int isEmpty(void);
int isFull(void);

P Q[LEN+1];
int head=0, tail=0, n;

int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
    enqueue(Q[i]);
  }
  while(head!=tail||elaps==0){
    u=dequeue();
    if(u.t>q){
      elaps+=q;
      u.t-=q;
      enqueue(u);
    }else{
      elaps+=u.t;
      cout<<u.name<<" "<<elaps<<endl;
    }
    //cout<<u.name<<" "<<u.t<<" "<<elaps<<endl;
  }
  return 0;
}

int isEmpty(){
  return head==tail;
}

int isFull(){
  return head==(tail+1)%MAX;
}

void enqueue(P x){
  if(isFull()){
    cout<<"Full!"<<endl;
    exit(2);
  }
  Q[tail]=x;
  if(tail+1==MAX)tail=0;
  else tail++;
}

P dequeue(){
  P x;
  if(isEmpty()){
    cout<<"Empty!"<<endl;
    exit(2);
  }
  x=Q[head];
  if(head+1==MAX)head=0;
  else head++;
  return x;
}



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

typedef long long int ll;
typedef unsigned long long int ull;

using namespace std;

int main() {

	int n, k; cin >> n >> k;
	int a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a+n);
	int sum = 0;
	cout << accumulate(a, a+k, sum);

	return 0;
}

Measured memory_bytes: 3628
import java.util.*;
import java.io.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        //BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        //StringTokenizer st = new StringTokenizer(br.readLine());
        //PrintWriter pw = new PrintWriter("Main.out");

        int n = sc.nextInt();
        sc.nextLine();
        String s = sc.nextLine();

        int diff = 1;
        char prev = s.charAt(0);
        for(int i = 0; i<n; i++){
            if(s.charAt(i) != prev){
                diff++;
            }
            prev = s.charAt(i);
        }
        System.out.println(diff);

    }
}

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

char ch[2][2]={{'R','B'},{'G','Y'}}; int n,m,k;
char calc(int x,int y){
	int a=x+y,b=x-y;
	a+=2000; b+=2000;
	a/=k; b/=k; a&=1; b&=1;
	return ch[a][b];
}
int main(){
	scanf("%d%d%d",&m,&n,&k);
	int i,j;
	for (i=1; i<=m; i++){
		for (j=1; j<=n; j++) printf("%c",calc(i,j)); puts("");
	}
	return 0;
}


Measured memory_bytes: 512
import sys
import heapq
range = xrange
input = raw_input

n,m = [int(x) for x in input().split()]

A = [(int(x),1) for x in input().split()]

# Keep track of number of elements in A and the sum of all the elements
Acount = n
Asum = sum(a[0]*a[1] for a in A)

heapq.heapify(A)
for _ in range(m):
    new_count,new_val = [int(x) for x in input().split()]
    new_pair = (new_val,new_count)
    
    # Try to add this new pair to A
    heapq.heappush(A, new_pair)
    Acount += new_count
    Asum += new_count * new_val

    # While there are too many elements in A
    while Acount>n:
        # Remove the ones with the smallest values
        old_pair = heapq.heappop(A)
        
        old_count = old_pair[1]
        old_val = old_pair[0]
        Acount -= old_count
        Asum -= old_count * old_val

        # If there are too few elements left in A, then add back
        # some of the elements in the old pair
        if Acount<n:
            count = min(n - Acount, old_count)
            
            heapq.heappush(A, (old_val, count))
            Acount += count
            Asum += count * old_val

    # print Asum
print Asum

Measured memory_bytes: 48224
#include <iostream>
#include <cmath>

using namespace std;

int main() {
  int x1, y1, x2, y2, x3, y3, x4, y4;
  cin >> x1 >> y1 >> x2 >> y2;
  int dx, dy;
  dx = x2 - x1;
  dy = y2 - y1;

  // cout << "dx:" << dx << ", dy:" << dy << endl;

  x3 = x2 - dy;
  y3 = y2 + dx;

  x4 = x3 - dx;
  y4 = y3 - dy;

  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}


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

for i in range(2001):
    a = i
    b = (y-10000*a-1000*n+1000*a) / 4000
    c = n-a-b
    if b == int(b) and c == int(c) and b >= 0 and c >= 0:
        print(a, int(b), int(c))
        exit()
print(-1, -1, -1)


Measured memory_bytes: 3060
import java.util.*;


public class Main {
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
			int [][] data = new int[n][3];
			for(int i = 0; i < n;i++){
				data[i][0] = sc.nextInt();
				data[i][1] = sc.nextInt();
				data[i][2] = sc.nextInt();
			}
			
			int x = 0, y = 0, time = 0;
			boolean flg = true;
			for(int i = 0; i < n; i++){
				int dis = Math.abs(x - data[i][1]) + Math.abs(y - data[i][2]);
				int distime = data[i][0] - time;
				if(distime < dis){
					flg = false;
					break;
				}
				int diff = distime - dis;
				if(diff % 2 != 0){
					flg = false;
					break;
				}
			}
			System.out.println(flg ? "Yes" : "No");
			
		}
	}



	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

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

}


Measured memory_bytes: 94204
import math


def check(p1, p2, D):
    sq = 0
    for i in range(D):
        sq += (p1[i] - p2[i]) ** 2
    rt = int(math.sqrt(sq))
    return rt**2 == sq


def main():
    N, D = map(int, input().split())
    P = [tuple(map(int, input().split())) for _ in range(N)]
    ans = 0
    for i in range(N):
        for j in range(i+1, N):
            if check(P[i], P[j], D):
                ans += 1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 38384
//https://atcoder.jp/contests/abc116/tasks/abc116_a
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/














int A, B, C;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> A >> B >> C;
	cout << A * B / 2 << endl;
}


Measured memory_bytes: 256
using System.Linq;
using System;

public class P
{
    public int x { get; set; }
    public int y { get; set; }
    public bool del { get; set; }
}

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var red = setArray(n);
        var blue = setArray(n);
        var count = 0;
        foreach (var x in blue.OrderBy(y => y.y))
        {
            var t = red.Where(z => z.x < x.x && z.y < x.y && !z.del).OrderByDescending(z => z.x);
            if (t.Count() > 0) { t.First().del = true; count++; }
        }
        Console.WriteLine(count);
    }
    public static P[] setArray(int n)
    {
        var w = new P[n];
        for (int i = 0; i < n; i++)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var c = int.Parse(line[0]);
            var d = int.Parse(line[1]);
            w[i] = new P { x = c, y = d };
        }
        return w;
    }
}

Measured memory_bytes: 13524
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    double a[n+1];
    for(int i=1;i<=n;i++)
    cin>>a[i];
    vector<vector<double>> dp(n+1,vector<double> (n+1,0.0));
    dp[1][0]=a[1];
    for(int i=2;i<=n;i++)
    dp[i][0]=dp[i-1][0]*a[i];
    dp[1][1]=1-a[1];
    for(int i=2;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(j==i)
            dp[i][j]=dp[i-1][j-1]*(1-a[i]);
            else if(j<i)
            dp[i][j]=dp[i-1][j]*a[i]+dp[i-1][j-1]*(1-a[i]);
        }
    }
    double ans=0.0;
    for(int i=0;i<=n/2;i++)
    ans+=dp[n][i];
    cout<<fixed<<showpoint<<setprecision(9)<<ans;
    return 0;
}

Measured memory_bytes: 73656
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll N;
ll dp[400+5][400+5];
ll arr[400+5];
ll pre[400+5];
ll min(ll a, ll b){if(a<b) return a;return b;}

void preC(){
	pre[0] = arr[0];
	for(ll i = 1;i<N;i++)
		pre[i] = arr[i]+pre[i-1];
}

ll sum(ll i, ll j){
	if (i == 0)return pre[j-1];
	return pre[j-1]-pre[i-1];
	
	/*ll s = 0;
	for(ll k = i;k<j;k++)s+=arr[k];
	return s;*/
}

ll solve(ll i, ll j){
	if (i>j) return 0;
	
	if(dp[i][j] != -1) return dp[i][j];
	
	if (i+1 == j) return dp[i][j] = 0;
	ll ans = 1e18;
	for(ll k = i+1;k<j;k++){
		ans = min(ans, sum(i,j) + solve(i,k) + solve(k,j));
	}
	dp[i][j] = ans;
	return dp[i][j];
}
int main(){
	cin>>N;
	for(ll i = 0;i<N;i++)cin>>arr[i];
	memset(dp, -1, sizeof dp);
	preC();
	cout<<solve(0, N)<<endl;
}

Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <stdio.h>

using namespace std;
int main(int argc, char *argv[])
{
  int sum = 0;
  int N,K,X,Y;
  for (int i = 0; i < 4; i++) {
    switch (i) {
    case 0: {
      cin >> N;
      break;
    }
    case 1: {
      cin >> K;
      break;
    }
    case 2: {
      cin >> X;
      break;
    }
    case 3: {
      cin >> Y;
      break;
    }
    default:
      break;
    }
  }


  for (int i = 1; i <= N; i++) {
    if (i<=K) {
      sum = sum+X;
    }else {
      sum = sum+Y;
    }
  }
  cout << sum;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
using namespace std;
 
int main (){
        int N,M;
        cin >> N >>M;
        string ans = "Yay!";
    if(N>8||M>8){
        ans = ":(";
    }
 
        cout << ans << endl;
 
        return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextInt();
		long m = sc.nextInt();
		long k = sc.nextInt();
		sc.close();

		int mod = 1000000007;
		long a = nCr(n * m - 2, k - 2, mod);

		long n2 = n * n % mod;
		long m2 = m * m % mod;

		long b1 = 0;
		for (int i = 1; i < m; i++) {
			b1 += i * (m - i) % mod;
			b1 %= mod;
		}
		long b2 = 0;
		for (int i = 1; i < n; i++) {
			b2 += i * (n - i) % mod;
			b2 %= mod;
		}

		long ans = 0;
		ans += a * n2 % mod * b1 % mod;
		ans += a * m2 % mod * b2 % mod;
		ans %= mod;
		System.out.println(ans);
	}

	static long nCr(long n, long r, int m) {
		long val = 1;
		for (int i = 1; i <= r; i++) {
			val = val * (n - i + 1) % m;
			val = val * modinv(i, m) % m;
		}
		return val;
	}

	static long modinv(long a, int m) {
		long b = m;
		long u = 1;
		long v = 0;
		long tmp = 0;

		while (b > 0) {
			long t = a / b;
			a -= t * b;
			tmp = a;
			a = b;
			b = tmp;

			u -= t * v;
			tmp = u;
			u = v;
			v = tmp;
		}

		u %= m;
		if (u < 0) u += m;
		return u;
	}
}


Measured memory_bytes: 25172