akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

template <typename T>
T mod_pow(T x, ll k, T m) {
	T res = 1;
	while (k) {
		if (k & 1) res = res * x % m;
		k >>= 1;
		x = x * x % m;
	}
	return res;
}

bool miller_rabin_test(ll n) {
	const static vector<ll> sprp = { 2 , 7 , 61 };
	if (n < 2) return false;
	ll d = n - 1, s = 0;
	while ((d & 1) == 0) d >>= 1, ++s;
	for (ll a : sprp) if (a <= n) {
		if (a == n) return true;
		if (mod_pow(a, d, n) != 1) {
			bool ok = true;
			for (ll r = 0; r < s; r++) {
				if (mod_pow(a, d << r, n) == n - 1) {
					ok = false;
					break;
				}
			}
			if (ok) return false;
		}
	}
	return true;
}

ll pollard_rho(ll n) {
	static mt19937 mt(random_device{}());
	if (n == 4) return 2;
	ll c = mt() % n;
	ll x = mt() % n, y = x, d = 1;
	while (d == 1) {
		x = (x * x + c) % n;
		y = (y * y + c) % n;
		y = (y * y + c) % n;
		d = __gcd(abs(x - y), n);
	}
	return d;
}

template <typename T>
vector<pair<T, int>> factorize(T n) {
	if (n <= 1) return{};
	vector<T> st = { n }, ps;
	while (!st.empty()) {
		T t = st.back(); st.pop_back();
		if (t <= 1) continue;
		if (miller_rabin_test(t)) {
			ps.push_back(t);
			continue;
		}
		T x;
		while (x = pollard_rho(t), x == t);
		st.push_back(x);
		st.push_back(t / x);
	}
	sort(ps.begin(), ps.end());
	vector<pair<T, int>> res;
	for (auto p : ps) {
		if (res.empty() || res.back().first != p) res.emplace_back(p, 1);
		else res.back().second++;
	}
	return res;
}

int main()
{
	int n;
	cin >> n;
	cout << n << ':';
	for (auto p : factorize(n)) {
		for (int i = 0; i < p.second; i++) cout << ' ' << p.first;
	}
	cout << endl;
	return 0;
}



Measured memory_bytes: 3216
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main(int argc, char* argv[])
{
    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    double dist = sqrt((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1));

    cout << setprecision(15) << dist << endl;
    return 0;
}


Measured memory_bytes: 3296
#include <stdio.h>
int main(void)
{
    int a,b,d,r;
    double f;
    scanf("%d%d",&a,&b);
    d=a/b;
    r=a%b;
    f=(double)a/b;
    if(a>=1&&a<=1000000000&&b>=1&&b<=1000000000)
    {
        printf("%d %d %.5lf\n",d,r,f);
    }
    return 0;
}


Measured memory_bytes: 2100
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <map>
#include <queue>
using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++) 

