akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.AGC_043
{
    class A
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int[] hw = ReadInts();
            int h = hw[0];
            int w = hw[1];
            bool[,] grid = new bool[h, w];
            for(int i = 0; i < h; i++)
            {
                string s = Read();
                for(int j = 0; j < w; j++)
                {
                    grid[i, j] = s[j] == '.';
                }
            }

            int[,] costs = new int[h, w];
            if (grid[0, 0])
            {
                costs[0, 0] = 0;
            }
            else
            {
                costs[0, 0] = 1;
            }

            for(int i = 1; i < h; i++)
            {
                if (grid[i - 1, 0] && !grid[i, 0])
                {
                    costs[i, 0] = costs[i - 1, 0] + 1;
                }
                else
                {
                    costs[i, 0] = costs[i - 1, 0];
                }
            }

            for (int i = 1; i < w; i++)
            {
                if (grid[0, i - 1] && !grid[0, i])
                {
                    costs[0, i] = costs[0, i - 1] + 1;
                }
                else
                {
                    costs[0, i] = costs[0, i - 1];
                }
            }

            for(int i = 1; i < h; i++)
            {
                for(int j = 1; j < w; j++)
                {
                    if(grid[i-1, j] && !grid[i, j])
                    {
                        costs[i, j] = costs[i - 1, j] + 1;
                    }
                    else
                    {
                        costs[i, j] = costs[i - 1, j];
                    }

                    if (grid[i, j - 1] && !grid[i, j])
                    {
                        costs[i, j] = Min(costs[i, j], costs[i, j - 1] + 1);
                    }
                    else
                    {
                        costs[i, j] = Min(costs[i, j], costs[i, j - 1]);
                    }
                }
            }

            WriteLine(costs[h - 1, w - 1]);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 11288
#include <iostream>
#include <map>
#define rep(i,n) for (int i=0; i<(n); i++)
using namespace std;

int main(){
    int n;
    cin >> n;
    int a;
    map<int, int> sorted_map;
    rep(i,n){
        cin >> a;
        sorted_map.insert(make_pair(a, i+1));
    }
    
    for (auto const& entry: sorted_map){
        cout << entry.second << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 5504
s = int(input())
arr = []
arr.append(s)

def sample(s):
    if s % 2 is 0:
    	  s2 = int(s / 2)
    else:
    	  s2 = int(s * 3 + 1)

    if s2 in arr:
        print(arr.index(s) + 2)
        return
    
    arr.append(s2)
    sample(s2)

sample(s)

Measured memory_bytes: 3060
#include <algorithm>
#include <cstdio>
#include <cstring>

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

using namespace std;

int main(){

	int n; scanf("%d",&n);
	for(int i=n;;i++){
		char s[8];
		sprintf(s,"%d",i);
		int len=strlen(s);
		if(count(s,s+len,s[0])==len){
			printf("%d\n",i);
			break;
		}
	}

	return 0;
}


Measured memory_bytes: 128
N = int(input())
L = [[x for x in input().split()] for i in range(N)]

for i in range(N):
    L[i].append(i+1)
    
for _ in range(N):
    idx = 0
    temp = L[0]
    ans = 0
    while idx < len(L):
        if temp[0] > L[idx][0]:
            ans = idx
            temp = L[idx]
        elif temp[0] == L[idx][0] and int(temp[1]) < int(L[idx][1]):
            ans = idx
            temp = L[idx]
        idx += 1
    ans_list = L.pop(ans)
    print(ans_list[2])

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    int a,b,c;
    int dp[100000][4]={};
    REP(i,1,n+1){
	cin>>a>>b>>c;
	dp[i][1]=max(dp[i-1][2]+a,dp[i-1][3]+a);
	dp[i][2]=max(dp[i-1][1]+b,dp[i-1][3]+b);
	dp[i][3]=max(dp[i-1][1]+c,dp[i-1][2]+c);
    }
    chmax(dp[n][1],dp[n][2]);
    chmax(dp[n][1],dp[n][3]);
    cout<<dp[n][1]<<'\n';
    return(0);
}


Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#define lson node<<1,st,mid
#define rson node<<1|1,mid+1,ed
#define mem(a,x) memset(a,x,sizeof(a))
#define me(a) memset(a,0,sizeof(a))
#define IOS ios::sync_with_stdio(false)
#define lowbit(x) x&(-x)
#define up(i,x,y) for(long long i=x;i<y;i++)
#define down(i,x,y) for(long long i=x;i>=y;i--)
#define in freopen("in.txt","r",stdin)
#define out freopen("out.txt","w",stdout)   
typedef long long ll;
const ll mod = 998244353;
const ll INF = 0x3f3f3f3f;
const ll maxn = 1e6 + 5;
const double pi = acos(-1.0);
const double eps=1e-9;
using namespace std;
ll qpow(ll a, ll b) { ll s = 1; while (b > 0) { if (b & 1)s = s * a % mod; a = a * a % mod; b >>= 1; }return s; }

int a[100];
int main(){
    // in;
    // out;
    for(int zz=0;zz<1000;zz++); 
    int n,m;
    cin>>n>>m;
    for(int zz=0;zz<1000;zz++); 
    for(int zz=0;zz<1000;zz++); 
    mem(a,-1);
    for(int zz=0;zz<1000;zz++); 
    bool flag=true;
    while(m--){
        int x,y;
        cin>>x>>y;
        for(int zz=0;zz<1000;zz++); 
        if(a[x]!=-1){
            int z=a[x];
            if(z!=y){
                flag=false;
            }
        }
        else if(x>n) flag=false;
        else{
            a[x]=y;for(int zz=0;zz<1000;zz++); 
        }
    }
    if(!flag||(a[1]==0&&n>1)) cout<<"-1"<<endl;//for(int zz=0;zz<1000;zz++); 
    else{
        if(a[1]==-1&&n>1) a[1]=1;
        else if(a[1]==-1&&n==1) a[1]=0;
        for(int i=1;i<=n;i++){
            if(a[i]==-1) a[i]=0;for(int zz=0;zz<1000;zz++); 
                cout<<a[i];for(int zz=0;zz<1000;zz++); 
        }
        for(int zz=0;zz<1000;zz++); 
        for(int zz=0;zz<1000;zz++); 
        cout<<endl;
    }
}

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

const int mod = 1e9 + 7;
constexpr ll modpow(ll A, ll B) {
	ll kotae = 1;
	while (B > 0) {
		if (B & 1) kotae = kotae * A % mod;
		A = A * A % mod;
		B >>= 1;
	}
	return kotae;
}

int gcd2(int A, int B) {
	if (B == 0) return A;
	else return gcd2(B, A % B);
}
ll gcd(ll A, ll B) {
	if (B == 0) return A;
	if (B < 2e9) return gcd2(B, A % B);
	else return gcd(B, A % B);
}

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


	int N;
	cin >> N;
	pair<ll, ll> AB[200200], BA[200200];
	int a0 = 0, b0 = 0;
	int ab00 = 0;
	int ka = 0, kb = 0;
	rep(i, N) {
		ll a, b;
		cin >> a >> b;

		if (a == 0 && b == 0) {
			ab00++;
			continue;
		}
		if (a == 0) {
			a0++;
			continue;
		}
		if (b == 0) {
			b0++;
			continue;
		}

		ll G = gcd(abs(a), abs(b));
		a /= G;
		b /= G;
		if (a < 0) {
			a = -a;
			b = -b;
		}
		if (b > 0) AB[ka++] = { a,b };
		else BA[kb++] = { -b,a };
	}

	ll kotae = 1;
	sort(AB, AB + ka);
	sort(BA, BA + kb);
	BA[kb] = { 2e18, 2e18 };

	pair<ll, ll> mae = AB[0];
	int p = 0;
	int kA = 0;
	rep(i, ka) {
		ll a = AB[i].first;
		ll b = AB[i].second;
		if (mae != AB[i]) {
			int tmp = 0;

			pair<ll, ll> mae2 = BA[p];
			int kB = 0;
			while (p < kb && BA[p] <= mae) {
				if (mae2 != BA[p]) {
					kotae = kotae * modpow(2, kB) % mod;
					mae2 = BA[p];
					kB = 1;
				}
				else kB++;
				p++;
			}

			if (mae == mae2) {
				tmp = kB;
			}
			else {
				kotae = kotae * modpow(2, kB) % mod;
			}

			if (tmp) {
				kotae = kotae * (modpow(2, kA) + modpow(2, kB) - 1) % mod;
			}
			else {
				kotae = kotae * modpow(2, kA) % mod;
			}

			mae = AB[i];
			kA = 1;
		}
		else kA++;
	}

	int tmp = 0;
	pair<ll, ll> mae2 = BA[p];
	int kB = 0;
	while (p < kb) {
		if (mae2 != BA[p]) {
			if (AB[ka - 1] == mae2) {
				tmp = kB;
			}
			else {
				kotae = kotae * modpow(2, kB) % mod;
			}
			mae2 = BA[p];
			kB = 1;
		}
		else kB++;
		p++;
	}

	if (AB[ka - 1] == mae2) {
		tmp = kB;
	}
	else {
		kotae = kotae * modpow(2, kB) % mod;
	}

	if (tmp) {
		kotae = kotae * (modpow(2, kA) + modpow(2, kB) - 1) % mod;
	}
	else {
		kotae = kotae * modpow(2, kA) % mod;
	}

	kotae = kotae * (modpow(2, a0) + modpow(2, b0) - 1) % mod;

	co((kotae - 1 + ab00 + 2 * mod) % mod);

	Would you please return 0;
}

Measured memory_bytes: 9924
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;


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


#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pii pair<int,int>
#define pf push_front
#define mp make_pair
#define vi vector<int>
#define vip vector<pair<int,int> >
#define ff first
#define ss second
#define int long long
#define mod 1000000007
#define BIG 998244353
#define s(t) scanf("%lld",&t)
#define p(t) printf("%lld\n",t)
#define mii map<int,int>
#define MSET(table,i) memset(table, i, sizeof(table))
#define endl '\n'
#define tc int t;cin>>t;while(t--)
#define pi  3.1415926358
#define bits(x) __builtin_popcount(x)
#define minimum(a,n) min_element(a,a+n)-a
#define maximum(a,n) max_element(a,a+n)-a
#define pqbig priority_queue<int>
#define pqsmall priority_queue<pair<int,pii>,vector<pair<int,pii> >,greater<pair<int,pii> > >
#define all(v) v.begin(),v.end()
#define sitr set<int>:: iterator
#define spitr set<pii>:: iterator
#define mitr map<int,int>:: iterator


#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

const int N=2e6+5;
int fact[N];
int invfact[N];

int  powermod(int  x, int  y, int p )
{
    int res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res % p;
}

int modinv(int x)
{
    return powermod(x, mod - 2, mod);
}

void precompute()
{
    fact[0]=1;
    invfact[0]=modinv(fact[0]);
    for(int i=1;i<N;i++)
    {
        fact[i]=fact[i-1]*i;
        fact[i]%=mod;
        invfact[i]=modinv(fact[i]);
    }
}


int32_t main() 
{ 
    fast;
    precompute();
    int r1,c1,r2,c2;cin>>r1>>c1>>r2>>c2;

    int ans=0;
    for(int i=c1;i<=c2;i++)
    {
        int pehla=fact[r2+i+1];
        pehla*=invfact[i+1],pehla%=mod;
        pehla*=invfact[r2],pehla%=mod;

        int dusra=fact[r1+i];
        dusra*=invfact[i+1],dusra%=mod;
        dusra*=invfact[r1-1],dusra%=mod;

        int cur=(pehla-dusra+mod)%mod;
        ans+=cur,ans%=mod;
    }
    cout<<ans;
} 

Measured memory_bytes: 31488
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
typedef long long ll;

using namespace std;




int main() {
	int ans = -10;
	int k2 = 10;
	rep(i, 5) {
		int k = 0;
		cin >> k;
		if (k % 10 == 0) ans += k;
		else {
			ans += (k / 10 + 1) * 10;
			k2 = min(k2, k % 10);
		}

	}
	ans += k2;
	cout << ans << endl;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


fn main() {
    let n:usize = read();
    let mut arr:Vec<i64> = (0..n).map(|_| read()).collect();

    for i in 1..n {
        if arr[i] > arr[i-1] {
            arr[i]-= 1;
        }
    }

    let ans = if arr.windows(2).all(|x| x[1] >= x[0]) {
        "Yes"
    } else {
        "No"
    };

    println!("{}", ans);
}


Measured memory_bytes: 2736
#include<bits/stdc++.h>
using namespace std;
const int N=1e3;
string s;
int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  cin>>s;
  if(s[0]!='A')cout<<"WA"<<endl,exit(0);

  int cnt=0;
  for(int i=1;i<s.size();i++)
  {
    if(s[i]>='A'&&s[i]<='Z')cnt++;
  }
  if(cnt!=1)cout<<"WA"<<endl,exit(0);
  cnt=0;
  for(int i=2;i<s.size()-1;i++)
  {
    if(s[i]=='C')cnt++;
  }
  if(cnt!=1)cout<<"WA"<<endl,exit(0);
  cout<<"AC"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int n,i;
	cin>>n;
	int p[n+1];
	for(i=1;i<=n;i++)cin>>p[i];
	int minv=p[1],ans=1;
	for(i=2;i<=n;i++)
	if(p[i]<=minv){
		ans++;
		minv=p[i];
	}
	cout<<ans;
	return 0;
}

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

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, m, n) for (ll i = (m); i < (n); i++)
#define FORR(i, m, n) for (ll i = (m); i >= (n); i--)
#define INF 1e9
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((ll)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl

int main(int argc, char const *argv[])
{
    string b;
    cin >> b;
    if (b == "A")
        cout << "T" << endl;
    else if (b == "T")
        cout << "A" << endl;
    else if (b == "C")
        cout << "G" << endl;
    else if (b == "G")
        cout << "C" << endl;
    return 0;
}


Measured memory_bytes: 256
import sys

S = sys.stdin.readline().strip()
N = len(S)

def check(s):
    # print(s)
    len_s = len(s)
    i, j = 0, len_s - 1
    while i <= j:
        if s[i] != s[j]:
            return False
        i += 1
        j -= 1
    return True

if check(S) and check(S[:(N-1)//2]) and check(S[(N+3)//2 - 1:]):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;

long MOD = 998244353;

void main() {
    auto N = readln.chomp.to!int;
    auto P = N.iota.map!(_ => readln.split.map!(to!long).array).array;
    P.sort();

    auto rev = P.map!(p => p[1]).array;
    rev = rev.dup.sort().uniq().array;
    int[long] comp;
    foreach (i; 0..rev.length.to!int) comp[rev[i]] = i;

    auto left = new SegmentTree!(int, (a,b)=>a+b, 0)(N);
    auto right = new SegmentTree!(int, (a,b)=>a+b, 0)(N);
    foreach (i; 0..N) right.add(i, 1);

    long lc = 0;
    long rc = N;
    long ans = 0;

    foreach (p; P) {
        right.add(comp[p[1]], -1);
        rc -= 1;

        long tmp = powmod(2, N, MOD) - 1;
        tmp -= powmod(2, lc, MOD) - 1;
        tmp -= powmod(2, rc, MOD) - 1;

        long ld = left.query(0, comp[p[1]]);
        long rd = right.query(0, comp[p[1]]);
        long lu = left.query(comp[p[1]], N-1);
        long ru = right.query(comp[p[1]], N-1);

        tmp -= (powmod(2, ld, MOD) - 1) * (powmod(2, rd, MOD) - 1) % MOD;
        tmp -= (powmod(2, lu, MOD) - 1) * (powmod(2, ru, MOD) - 1) % MOD;

        tmp = (tmp % MOD + MOD) % MOD;
        (ans += tmp) %= MOD;

        left.add(comp[p[1]], 1);
        lc += 1;
    }

    ans.writeln;
}

long powmod(long a, long p, long m) {
    long ret = 1;
    while (p > 0) {
        if (p % 2) ret = ret * a % m;
        a = a * a % m;
        p /= 2;
    }
    return ret;
}


class SegmentTree(T, alias op, T e) {
    T[] table;
    int size;
    int offset;

    this(int n) {
        size = 1;
        while (size <= n) size <<= 1;
        size <<= 1;
        table = new T[](size);
        fill(table, e);
        offset = size / 2;
    }

    void assign(int pos, T val) {
        pos += offset;
        table[pos] = val;
        while (pos > 1) {
            pos /= 2;
            table[pos] = op(table[pos*2], table[pos*2+1]);
        }
    }

    void add(int pos, T val) {
        pos += offset;
        table[pos] += val;
        while (pos > 1) {
            pos /= 2;
            table[pos] = op(table[pos*2], table[pos*2+1]);
        }
    }

    T query(int l, int r) {
        return query(l, r, 1, 0, offset-1);
    }

    T query(int l, int r, int i, int a, int b) {
        if (b < l || r < a) {
            return e;
        } else if (l <= a && b <= r) {
            return table[i];
        } else {
            return op(query(l, r, i*2, a, (a+b)/2), query(l, r, i*2+1, (a+b)/2+1, b));
        }
    }
}


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

int n;
int main() {
	cin >> n;
	int c = 0, x;
	while (1) {
		++c;
		x = (x + n) % 360;
		if (x == 0)
			break;

	}
	cout << c << endl;

}


Measured memory_bytes: 3632
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    xyh = [list(map(int, input().rstrip('\n').split())) for _ in range(n)]
    xyh.sort(key=lambda w: w[2], reverse=True)

    for cx in range(101):
        for cy in range(101):
            th = xyh[0][2] + abs(cx - xyh[0][0]) + abs(cy - xyh[0][1])
            b = True
            for x, y, h in xyh:
                if h != max(th - abs(cx - x) - abs(cy - y), 0):
                    b = False
                    break
            if b:
                print(cx, cy, th)
                exit()


if __name__ == '__main__':
    slove()


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

using namespace std;

int main() {
    int n;
    while (cin >> n, n != 0) {
        vector<int> a(n);
        for (int& x : a) {
            cin >> x;
        }

        sort(a.begin(), a.end());

        int mini = 1 << 25;

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

        cout << mini << endl;
    }
}

Measured memory_bytes: 3136
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<numeric>
#include<queue>

using namespace std;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int mod = 1000000007;
	int n;
	cin >> n;
	vector<char> s1(n);
	vector<char> s2(n);
	for (auto &e : s1) cin >> e;
	for (auto &e : s2) cin >> e;
	int i = 1;
	long long ans = 3;
	bool prev = true;
	if (s1[0] != s2[0]) {
		ans *= 2;
		prev = false;
		i++;
	}
	for (; i < n; i++) {
		if (prev) {
			ans *= 2;
			ans %= mod;
		}
		else if(s1[i] != s2[i]){
			ans *= 3;
			ans %= mod;
		}
		prev = (s1[i] == s2[i]);
		if (!prev) i++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i < (int)n;i++)
#define repb(i,n) for(int i = (int)n;i >= 0;i--)
#define reps(i,m,n) for(int i = (int)m;i < (int)n;i++)
#define repsb(i,m,n) for(int i = (int)m;i >= (int)n;i--)
#define SORT(v,n) sort(v,v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define INF 999999999999999999
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
using namespace std;
int main(int argc, char const *argv[]) {
    int n[5];
    bool f[5];
    rep(i,4){
      cin>>n[i];
      f[i]=false;
    }
    rep(i,4){
      if(n[i]==1) f[0]=true;
      if(n[i]==9) f[1]=true;
      if(n[i]==7) f[2]=true;
      if(n[i]==4) f[3]=true;
    }
    if(f[0]==true&&f[1]==true&&f[2]==true&&f[3]==true)  cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.lang.Integer.max

fun main() {
    val input = readLine()!!.split(" ")
    val n = input[0].toInt()
    val m = input[1].toInt()
    val k = input[2].toLong()
    val A = readLine()!!.split(" ").map { it.toLong() }
    val B = readLine()!!.split(" ").map { it.toLong() }

    val a = mutableListOf<Long>(0)
    for (i in 0 until n) {
        a.add(a[i] + A[i])
    }

    val b = mutableListOf<Long>(0)
    for (i in 0 until m) {
        b.add(b[i] + B[i])
    }

    var answer = 0
    var j = m


    for (i in 0 until (n + 1)) {
        if (a[i] > k) {
            break
        }

        while (b[j] > k - a[i]) {
            j -= 1
        }

        answer = max(answer, i + j)

    }

    print(answer)
}


Measured memory_bytes: 93580
#include <vector>

#include <iostream>

// nまでの数が素数かどうかを判定できるvectorを返す
std::vector<bool> factor(const int n) {
  int size = n + 1;
  std::vector<bool> isPrime(size, true);
  isPrime[0] = false;
  isPrime[1] = false;
  for (int i = 2; i < size; i++) {
    if (!isPrime[i])
      continue;
    for (int k = 2; i * k < size; k++) {
      isPrime[i * k] = false;
    }
  }
  return isPrime;
}

// minFactor[i]: iを割り切る最小の素数。存在しない場合は-1。
std::vector<int> fastFactor(const int n) {
  int size = n + 1;
  std::vector<int> minFactor(size, -1);
  for (int i = 2; i < size; i++) {
    if (minFactor[i] != -1)
      continue;
    minFactor[i] = i;
    for (int k = 2; i * k < size; k++) {
      if (minFactor[i * k] == -1) {
        minFactor[i * k] = i;
      }
    }
  }
  return minFactor;
}

// factor
// verify https://onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/1/ALDS1_1_C
int main() {
  std::vector<bool> isPrime = factor(10000);
  int n;
  std::cin >> n;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int a;
    std::cin >> a;
    bool flag = true;
    for (int j = 1; j < std::min(a, (int)isPrime.size()); j++) {
      if (!isPrime[j])
        continue;
      if (a % j == 0) {
        flag = false;
        break;
      }
    }
    if (flag)
      ans++;
  }
  std::cout << ans << std::endl;
}

// fastFactor
// verify



Measured memory_bytes: 3088
#include<bits/stdc++.h>
#define sqr(x) ((x)*(x))
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define ld long double
#define vi vector<int>-
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define debuge cerr<<"isok"<<endl
#define debug(x) cerr<<#x<<"="<<x<<endl
#define SS second
#define FF first
#define ls (k<<1)
#define rs (k<<1|1)
#define cpy(a,x) memcpy(a,x,sizeof(a))
#define clr(a,x) memset(a,x,sizeof(a))
#define input(x) freopen(x".in","r",stdin)
#define output(x) freopen(x".in"",w",stdout)
#define file(x) input(x),output(x)
using namespace std;

const ll inf=1ll<<60;
const int N=400005,M=100005,mod=1e9+7,INF=1e9+7;
template<class T> inline void gmin(T &x,const T &y){if(x>y) x=y;}
template<class T> inline void gmax(T &x,const T &y){if(x<y) x=y;}
inline void ch(int &x,int y){x+=y;if(x>=mod) x-=mod;}
inline void read(int &x){
	x=0;char ch=getchar();
	while(ch>'9'||ch<'0') ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
}

ll ans;
int n,u[N],v[N];
pii a[N];

int c[N];

ll s1(){
	int b1=0,b2=1e9+7,r1=0,r2=1e9+7;
	for(int i=1;i<=n;i++) gmax(b1,u[i]),gmin(b2,u[i]),gmax(r1,v[i]),gmin(r2,v[i]);
	return (ll)(r1-r2)*(b1-b2);
}
ll s2(){
	int b1=a[1].FF,b2=a[n*2].FF,ans=INF;
	int k=2,cnt=0;
	while(k<n*2){
		if(!c[a[k].SS]) cnt++;
		c[a[k].SS]++;
		if(cnt==n) break;
		k++;
	}
	for(int i=2;i<n*2&&k<n*2;i++){
		gmin(ans,a[k].FF-a[i].FF);
		if(c[a[i].SS]==1) cnt--;
		c[a[i].SS]--;
		while(k<=n*2&&cnt<n){
			if(!c[a[k].SS]) cnt++;
			c[a[k].SS]++;
			if(cnt==n) break;
			k++;
		}
	}//debug(ans);
//	debug(b2-b1);
	return (ll)ans*(b2-b1);
}

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&u[i],&v[i]);
		if(u[i]>v[i]) swap(u[i],v[i]);
	}
	for(int i=1;i<=n;i++) a[i]=mp(u[i],i),a[i+n]=mp(v[i],i);
	sort(a+1,a+n*2+1);
//	debug(a[1].FF);
	for(int i=1;i<=n;i++)
		if(u[i]==a[1].FF&&v[i]==a[n*2].FF){
			cout<<s1()<<endl;return 0;
		}
	ans=s1();
//	debug(ans);
	gmin(ans,s2());
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 6400
using System;

namespace ConsoleApplication7
{
    class Program
    {
        static void Main(string[] args)
        {
           while(true)
           {

                string Date = Console.ReadLine();
                string[] date = Date.Split(' ');
                int H = int.Parse(date[0]);
                int W = int.Parse(date[1]);

                if (H == 0 && W == 0)       //H,W??±???0????????????
                {
                    break;
                }
                for(int i = 1; i <= H; i++)
                {
                    for (int n = 1; n < W; ++n)
                    {
                        Console.Write("#");
                    }
                    Console.WriteLine("#");
                }
                Console.WriteLine();
            }
        }
    }
}

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


char grid[1002][1002];
int solve(int n,int m){
       
  int dp[n+1][m+1];
  dp[n][m]=1;
  for(int i=n;i>=1;i--){
    for(int j=m;j>=1;j--){
        if(i==n && j==m){
            continue;
        }
        if(grid[i][j]=='#'){
            dp[i][j]=0;
        }
        else{
           dp[i][j] =( ((i==n)? 0 : dp[i+1][j]) + ((j==m)?0:dp[i][j+1]) ) %(1000000007);
        }
    }
  }
  
  return dp[1][1];
}



int main(){

    int n,m;
    cin>>n>>m;
     
    for(int i=1;i<=n;i++){ 
       for(int j=1;j<=m;j++){
          cin>>grid[i][j];
       } 
    }
    cout<<solve(n,m);
    return 0;
}






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


void Main()
{
  int N;
  cin >> N;
  vector<int> d(N);
  rep(i,N){ cin >> d[i]; }
  sort(d.begin(), d.end());
  int samenum = 0;
  for(int k = 1; k <= 100000; k++) {
    auto idx = lower_bound(d.begin(), d.end(), k);
    //cout << idx << endl;
    //cout << idx-d.begin() << endl;
    if (idx-d.begin() == N / 2) samenum++;
  }
  cout << samenum << endl;
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  Main();
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
long long n,a,b;
const int maxn=1e5+5;
long long p[maxn];
bool check(long long x)
{
    long long sum=0;
    for(int i=n; i>=1; i--)
    {
        long long heal=p[i];
        heal=heal-x*b;
        if(heal<=0)
        {
            continue;
        }
        sum=sum+heal/(a-b);
        if(heal%(a-b)!=0)
        {
            sum++;
        }
        if(sum>x)
            return false;
    }
    return true;
}
int main()
{
    scanf("%lld%lld%lld",&n,&a,&b);
    long long l=1,r=0;
    for(int i=1; i<=n; i++)
    {
        scanf("%lld",&p[i]);
        r=r+p[i]/a+1;
    }
    sort(p+1,p+1+n);
    long long ans;
    while(l<=r)
    {
        long long mid=(l+r)/2;
        if(check(mid))
        {
            r=mid-1;
            ans=mid;
        }
        else
        {
            l=mid+1;
        }
    }
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 1024
module Main where

import Control.Applicative
import Text.Printf
import Numeric

main :: IO ()
main = loop

loop :: IO ()
loop = do
  { [as, os, bs] <- getStrings
  ; case os of
      "?" -> return ()
      "+" -> print (readInt' as + readInt' bs) >> loop
      "-" -> print (readInt' as - readInt' bs) >> loop
      "*" -> print (readInt' as * readInt' bs) >> loop
      "/" -> print (readInt' as `div` readInt' bs) >> loop
  }

--

getInts :: IO [Int]
getInts = map read . words <$> getLine

putInts :: [Int] -> IO ()
putInts = putStrLn . unwords . map show

getDoubles :: IO [Double]
getDoubles = map read . words <$> getLine

putDoubles :: [Double] -> IO ()
putDoubles = putStrLn . unwords . map showDouble

showDouble :: Double -> String
showDouble x = showFFloat Nothing x ""

getStrings :: IO [String]
getStrings = words <$> getLine 

readInt' :: String -> Int
readInt' = read



Measured memory_bytes: 4152
/*deco loves Chino*/
#include <bits/stdc++.h>
using namespace std;
#define int long long
int fib[1100];
vector<pair<int,int> > ans[1100];
const int mod=1e9+7;
signed main()
{
	fib[0]=fib[1]=1;
	for(int i=2;i<=90;i++)
	{
		fib[i]=fib[i-1]+fib[i-2];
	}
	ans[1].push_back(make_pair(1,2)),ans[1].push_back(make_pair(1,3)),ans[1].push_back(make_pair(1,4));
	for(int i=1;i<=87;i++)
	{
		for(int j=0;j<ans[i].size();j++)
		{
			pair<int,int> qwq=ans[i][j];
			int dx=qwq.second,dy=qwq.first+dx;
			while(dy<=fib[i]+fib[i+3])
			{
				ans[i+1].push_back(make_pair(dx,dy));
				dy+=dx;	
			} 
		}
	}
	int t;
	cin>>t;
	while(t--)
	{
		int n,m;
		scanf("%lld%lld",&n,&m);
		if(n>m)
		{
			swap(n,m);
		}
		int now=1;
		while(fib[now+1]<=n&&fib[now+2]<=m)
		{
			++now;
		}
		cout<<now<<" ";
		if(now==1)
		{
			cout<<n*m%mod<<"\n";
			continue;
		}
		int anss=0;
		for(int i=0;i<ans[now-1].size();i++)
		{
			pair<int,int> qwq=ans[now-1][i];
			if(qwq.second<=m)
			{
				anss+=((n-qwq.first)/qwq.second)%mod;
			}
			if(qwq.second<=n)
			{
				anss+=((m-qwq.first)/qwq.second)%mod;
			}
			anss%=mod;
		}
		cout<<anss<<"\n";
	} 
}


Measured memory_bytes: 4096
#include <iostream>
#include <stdio.h>
#include <string>
#include <complex>
using namespace std;
int main(void) {
  long X=0, A=0, B=0, rest=0;
  cin >> X;
  cin >> A;
  cin >> B;
  rest = (X - A) % B;
  cout << rest << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<limits>
#include<iomanip>
#include<cmath>
#include<climits>

using namespace std;



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

const int mod=1e9+7;

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

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    ll cnt=0,AbsMin=INT_MAX,Sum=0;
    bool exist0=false;
    for(ll i=0;i<n;i++){
        cin >> a[i];
        if(a[i]<0){
            cnt++;
        }else if(a[i]==0){
            exist0=true;
        }
        AbsMin=min(AbsMin,abs(a[i]));
        Sum+=abs(a[i]);
    }  
    if(exist0){
        cout << Sum << endl;
    }else if(cnt%2==0){
        cout << Sum << endl;
    }else{
        cout << Sum-2*AbsMin << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code

def resolve():
    a,b=pin()
    print(max(a+b,a-b,a*b))
#%%submit!
resolve()

Measured memory_bytes: 38456
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
 
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

int main()
{
    ll N;
    cin >> N;
    vector<ll> A1(N);
    vector<ll> A2(N);
    rep(i, N) cin >> A1[i];
    rep(i, N) cin >> A2[i];
    rep(i, N-1) {
        A1[i+1] += A1[i];
        A2[N-1-(i+1)] += A2[N-1-i];
    }
    ll ma = 0;
    rep(i, N) {
        ma = max(ma, A1[i] + A2[i]);
    }
    print(ma);
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		String S = input.next();
		int N=S.length();
		char[] a;
		char[] b;
		int check=0;
		
		String x,y;
		x=S.substring(0,N/2);
		y=S.substring(N/2+1,N);
		if(x.equals(y)) {
			check++;
		}
		a=x.toCharArray();
		b=y.toCharArray();
		
		for(int i=0;i<x.length()/2;i++) {
			if(a[i]!=a[a.length-(i+1)]) {
				check--;
			}
		}
		for(int i=0;i<y.length()/2;i++) {
			if(b[i]!=b[b.length-(i+1)]) {
				check--;
			}
		}
		
		if(check==1) {
			System.out.println("Yes");
	    }else{
	    	System.out.println("No");
	    }		
	}		
}
	



Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(x) cerr << #x << ": " << endl
#define rep(i,n) for(int i=0; (i)<(n); ++(i))
#define rrep(i,n) for(int i=(n); (i)>0; --(i))
#define reps(i,s,n) for(int i=(s); (i)<(n); ++(i))
#define maxi(v) distance(v.begin(), max_element(v.begin(), v.end()))
#define mini(v) distance(v.begin(), min_element(v.begin(), v.end()))
#define ALL(obj) (obj).begin(),(obj).end()
template<class T> inline bool print(T& x){ cout << x << endl; return true; }
template<class T> inline bool print_(T& x){ cout << x << " "; return true; }
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; }
ll gcd(ll x, ll y){
  if(y==0) return x;
  else return gcd(y, x%y);
  }
const int INF = 1e9;
const ll llINF = 1LL<<60;
const int MOD = 1e9+7;
const double EPS = 1e-9;

int main(){
    ll n; cin >> n;
    vector<ll> v(6); v[0]=1e15; reps(i,1,6) cin >> v[i];
    ll ans = (n/v[mini(v)])+5;
    if(n%v[mini(v)]==0) ans--;
    cout << ans;
    
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG

signed main() {
  int N, M; cin >> N >> M;
  vector<int> k(M);
  vector<vector<int>> s(M, vector<int>(0));
  rep(i, M) {
    cin >> k[i];
    rep(j, k[i]) {
      int ss; cin >> ss;
      s[i].push_back(ss-1);
    }
  }
  vector<int> p(M);
  rep(i, M) cin >> p[i];
  

  
  
  int ans = 0;
  rep(i, (1<<N)) {
    bitset<10> b = i;
    bool t = true;
    rep(j, M) {
      int a = 0;
      rep(l, k[j]) {
        if(b[s[j][l]] == 1) a++;
      }
      if(a%2 != p[j]) t = false;
    }
    if(t) ans++;
  }
  
  cout << ans << endl;

}

Measured memory_bytes: 3608
import java.util.*;

public class Main {

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

  public static void main(String[] args) {
    int n = scan.nextInt();
    int[] A = new int[n];
    for (int i = 0; i < n; i++) {
      A[i] = scan.nextInt();
    }

    Map<Integer, Integer> countMap = new HashMap<>();

    long total = 0;
    for (int i = 0; i < n; i++) {
      int cur = A[i];
      int diff = i - cur;

      if (countMap.containsKey(diff)) {
        total += countMap.get(diff);
      }

      int sum = i + cur;
      if (!countMap.containsKey(sum)) {
        countMap.put(sum, 0);
      }
      countMap.put(sum, countMap.get(sum) + 1);
    }

    System.out.println(total);
  }
}

Measured memory_bytes: 57092
#include "bits/stdc++.h"
using namespace std;
const int N = 1e5 + 5;

string s;
int n, K;
int dp[305][305][305];
int solve(int i = 0, int j = n - 1, int k = K) {
    if (i > j) return 0;
    if (dp[i][j][k] == -1) {
        if (i == j) dp[i][j][k] = 1;
        else if (i + 1 == j) {
            if (s[i] == s[j])
                dp[i][j][k] = 2;
            else if (k) 
                dp[i][j][k] = 2;
            else
                dp[i][j][k] = 1;
        }
        else if (s[i] == s[j]) {
            dp[i][j][k] = 2 + solve(i + 1, j - 1, k);
        }
        else {
            dp[i][j][k] = max(solve(i, j - 1, k), solve(i + 1, j, k));
            if (k) {
                dp[i][j][k] = max(dp[i][j][k], 2 + solve(i + 1, j - 1, k - 1));
            }
        }
    }
    return dp[i][j][k];
}
int32_t main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    memset(dp, -1, sizeof(dp));
    cin >> s;
    n = s.size();
    cin >> K;
    cout << solve();
}


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

typedef long long ll;
const ll MOD = 1e9+7;
const int N = 1e5+5;

int n;
ll k,ans;
vector<int>v[N];


void dfs(int s,int p){
    ll cnt=2;
    for(auto e:v[s]){
        if(e!=p){
            ans*=(k-cnt);
            if(ans>=MOD)ans%=MOD;
            cnt++;
        }
    }
    for(auto e:v[s]){
        if(e!=p)dfs(e,s);
    }
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>n>>k;

    for(int i=1;i<=n-1;i++){
        int a,b;
        cin>>a>>b;

        v[a].push_back(b);
        v[b].push_back(a);
    }

    ans=1;
    ans*=k;
    for(int i=0;i<(int)v[1].size();i++){
        ans*=(k-i-1);
        if(ans>=MOD)ans%=MOD;
    }

    for(auto e:v[1]){
        dfs(e,1);
    }

    cout<<ans;
    return 0;
}


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

int main() {
	long N, H;
	cin>>N>>H;
	vector<long>a, b;
	long tmpa, tmpb;
	for(int i=0;i<N;++i){
		cin>>tmpa>>tmpb;
		a.push_back(tmpa);
		b.push_back(tmpb);
	}
	sort(a.begin(), a.end(), greater<long>());
	sort(b.begin(), b.end(), greater<long>());
	long nage = 0;
	int nagenum = 0;
	for(int i=0;i<N;++i){
		if(a[0] <= b[i]){
			nage += b[i];
			nagenum++;
			if(nage >= H){
				break;
			}
		}
	}
	if(nage>=H){
		cout<<nagenum<<endl;
	}
	else if((H-nage)%a[0]==0){
		cout<<nagenum+(H-nage)/a[0]<<endl;
	}
	else {
		cout<<nagenum+(H-nage)/a[0]+1<<endl;
	}
}


Measured memory_bytes: 2036
def calc_distance(p, q)
  Math.sqrt((p ** 2) + (q ** 2))
end

n, d = gets.chomp.split(' ').map(&:to_i)
count = 0
values = []
caches = {}
n.times do
  value = gets.chomp
  result = caches[value]
  unless result
    x, y = value.split(' ').map(&:to_i)
    distance = calc_distance(x, y)
    result = distance <= d
    caches[value] = result
  end
  count += 1 if result
end

puts count

Measured memory_bytes: 39300
#include<bits/stdc++.h>
using namespace std;
int X[200100];
int main()
{
  int N;
  cin>>N;
  int Sum=0;
  for(int i=0;i<N;i++)
  {
    cin>>X[i];
    Sum^=X[i];
  }
  for(int i=0;i<N;i++)
    cout<<(Sum^X[i])<<" ";
  return 0;
}

Measured memory_bytes: 4372
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define rep(i,a,b) for (int i = (a); i < (b); i++)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const int inf = 2e9;

ll mpow(ll a, ll b) {
	ll res = 1;
	a %= mod;
	while (b) {
		if (b & 1) res = res * a % mod;
		a = a * a % mod;
		b >>= 1;
	}
	return res;
}
vector<int> fac, finv;
void factor(int N) {
	fac.resize(N); finv.resize(N);
	fac[0] = finv[0] = 1;
	rep(i, 1, N)fac[i] = 1LL * fac[i - 1] * i % mod;
	finv[N - 1] = mpow(fac[N - 1], mod - 2);
	for (int i = N - 2; i; --i) finv[i] = 1LL * finv[i + 1] * (i + 1) % mod;
}
int nCr(int n, int m) {
	if (m < 0 || n < m) return 0;
	return 1LL * (1LL * fac[n] * finv[m] % mod) * finv[n - m] % mod;
}


int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n; cin >> n;
	int a, b, c; cin >> a >> b >> c;
	int sum = a + b;
	a = (1LL * a * mpow(sum, mod - 2)) % mod;
	b = (1LL * b * mpow(sum, mod - 2)) % mod;
	factor(200010);
	ll add1 = 0,add2=0;
	rep(i, 0, n) {
		add1 = (add1 + (1LL * (n + i) * (1LL * nCr(n + i - 1, n - 1) * mpow(b, i) % mod)) % mod) % mod;
	}
	add1 = (1LL * add1 * mpow(a, n)) % mod;
	rep(i, 0, n) {
		add2 = (add2 + (1LL * (n + i) * (1LL * nCr(n + i - 1, n - 1) * mpow(a, i) % mod)) % mod) % mod;
	}
	add2 = (1LL * add2 * mpow(b, n)) % mod;
	add1 = (add1 + add2) % mod;
	printf("%lld", add1* (100LL * mpow(sum, mod - 2) % mod) % mod);
 	return 0;
}


Measured memory_bytes: 1792
#include "stdio.h"

int main(){
    int N,M,K,i,j,F[31],t;
    scanf("%d%d",&N,&M);
  	for(i=0;i<=30;i++) F[i]=0;
    for(i=0;i<N;i++){
        scanf("%d",&K);
        for(j=0;j<K;j++){
            scanf("%d",&t);
            F[t]++;
        }
    }
    t=0;
    for(i=1;i<=M;i++){
        if(F[i]==N){
            t++;
        }
    }
    printf("%d",t);
    return 0;
}

Measured memory_bytes: 1732
N,L= list(map(int, input().split()))
li=[L+i for i in range(N)]
mi=100000
ma=-1000000000
for i in li:
    if i>=0:
        mi=min(mi,i)
    else:
        ma=max(ma,i)
if abs(ma)>mi:
    print(sum(li)-mi)
else:
    print(sum(li)-ma)

Measured memory_bytes: 3060
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int[][] list = new int[2][4];
		
		 while(sc.hasNext()){
			 String[] eye = sc.nextLine().split(" ");
			 
			 for(int i = 0; i < 2; i++){
				 if(Double.parseDouble(eye[i]) >= 1.1)
					 list[i][0]++;
				 else if(Double.parseDouble(eye[i]) >= 0.6 && Double.parseDouble(eye[i]) < 1.1)
					 list[i][1]++;
				 else if(Double.parseDouble(eye[i]) >= 0.2 && Double.parseDouble(eye[i]) < 0.6)
					 list[i][2]++;
				 else if(Double.parseDouble(eye[i]) < 0.2)
					 list[i][3]++;
			 }
			 }
		 for(int i = 0; i < 4; i++)
				 System.out.println(list[0][i] + " " + list[1][i]);
		 
		 sc.close();
		 }
	}

