akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int D = sc.nextInt();

		double x = 0;
		double y = 0;
		int result = 0;
		for(int i=0;i<N;i++) {
			x = sc.nextDouble();
			y = sc.nextDouble();
			if(Math.sqrt(x*x+y*y)<= D) {
				result++;
			}
		}
		sc.close();

		System.out.println(result);

	}


}

Measured memory_bytes: 50524
import java.util.Scanner;
class Main{
    public static void main(String args[]){
        Scanner scan = new Scanner(System.in);
        int total = scan.nextInt();
        int one = scan.nextInt();
        int div = total/500;
        int num = total - 500*div;

        if(num <= one){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

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

using namespace std ; 

const int N = 3e5 + 7 ; 

int n ; 
vector<int> adj[N] ; 
int a[N] ; 
int tree[N * 4 ] ; 
int ans[N] ; 
int cnt ; 
vector<int> treev[N * 4] , mxs[4 * N] ;  

void update(int node , int L , int R , int ix , int val){

        if(L == R){
                if(mxs[node].size() == 0){
                        mxs[node].push_back(0) ;
                }
                if(val > 0){
                        mxs[node].push_back(max(val , mxs[node].back())) ;         
                        treev[node].push_back(val) ;              
                }
                else{
                        treev[node].pop_back() ; 
                        mxs[node].pop_back() ; 
                }
                tree[node] = mxs[node].back() ; 
                return ; 
        }

        int mid = (L + R) >> 1 ; 
        if(ix<=mid){
                update(node*2+1 , L , mid , ix , val) ; 
        }
        else{   
                update(node*2+2 , mid+1 , R , ix , val) ; 
        }
        tree[node] = max(tree[node*2+1] , tree[node*2+2] ) ; 
}

int get(int node , int L , int R , int l , int r){      
        if(l > R || r < L) return 0 ; 
        if(L>= l && R<= r)
                return tree[node] ; 
        int mid = (L+R) >>1 ; 
        int s1 = get(node*2+1 , L , mid , l , r) ; 
        int s2 = get(node*2+2 , mid+1 , R , l , r) ; 
        return max(s1 , s2) ;
}

vector<int> liss = {0} ; 
vector<int> mxl  = {0} ; 

void dfs(int x , int p){

        int mxp = get(0 , 1 , N , 1 , a[x] -1 ) ; 
        liss.push_back({mxp+1}) ; 
        mxl.push_back(max(mxl.back() , liss.back())) ;
        ans[x] = mxl.back() ; 
        update(0 , 1 , N , a[x] , mxp + 1 ) ; 

        for(auto u : adj[x]){
                if(u == p)
                        continue ; 
                dfs(u , x) ;        
        }
        update(0 , 1 , N , a[x] , -1) ; 
        mxl.pop_back() ; 
        liss.pop_back() ;
}


int main(){
        ios_base::sync_with_stdio(0) ; 
        cin.tie(0) ; 
        //freopen("in.in" ,"r" , stdin) ; 

        cin >> n; 
        vector<pair<int , int > > dbl ; 
        for(int i = 1;i <=n;i++){
                int x ; cin >> x ; 
                dbl.push_back({x , i}) ; 
        }
        sort(dbl.begin() , dbl.end()) ; 
        int T = 1 , l = 0  ;
        for(int i = 0 ;i < n;i++){
                T += (dbl[i].first != l) ; 
                a[dbl[i].second] = T ; 
                l = dbl[i].first ; 
        }
        for(int i = 0 ;i < n -1 ;i ++){
                int u , v; 
                cin >> u >> v ; 
                adj[u].push_back(v) ; 
                adj[v].push_back(u) ; 
        }

        dfs(1 , 1) ; 
        for(int i =1 ;i <=n;i++)
                cout<< ans[i] <<"\n" ; 

        return 0; 
}

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

struct Edge {
    int to;
    ll ch;
};

ll solve() {
    ll N, a, b;
    cin >> N;
    vector<vector<Edge>> G(N);
    for ( int i = 0; i < N-1; i++ ) {
        cin >> a >> b;
        a--, b--;
        G[a].push_back(Edge{b,0LL});
        G[b].push_back(Edge{a,0LL});
    }

    function<ll(int, int)> dfs = [&](int v, int p) {
        ll ch = 1;
        for ( auto& e : G[v] ) {
            if ( e.to == p ) continue;
            e.ch = dfs( e.to, v );
            ch += e.ch;
        }
        for ( auto& e : G[v] ) {
            if ( e.to == p ) {
                e.ch = N - ch;
            }
        }
        return ch;
    };

    dfs(0, -1);

    const ll MOD = 1e9 + 7;
    auto Add = [&](ll& x, ll y) { x = ( x % MOD + y % MOD ) % MOD; };
    auto Mul = [&](ll& x, ll y) { x = ( x % MOD * y % MOD ) % MOD; };
    auto Pow = [&](ll x, ll n) -> ll {
        ll t = x % MOD, r = 1;
        while ( n > 0 ) {
            if ( n & 1 ) Mul(r, t);
        Mul(t, t);
        n >>= 1;
        }
        return r;
    };
    auto Inv = [&](ll a) -> ll {
        return Pow(a, MOD - 2);
    };

    ll M = 2*10e5;
    vector<ll> pow2(M+1);
    ll pw = 1;
    for ( int i = 0; i <= M; i++ ) {
        pow2[i] = pw;
        Mul(pw, 2);
    }

    ll hc = 0;
    for ( int i = 0; i < N; i++ ) {
        ll noh = 1;
        for ( auto e : G[i] ) {
            Add(noh, pow2[e.ch]);
            Add(noh, MOD - 1);
        }
        Add(hc, pow2[N-1]);
        Add(hc, MOD - noh);
    }
    ll ans = hc;
    Mul(ans, Inv(pow2[N]));
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 44544
/*
  || Shree Ganeshay Namah ||

     || Jai Shree Ram ||
  || Nabh Sparsham Diptam ||
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

#define mod 1000000007
#define block 180
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define f1 first
#define s1 second
#define pb push_back
// to floor a/b you can do a/b and to ceiling a/b you can do (a+b-1)/b
int jai_shree_ram()
{
    return 1;
}
int shree_ganeshay_namah()
{
    return 1;
}
ll power(ll x,ll y)
{
    ll r=1;
    while(y>0)
    {
        if(y%2!=0)
            r=(r%mod * x%mod)%mod;
        x=(x%mod * x%mod)%mod;
        y=y/2;
    }
    return r;
}
ll ncr(ll n,ll k)
{

    ll c[k+1];
    memset(c,0,sizeof(c));
    c[0]=1;
    for(ll i=1;i<=n;i++)
    {
        for(ll j=min(i,k);j>0;j--)
            c[j]=(c[j]%mod + c[j-1]%mod)%mod;
    }
    return c[k];
}

bool prime[1001];
void sieve()
{
    ll i,j;
    memset(prime,true,sizeof(prime));
    prime[0]=false;
    prime[1]=false;
    for(i=2;i<=sqrt(100);i++)
    {
        if(prime[i])
        {
            for(j=i*i;j<=100;j=j+i)
                prime[j]=false;
        }
    }
}
//Start of Matrix Exponentiation Code
void mat_mul(ll F[2][2],ll M[2][2]) {
   ll a = ((F[0][0]%mod * M[0][0]%mod)%mod + (F[0][1]%mod * M[1][0]%mod)%mod)%mod;
   ll b = ((F[0][0]%mod * M[0][1]%mod)%mod + (F[0][1]%mod * M[1][1]%mod)%mod)%mod;
   ll c = ((F[1][0]%mod * M[0][0]%mod)%mod + (F[1][1]%mod * M[1][0]%mod)%mod)%mod;
   ll d = ((F[1][0]%mod * M[0][1]%mod)%mod + (F[1][1]%mod * M[1][1]%mod)%mod)%mod;
   F[0][0] = a;
   F[0][1] = b;
   F[1][0] = c;
   F[1][1] = d;
}
void mpower(ll F[2][2], ll n) {
   if (n == 0 || n == 1)
      return;
   ll M[2][2] = {{1,1},{1,0}};
   mpower(F, n / 2);
   mat_mul(F, F);
   if (n % 2 != 0)
      mat_mul(F, M);
}
ll fib_mat(ll n) {
   ll F[2][2] = {{1,1},{1,0}};
   if (n == 0)
      return 0;
   mpower(F, n - 1);
   return F[0][0]%mod;
}
//End of Matrix Exponentiation
/*
Segment Tree
ll ar[200005];
ll st[800005];
void build(ll si,ll ss,ll se)
{
    if(ss==se)
    {
        st[si]=ar[ss];
        return ;
    }
    ll mid=(ss+se)/2;
    build(2*si,ss,mid);
    build(2*si+1,mid+1,se);
    st[si]=(st[2*si]+st[2*si+1]);
}
ll query(ll si,ll ss,ll se,ll l,ll r)
{

   if(l<=ss && se<=r)
     return st[si];
   if(l>se || r<ss)
    return 0;
   ll mid=(ss+se)/2;
   ll x=query(2*si,ss,mid,l,r);
   ll y=query(2*si+1,mid+1,se,l,r);
   return x+y;
}
void update(ll si,ll ss,ll se,ll qi)
{
    if(ss==se)
    {
        st[si]=ar[ss];
        return;
    }
    ll mid=(ss+se)/2;
    if(qi<=mid)
        update(2*si,ss,mid,qi);
    else
        update(2*si+1,mid+1,se,qi);
    st[si]=st[2*si]+st[2*si+1];
}
*/


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
    string s;
    ll f=0,i;
    cin>>s;
    for(i=0;i<s.size();i++)
    {
        f=f+(s[i]-'0');
    }
    if(f%9==0)
        cout<<"Yes\n";
    else
        cout<<"No\n";
	return 0;
}


Measured memory_bytes: 3756
#include<stdio.h>
int main()
{
    char s[1000000];
    char ch;
    int i,n,count;
    gets(s);
    n=strlen(s);
    for(ch=97; ch<123; ch++)
    {
            count=1;
        for(i=0; i<n; i++)
        {
            if(ch==s[i])
                count=0;
        }
        if(count)
        {
            break;
        }
    }

    if(ch==123)
        printf("None\n");
    else
        printf("%c\n",ch);
    return 0;

}


Measured memory_bytes: 1740
#include<cstdio> 
#include<cmath>。 
using namespace std;
long long n,ans,s;
int main()
{
    scanf("%lld",&n); 
    for(int i=sqrt(n);i>0;--i) if(n%i==0) {ans=n/i; break;}
    while(ans>0) {++s; ans/=10;}
    printf("%d\n",s); 
    return 0;
} 


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

int main() {

	int n;
	cin>>n;
	int arr[n+1] = {0};
	for(int i=0;i<n-1;++i) {
        int x;
        cin>>x;
        arr[x]++;
	}
	for(int i=1;i<=n;++i)
        cout<<arr[i]<<endl;
}


Measured memory_bytes: 4404
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;
// ------------------------------

int main() {
    string S, T;
    cin >> S >> T;
    int mx = 0;
    rep(i, S.size() - T.size() + 1) {
        int tmp = 0;
        rep(j, T.size()) if (S[i + j] == T[j]) tmp += 1;
        mx = max(mx, tmp);
    }
    cout << T.size() - mx << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int h,w;
  cin >> h >> w;

  map<int,int> t;
  multiset<int> s;
  rep(i,w) t[i]=i, s.insert(0);
  rep(k,h) {
    int l,r;
    cin >> l >> r;
    int d = -1;
    auto i=t.lower_bound(--l);
    while(i!=t.end() && i->first<=r){
      d = max(d,i->second);
      s.erase(s.find(i->first - i->second));
      t.erase(i++);
    }
    if(0<=d && r<w){
      s.insert(r-d);
      t[r] = d;
    }
    int ans = s.empty() ? -1 : *s.begin() + k + 1;
    cout << ans << endl;
  }
}


Measured memory_bytes: 22344
//11
#include<iostream>
#include<complex>
#include<algorithm>
#include<vector>

using namespace std;

typedef complex<double> P;

double det(P a,P b){
  return a.real()*b.imag()-a.imag()*b.real();
}

bool cmp(P a,P b){
  if(a.real()!=b.real()){
    return a.real()<b.real();
  }else{
    return a.imag()<b.imag();
  }
}

int main(){
  for(int n;cin>>n,n;){
    P ps[100];
    for(int i=0;i<n;i++){
      double x,y;
      (cin>>x).ignore()>>y;
      ps[i]=P(x,y);
    }
    sort(ps,ps+n,cmp);
    int k=0;
    vector<P> qs(n*2);
    for(int i=0;i<n;i++){
      while(k>1&&det(qs[k-1]-qs[k-2],ps[i]-qs[k-1])<=0)k--;
      qs[k++]=ps[i];
    }
    for(int i=n-2,t=k;i>=0;i--){
      while(k>t&&det(qs[k-1]-qs[k-2],ps[i]-qs[k-1])<=0)k--;
      qs[k++]=ps[i];
    }
    cout<<n-(k-1)<<endl;
  }
  return 0;
}
    

Measured memory_bytes: 1240
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def MAP1()  : return map(lambda x:int(x)-1,input().split())
def LIST()  : return list(MAP())
def LIST1() : return list(MAP1())

def solve():
    N, M = MAP()
    d = defaultdict(int)
    for i in range(M):
        a, b = MAP()
        d[a] += 1
        d[b] += 1

    ans = "YES"
    for x in d.values():
        if x % 2 == 1:
            ans = "NO"
    print(ans)

if __name__ == '__main__':
    solve()

Measured memory_bytes: 15532
#include <iostream>
#include <string>
#include <string.h>
using namespace std;

char CODE[17] = "CODEFESTIVAL2016";


int main(){
	
	int cnt = 0;
	char S[17];
	for(int i = 0 ; i < 17 ; i++){
		scanf("%c",&S[i]);
	}
	for(int i = 0 ; i < 17 ; i++){
		if(!(CODE[i] == S[i])){
			cnt++;
		}
	}
	printf("%d\n",cnt - 1);


}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
using namespace std;

#define ABS(a) (((a) >= 0) ? (a) : -(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define RFOR(i, a, b) for (int i = a; i > b; --i)
#define REP(i, n) for (int i = 0; i < n; ++i)

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

// const int kMaxN;

int N, K;
ll ans;

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

  if (K == 0) {
    ans = (ll)N*N;
  } else {
    FOR(b, 1, N+1) {
      if (b-1 < K) { continue; }

      // cout << ((N+1)/b * (b-K)) << endl;
      // cout << ((N+1)%b -1-K) << endl;
      ans += ((N+1)/b * (b-K)) + MAX(0, ((N+1)%b - K));
    }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

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

    vs ans;
    function<void(int, string&)> dfs = [&](int i, string &s) {
        if(s.size() == n) {
            ans.emplace_back(s);
            return;
        }
        rep(j, i+1) {
            s += char('a' + j);
            dfs(i, s);
            s.pop_back();
        }
        s += char('a' + i + 1);
        dfs(i+1, s);
        s.pop_back();
        return;
    };
    string h = "a";
    dfs(0, h);

    sort(all(ans));
    rep(i, ans.size()) {
        cout << ans[i] << '\n';
    }
}

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

long long int list[100][5001];
int main(void){
	int m = 10;
  	int base[] = {2, 3, 5, 7, 9, 11, 13, 17, 19, 23};
    int n;
    int i, j, k;
    char s[5001];
    scanf("%d", &n);
    scanf("%s", s);
	for(i = 0; i < n; i++){
    	s[i] -= 'a';
        s[i] += (char)1;
        if(s[i] <= 0){
            printf("errr");
        }
    }
    long long int mod = 9007199254740997;
    int left = 0;
    int right = n/2+1;
    int flag, mid;
    //lenを二分探索で求める
    //lenは，0以上，(文字列の長さ/2,を小数点以下切り捨てたもの)以下である
    while(right - left > 1){
        long long int hash[m];
		for(i = 0; i < m; i++){
	        hash[i] = 0;
		}
        mid = (left + right)/2;//文字列の長さ

        //以下midの検討

        //1:初期のhash値を計算
		for(j = 0; j < m; j++){
			for(i = 0; i < mid; i++){
				hash[j] += s[i];
				hash[j] %= mod;
				if(i == mid - 1){
					break;
				}
				hash[j] *= base[j];
				hash[j] %= mod;
			}
		}

        //2:10^(mid-1)%mod の値を求める
        long long int tmp[m];
		for(i = 0; i < m; i++){
	        tmp[i] = 1;
		}
		for(j = 0; j < m; j++){
			for(i = 0; i < mid - 1; i++){
				tmp[j] *= base[j];
				tmp[j] %= mod;
			}
		}

        //3:hash値のリストを作り，listに格納する
        //データ個数は，(文字列の長さn - 検証している文字列の長さmid)+1
		for(j = 0; j < m; j++){
        	list[j][0] = hash[j];
		}
		for(j = 0; j < m; j++){
			for(i = 0; i < n - mid; i++){
				hash[j] = (hash[j] - tmp[j] * s[i])*base[j] + s[i+mid];
				while(hash[j] < 0){
					hash[j] += mod; 
				}
				hash[j] %= mod;
				list[j][i + 1] = hash[j];
			}
		}
        //4:作成したhash値のリストにおいて，一致しているものがあるか検証
        //ただし，文字がかぶる箇所は検証しない
        flag = 0;
        for(i = 0; i < n - mid + 1; i++){
            for(j = i + mid; j < n - mid + 1; j++){
				int cnt = 0;
				for(k = 0; k < m; k++){
	            	if(list[k][i] == list[k][j]){
                   		cnt++;
               		}
				}
				if(cnt != m){
					continue;
				}
                //一致した場合
                flag = 1;
                break;
            }
            if(flag == 1){
              //printf("%d %d\n", i, j);
                break;
              
            }
        }

        //5:okなら(一致するものがあれば)flag = 1となっているので，r, lを更新
        if(flag == 1){
            left = mid;
        }else{
            right = mid;
        }
      	//printf("%d %d\n", mid, flag);
    }

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

Measured memory_bytes: 2124
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
typedef long long ll;
typedef long double ld;
const ll MOD = 998244353;
void add(ll& x, ll y) {
	x += y;
	if (x >= MOD) x -= MOD;
}
void sub(ll& x, ll y) {
	x -= y;
	if (x < 0) x += MOD;
}
int main() {
	int n;
	scanf("%d", &n);
	vector<ll> ndp(90001), dp(90001);
	vector<ll> ndp2(90001), dp2(90001);
	dp[0] = dp2[0] = 1;
	ll sum = 0;
	for (int i = 0; i < n; ++i) {
		int a; 
		scanf("%d", &a);
		sum += a;
		fill(ndp.begin(), ndp.end(), 0);
		fill(ndp2.begin(), ndp2.end(), 0);
		for (int s = 0; s <= i * 300; ++s) {
			add(ndp[s], dp[s]);
			add(ndp[s], dp[s]);
			add(ndp[s + a], dp[s]);
			add(ndp2[s], dp2[s]);
			add(ndp2[s + a], dp2[s]);
		}
//		for (int s = 0; s <= 10; ++s) db2(s, ndp[s]);
		swap(dp, ndp);
		swap(dp2, ndp2);
	}
	ll ans = 1;
	for (int i = 1; i <= n; ++i) ans = ans * 3 % MOD;
	for (int i = (sum + 1) / 2; i <= sum; ++i) {
//		db2(i, dp[i]);
		sub(ans, dp[i] * 3 % MOD);
	}
	if (sum % 2 == 0) {
		add(ans, dp2[sum / 2] * 3 % MOD);
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 3072
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int d = Integer.parseInt(sc.next());
        int n = Integer.parseInt(sc.next());

        // 主処理
        if (n == 100) {
            n++;
        }
        int result = (int) Math.pow(100, d) * n;

        // 出力
        System.out.println(result);
        sc.close();
    }
}


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

int main(){
  long int x, y;
  cin >> x >> y;
  if(x * y == 0){
    if(x > 0){
      cout << x + 1;
    }else if(x < 0){
      cout << -x;
    }else if(y < 0){
      cout << -y + 1;
    }else{
      cout << y;
    }
  }else if(x * y < 0){
    if(x + y > 0){
      cout << x + y + 1;
    }else{
      cout << -(x + y) + 1;
    }
  }else if(x > y){
    cout << x - y + 2;
  }else{
    cout << y - x;
  }
}

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

int main() {

  int A, B;
  cin >> A >> B;

  string S;
  cin >> S;

  string answer = "Yes";

  for (int i = 0; i < A; i++) {
    if ((S[i] - '0') < 0 || 9 < (S[i] - '0')) {
      answer = "No";
      break;
    }
  }

  if (answer == "Yes") {
    if (S[A] != '-') {
      answer = "No";
    }
  }

  if (answer == "Yes") {
    for (int i = 0; i < B; i++) {
      if ((S[A + 1 + i] - '0') < 0 || 9 < (S[A + 1 + i] - '0')) {
        answer = "No";
        break;
      }
    }
  }

  cout << answer << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

const int MOD = 1000000007;


int main(){
    string S, T; cin >> S >> T;
    int sn = S.size();
    int tn = T.size();

    //reverse(S.begin(),S.end());
    //reverse(T.begin(),T.end());
    int index = -1;
    rep(i,sn){
        if (i+tn-1 >= sn) break;
        bool isOK = true;
        rep(j,tn){
            if (S[i+j] == '?' || S[i+j] == T[j]) continue;
            isOK = false;
            break;
        }
        if(isOK) index = i; 
    }

    if (index == -1){
        cout << "UNRESTORABLE" << endl;
    }
    else{
        rep(i,tn){
            S[index+i] = T[i];
        }
        rep(i,sn){
            if (S[i] == '?'){
                S[i] = 'a';
            }
        }
        //reverse(S.begin(), S.end());
        cout << S << endl;
    }
    
}

Measured memory_bytes: 3512
// Problem: https://atcoder.jp/contests/dp/tasks/dp_i
#include <bits/stdc++.h>
#define fname "I"
#define bug(x) cerr << (#x) << " = " << (x) << '\n'
#define ll long long
#define ld long double
#define ull unsigned long long
#define ui unsigned int
#define REP0(i, n) for(int i = 0, _n = (n); i < _n; ++i)
#define REP1(i, n) for(int i = 1, _n = (n); i <= _n; ++i)
#define REPB0(i, n) for(int i = (n) - 1; i >= 0; --i)
#define REPB1(i, n) for(int i = (n); i > 0; --i)
#define FOR(i, a, b) for(int i = (a), _b = (b); i <= _b; ++i)
#define FORB(i, a, b) for(int i = (a), _b = (b); i >= _b; --i)
#define ARR0(a, n) {cerr <<(#a)<< ": ["; REP0(i, n) cerr<< ' ' << a[i] <<','; cerr<<"]\n";}
#define ARR1(a, n) {cerr <<(#a)<< ": ["; REP1(i, n) cerr<< ' ' << a[i] <<','; cerr<<"]\n";}
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define ins insert
#define ers erase
#define LB lower_bound
#define UB upper_bound
#define X first
#define Y second

using namespace std;
template<typename T, typename V>
inline void bugp(const pair<T, V> &x) {cerr << '{' << x.X << ", " << x.Y << "}\n";}
template<typename T, typename U, typename V>
inline void bugpp(const pair<T, pair<U, V> > &x) {cerr << '{' << x.X << ", {" << x.Y.X << ", " << x.Y.Y << "}}\n";}
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef pair<float, float> ff;
typedef pair<int, ii> iii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef pair<ll, ii> lii;
const int N = 3003;
int n;
double p[N], dp[N][N];

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n;
    dp[0][0] = 1;
    REP1(i, n) {
        cin >> p[i];
        dp[i][i] = dp[i - 1][i - 1]*p[i];
        REPB0(j, i) {
            dp[i][j] = dp[i - 1][j]*(1 - p[i]);
            if(j) dp[i][j] += dp[i - 1][j - 1]*p[i];
        }
    }
    double ans = 0;
    FORB(i, n, (n >> 1) + 1) ans += dp[n][i];
    cout << fixed << setprecision(10) << ans;
	return 0;
}


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

int main() {
  int64_t a,b,c,d;
  cin >> a >> b >> c >> d;
  vector<int64_t> v(4);
  v.at(0) = a*c;
  v.at(1) = a*d;
  v.at(2) = b*c;
  v.at(3) = b*d;
  sort(v.begin(), v.end());
  cout << v.at(3) << endl;
}

Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, A;
    cin >> N >> A;
    if (N % 500 <= A) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

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

int main(){
  int x[5],i;

  for(i=0;i<5;i++)
    scanf("%d",&x[i]);

  for(i=0;i<5;i++){
    if(x[i] == 0){
      printf("%d",i+1);
      exit(0);
    }
  }
}

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

int n,pos;
vector<int> pre,in,post;

void rec(int l,int r){
    if(l>=r) return;
    int root = pre[pos++];
    int m = distance(in.begin(), find(in.begin(),in.end(),root));
    rec(l,m);
    rec(m+1,r);
    post.push_back(root);
}

void solve(){
    pos = 0;
    rec(0,pre.size());
    for(int i=0;i<n;i++){
        if(i) cout << " ";
        cout << post[i];
    }
    cout << endl;
}

int main(){
    int num;
    cin >> n;
    
    for(int i=0;i<n;i++){
        cin >> num;
        pre.push_back(num);
    }
    
    for(int i=0;i<n;i++){
        cin >> num;
        in.push_back(num);
    }
    
    solve();
    
    return 0;
}



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

int main() {
	int n;cin >> n;
	int x = (int)((double)n/108.0d*100.0d);
	int nd = x*108/100;
	if(n==nd){
		cout << x << endl;
	} else {
		nd = (x+1)*108/100;
		if(n==nd){
		cout << x+1 << endl;
		} else {
			cout << ":(" << endl;	
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
  cin>>n;
  int a[n];int c=0;
  for(int i=0;i<n;i++)
  {cin>>a[i];}
 for(int i=1;i<n-1;i++)
 {if((a[i]<a[i-1])&&(a[i]>a[i+1]))
 c++;
 else if((a[i]>a[i-1])&&(a[i]<a[i+1]))
   c++;}
  cout<<c;
}

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

typedef pair<int,int> pi;
typedef vector<int> vi;
 
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define pb push_back

template<typename T> void max_self(T &a, T b) { a = max(a,b); return;}
template<typename T> void min_self(T &a, T b) { a = min(a,b); return;}
 
const int nax = 2e6 + 5;
const int mod = 1e9 + 7;

int modExpo(int a,int b,int c){
	if(b == 0) return 1;
	int answer = 1;
	while(b){
		if(b & 1) answer = ((answer % c) * (a % c)) % c;
		a = ((a % c) * (a % c)) % c;
		b /= 2; 
	}
	
	return answer;
}

int d;
int dp[10005][125][2];
string s;

int f(int index,int sum,int flag){
	int n = (int)s.size();
	if(index == n){
		if(sum == 0) return 1;
		return 0;
	}
	
	assert(index >= 0 && index <= 10000);
	assert(sum >= 0 && sum <= 100);
	assert(flag >= 0 && flag <= 1);
	
	if(dp[index][sum][flag] != -1) return dp[index][sum][flag];
	
	int limit = 9;
	if(flag) limit = s[index] - '0';
	
	int ans = 0;
	for(int i = 0; i <= limit; ++i){
		int newflag = flag;
		if(flag && i == limit) newflag = 1;
		else newflag = 0;
		ans = ((ans % mod) + f(index + 1,(sum + i) % d,newflag) % mod) % mod; 
	}
	
	dp[index][sum][flag] = ans;  
	return ans;
}

signed main(){
	
	std::ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int t = 1;
	//cin >> t;
	while(t--){
		cin >> s;
		cin >> d;
		
		memset(dp,-1,sizeof(dp));
		
		int res = f(0,0,1) - 1;
		if(res == -1) res += mod;
		cout << res;
	}
	
	return 0;
}


Measured memory_bytes: 23920
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String a = s.substring(0, 1);
    String b = s.substring(1, 2);
    String c = s.substring(2, 3);
    int ans = 700;
    if(a.equals("o")) {
    	ans += 100;
    }
    if(b.equals("o")) {
    	ans += 100;
    }
    if(c.equals("o")) {
    	ans += 100;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 35344
#include "bits/stdc++.h"
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
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; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, INF = 1e18;

string s;
int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	cin >> s;
	lint N = SZ(s);
	if (s[0] == s[1]) {
		cout << 1 << " " << 2 << endl;
		return 0;
	}
	REP(i, N - 2) {
		if (s[i] == s[i + 1] || s[i] == s[i + 2] || s[i+1] == s[i+2]) {
			cout << i + 1 << " " << i + 3 << endl;
			return 0;
		}
	}
	cout << -1 << " " << -1 << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <algorithm>
#include <climits>
#include <iostream>
using namespace std;
#define ll long long
#define vll vector<ll>
#define ot cout 
#define nl endl
#define fr(a,b) for(auto i=a;i<b;i++)
#define in cin 
#define pll pair<ll,ll>
#define f first
#define s second
#define vpll vector<pll>
#define ump unordered_map
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define IN(a,b) ((a).find(b)!=(a).end())
#define pb push_back
#define mkp make_pair
#define PI 3.14159265
#define INF 1e18
#define deb(x) if(ON) cout << #x <<" : " << x << endl
#define fast ios_base::sync_with_stdio(false)
#define io cin.tie(NULL),cout.tie(NULL)
#define ON !false
ll dx[]={0,-1,0,1};
ll dy[]={1,0,-1,0};
const ll mod=1e9+7;
ll i,j;
ll add(ll a,ll b){
    return  ((a%mod)+(b%mod)+mod)%mod;
}
ll mul(ll a,ll b){
    return ((a%mod)*(b%mod)+mod)%mod;
}
void pause(ll id){
    cout << "Waiting " << id << endl;
    cin >> id;
}


signed main(){
    fast;
    io;
    if(!true){
        freopen("in.txt","r",stdin);
        freopen("out.txt","w",stdout);
    }
    string s[2];
    cin >> s[0] >> s[1];
    bool flag=true;
    for(i=0;i<3;i++){
        flag=flag && s[0][i]==s[1][2-i];
    }
    if(flag){
        YES;
    }
    else{
        NO;
    }
   
    return 0;
}


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

using namespace std;

int main() {
	string s, t;
	vector<string> ans;
	cin >> s >> t;
  	if (s.size() < t.size()) {
		cout << "UNRESTORABLE" << endl;
		return 0;
	}
	for (int i = 0; i <= s.size() - t.size(); i++) {
		bool flag = true;
		for (int j = 0; j < t.size(); j++) {
			if (s[i+j] != '?' && s[i + j] != t[j]) {
				flag = false;
				break;
			}
		}
		if (flag) {
			string u = s;
			for (int j = 0; j < t.size(); j++) {
				u[i + j] = t[j];
			}
			for (int j = 0; j < u.size(); j++) {
				if (u[j] == '?')u[j] = 'a';
			}
			ans.push_back(u);
		}
	}
	if (!ans.empty()) {
		sort(ans.begin(), ans.end());
		cout << ans[0] << endl;
	}
	else cout << "UNRESTORABLE" << endl;
	return 0;
}

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

int main(){
  
    int h, m, s, S;
    cin >> S;
    h = S / 3600;
    m = S % 3600 / 60;
    s = S % 60%60;
    cout << h << ":" << m << ":" << s<< endl;

    return 0;

}


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

const int MAX_N = 100010;
using pii = pair<int, int>;


int N;
vector<int> G[MAX_N];

/*
  木の直径を求める。
  diameter(G)で、木の直径を計算する。
  diameter_pair(G)で、木の直径を構成する２点を求める。
 */
struct TreeDiameter{
    using pii = pair<int, int>;
    pii visit(int p, int v, vector<int> *G){
        pii r(0, v);
        for(int to : G[v]){
            if(to != p){
                pii t = visit(v, to, G);
                t.first += 1; // cost = 1
                if(r.first < t.first) r = t;
            }
        }
        return r;
    }

    pair<pii, pii> diameter_impl(vector<int> *G){
        pii r = visit(-1, 0, G);
        pii t = visit(-1, r.second, G);
        return make_pair(r, t);
    }

    int diameter(vector<int> *G){
        auto pp = diameter_impl(G);
        pii t = pp.second;
        return t.first;
    }

    pii diameter_pair(vector<int> *G){
        auto pp = diameter_impl(G);
        pii r = pp.first;
        pii t = pp.second;
        return pii(r.second, t.second);
    }
};


bool solve(int start, int p, int next, vector<int> &ans){
    // startから順番にシーケンスをみていく
    int deg_over = 0;
    int second = -1;
    for(int i = 0; i < (int)G[start].size(); i++){
        int to = G[start][i];
        if(to == p) continue;
        // 次数を確認する
        if(G[to].size() > 1){
            deg_over++;
            second = to;
        }
    }
    if(deg_over > 1){
        return false;
    }
    else{
        for(int i = 0; i < (int)G[start].size() - 1 - (p != -1); i++){
            ans.push_back(i + 1 + next);
        }
        ans.push_back(next);
        // end
        if(deg_over == 0){
            ans.push_back((int)G[start].size() - (p != -1) + next);
            return true;
        }
        else{
            return solve(second, start, next + (int)G[start].size() - (p != -1), ans);
        }
    }
    return false;
}

int main(){

    cin >> N;
    for(int i = 0; i < N - 1; i++){
        int v, w;
        cin >> v >> w;
        v--; w--;
        G[v].push_back(w);
        G[w].push_back(v);
    }
        
    // 木の直径を構成する２点を求める
    TreeDiameter td;
    pii p = td.diameter_pair(G);

    // p.firstか、p.secondから初めてシーケンスを作れるか調べる
    vector<int> tmp, ans;
    if(solve(p.first, -1, 1, tmp)){
        if(ans.size() == 0 || tmp < ans){
            ans = tmp;
        }
    }
    tmp.clear();
    if(solve(p.second, -1, 1, tmp)){
        if(ans.size() == 0 || tmp < ans){
            ans = tmp;
        }
    }

    if(ans.size() == 0)
        cout << -1 << endl;
    else{
        for(int a: ans){
            cout << a << " ";
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 16632
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pld pair<ld,ld>
#define all(v) v.begin(), v.end()
#define pi 3.1415926535897
using namespace std;

ld dist(pld A , pld B){
    return sqrt( (A.fi-B.fi)*(A.fi-B.fi)+(A.se-B.se)*(A.se-B.se) );
}

pld p1,p2;
ld a,b,h,m;

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> a >> b >> h >> m;

    ld ang1 = m*pi/30.0L;
    ld ang2 = h*pi/6.0L + m*pi/360.0L;
    p1 = { a*sin( ang1 ) , a*cos( ang1 ) };
    p2 = { b*sin( ang2 ) , b*cos( ang2 ) };

    cout << setprecision( 15 ) << fixed;
    cout << dist( p1 , p2 );

    return 0;
}


Measured memory_bytes: 4180
from collections import deque

H, W = map(int, input().split())
A = [list(input()) for i in range(H)]

q = deque()
for i in range(H):
    for j in range(W):
        if A[i][j] == '#':
            q.append((i, j))

ans = 0
while q:
    nq = deque()
    while q:
        h, w = q.popleft()
        if h > 0 and A[h - 1][w] == '.':
            A[h - 1][w] = '#'
            nq.append((h - 1, w))
        if h < H - 1 and A[h + 1][w] == '.':
            A[h + 1][w] = '#'
            nq.append((h + 1, w))
        if w > 0 and A[h][w - 1] == '.':
            A[h][w - 1] = '#'
            nq.append((h, w - 1))
        if w < W - 1 and A[h][w + 1] == '.':
            A[h][w + 1] = '#'
            nq.append((h, w + 1))
    if not nq:
        break
    q = nq
    ans += 1
print(ans)


Measured memory_bytes: 130268
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
using namespace std;

void Sol3()
{
	int X, N;
	cin >> X >> N;

	vector<int> input;
	unordered_map <int, bool> hsh_map;
	if (N == 0)
	{
		cout << X << endl;
		return;
	}

	for (int i = 0; i < N; i++)
	{
		int num;
		cin >> num;
		hsh_map[num] = true;
	}

	int X1 = X , X2 = X;
	while (hsh_map.find(X1) != hsh_map.end())
	{
		X1--;
	}
	while (hsh_map.find(X2) != hsh_map.end())
	{
		X2++;
	}

	int res1 = abs(X - X1);
	int res2 = abs(X - X2);
	if (res1 <= res2)
		cout << X1 << endl;
	else
		cout << X2 << endl;

}

int main()
{
    //Sol1();
    //Sol2();
    Sol3();
    //Sol4();
    //Sol5();
    //Sol6();
    //cin.get();
}


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

using namespace std;

map<int, int> M;

int main()
{
    int mx = 0, a, n;
    cin >> n;
    for(int i = 0; i < n ; i++){
        cin >> a;
        M[a] = M[a-1]+1;
        mx = max(mx, M[a]);
    }
    cout << n - mx << endl;
    return 0;
}


Measured memory_bytes: 9728
#!/usr/bin/env python3
import sys


def solve(x: int):

    ct = (x//11)*2
    m = x%11
    if(m > 6):
        ct += 2
    elif(1 <= m <= 6):
        ct += 1
    
    print(ct)

    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    x = int(next(tokens))  # type: int
    solve(x)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 100100100100100;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
#define fi first
#define se second
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c*d/gcd(c,d);}
int main(){
 ll n,m;
  cin>>n>>m;
  vector<P> a(n);
  for(int i=0;i<n;i++)cin>>a.at(i).fi>>a.at(i).se;
  sort(a.begin(),a.end());
  ll tmp=0,ans=0;
  for(int i=0;i<n;i++){
        tmp+=a.at(i).se;
        if(tmp<=m)ans+=a.at(i).fi*a.at(i).se;
        else ans+=a.at(i).fi*(a.at(i).se-(tmp-m));
        if(tmp>=m)break;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 1792
from itertools import accumulate

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

for _ in range(K):
  arr = [0]*(N+1)
  for i, a in enumerate(A):
    left = max(0, i-a)
    right = min(N, i+a+1)
    arr[left] += 1
    arr[right] -= 1
  
  A = list(accumulate(arr[:-1]))
  if all(a == N for a in A):
    break

print(*A, sep=" ")


Measured memory_bytes: 181116
//A
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		
		if ("ABC".equals(s)) {
			System.out.println("ARC");
		} else {
			System.out.println("ABC");
		}
	}
}

Measured memory_bytes: 35596
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <math.h>
#include <bits/stdc++.h>
#include <queue>
#include <map>

using namespace std;

#define INF (1ll<<60)
#define INFint (1<<30)
#define MOD 1000000007
#define BOUND 27182818284

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

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

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

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

// gcd
template<typename T>
T gcd(T a, T b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}

// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);
    return result;
}

template<typename T>
T lcm( T m, T n ){
    // 引数に0がある場合は0を返す
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;
    return ((m/gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}


int dx[5]={1,0,-1,0};
int dy[5]={0,1,0,-1};
// v.front() = -BOUND;
// v.back() = BOUND;

int main(){
    ll A,B;
    cin >> A >> B;
    char tile[100][100];

    for(int i=0; i<50; i++){
        for(int j=0; j<100; j++){
            tile[i][j]='#';
        }
    }

    for(int i=50; i<100; i++){
        for(int j=0; j<100; j++){
            tile[i][j]='.';
        }
    }

    for(int i=0; i<A-1; i++){
        tile[i/50*2][i%50*2]='.';
    }

    for(int i=0; i<B-1; i++){
        tile[99-i/50*2][i%50*2]='#';
    }
    
    cout << 100 << " " << 100<<endl;
    for(int i=0; i<100; i++){
        for (int j = 0; j < 100; ++j) {
            cout << tile[i][j];
        }
        cout << endl;
    }
    return 0;
}



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

int n;
int p[200000];

int main() {
	int i;
	int mmin = 11451419;
	int ans = 0;
	
	cin >> n;
	rep(i, n) {
		cin >> p[i];
		if (mmin > p[i]) {
			mmin = p[i];
			ans++;
		}
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
require 'matrix'


n, m= gets.split.map(&:to_i)

a = n.times.map do
      gets.split.map(&:to_i)
    end

b = m.times.map do
      gets.split.map(&:to_i)
    end

ma = Matrix.rows(a)
mb = Matrix.rows(b)
mc = ma * mb


mc.row_vectors.each {|row| puts row.to_a.join("\s")}


Measured memory_bytes: 7640
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define endl '\n'
#define ld long double
#define FOR(i,a,n) for (int i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (int i=(n);i>=(a);--i)
#define FI(i,n) for (int i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }

// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

// I am questioning life and universe and 
// everything else after looking at this

void solve(){   
    ll n,a,b,c,d; string s;
    cin>>n>>a>>b>>c>>d;

    cin>>s; s = '{'+s;

    bool flag = false;
    FOR(i,a,c-1) if(s[i] == '#' && s[i+1] == '#') flag = true;
    FOR(i,b,d-1) if(s[i] == '#' && s[i+1] == '#') flag = true;

    if(c == d) flag = true;

    if(s[a] == '#' || s[b] == '#' || s[c] == '#' || s[d] == '#') flag = true;
    if(flag){
        cout<<"No\n";
        return;
    }

    if(c>d){
        bool ff = false;
        FOR(i,b,d) if(s[i] != '#' && s[i-1] != '#' && s[i+1] != '#') ff = true;

        if(!ff) flag = true; 
    }

    if(flag) cout<<"No\n";
    else cout<<"Yes\n";
}   

signed main(){

   FastRead;    


    ll t;
    t = 1; 
    // cin>>t;
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}




Measured memory_bytes: 764
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
    int n; string s; cin >> n >> s;
    int dp[n+1][n+1] = {};
    for (int len = 1; len < n; len++)
        for (int i = n-len-1, j = n-1; i >= 0; i--, j--)
            if (s[i] == s[j]) dp[i][j] = min(len, 1 + dp[i+1][j+1]);
    cout << *max_element(dp[0], dp[0]+(n+1)*(n+1)) << endl;
}


Measured memory_bytes: 97920
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pii pair<ll, ll>
#define to second
#define cost first
typedef long long ll;
typedef long double ld;
using namespace std;

int dp[100005];
const int m = 1e9+7;

void add(int &a, int b) {
	a += b;
	if(a >= m) a -= m;
}
void sub(int &a, int b) {
	a -= b;
	if(a < 0) a += m;
}

int main()
{	
	int n, k;

	cin >> n>>k;

	dp[0] = 1;
	for(int i = 0; i < n; i++) {
		int lim;
		cin >> lim;
		std::vector<int> upd(k+5);

		for(int used = k; used >= 0; used--) {
			int l = used+1;
			int r = used + min(lim, k-used);
			int t = dp[used];

			if(l <= r) {
				add(upd[l], t);
				if(r+1 <= k) sub(upd[r+1], t);
			}

			//for(int j = used+1; j <= used+min(lim, k-used); j++) {
			//	dp[j] += dp[used];
			//}
		}
		int pre = 0;
		for(int i = 0; i <= k; i++) {
			add(pre, upd[i]);
			add(dp[i], pre);
		}
	}	

	cout << dp[k] % m << endl;

    return 0;
}

Measured memory_bytes: 1024
# from fractions import gcd
# from functools import reduce

# def convert(i):
# 	return int(i) - x

# def my_gcd(numbers):
# 	return reduce(gcd, numbers)

h, w = map(int, input().split())
# h1 = int(input())
# n = int(input())
x = []
for i in range(1, h + 1):
	x.append(list(map(int, input().split())))
# checks = []
# for i in range(0, h):
# 	checks.append([])
# 	for j in range(0, w):
# 		checks[i].append(False)

operations = []

def main():
	for i in range(0, h):
		for j in range(0, w):
			if x[i][j] % 2 == 1:
				if j < w - 1:
					x[i][j] -= 1
					x[i][j + 1] += 1
					operations.append([i + 1, j + 1, i + 1, j + 2])
				elif i < h - 1:
					x[i][j] -= 1
					x[i + 1][j] += 1
					operations.append([i + 1, j + 1, i + 2, j + 1])
	print(len(operations))
	for ope in operations:
		print(ope[0], ope[1], ope[2], ope[3])
			
main()


Measured memory_bytes: 30264
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<queue>
using namespace std;


struct p
{
    double x,y;
}l,r,c,cl,cr,mc;
void rato(p &a,double deg,p s)
{
    p n,m;
    n.x=a.x-s.x;
    n.y=a.y-s.y;
    m.x=n.x*cos(deg)+n.y*sin(deg);
    m.y=n.y*cos(deg)-n.x*sin(deg);
    a.x=a.x+m.x-n.x;
    a.y=a.y+m.y-n.y;
}
int main()
{
    int n,d;
    double pi=acos(-1);
    while(scanf("%d%d",&n,&d))
    {
        if(n==0 && d==0) break;
        l.x=-d*1.0;l.y=0.0;
        r.x=d*1.0;r.y=0.0;
        cl.y=d*1.0;cl.x=0.0;
        cr.y=-d*1.0;cr.x=0.0;
        c.x=c.y=0.0;
        int sl,sr,t;
        for(int i=0;i<n;i++)
        {
            scanf("%d%d%d",&sl,&sr,&t);
            if(sl==sr)
            {
                double dx,dy,bi;
                bi=1.0*sl*t/180*pi;
                dx=(cl.x-c.x)*bi/d;
                dy=(cl.y-c.y)*bi/d;
                l.x+=dx;l.y+=dy;
                cl.x+=dx;cl.y+=dy;
                r.x+=dx;r.y+=dy;
                cr.x+=dx;cr.y+=dy;
                c.x+=dx;c.y+=dy;
            }
            else
            {
                double dis=1.0*(sr*2*d)/(sl-sr);
                double bi;
                bi=1.0*(dis+d)/d;
                mc.x=(r.x-c.x)*bi+c.x;
                mc.y=(r.y-c.y)*bi+c.y;
                int spd=sl-sr;
                double ts,T=4.0*d*180/spd;
                int h=4*d*180;
                h=(t*spd)%h;
                ts=1.0*h/spd;
                double deg=ts/T*2*pi;
                rato(l,deg,mc);
                rato(r,deg,mc);
                rato(cl,deg,mc);
                rato(cr,deg,mc);
                rato(c,deg,mc);
            }
        }
        if(fabs(c.x)<1e-7) c.x=0.0;
        if(fabs(c.y)<1e-7) c.y=0.0;
        printf("%.5lf\n%.5lf\n",c.x,c.y);
    }
    return 0;
}

Measured memory_bytes: 1072