int main() {
    ll x;
    cin >> x;
    ll ans = 0;
    ll val = 100;
    while(1) {
        if(val >= x) {
            break;
        } 
        val = val+val*0.01;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define req(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define qer(i,a,n) for (int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

const int N=200000;
int x[N],y[N];
int main(){
    int n;cin>>n;rep(i,0,n)cin>>x[i]>>y[i];int ans=0;
    int MN=mod*2,MX=-mod*2;rep(i,0,n)MN=min(MN,x[i]+y[i]),MX=max(MX,x[i]+y[i]);ans=max(ans,MX-MN);
    MN=mod*2,MX=-mod*2;rep(i,0,n)MN=min(MN,x[i]-y[i]),MX=max(MX,x[i]-y[i]);ans=max(ans,MX-MN);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 5168
#include <bits/stdc++.h>
using namespace std;
 
using ll = int64_t;
constexpr ll mod = ll(1e9 + 7);
 
 class UnionFind {
  public:
   vector<ll> parent, size;
   vector<ll> n_white, n_black;
  
   UnionFind(ll n) {
     parent.resize(n);
     n_black.resize(n);
     n_white.resize(n);
     iota(parent.begin(), parent.end(), 0);
     size.resize(n, 1);
   }  
  
   ll Find(ll x) {
     return x == parent[x] ? x : parent[x] = Find(parent[x]);
   }
   bool Merge(ll x, ll y) {
     ll px = Find(x), py = Find(y);
     if (px == py) return false;
     if (size[px] < size[py]) swap(px, py);
     parent[py] = px;
     size[px] += size[py];
     n_black[px] += n_black[py];
     n_white[px] += n_white[py];
     return true;
   }
 };

int main () {
  ios::sync_with_stdio(0); cin.tie(0);
 
  // cin >> TT;
  ll h,w;
  cin >> h >> w;
  vector<string> M(h);
  for (auto& aa : M) cin >> aa;
  UnionFind uf(h*w);
  for (ll y = 0; y < h; ++y) {
    for (ll x = 0; x < w; ++x) {
      if (M[y][x] == '#') {
        ++uf.n_black[y*w+x];
      } else {
        ++uf.n_white[y*w+x];
      }
    }
  }

  for (ll y = 0; y < h; ++y) {
    for (ll x = 0; x < w; ++x) {
      for (ll dy = -1; dy <= 1; ++dy) {
        for (ll dx = -1; dx <= 1; ++dx) {
          if (abs(dy) + abs(dx) != 1) continue;
          if (y+dy < h && y+dy >= 0 && x+dx < w && x+dx >= 0 && M[y+dy][x+dx] != M[y][x]) {
            uf.Merge(y*w+x, (y+dy)*w + x+dx);
          }
        }
      }
    }
  }
  vector<bool> seen(h*w);
  ll ans = 0;
  for (ll y = 0; y < h; ++y) {
    for (ll x = 0; x < w; ++x) {
      ll p = uf.Find(y*w+x);
      if (!seen[p]) {
        ans += uf.n_black[p] * uf.n_white[p];
        seen[p] = true;
      }
    }
  }
  cout << ans << endl;

}


Measured memory_bytes: 8460
def main():
    W, H = (int(i) for i in input().split())
    while H != 0 or W != 0:
        c = [[int(i) for i in input().split()] for j in range(H)]
        seen = [[False for i in range(W)] for j in range(H)]
        def dfs(G,h,w,seen,H,W):
            todo = []
            hws = ((1,0),(0,1),(-1,0),(0,-1),(1,1),(1,-1),(-1,1),(-1,-1))
            seen[h][w] = True
            todo.append((h,w))
            # todoが非空の間繰り返し
            while todo:
                h, w = todo[-1]
                for dh,dw in hws:
                    next_h = h + dh
                    next_w = w + dw
                    if not ((0 <= next_h < H) and (0 <= next_w < W)): continue
                    if G[next_h][next_w] == 0: continue
                    if seen[next_h][next_w]: continue
                    seen[next_h][next_w] = True
                    todo.append((next_h,next_w))
                    break
                else:
                    todo.pop()
        ans = 0
        for i in range(H):
            for j in range(W):
                if c[i][j] == 0 or seen[i][j]: continue
                dfs(c,i,j,seen,H,W)
                ans += 1
        print(ans)
        W, H = (int(i) for i in input().split())

if __name__ == '__main__':
    main()


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

int main() {
  int n;
  cin>>n;
  int vec[n],vecb[n];
  for(int i=0;i<n;i++){
    cin>>vec[i];
    vecb[i]=vec[i];
  }
  sort(vecb,vecb+n);
  map<int,int> ma;
  for(int i=0;i<n;i++){
    ma[vecb[i]]=i%2;
  }
  int ans=0;
  for(int i=0;i<n;i++){
    if(ma[vec[i]]!=i%2){
      ans++;
    }
  }
  cout<<ans/2<<endl;
  return 0;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n; cin >> n;
	cout << n*n << endl;

}



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

using namespace std;

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define FOR(i,m,n) for(int i=(m) ; i<(n) ; i++)
#define FORR(i,m,n) for(int i=(m) ; i>=(n) ; i--)
#define ALL(x) (x).begin(),(x).end()

int GCD(int a,int b){ return b ? GCD(b,a%b) : a ;}
int LCM(int a,int b){ return a*b / GCD(a,b) ;}

typedef long long ll;
typedef unsigned long long ull;

const int INF = 1e9;

int main(){
   string s;
   cin >> s;
   for(int i=0;i<s.size();i++){
      if(count(ALL(s),s[i]) % 2 != 0){
         cout << "No";
         return 0;
      }
   }
   cout << "Yes";
   return 0;
}

Measured memory_bytes: 256
// 写経AC

#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;

//
const long long INF = 1LL << 60;
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false;}

int N;
int K;
long long h[100010];

//DP table
long long dp[100010];

void input(void){
    cin >> N;
    cin >> K;
    for(int i=0; i< N; i++){
        cin >> h[i];
    }
    return;
}

void init(void){
    for(int i=0; i< 100010; i++){
        dp[i]= INF;
    }
    return;
}

void solve(){
    //初期条件
    dp[0] = 0;

    // dp
    for(int i=1; i<N; i++){
        for(int j=1; j<=K; j++){
            if( i<j){
                break;
            }
            chmin(dp[i], dp[i-j]+abs(h[i]-h[i-j]));

//            for(int k=0; k<N;k++){
//                cout << " " << dp[k] ;
//            }
//            cout << endl;
        }
//        chmin(dp[i], dp[i-1]+abs(h[i]-h[i-1]));
//        if(i>1){
//            chmin(dp[i], dp[i-2]+abs(h[i]-h[i-2]));
//        }
    }

    cout << dp[N-1] << endl;
    return;
}

int main(void){
    input();
    init();
    solve();
    return 0;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
#define int long long
#define all(c) (c).begin(), (c).end()
#define cpresent(c,x) ((c).find(x) != (c).end()) 
#define vpresent(c,x) (find(all(c),x) != (c).end())
#define endl '\n'
#ifdef LOCAL
#include "/home/iggaboi/Desktop/CP/debug.h"
#else
#define debug(x...)
#endif
using namespace std;

int n, k;

void solve(){
    cin >> n >> k;
    vector<int> ara(n);
    for(int& it : ara)
        cin >> it;
    sort(all(ara));
    int sum = 0;
    for(int i = 0; i < k; ++i)
        sum += ara[i];
    cout << sum << endl;
}

int32_t main(){
	ios_base::sync_with_stdio(false),cin.tie(nullptr);
	// int t; cin >> t;
	// while(t--)
		solve();
	return 0;
}


Measured memory_bytes: 3664
open System

[<EntryPoint>]
let main _argv =
    let inputNums = stdin.ReadLine().Split(' ') |> Array.map int |> Array.toList
    let N = inputNums.[0]
    let A = inputNums.[1]
    let B = inputNums.[2]
    
    [ for i in [1 .. N] do
        let total = i.ToString().ToCharArray(0, i.ToString().Length) |> Array.toList |> List.map string |> List.map int |> List.sum
        yield if total >= A && total <= B then i else 0]
        |> List.sum
        |> printfn "%A"
    0

Measured memory_bytes: 18648
#include <bits/stdc++.h>
using namespace std;
int main(void) {
  string s;
  cin >> s;

  int g, p, ans;
  g = p = ans = 0;
  for (int i = 0; i < s.size(); i++) {
    if (g == p) {
      g++;
      if (s[i] == 'p') ans--;
    } else if (s[i] == 'g') {
      p++;
      ans++;
    } else {
      p++;
    }
  }
  cout << ans << endl;
}

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

using namespace std;
int input(){
    int res = 0; char c = ' ';
    while (c < '0') c = getchar();
    while (c >= '0') res = res * 10 + (c - '0'), c = getchar();
    return res;
}
const int N = 2e5 + 1;

int b[N << 1];
int main(){
    int n = input(), start = N, l = N, r = N - 1;
    for (int i = 0; i < n; ++ i){
        if (i & 1)
            b[-- l] = input();
        else
            b[++ r] = input();
    }
    if (n & 1)
        for (int i = r; i >= l; -- i)
            cout << b[i] << " ";
    else
        for (int i = l; i <= r; ++ i)
            cout << b[i] << " ";
}


Measured memory_bytes: 2944
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func nextLine(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func main() {
	totalMoney := 0.0
	rate := 380000.0
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n, _ := strconv.Atoi(nextLine(sc))
	for i := 0; i < n; i++ {
		x, _ := strconv.ParseFloat(nextLine(sc), 64)
		u := nextLine(sc)

		if u == "JPY" {
			totalMoney += x
		} else {
			totalMoney += x * rate
		}
	}
	fmt.Println(totalMoney)
}


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

// TYPEDEF
// ----------------------------------------
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pair;
typedef vector<ll> vll;
typedef vector<vector<ll>> Graph;
typedef vector<string> vs;
typedef vector<pair<ll, ll>> Pll;
typedef queue<ll> qll;

// REPEAT
// ----------------------------------------
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REPA(i,a) for(ll i=0;i<(ll)(a.size());i++);
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define COUT(a) cout << (a) << endl;
#define ENDL(a) cout << endl;
#define COUTA(i,a) for(ll i=0;i<(ll)(a.size());i++) {cout << (a)[i] << " ";} cout << endl;

// UTIL
// ----------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())

// DEBUG
// ----------------------------------------
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

// BIT FLAG
// ----------------------------------------
const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000
const unsigned int BIT_FLAG_8 = (1 << 8); // 0000 0001 0000 0000
const unsigned int BIT_FLAG_9 = (1 << 9); // 0000 0010 0000 0000
const unsigned int BIT_FLAG_10 = (1 << 10); // 0000 0100 0000 0000
const unsigned int BIT_FLAG_11 = (1 << 11); // 0000 1000 0000 0000

// CONST
// ----------------------------------------
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI=3.14159265358979323846; // or M_PI
constexpr int MOD = 1000000007;


void Main() {
  ll a, b;
  cin >> a >> b;
  if (a < 10 and b < 10) {
    COUT(a * b);
  }
  else {
    COUT(-1)
  }
}

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

/*

3 2
*/


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

int main() {

    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;

    if (x-r>=0 && x+r<=W && y-r>=0 && y+r<=H) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3108
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        final int N = sc.nextInt();
        final int M = sc.nextInt();
        final int K = sc.nextInt();
        
        final long[] A = new long[N];
        final long[] B = new long[M];
        
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextLong();
        }
        for (int j = 0; j < M; j++) {
            B[j] = sc.nextLong();
        }
        
        long total = 0;
        int j = 0;
        
        while (j < M) {
            if (total + B[j] <= K) {
                total += B[j];
                j++;
            } else {
                break;
            }
        }
        
        int max = j;
        int i = 0;
        
        while (i < N) {
            total += A[i];
            i++;
            
            while (0 < j && K < total) {
                j--;
                total -= B[j];
            }
            if (K < total) {
                break;
            }
            if (max < i + j) {
                max = i + j;
            }
        }
        
        System.out.println(max);
    }
}


Measured memory_bytes: 63064
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int>P;

int main(){
  int N,K;
  cin>>N>>K;
  if(!(0<=K && K<=(N-2)*(N-1)/2)){
    cout<<-1<<endl;
    return 0;
  }
  
  
  vector<P>ans;
  //ウニの構築
  for(int i=2;i<=N;i++){
    ans.push_back(pair<int,int>(1,i));
  }
  //ちょうどK個になるよう減らす
  vector<P>ve;
  for(int i=2;i<=N;i++){
    for(int j=i+1;j<=N;j++){
      ve.push_back(pair<int,int>(i,j));
    }
  }
  for(int i=0;i<(N-2)*(N-1)/2-K;i++){
    ans.push_back(ve[i]);
  }
  
  cout<<ans.size()<<endl;
  for(int i=0;i<ans.size();i++){
    cout<<ans[i].first<<" "<<ans[i].second<<endl;
  } 
  return 0;
}




Measured memory_bytes: 3704
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

int main() {
	long long int n,m,a,b,c,d,e;
	long double z,w;
	string str;
	char ch;
	long long int x[130]={};
	cout << fixed << setprecision(10);
	cin>>a>>b;
	cout<<(a-1)*(b-1);



	cout<<endl;
} 


Measured memory_bytes: 256
// Palindromic Number
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;


int main()
{
  int N, L;
  cin >> N >> L;
  vector<string> s;
  string buff, ssum;
  for (int i = 0; i < N; i++) {
    cin >> buff;
    s.push_back(buff);
  }
  sort(s.begin(), s.end());
  for (auto it = s.begin(); it != s.end(); ++it) {
    ssum+=*it;
  }
  cout << ssum << endl;
  return 0;
}


Measured memory_bytes: 256
use std::io::{self, Stdin};
use std::str::{self, FromStr};
use std::error::Error;

fn exec() {
    let mut sc = Scanner::new();
    let n: usize = sc.ne();
    let mut a: Vec<i64> = (0..3 * n).map(|_| sc.ne()).collect();
    a.sort();
    let mut sum = 0;
    for i in 0..n {
        sum += a[n + i * 2];
    }
    println!("{}", sum);
}

fn main() {
    const STACK: usize = 16 * 1024 * 1024;
    let _ = std::thread::Builder::new()
        .stack_size(STACK)
        .spawn(|| { exec(); })
        .unwrap()
        .join()
        .unwrap();
}

#[allow(dead_code)]
struct Scanner {
    stdin: Stdin,
    id: usize,
    buf: Vec<u8>,
}

#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner {
        Scanner {
            stdin: io::stdin(),
            id: 0,
            buf: Vec::new(),
        }
    }
    fn next_line(&mut self) -> Option<String> {
        let mut res = String::new();
        match self.stdin.read_line(&mut res) {
            Ok(0) => None,
            Ok(_) => Some(res),
            Err(why) => panic!("error in read_line: {}", why.description()),
        }
    }
    fn next<T: FromStr>(&mut self) -> Option<T> {
        while self.buf.len() == 0 {
            self.buf = match self.next_line() {
                Some(r) => {
                    self.id = 0;
                    r.trim().as_bytes().to_owned()
                }
                None => return None,
            };
        }
        let l = self.id;
        assert!(self.buf[l] != b' ');
        let n = self.buf.len();
        let mut r = l;
        while r < n && self.buf[r] != b' ' {
            r += 1;
        }
        let res = match str::from_utf8(&self.buf[l..r]).ok().unwrap().parse::<T>() {
            Ok(s) => Some(s),
            Err(_) => {
                panic!("parse error, {:?}",
                       String::from_utf8(self.buf[l..r].to_owned()))
            }
        };
        while r < n && self.buf[r] == b' ' {
            r += 1;
        }
        if r == n {
            self.buf.clear();
        } else {
            self.id = r;
        }
        res
    }
    fn ne<T: FromStr>(&mut self) -> T {
        self.next::<T>().unwrap()
    }
}


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

void solve(long long H, long long W, long long N, vector<long long> a, vector<long long> b){
	map< pair<int,int> , int> s;
	vector< pair<int,int> > l;
	for(int i = 0 ; i < N ; i++){
		a[i]--;
		b[i]--;
		
		s[{a[i],b[i]}] = true;
		for(int j = 0 ; j < 3 ; j++){
			for(int k = 0 ; k < 3 ; k++){
				int y = a[i]-j;
				int x = b[i]-k;
				if( x >= 0 and y >= 0 and x + 2 < W and y + 2 < H ){
					l.push_back({y,x});
				}
			}
		}
	}
	sort(l.begin(),l.end());
	l.erase(unique(l.begin(),l.end()),l.end());
	long long memo[10] = {};
	
	for(int i = 0 ; i < l.size() ; i++){
		int tot = 0;
		for(int j = 0 ; j < 3 ; j++){
			for(int k = 0 ; k < 3 ; k++){
				int y = l[i].first + j;
				int x = l[i].second + k;
				if( s.count({y,x}) ) tot++;
			}
		}
		memo[tot]++;
	}
	memo[0] = 0;
	long long sum = 0;
	for(int i = 1 ; i < 10 ; i++){
		sum += memo[i];
	}
	memo[0] = (H-2) * (W-2) - sum;
	
	for(int i = 0 ; i < 10 ; i++) cout << memo[i] << endl;
}



int main(){	
	ios::sync_with_stdio(false);
	long long H;
	long long N;
	long long W;
	cin >> H;
	cin >> W;
	cin >> N;
	vector<long long> b(N-1+1);
	vector<long long> a(N-1+1);
	for(int i = 0 ; i <= N-1 ; i++){
		cin >> a[i];
		cin >> b[i];
	}
	solve(H, W, N, a, b);
	return 0;
}


Measured memory_bytes: 16744
#include<bits/stdc++.h>
using namespace std;
#define N 808
#define pii pair<int,int>
#define tri pair<pii,int>
#define mp make_pair
#define F first
#define S second 

int n,m,k,ans;
char s[N][N];
bool vis[N][N];
queue<tri> q;
bool inRange(int x,int y)
{
	return x>=0 && x<n && y>=0 && y<m && s[x][y]!='#';
}

int main()
{
	
	cin>>n>>m>>k;
	for(int i=0;i<n;i++)
	{
		cin>>s[i];
		for(int j=0;j<m;j++)
			if(s[i][j]=='S')
			{
				q.push(mp(mp(i,j),0));
				vis[i][j]=1;
			}
	}
	
	ans=1e9;
	while(!q.empty())
	{
		int x=q.front().F.F;
		int y=q.front().F.S;
		int step=q.front().S;
		q.pop();
		ans=min(ans,min(min(x,y),min(n-1-x,m-1-y)));
		for(int dx=-1;dx<=1;dx++)
		for(int dy=-1;dy<=1;dy++)
		{
			if(abs(dx)+abs(dy)!=1) continue;
			if(!inRange(x+dx,y+dy)) continue;
			if(vis[x+dx][y+dy]) continue;
			if(step==k) continue;
			vis[x+dx][y+dy]=1;
			q.push(mp(mp(x+dx,y+dy),step+1));
		}
	}
	cout<<(ans+k-1)/k+1<<'\n';
	
	return 0;
}

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



int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL) ; 
	int a , b ; 
  cin >> a >> b ; 
  cout << a*b; 
	

	
	return 0 ;
}