Measured memory_bytes: 17228
import Control.Monad
import Data.List

getNums = getLine >>= return . map read . words

solve n ps js = f (n*m) n m (reverse $ sort js)
 where
  m = sum ps
  f a _ _ [] = a
  f a n m (j:js)
   | a > a' = a
   | otherwise = f a' n' m' js
   where 
    n' = n-1
    m' = m+j
    a' = n'*m'

main = do
 (n:_) <- getNums
 when (n /= 0) $ do
  ps <- getNums
  js <- getNums
  print $ solve n ps js
  main

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

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

    int n;
    cin >> n;

    vector<int> a(n);
    vector<int> p(n);
    vector<int> q(n);

    rep(i,n) a[i] = i + 1;
    rep(i,n) cin >> p[i];
    rep(i,n) cin >> q[i];

    int ansA = 0;
    int ansB = 0;
    int cnt = 0;
    do {
        cnt++;
        bool isP = true;
        bool isQ = true;
        for (int i = 0; i < n; i++) {
            if(a[i] != p[i]) isP = false;
            if(a[i] != q[i]) isQ = false;
        }
        if(isP) ansA = cnt;
        if(isQ) ansB = cnt;
    }while (next_permutation(a.begin(),a.end()));

    cout << abs(ansA - ansB) << endl;
}