Measured memory_bytes: 3652
s = list(input())
q = int(input())
judge = 1
front = []
back = []
for i in range(q):
  a = list(map(str,input().split()))
  if int(a[0]) == 1:
    judge *= -1
  else:   
    if (int(a[1]) == 1 and judge == 1) or (int(a[1]) == 2 and judge == -1):
      front.append(a[2])
    else:
      back.append(a[2])
ans = front[::-1] + s + back
if judge == -1:
  ans.reverse()
print(*ans, sep='')

Measured memory_bytes: 14176
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
LL p = 1000000007ll;

int main(void)
{
  LL n, k;
  cin >> n >> k;
  vector<vector<LL>> hope(k*2,vector<LL>(k*2));
  REP(i,n) {
    LL x,y;
    string s;
    cin >> x >> y >> s;
    if(s=="B") y+=k;
    ++hope[x%(k*2)][y%(k*2)];
  }
  vector<vector<LL>> imos(k*4+1,vector<LL>(k*4+1));
  REP(i,k*4+1) REP(j,k*4+1) imos[i][j]=hope[i%(k*2)][j%(k*2)];
  REP(i,k*4+1) REP(j,k*4) imos[i][j+1]+=imos[i][j];
  REP(i,k*4) REP(j,k*4+1) imos[i+1][j]+=imos[i][j];
  LL answer = 0;
  REP(i,k*2) {
    REP(j,k*2) {
      answer = max(answer,
                   imos[i+k][j+k]*2 - imos[i+k][j] - imos[i][j+k] + imos[i][j] +
                   imos[i+k*2][j+k*2] - imos[i+k*2][j+k] - imos[i+k][j+k*2]);
    }
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 156800
s = list(str(input()))
t = list(str(input()))

ss = s[::-1]
tt = t[::-1]
ss.sort()
tt.sort()

if(min(s) < max(t) or (len(s) < len(t) and ss == tt[:len(s)])):
    print("Yes")
else:
    print("No")

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

using namespace std;

typedef long long ll;
typedef pair< ll, ll > pll;
typedef pair< int, int > pii;

const double pi = 3.14159265358979323846;

#define MOD 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define TG0 get< 0 >
#define TG1 get< 1 >
#define TG2 get< 2 >
#define F first
#define S second
#define VL vector< ll >

// to_string(123)
// atoi("123"); atoi(s.c_str());
// "abc".size()
// s.find('+') == string::npos

string s;

string dfs(string str, int total, int i) {
  // cout << str << " t:" << total << endl;
  if (4 <= i) {
    if (total == 7) {
      return str;
    } else {
      return "";
    }
  }

  int n = s[i] - '0';
  string tmp;
  tmp = dfs(str + "+" + s[i], total + n, i + 1);
  if (tmp != "") {
    return tmp;
  }

  tmp = dfs(str + "-" + s[i], total - n, i + 1);
  if (tmp != "") {
    return tmp;
  }

  return "";
}
// -----------------------------------------------------------------------------
// main
// -----------------------------------------------------------------------------
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> s;

  int n = s[0] - '0';
  string r = dfs(to_string(n), n, 1);

  cout << r << "=7" << endl;

  return 0;
}


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

for i in range(k):
    if i % 2 == 0:
        if a % 2 == 1:
            a -= 1
            a //= 2
            b += a
        else:
            a //= 2
            b += a
    else:
        if b % 2 == 1:
            b -= 1
            b //= 2
            a += b
        else:
            b //= 2
            a += b
print(a,b)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;



//void merge
//
//void split(int array [] , int l ,int r)
//{
//    if(l<r)
//    {
//
//        int mid=(l+r)/2;
//
//        split(array , l , mid);
//        split(array , mid+1 , r);
//
//    }
//
//}
//
//int main()
//{
////    freopen("C:\\Users\\Dell\\CLionProjects\\untitled6\\AAA.txt", "r", stdin);
//
//
//    int n;
//    cin>>n;
//
//    int arr[n];
//
//    for(int i=0 ; i<n ;i++)
//    {
//        cin>>arr[i];
//    }
//
//    split(arr,0,n);
//
//}


//void printDivisors(int n)
//{
//    for(int i=1 ; i<= sqrt(n) ; i++)
//    {
//        if(n%i==0)
//        {
//            if(n/i==i)
//            {
//                printf("%d",i);
//                puts("");
//            } else
//            {
//                printf("%d\n%d",i,n/i);
//                puts("");
//            }
//        }
//    }
//}
//void printPrimes(int n)
//{
//    bool arr[n+1];
//    memset(arr,true, sizeof(arr));
//
//    for(int i=2 ; i*i <=n ; i++)
//    {
//        if(arr[i]== true)
//        {
//            for(int j=i*i ; j<=n ; j+=i)
//            {
//                arr[j]= false;
//            }
//        }
//    }
//    for(int ii=2 ;ii<=n ; ii++)
//    {
//        if(arr[ii]== true)
//        {
//            printf("%d ",ii);
//
//        }
//    }
//
//}

int n,ans;
string str;

int main()
{

    ios::sync_with_stdio(false);
    cin.tie(0);

    cin>>n>>str;

    char tst=0;

    for(int i=0 ; i<n ; i++)
    {
        if(str[i] != tst)
        {
            ans++;
            tst=str[i];
        }

    }

    cout<<ans;



}

Measured memory_bytes: 512
import sys
# 許容する再帰処理の回数を変更
sys.setrecursionlimit(10**5+10)
# input処理を高速化する
input = sys.stdin.readline

node_num, path_num = map(int, input().split())
graph = [[] for _ in range(node_num)]

for i in range(path_num):
    from_node, to_node = map(int, input().split())
    graph[from_node - 1].append(to_node - 1)
#print(graph)

#dp[i]はiを始点としたときの経路長の最大値
dp = [-1] * node_num

def rec(v):
    #print(v)
    #print(dp)
    if dp[v] > -1:
        return dp[v]
    else:
        dp[v] = 0
        for nv in graph[v]:
            dp[v] = max(dp[v], rec(nv) + 1)
        return dp[v]

ans = 0
for node in range(node_num):
    ans = max(ans, rec(node))
print(ans)

Measured memory_bytes: 59056
#include <iostream>
#include <math.h>
#include <cstdlib>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <stdio.h>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;

pair <int,int> T_z[500100], T_or[500100];
int T_l[500100], T_najb[500100], tree[1048576], sts[500100];

bool comparison(const pair<int,int> &a,const pair<int,int> &b){
    return ((a.first>b.first)||((a.first==b.first)&&(a.second>b.second)));
}
void wstaw(int x, int indx, int drz[])
{
    drz[indx]=x;
    while (indx!=1)
    {
        indx/=2; drz[indx]=drz[indx*2]+drz[indx*2+1];
    }
}
int suma_prz(int l, int p, int drz[])
{
    if (l==p) return drz[l];
    if (l/2==p/2) return drz[l/2];
    int res=drz[l]+drz[p];
    if (l%2==0) res+=drz[l+1];
    if (p%2==1) res+=drz[p-1];
    while (l/2/2!=p/2/2)
    {
        l/=2; p/=2;
        if (l%2==0) res+=drz[l+1];
        if (p%2==1) res+=drz[p-1];
    }
    return res;
}
int su_bin(int p1, int p2, int poc, int kon,  pair <int,int> T_wys[])
{
    int res, sr;
    while (poc<=kon)
    {
    sr=(poc+kon)/2;
    if (T_wys[sr].first<p1) {res=sr; kon=sr-1; continue;}
    if ((T_wys[sr].first==p1)&&(T_wys[sr].second<=p2)) {res=sr; kon=sr-1; continue;}
    poc=sr+1;
    }
    return res;
}

int main()
{
    ios_base::sync_with_stdio(0);
    int n, q; cin>>n>>q;
    for (int i=0;i<n;i++) cin>>T_l[i];
    for (int i=0;i<q;i++)
    {
    cin>>T_z[i].first>>T_z[i].second;
    T_or[i].first=T_z[i].first; T_or[i].second=T_z[i].second;
    }
    sort(T_z, T_z+q, comparison);
    int pot;
    for (int i=1;;i=i*2)
    {
        if (i>=n) { pot=i; break; }
    }
    int kt_q=0; bool prz=false;
    for (int i=n-1;i>=0;i--)
    {
       if (prz) break;
       if (T_najb[T_l[i]]!=0) wstaw(0, pot+T_najb[T_l[i]], tree);
       wstaw(1, pot+i, tree);
       T_najb[T_l[i]]=i;
       while (T_z[kt_q].first==i+1)
       {
           sts[kt_q]=suma_prz(T_z[kt_q].first+pot-1, T_z[kt_q].second+pot-1, tree);
           kt_q++;
           if (kt_q==q)  {prz=true; break;}
       }
    }
    for (int i=0;i<kt_q;i++)
    {
        cout<<sts[su_bin(T_or[i].first,T_or[i].second, 0, kt_q, T_z)]<<"\n";
    }

}


Measured memory_bytes: 21404
using System;

namespace A___Can_t_Wait_for_Holiday
{
    class Program
    {
        static void Main(string[] args)
        {
            var s=Console.ReadLine();
            if(s=="SUN")
            {
                Console.WriteLine(7);
            }
            else if(s=="MON")
            {
                Console.WriteLine(6);
            }
            else if(s=="TUE")
            {
                Console.WriteLine(5);
            }
            else if(s=="WED")
            {
                Console.WriteLine(4);
            }
            else if(s=="THU")
            {
                Console.WriteLine(3);
            }
            else if(s=="FRI")
            {
                Console.WriteLine(2);
            }
            else
            {
                Console.WriteLine(1);
            }
        }
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <cassert>
#include <limits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <array>
#include <map>
#include <set>
#include <deque>
#include <list>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cstring>
#include <bitset>
#include <stack>
#include <queue>

#define MOD (1e9 + 7);
#define PI (3.14159265358979323846)

using ll = int64_t;
using ull = uint64_t;

using namespace std;

[[maybe_unused]] static auto __x = [](){ios_base::sync_with_stdio(0); cin.tie(0);};

int main() {
    int r;
    cin >> r;
    cout << (3 * r * r);
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		int count = 0;
		
		for(int i = a; i <= b; i++) {
			if ( (c % i) == 0 ) {
				count++;
			}
			
		}
		
		System.out.println( count );

	}
}

Measured memory_bytes: 17356
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>

int main(void){
    int N;
    int cnt = 0;
    std::vector<std::string> S;
    std::cin >> N;

    for(int i=0;i<N;i++){
        std::string _S;
        std::cin >> _S;
        S.emplace_back(_S);
    }

    std::sort(S.begin(), S.end());

    std::string tmp = "\n";
    for(auto s : S){
        if(tmp!=s) cnt++;
        tmp = s;
    }

    std::cout << cnt << std::endl;

    return 0;
}

Measured memory_bytes: 11600
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5;
vector<int> adj[N];
int val[N];
void dfs(int s, int p) {
  for (int nbr : adj[s]) {
    if (nbr != p) {
      val[nbr] += val[s];
      dfs(nbr, s);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  int n, q;
  cin >> n >> q;
  for (int i = 1; i < n; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  while (q--) {
    int p, x;
    cin >> p >> x;
    p--;
    val[p] += x;
  }
  dfs(0, -1);
  for (int i = 0; i < n; i++)
    cout << val[i] << ' ';
  return 0;
}

Measured memory_bytes: 27880
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1e18;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

void solve(){
   int n;
   cin >> n;
   vector<int> v;
   set<int> s;
   for(int i = 0; i < n; i++){
	  int x;
	  cin >> x;
	  v.push_back(x);
	  s.insert(x);   
	}
  for (auto i = s.begin(); i != s.end(); i++) {
		if (i != s.begin())cout << ' ';
		cout << *i;
	}cout << endl;
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}



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

const int MAX_N=1e3+5;

string s1,s2;

int dp[MAX_N][MAX_N];


int lcs(int i,int j){
	if(i==s1.size() || j==s2.size())return 0;
	if(dp[i][j]!=-1)return dp[i][j];
	if(s1[i]==s2[j])return dp[i][j]=lcs(i+1,j+1)+1;
	return dp[i][j]=max(lcs(i+1,j),lcs(i,j+1));
}

int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		s1.clear();s2.clear();
		for(int j=0;j<MAX_N;j++)fill(dp[j],dp[j]+MAX_N,-1);
		cin>>s1>>s2;
		cout<<lcs(0,0)<<endl;
	}
}

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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF = 1e9;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

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

    int H, W;
    cin >> H >> W;
    rep(y, H) {
        rep(x, W) {
            string S; cin >> S;
            if (S == "snuke") {
                cout << (char)(x + 'A') << (y+1) << endl;
                return 0;
            }
        }
    }
}



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

typedef long long ll;

int main() {
  ll X,Y,Z; cin >> X >> Y >> Z;
  int K; cin >> K;
  ll A[1010],B[1010],C[1010];
  for ( int i = 0; i < X; i++ ) cin >> A[i];
  for ( int i = 0; i < Y; i++ ) cin >> B[i];
  for ( int i = 0; i < Z; i++ ) cin >> C[i];
  if ( X*Y*Z < 3000 ) {
    vector<ll> ABC;
    for ( int i = 0; i < X; i++ ) {
      for ( int j = 0; j < Y; j++ ) {
	for ( int k = 0; k < Z; k++ ) {
	  ABC.push_back(A[i]+B[j]+C[k]);
	}
      }
    }

    sort(ABC.begin(),ABC.end(),greater<ll>());
    for ( int i = 0; i < K; i++ ) {
      cout << ABC[i] << endl;
    }
  } else {
    vector<ll>AB;
    for ( int i = 0; i < X; i++ ) {
      for ( int j = 0; j < Y; j++ ) {
	AB.push_back(A[i]+B[j]);
      }
    }
    sort(AB.begin(),AB.end(),greater<ll>());
    vector<ll>ABC;
    sort(C,C+Z,greater<ll>());
    for ( int i = 0; i < min(3000,(int)AB.size() ); i++ ) {
      for ( int j = 0; j < Z; j++ ) {
	ABC.push_back(AB[i]+C[j]);
      }
    }
    sort(ABC.begin(),ABC.end(),greater<ll>());
    for ( int i = 0; i < K; i++ ) {
      cout << ABC[i] << endl;
    }
    
  }

  
  return 0;
}


Measured memory_bytes: 43236
#include<bits/stdc++.h>
using namespace std;
int main(){
int a, b, c;
  cin >> a >> b >> c;
  if(a * 2 == b * 2)
    cout << c << endl;
  else if(a * 2 == c * 2)
    cout << b << endl;
  else
    cout << a << endl;
}

Measured memory_bytes: 256
<?php
    $min = 124;
    $max = 0;
    for ($i=0; $i < 5; $i++) { 
        fscanf(STDIN, "%d", $now);
        if ($max < $now) {
            $max = $now;
        }
        if ($min > $now) {
            $min = $now;
        }
    }
    fscanf(STDIN, "%d", $k);


    echo ($max - $min <= $k)?"Yay!":":(";


Measured memory_bytes: 4728
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let mut reds: Vec<(usize, usize)> =
        (0..n)
            .map(|_| {
                let ai: usize = iterator.next().unwrap().parse().unwrap();
                let bi: usize = iterator.next().unwrap().parse().unwrap();
                (ai, bi)
            })
            .collect();
    let mut blues: Vec<(usize, usize)> =
        (0..n)
            .map(|_| {
                let ci: usize = iterator.next().unwrap().parse().unwrap();
                let di: usize = iterator.next().unwrap().parse().unwrap();
                (ci, di)
            })
            .collect();

    reds.sort_by_key(|it| 1000 - it.1);
    blues.sort();

    let mut ans: usize = 0;
    let mut used: Vec<bool> = vec![false; n];
    for i in 0..n {
        for j in 0..n {
            if used[j] {
                continue;
            }
            if reds[j].0 < blues[i].0 && reds[j].1 < blues[i].1 {
                ans += 1;
                used[j] = true;
                break;
            }
        }
    }
    ans.to_string()
}


Measured memory_bytes: 2132
#include<iostream>
using namespace std;
int main(){
  int x;
  cin>>x;
  if(x<600){
    cout<<8<<endl;
  }else if(x<800){
    cout<<7<<endl;
  }else if(x<1000){
    cout<<6<<endl;
  }else if(x<1200){
    cout<<5<<endl;
  }else if(x<1400){
    cout<<4<<endl;
  }else if(x<1600){
    cout<<3<<endl;
  }else if(x<1800){
    cout<<2<<endl;
  }else{
    cout<<1<<endl;
  }
  return(0);
}

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

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

ll n, a, b, c, d;

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

    ll A = min(a, b), B = max(a, b);
    rep(i, n) {
        ll l, m;
        l = c * i - d * (n - 1 - i);
        m = d * i - c * (n - 1 - i);
        if (l <= b - a && b - a <= m) {
            puts("YES");
            return 0;
        }
    }

    puts("NO");

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
int main ()
{
    int a[105];
    int n,sum1=0,sum2=0;
    scanf("%d",&n);
    int c=10000;
    for (int i=1; i<=n; i++)
    {
        scanf("%d",&a[i]);
        sum1=sum1+a[i];
    }
    int ans=sum1;
    for (int i=1; i<=n-1; i++)
    {
        sum2=sum2+a[i];
        sum1=ans-sum2;


        int t=sum1-sum2;

        if (abs(t)<c)
            c=abs(t);
    }
    printf("%d\n",c);


    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define sz(x) (int)x.size()
#define pb push_back
#define mp make_pair
#define ll long long 
#define mod 1000000007
void setIO(string name) {
  ios_base::sync_with_stdio(0); cin.tie(0);
  freopen((name+".in").c_str(),"r",stdin);
  freopen((name+".out").c_str(),"w",stdout);
}
void fast(){
  ios_base::sync_with_stdio(false);cin.tie(NULL);
}
vector<int> arr(int i){
    int l=(sqrt(1+8*i)-1)/2;
    vector<int> m;
    if(i==1){
        m={1};
    }else if(i==0){
        m={};
    }else{
        if(2*i==l*(l+1)){
           m=arr(i-l);
           m.push_back(l);
       }else{
           m=arr(i-l-1);
           m.push_back(l+1);
       }
       
    }
    return m;
}
int main() {
   fast();
   int n;
   cin>>n;
   vector<int> v=arr(n);
   for(int i=0;i<v.size();i++){
       cout<<v[i]<<"\n";
   }
} 

Measured memory_bytes: 4352
N,K = map(int,input().split())
D = list(input().split())

for x in range(N,10**6):
  x = str(x)
  judge = 1
  for xi in x:
    if(xi in D):
      judge = 0 
  if(judge == 1):
    ans = x
    break
    
print(ans)    

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N, M; 
	cin >> N >> M; 
	int A[52] = {}; int B[52] = {}; int C[52] = {}; int D[52] = {}; 
	for(int i = 0; i < N; i++){
		cin >> A[i] >> B[i]; 
	}
	for(int i = 1; i <= M; i++){
		cin >> C[i] >> D[i]; 
	}
	for(int i = 0; i < N; i++){
		int dist = 1145141919; 
		int index = 0; 
		for(int j = 1; j <= M; j++){
			if(abs(A[i] - C[j]) + abs(B[i] - D[j]) < dist){
				index = j; 
				dist = abs(A[i] - C[j]) + abs(B[i] - D[j]); 
			}
		}
		cout << index << endl; 
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main () {
    string S[105];
    int x[105]={0, }, y[105]={0, };
    int N, M;
    cin >> N >> M;
    for (int i=0;i<N;i++)
        cin >> S[i];
    for (int i=0;i<N;i++){
        for (int j=0;j<M;j++){
            if (S[i][j]=='#'){
                x[i]++;
                y[j]++;
            }
        }
    }
    for (int i=0;i<N;i++){
        for (int j=0;j<M;j++){
            if (x[i] && y[j])
                cout << S[i][j];
        }
        if (x[i])
        cout << "\n";
    }
    return 0;
}

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

int main()
{
	long long K, A, B;
	cin >> K >> A >> B;

	long long ans = 0;
	if( A >= K ) ans = 1;
	else if( A <= B ) ans = -1;
	else {
		long long d = A - B;
		ans = (K - A + d - 1) / d * 2 + 1;
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
import math

s = list(map(float,input().split()))

if(s[2] <= 12):
  dig = (360 * (s[2] / 12) + 30 * (s[3] / 60)) - 360 * s[3] / 60
else:
  dig = (360 * ((s[2] - 12) / 12) + 30 * (s[3] / 60)) - 360 * s[3] / 60

l = s[0] * s[0] + s[1] * s[1] - 2 * s[0] * s[1] * math.cos(math.radians(dig)) 
le = math.sqrt(l)

print(le)

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

int main() {
	vector<int> vec1, vec2; int temp;
	cin >> temp; vec1.resize(temp);
	for (int i = 0; i < temp; i++) cin >> vec1[i];
	cin >> temp; vec2.resize(temp);
	for (int i = 0; i < temp; i++) cin >> vec2[i];
	cout << (int)(vec1 < vec2) << endl;
	return 0;
}


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

int main(){
    const int MOD = 998244353;
    int N, M;
    cin >> N >> M;
    vector<long long> a(N), b(M);
    for(int i = 0; i < N; i++) cin >> a[i];
    for(int i = 0; i < M; i++) cin >> b[i];
    vector<long long> ans = convolution<MOD>(a, b);
    for(int i = 0; i < N + M - 1; i++){
        (i != N + M - 2) ? cout << ans[i] << ' ' : cout << ans[i] << endl;
    }
}

Measured memory_bytes: 27276
import math
N, P = map(int, input().split())
A = list(map(int, input().split()))
odd = 0
even = 0

def nCr(n, r):
    return math.factorial(n) // math.factorial(n-r) // math.factorial(r)

for a in A:
    if a % 2 == 0:
        even += 1
    else:
        odd += 1
even_cmb = 1
for i in range(1, even+1):
    even_cmb += nCr(even, i)

if P == 0:
    odd_cmb = 1
    for i in range(2, odd+1):
        if i % 2 != 0:
            continue
        odd_cmb += nCr(odd, i)
    ans = even_cmb * odd_cmb
else:
    odd_cmb = 0
    for i in range(1, odd+1):
        if i % 2 == 1:
            odd_cmb += nCr(odd, i)
    ans = even_cmb * odd_cmb
print(ans)
exit()


Measured memory_bytes: 39024
#include<stdio.h>
char a[200][200];
int main(){
    int h,w;
    while(~scanf("%d%d",&h,&w)){
        for(int i=0;i<h;i++){
            scanf("%s",a[i]);
        }
        for(int i=0;i<h;i++){
            printf("%s\n%s\n",a[i],a[i]);
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;
int kcal(int p,int q,int r){
	return (p+r)*4+q*9;
	}
int tyosa(int i,int p,int q,int r,int cal,int P,int Q,int R,int C){
		if(P>=p&&Q>=q&&R>=r&&C>=cal) return i;
		else return 0;
		}
int main(){
	int n,i[1000],p[1000],q[1000],r[1000],P,Q,R,C,cal[1000],flag;
	while(cin>>n){
	if(n==0) break;
	flag=0;
	for(int j=0;j<n;j++){
		cin>>i[j]>>p[j]>>q[j]>>r[j];
		cal[j]=kcal(p[j],q[j],r[j]);
		}
	cin>>P>>Q>>R>>C;
	for(int j=0;j<n;j++){
			if(tyosa(i[j],p[j],q[j],r[j],cal[j],P,Q,R,C)!=0){
			cout<<tyosa(i[j],p[j],q[j],r[j],cal[j],P,Q,R,C)<<endl;
			flag++;
			}
		}
		if(flag==0){
			cout<<"NA"<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1180
def main():
    import sys
    input = sys.stdin.readline

    grid = []
    for _ in range(3):
        grid.append(list(map(int, input().split())))
    N = int(input())
    B = []
    for _ in range(N):
        B.append(int(input()))

    check = [[0] * 3 for _ in range(3)]
    for b in B:
        for i in range(3):
            for j in range(3):
                if grid[i][j] == b:
                    check[i][j] = 1

    ok = 0
    for i in range(3):
        if sum(check[i]) == 3:
            ok = 1
    for j in range(3):
        flg = 0
        for i in range(3):
            flg += check[i][j]
        if flg == 3:
            ok = 1
    if check[0][0] == check[1][1] == check[2][2] == 1:
        ok = 1
    if check[0][2] == check[1][1] == check[2][0] == 1:
        ok = 1
    if ok:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
N = int(input())
A = list(map(int, input().split()))
a = [0]*N
a[0] = sum(A) - 2*sum(map(lambda i,x: x if i%2==1 else 0, range(N), A))
for i in range(1, N):
    a[i] = 2*A[i-1]-a[i-1]
print(*a)

Measured memory_bytes: 14028