Measured memory_bytes: 256
D,d=$<.map &:split
f=->a{a.map{|i|d[i]}.rotate.map.with_index{|v,i|d[a[i]]=v}}
(0..23).map{|i|f[[1,2,4,3]]
if d==D
puts:Yes
exit
end
f[i%8<4?[0,4,5,1]:[0,2,5,3]] if i%4<1}
puts:No

Measured memory_bytes: 6128
#include <vector>
#include <cstring>
#include <iostream>
using namespace std;
int n, c, a[10000]; bool p[10000], prime[10000];
int main() {
	for(int i = 2; i < 10000; i++) prime[i] = true;
	for(int i = 2; i * i < 10000; i++) {
		if(!prime[i]) continue;
		for(int j = i * i; j < 10000; j += i) prime[j] = false;
	}
	while(scanf("%d", &n), c = 0, n) {
		if(prime[n] && n % 4 == 3) {
			for(int i = 0; i < n / 2; i++) printf("%d\n", (n - 3) / 2);
			continue;
		}
		vector<int> v;
		for(int i = 0; i < n; i++) a[i] = 0, p[i] = 0;
		for(int i = 1; i < n; i++) p[i * i % n] = true;
		for(int i = 0; i < n; i++) {
			if(p[i]) v.push_back(i);
		}
		for(int i = 0; i < v.size(); i++) {
			for(int j = i + 1; j < v.size(); j++) {
				int r = v[j] - v[i];
				if(r < 0) r += n;
				if(r > n / 2) r = n - r;
				a[r - 1]++;
			}
		}
		for(int i = 0; i < n / 2; i++) printf("%d\n", a[i] * 2);
	}
}

Measured memory_bytes: 3348
#include<stdio.h>
#include<string.h>
int main(){
    char str[21];
    int len;
    scanf("%s",str);
    len=strlen(str);
    for (int i=0; i<(len/2); i++) {
        char c;
        c=str[i];
        str[i]=str[len-i-1];
        str[len-i-1]=c;
    }
    printf("%s\n",str);
    return 0;
}



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

// Shrotening
#define fst first
#define snd second
#define pb push_back

// Loop
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define RFOR(i,a,b) for(long i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

typedef std::pair<int,int> PII;

int N, x;
VL a;
int main() {
    std::cin >> N >> x;
    a.resize(N);
    REP(i, N) std::cin >> a[i];

    LL res = 0LL;
    FOR(i, 1, N) {
        long sum = a[i] + a[i-1];
        if(sum > x) {
            long da = std::min(sum-x, a[i]);
            res += da;
            a[i] -= da;
            if(sum-x-da > 0) {
                long db = std::min(sum-x-da, a[i-1]);
                res += db;
                a[i-1] -= db;
            }
        }
    }
    std::cout << res << std::endl;
}

Measured memory_bytes: 1024