akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include <vector>
#include<string>
using namespace std;

string s;             //入力文字列
int x, y;             //最終到達目標
vector<int>dx, dy;    //x,y軸方向に動ける距離（正負は不明）
bool dir_is_X = true; //現在の入力文字"F"はx軸方向に進むものか

int main() {
	//入力
	cin >> s;
	s += "T";
	cin >> x >> y;

	//Tが出る前に存在するFの個数を数える。
	int step = 0;//直近の"F"の連続した個数
	for (char c : s) {
		if (c == 'F') {
			step++;
		}
		else {
			if (dir_is_X) {
				dx.push_back(step);
			}
			else {
				dy.push_back(step);
			}
			dir_is_X = !dir_is_X;
			step = 0;
		}
	}

	
	int origin = s.size();     //原点の位置（配列のindexは、負の値を取れないため）
	vector<vector<bool>> dpX;//1次元目:過去の移動回数,　2次元目：現在存在可能な位置（X座標において）
	vector<vector<bool>> dpY;//上記同

	//初期設定
	for (int t = 0; t < origin + 1; t++) {
		dpX.push_back(vector<bool>(origin *2+1));
		dpY.push_back(vector<bool>(origin *2+1));
	}
	dpX[1][origin + dx[0]] = true;//最初はX軸正の方向に進むので、先に進めておきます
	dpY[0][origin] = true;

	//後は、過去の移動回数がtのときに、次の移動で行けるところをtrueにするだけ
	for (int t = 1; t < dx.size(); t++) {
		for (int pos = 0; pos < origin * 2 + 1; pos++) {
			if (dpX[t][pos]) {
				dpX[t + 1][pos - dx[t]] = true;
				dpX[t + 1][pos + dx[t]] = true;
			}
		}
	}

	for (int t = 0; t < dy.size(); t++) {
		for (int pos = 0; pos < origin * 2 + 1; pos++) {
			if (dpY[t][pos]) {
				dpY[t + 1][pos - dy[t]] = true;
				dpY[t + 1][pos + dy[t]] = true;
			}
		}
	}

	//出力
	if (dpX[dx.size()][origin + x] && dpY[dy.size()][origin + y]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 32440
process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', function (chunk) {
	var a = chunk.split(' ');
	var b = parseInt(a[0],10);
	var c = parseInt(a[1],10);
	if(b>c)
		console.log('a'+" > "+'b');
	else if(b==c)
		console.log('a'+" == "+'b');
	else if(b<c)
		console.log('a'+" < "+'b');
});

Measured memory_bytes: 15540
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const LL mod = 1e9 + 7;
const LL N = 1e6 + 5;
const LL M = 1e3 + 5;
#define FOR(i, n, m) for (int i = n; i <= m; i++)
#define mid ((l + r) >> 1)
#define lson (l, mid)
#define rson (mid + 1, r)
#define r(a) read(a)
#define rr(a, b) r(a), r(b)
#define rrr(a, b, c) rr(a, b), r(c)
#define rrrr(a, b, c, d) rrr(a, b, c), r(d)
int n, m, k, T;
template <class T>
T read(T &x) {
    T f = 1;
    x = 0;
    char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        x = (x << 1) + (x << 3) + (ch - '0');
        ch = getchar();
    }
    x *= f;
}
LL qpow(LL a, LL b, LL p) {
    LL res = 1;
    while (b) {
        if (b & 1) res = (res * a) % p;
        a = (a * a) % p;
        b >>= 1;
    }
    return res;
}
LL ex_gcd(LL a, LL b, LL &x, LL &y) {
    if (!b) {
        x = 1, y = 0;
        return a;
    }
    LL res = ex_gcd(b, a % b, x, y);
    LL t = x;
    x = y;
    y = t - a / b * y;
    return res;
}
LL prime[N + 10], phi[N + 10], mou[N + 10], cnt_prime;
bool judgeprime[N + 10];
void ouler() {
    phi[1] = mou[1] = 1;
    FOR(i, 2, N) {
        if (!judgeprime[i]) prime[cnt_prime++] = i, phi[i] = i - 1, mou[i] = -1;
        for (int j = 0; j < cnt_prime && i * prime[j] <= N; j++) {
            judgeprime[i * prime[j]] = 1;
            if (i % prime[j] == 0) {
                phi[i * prime[j]] = phi[i] * prime[j];
                mou[i * prime[j]] = 0;
                break;
            } else {
                mou[i * prime[j]] = -mou[i];
                phi[i * prime[j]] = phi[i] * (prime[j] - 1);
            }
        }
    }
}
int main() {
    string a, b, c;
    int x, y;
    cin >> a >> b;
    cin >> x >> y;
    cin >> c;
    if (a == c)
        x--;
    else
        y--;
    cout << x << " " << y << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
int main()
{
  string s ;
  cin>>s ;
  for(int i =0; i<s.length();i++)
  {
    if(s[i] == ',')
      s[i] = ' ' ;
   }
  for(auto it :s )
    	cout<<it ;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    if(a%3==0 || b%3==0 || (a+b)%3==0){
      System.out.println("Possible");
    }else{
      System.out.println("Impossible");
    }
  }
}

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

namespace ABC090_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var aaa = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
            var A = aaa[0];
            var B = aaa[1];
            var count = 0;

            for(var i=A;i<=B;i++)
            {
                var s = i % 10;
                var t = i / 10000;
                var u = i % 10000 / 1000;
                var v = i %100 / 10;

                if (s == t && u == v)
                    count++;
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<cstdio>
using namespace std;
int n;
int main()
{
	int i,j,u,v;
	cin>>n;
	i=n/100;
	j=(n/10)%10;
	u=n%10;
	if(i>j)
	{
		cout<<i<<i<<i<<endl;
	}
	else if(i<j)
	{
		cout<<i+1<<i+1<<i+1<<endl;
	}
	else
	{
		if(u<=j)
		{
			cout<<i<<i<<i<<endl;
		}
		else
		{
			cout<<i+1<<i+1<<i+1<<endl;
		}
	}
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#define LL long long

using namespace std;

int main()
{
    char s[100005];
    while(scanf("%s",s)!=EOF)
    {
        int len=strlen(s);
        for(int i=0;i<len;i++)
        {
            if(i%2==0)
            {
                printf("%c",s[i]);
            }
        }
        printf("\n");

    }
    return 0;
}


Measured memory_bytes: 384
H,W = map(int,input().split())
List = []
for _ in range(H):
  S = input()
  List.append(S)
print('#'*(W+2))
for i in range(H):
  print('#'.strip(),end='')
  print(List[i].strip(),end='')
  print('#')
print('#'*(W+2))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define SORT(v) sort((v).begin(), (v).end())
#define REV(v) sort((v).begin(), (v).end(), greater<int>())
typedef long long ll;
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);};

int main() {
  int n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  cout << min(((n - 1) / a + 1) * b, ((n - 1) / c + 1) * d) << endl;
  return 0;
}



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

using namespace std;

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

int main(){
  int n, m, x;
  cin >> n >> m >> x;
  vector<int> c(n);
  vector<vector<int> > a(n);
  REP(i, n){
    cin >> c[i];
    REP(j, m){
      int d;
      cin >> d;
      a[i].push_back(d);
    }
  }
  int mini = 1 << 30;
  REP(i, 1 << n){
    vector<int> v(m);
    int p = 0;
    REP(j, n) if(i & (1 << j)){
      p += c[j];
      REP(k, m){
        v[k] += a[j][k];
      }
    }
    bool ok = true;
    REP(j, m) if(v[j] < x) ok = false;
    if(ok) mini = min(mini, p);
  }
  if(mini == (1 << 30)) mini = -1;
  cout << mini << endl;
  return 0;
}

Measured memory_bytes: 3636
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();

    let n = n as i128;
    let mut count = 0i128;
    for i in 0..n - 1 {
        let v = read_vec::<i128>();
        let (mut u, mut v) = (v[0] - 1, v[1] - 1);
        if v < u {
            std::mem::swap(&mut u, &mut v);
        }
        count += (u as i128 + 1) * (n as i128 - v as i128);
    }

    let mut spans = 0i128;
    for i in 1..n + 1 {
        spans += i * (n - i + 1);
    }

    //debug!(spans, count);
    println!("{}", spans - count);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 2132
#include <iostream>
#include <cmath>
#include <vector>
#include <iomanip>
using namespace std;
using ll = long long;

const long double PI = acos(-1.0);
const int MOD = 1e9 + 7;

int main() {

    /*
    std::vector<int> v = {3, 1, 4};
    int& x = v.back();
    cout << x << endl;
    if(x < 5) cout << "Yes" << endl;
     */

    int n;
    cin >> n;
    ll a[n];
    for(int i = 0; i < n; i++) cin >> a[i];

    vector<ll> b;
    for(int i = 0; i < n - 1; i++) {
        ll tmp = a[i + 1] - a[i];
        if(tmp == 0) continue;

        if(b.size() == 0) {
            b.push_back(tmp);
            // cout << "tmp = " << tmp << endl;
            continue;
        }

        if(b.size() >= 1) {
            ll& x = b.back();
            // cout << "x = " << x << endl;
            if(x * tmp > 0) {
                b.back() += tmp;
                continue;
            }
            b.push_back(tmp);
        }
    }

    /*
    for(auto x : b) cout << x << ' ';
    cout << endl;
     */

    ll pos = 1000; // possession
    ll stock = 0;
    ll price = a[0];
    
    if(b.size() == 0) {
        cout << pos << endl;
        return 0;
    }

    /*
    if(b.size() == 1) {
        if(b[0] < 0) {
            cout << pos << endl;
            return 0;
        } else {
            // buy
            stock += pos / price;
            pos = pos % price;

            // sell
            pos += stock * (price + b[0]);

            cout << pos << endl;
            return 0;
        }
    }
     */

    for(auto x : b) {
        if(x > 0) {
            // buy
            stock += pos / price;
            pos %= price;
        }
        else if(x < 0) {
            // sell
            pos += stock * price;
            stock = 0;
        }
        price += x;
    }

    if(stock != 0) {
        pos += stock * price;
        stock = 0;
    } 

    cout << pos << endl;
    
    return 0;
}

Measured memory_bytes: 3552
#include <iostream> // cin, cout を利用
using namespace std;
 
int main() {

    int D,S,T;
    cin >> D >> S >> T;

    double time = (double) D / S;
    
    if(time <= T) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <set>
#include<math.h>
#include <typeinfo>
using namespace std;
 
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double    ld;
typedef pair <ll,ll>  pll;
typedef pair <int,int> pii;
#define rep(h)    for (long long int e=0; e<h; e++)
#define srep(a,b) for (int e=a; e<b; e++)
#define rrep(a,b) for (int e=a; e>b; e--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

// int binsearch(int l,int r, int arr,int x)
// {  int m= (l+r)/2;
//  while (l<r)
//  {
//        if(x==arr[m]) return x;
//        else if (x<arr[m]) binsearch(l,m,arr,x);
//        else binsearch(m+1,r,arr,x);

//  }
// ll mod (string str, int k)
// { ll rem;
  




// 	return rem;
// }
// ll mod(string num, ll m) 
// { 
//     // Store the modulus of big number 
//     vector<int> vec; 
//     ll moda = 0; 
  
//     // Do step by step division 
//     for (int i = 0; i < num.size(); i++) { 
           
//         int digit = num[i] - '0'; 
  
//         // Update modulo by concatenating 
//         // current digit. 
//         moda = moda * 10 + digit; 
  
//         // Update quotient  
//         int quo = moda / m; 
//         vec.push_back(quo); 
  
//         // Update mod for next iteration. 
//         moda = moda % m;         
//     } 
//       return moda; 
// } 
//  while(t--)
//  {  cin >> n >> k;
//       vector <ll> val(n);
//       rep (n) cin >> val[e];
//       rep (n)
//       { 
//       	if (fl>0) {cout <<  "NO"; return 0;}
//         string str =to_string( val[e]);
// //        int l = str.size();

//          while (mod (str,k)!=0)
//          {      cout<<"F";
// //            //  if (mod (str,k)==1) 
// //             //  continue;      
//                   if (mod (str,k)<k) break;
//                     str = to_string(mod (str,k));
//          cout << mod(str,k)<<"  ";
//          }
//         if ( mod (str,k) >1) {cout <<  "NO"; return 0;} 
//             val[e]= mod (str,k);
//       }
//  //cout<<"DF";
//  rep (n) {if (val[e]<=1)  cout << val[e]<<")";}
//  cout<<endl;
 // }     
   

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
 int n,m;
 cin  >> n>>m;
     
   if (m>1) cout << n*(n-1)/2+m*(m-1)/2;
   else cout <<n*(n-1)/2;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll GCD(ll a, ll b){ return a ? GCD(b % a, a) : b; }
int main(){
    ll x;
    cin>>x;
    for(ll i=-1e3; i<=1e3; i++){
        for(ll j=-1e3; j<=1e3; j++){
            if(pow(i,5)-pow(j,5)==x){
                cout<<i<<" "<<j<<endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 4084
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
//const long long MOD = 1000000007;
const long long MOD = 998244353;
using namespace std;


int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);
    
    vector<int> a(n);
    int i;
    for(i=0; i<n; i++) {
        int tmp;
        scanf("%d", &tmp);
        a[tmp-1]=i;
    }
    int max=0;
    int cnt=0;
    for(i=1; i<n; i++) {
        if(a[i-1]<a[i]) {
            cnt++;
            max=MAX(max,cnt);
        }
        else {
            cnt=0;
        }
    }
    printf("%d\n", n-max-1);
    return 0;
}


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

int main()
{
    int n;
    string s;

    cin >> n;
    cin >> s;

    int count = 0;

    int i = 0;
    while(i < n){
        if(s[i] == 'A'){
            if(s[i + 1] == 'B'){
                if(s[i + 2] == 'C'){
                    i += 2;
                    count++;
                }
            }
        }
        i++;
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int q;
	cin>>q;
	ll l=0,r=0;
	while(q--){
		ll p,n;
		char c;
		cin>>p>>c>>n;
		if(c=='(')l+=n;
		else r+=n;
		Yn(l==r);
	}
}



Measured memory_bytes: 3228
#include<bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  int table[1000][1000];
  for (int k = 1; k < 1000; k ++) {
    if (k * (k + 1) == N * 2) {
      cout << "Yes" << endl;
      cout << k + 1 << endl;
      int count = 1;
      for (int i = 0; i < k; i ++) {
        for (int j = i; j < k; j ++) {
          table[i][j] = count;
          table[j + 1][i] = count;
          count ++;
        }
      }
      for (int i = 0; i < k + 1; i ++) {
        cout << k << ' ';
        for (int j = 0; j < k; j ++) {
          cout << table[i][j];
          if (j < k - 1) cout << ' ';
        }
        cout << endl;
      }
      return 0;
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 5160
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  // ll n;
  // cin >> n;
  // ll n, m;
  // cin >> n >> m;
  ll n, a, b;
  cin >> n >> a >> b;
  if(a > b) {
    cout << "0\n";
    return 0;
  }
  if(n == 1) {
    if(a == b) {
      cout << "1\n";
    }
    else
      cout << "0\n";
    return 0;
  }
  ll min_sum = a * (n - 1) + b;
  ll max_sum = b * (n - 1) + a;
  ans = max_sum - min_sum + 1;
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      int[] seqS = new int[n];
      String[] line = br.readLine().split(" ");
      int cnt=0;
      for (String s : line)
        seqS[cnt++] = Integer.parseInt(s);

      int q = Integer.parseInt(br.readLine());
      line = br.readLine().split(" ");
      
      cnt=0;
      for (String ref : line) {
        if( isExistSeachByBinary(seqS, Integer.parseInt(ref)) )
          cnt++;
      }

      System.out.println(cnt);
    }
  }

  static boolean isExistSeachByBinary(int[] tar, int ref) {
    int left = 0;
    int right= tar.length;
    int mid;
    while( left < right ) {
      mid  = (left + right) / 2;
      if( tar[mid] == ref ) return true;
      else if( tar[mid] > ref ) right = mid;
      else left = mid + 1;
    }

    return false;
  }
}


Measured memory_bytes: 52252
#include<bits/stdc++.h>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define mp make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
int x;
int main(){
	cin>>x;
	int t=x/100;
	x%=100;
	for(int i=5;i>0;i--){
	if(x/i>t){
		cout<<0;
		re 0;
	}
	t-=x/i;
	x%=i;	
	}
	cout<<1;
	
	re 0;
}


Measured memory_bytes: 384
public class Main {

  private static void solve() {
    long x = ni();

    long y = x / 500;
    long z = (x - y * 500) / 5;

    System.out.println(1000 * y + 5 * z);

  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}



Measured memory_bytes: 24660
#include <bits/stdc++.h>
using namespace std;
int main () {
    int N;
    cin >> N;
    vector<pair<int, int>> r(N), b(N);
    for (int i = 0; i < N; i++) {
        cin >> r[i].first >> r[i].second;
    }
    for (int i = 0; i < N; i++) {
        cin >> b[i].first >> b[i].second;
    }
    sort(r.begin(), r.end(), [](pair<int, int> p, pair<int, int> q) {
        if (p.second != q.second) {
            return p.second > q.second;
        }
        return p.first < q.first;
    });
    sort(b.begin(), b.end());
    int ans = 0;
    for (auto B: b) {
        for (int i = 0; i < r.size(); i++) {
            if (r[i].first < B.first && r[i].second < B.second) {
                ans++;
                r.erase(r.begin()+i);
                break;
            }
        }
    }
    cout << ans << endl;
}

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

int main(void) {
  long long N, K;
  cin >> N >> K;
  vector<long long> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  vector<long long> sum;
  for (int i = 0; i < N; i++) {
    sum.push_back(a[i]);
    for (int j = i + 1; j < N; j++) {
      sum.push_back(sum.back() + a[j]);
    }
  }

  vector<bool> ok((N * (N + 1)) / 2, true);
  long long ans = 0;
  for (int i = 63; i >= 0; i--) {
    long long cnt = 0;
    vector<int> tmp;
    for (long long j = 0, end = (N * (N + 1) / 2); j < end; j++) {
      if (!ok[j]) continue;
      if (sum[j] & (1LL << i))
        cnt++;
      else
        tmp.push_back(j);
    }
    if (cnt >= K) {
      ans |= (1LL << i);
      for (auto t : tmp) ok[t] = false;
    }
  }
  cout << ans << endl;
  return 0;
}

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

class Main {
	static FastScanner sc = new FastScanner();
	static PrintWriter out = new PrintWriter(System.out);

	public void solve() {
		int H = sc.nextInt();
		int W = sc.nextInt();
		String[] C = new String[H];
		for (int i = 0; i < H; i++) {
			C[i] = sc.next();
		}
		for (int i = 0; i < H; i++) {
			out.println(C[i]);
			out.println(C[i]);
		}
	}
	
	

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

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 23124
import sys
from collections import deque
n = int(sys.stdin.readline())

ans = deque()

for i in range(n):
    c = sys.stdin.readline()[:-1]
    if c[0] == 'i':
        ans.appendleft(c[7:])
    elif c[6] == ' ':
        try:
            ans.remove(c[7:])
        except:
            pass
    elif c[6] == 'F':
        ans.popleft()
    else:
        ans.pop()

print(' '.join(ans))

Measured memory_bytes: 71968
package main

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

var sc *bufio.Scanner

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	a, b := nextInt(), nextInt()
	switch {
	case (b-1)%(a-1) > 0:
		fmt.Println(((b - 1) / (a - 1)) + 1)
	default:
		fmt.Println((b - 1) / (a - 1))
	}
}


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	int n, k; cin >> n >> k;
	vector<bool> gd(n + 1, false);
	rep(i, 0, k) {
		int t; cin >> t;
		rep(j, 0, t) {
			int d; cin >> d;
			gd[d] = true;
		}
	}
	int ans = 0;
	rep(i, 1, n + 1) if (!gd[i]) ans++;
	cout << ans << endl;
}


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

int main() {
  int n;
  cin >> n;
  ll a[n];
  for(int i=0;i<n;i++) cin >> a[i];
  int right=0;
  ll ans=0,sum=0;
  for(int left=0;left<n;left++){
    while(right<n && sum+a[right]==(sum ^ a[right])){
      sum+=a[right];
      right++;
    }
    ans += right-left;
    if(left==right) right++;
    else sum-=a[left];
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
# seishin.py
A, B = map(int, input().split())
D = [list(map(int, input().split())) for i in range(A)]

N = 101
F = [[0]*N for i in range(N)]
for a in range(N):
    for b in range(N):
        res = 0
        for x in range(A):
            for y in range(B):
                res = max(res, D[x][y] - (x+1)*a - (y+1)*b)
        F[a][b] = res

for x in range(A):
    for y in range(B):
        v = 101
        for a in range(N):
            for b in range(N):
                v = min(v, (x+1)*a + (y+1)*b + F[a][b])
        if v != D[x][y]:
            print("Impossible")
            exit(0)
print("Possible")
print(2*N, N**2 + 2*(N-1))
for i in range(N-1):
    print(i+1, i+2, "X")
    print(103+i, 102+i, "Y")
for a in range(N):
    for b in range(N):
        print(a+1, 102+b, F[a][b])
print(1, 102)


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

template<typename T_char>
T_char ToUpper(T_char cX){return toupper(cX);}

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

  int ans = t.size();
  for(int i=0; i<=s.size()-t.size(); ++i){
    int res = 0;
    for(int j=0; j<t.size(); ++j){
      if(t[j] != s[i+j]) res++;
    }
    ans = min(ans , res);
  }

  cout << ans << endl;

}

Measured memory_bytes: 3572
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
//#pragma GCC optimize("O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
using namespace std;
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef pair<int, int> pii;
typedef vector<pii> vii;
#define sz(c) (int)(c).size()
#define all(c) (c).begin(), (c).end()

void solve (int n)
{
    int m;
    cin >> m;

    vi cnt(n);
    forn (i, m)
    {
        int a, b;
        cin >> a >> b;
        --a, --b;
        cnt[a] ^= 1;
        cnt[b] ^= 1;
    }

    cout << (count(all(cnt), 0) == n ? "YES" : "NO") << endl;
}

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

    int n;
    while (cin >> n)
        solve(n);
}


Measured memory_bytes: 640
/* author   : mpily :-()
title : Competing.cpp
time :Sun Jun 14 13:11:23 2020

*/
#include<climits>
#include<random>
#include<cassert>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<algorithm>
#include<utility>
#include<cstdint>
#include<queue>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstdio>
//4611686018427387903
using namespace std;
//magic lines for ordered_set
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
/*
	fuctions :

    order_of_key (k) : Number of items strictly smaller than k .
    find_by_order(k) : K-th element in a set (counting from zero).


*/
const int64_t mod = 998244353.;

void solve(int cnum){
    int h, w , m;
    cin >> h >> w >>m;
    vector<int> rows(h);
    vector<int>cols(w);
    set<pair<int,int>>freq;
    for(int i = 0; i < m; ++i){
        int rn , cn;
        cin >> rn >>cn;
        rn--;cn--;
        rows[rn]++;
        cols[cn]++;
        freq.insert({rn,cn});
    }
    int br = 0,mx = 0,ans = 0;
    for(int i = 0; i < h; ++i){
        if(rows[i] > mx){
            mx = rows[i];
            br = i;
        }
    }
    vector<int>crows ;
    for(int i = 0;i < h; ++i){
        if(rows[i] == mx)
            crows.push_back(i);
    }
    mx = 0;
    for(int i = 0; i < w; ++i){
        if(cols[i] > mx){
            mx = cols[i];
        }
    }
    vector<int>ccols ;
    for(int i = 0;i < w; ++i){
        if(cols[i] == mx)
            ccols.push_back(i);
    }
    for(int i : crows){
        for(int j : ccols){
            ans = rows[i]+cols[j];
            if(freq.count({i,j}) == 0){
                cout << rows[i]+cols[j] <<"\n";
                return;
            }
        }
    }
    cout << ans-1<<"\n";
}
int main(){

	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	//cout.tie(nullptr);
	//initprime();
	cout << setprecision(12);
	cout << fixed;
	int t;
	int count = 1;
	for(  t = 1;t--; solve(count),count++);
	return 0;
}


Measured memory_bytes: 23744
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <queue>

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

   int v;
   std::priority_queue<double, std::vector<double>, std::greater<double> > rque;
   for(int i=0; i<N; ++i){
      std::cin >> v;
      rque.push(v);
   }
   double x, y;
   for(int i=0; i<N-1; ++i){
      x = rque.top();
      rque.pop();
      y = rque.top();
      rque.pop();
      rque.push((x+y)/2);
   }

   std::cout << std::setprecision(10) << rque.top() << std::endl;
   return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.InteropServices.ComTypes;


class Program
{

    static void Main(string[] args)
    {
        var arr = arrLong();
        long ans1 = maxL(arr[0] * arr[2], arr[1] * arr[3]);
        long ans2 = maxL(arr[1] * arr[2], arr[0] * arr[3]);
        long ans = maxL(ans1, ans2);
        Console.WriteLine(ans);


    }

    static long maxL(long a,long b)
    {
        if (a > b) return a;
        else return b;
    }

    





    //入力受け取り用
    static string crS() { return Console.ReadLine(); }
    static int crI() { return int.Parse(Console.ReadLine()); }
    static int[] arrInt() { return Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray(); }
    static long[] arrLong() { return Console.ReadLine().Split(' ').Select(v => long.Parse(v)).ToArray(); }
    static string[] arrStr() { return Console.ReadLine().Split(' ').ToArray(); }
    static List<int[]> mapInt(int h)
    {
        List<int[]> mapInt = new List<int[]>();
        for (int i = 0; i < h; i++)
        {
            mapInt.Add(arrInt());
        }
        return mapInt;
    }

    static List<long[]> mapLong(long h)
    {
        List<long[]> mapLong = new List<long[]>();
        for (int i = 0; i < h; i++)
        {
            mapLong.Add(arrLong());
        }
        return mapLong;
    }


    static List<string[]> mapStr(int h)
    {
        List<string[]> mapStr = new List<string[]>();
        for (int i = 0; i < h; i++)
        {
            mapStr.Add(arrStr());
        }
        return mapStr;
    }

    static List<char[]> mapChar(int h)
    {
        List<char[]> mapChar = new List<char[]>();
        for (int i = 0; i < h; i++)
        {
            string s = crS();
            mapChar.Add(s.ToCharArray());
        }
        return mapChar;
    }

    static List<char[]> mapCharCopy(List<char[]> map)
    {
        List<char[]> copyMap = new List<char[]>();
        foreach (var arr in map)
        {
            List<char> list = new List<char>();
            foreach (var ele in arr)
            {
                list.Add(ele);
            }
            copyMap.Add(list.ToArray());
        }
        return copyMap;
    }

    //二次元配列出力用
    static void output2DArray(int h , int w , int[,] map)
    {
        for (int i = 0; i < h; i++)
        {
            for (int j = 0; j < w; j++)
            {
                if (j == w - 1) Console.WriteLine(map[i, j]);
                else Console.Write(map[i, j] + " ");
            }
        }
    }
}

Measured memory_bytes: 28260
// 23
#include <bits/stdc++.h>
using namespace std;
#define coutc "\033[48;5;196m\033[38;5;15m"
#define endc "\033[0m"
#define endl '\n'
#define M(_1, _2, _3, _4, NAME, ...) NAME
#define rep(...) \
  M(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rep4(_, x, n, s) \
  for (int _ = x; (s < 0) ? _ > n : _ < n; _ += s)
#define rep3(_, x, n) rep4(_, x, n, (x < n ? 1 : -1))
#define rep2(_, n) rep3(_, 0, n)
#define rep1(n) rep2(i, n)
#define fi first
#define se second
#define pb push_back
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define len(x) int(x.size())
#define lli __int128_t
#define li long long int
#define ld long double
#ifdef DEBUG
// 3
ostream &operator<<(ostream &o, pair<auto, auto> p) {
  return o << "(" << p.fi << ", " << p.se << ")";
}
// 4
ostream &operator<<(ostream &o, vector<auto> v) {
  rep(i, len(v)) o << setw(7) << right << v[i];
  return o << endc << endl << coutc;
}
// 4
ostream &operator<<(ostream &o, map<auto, auto> m) {
  for (auto &kv : m) o << kv;
  return o;
}
// 7
void debug(const auto &e, const auto &... r) {
  cerr << coutc << e;
  ((cerr << " " << r), ..., (cerr << endc << endl));
}
#else
#define debug(...)
#endif
// 3
void _main(int tc) {
  int k;
  cin >> k;
  string s;
  cin >> s;
  if (len(s) > k) {
    cout << s.substr(0, k) << "..." << endl;
  } else {
    cout << s << endl;
  }
}
// 7
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  _main(0), exit(0);
  int tc;
  cin >> tc;
  rep(i, tc) _main(i + 1);
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  ll N;
  cin >> N;
  ll sum = 0;
  vi A(N);
  rep(i,N) {
    cin >> A[i];
    sum += A[i];
  }
  if(sum%(N*(N+1)/2)) {
    cout << "NO" << endl;
    return 0;
  }
  ll cnt = sum/(N*(N+1)/2);
  rep(i,N) {
    ll t = cnt-(A[(i+1)%N]-A[i]);
    if(t<0||t%N) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 640
import numpy as np

h, w = map(int, input().split())
grid = []
for i in range(h):
    grid.append(list(input()))
grid = (np.array(grid) == ".")

L = np.zeros((h, w), dtype=int)
R = np.zeros((h, w), dtype=int)
U = np.zeros((h, w), dtype=int)
D = np.zeros((h, w), dtype=int)

for j in range(w):
    if j == 0:
        L[:, j] = grid[:, j]
    else:
        L[:, j] = (L[:, j - 1] + 1) * grid[:, j]


for j in range(w - 1, -1, -1):
    if j >= w - 1:
        R[:, j] = grid[:, j]
    else:
        R[:, j] = (R[:, j + 1] + 1) * grid[:, j]

for i in range(h):
    if i <= 0:
        U[i, :] = grid[i, :]
    else:
        U[i, :] = (U[i - 1, :] + 1) * grid[i, :]


for i in range(h - 1, -1, -1):
    if i >= h - 1:
        D[i, :] = grid[i, :]
    else:
        D[i, :] = (D[i + 1, :] + 1) * grid[i, :]

print(np.max(L + R + U + D - 3))


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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int a, b; cin >> a >> b;
  if(b % a) {
    cout << b - a << endl;
  } else {
    cout << b + a << endl;
  }
}


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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  vector<int> sime(181),kisi(46);
  for(int i=0;i<=180;i++){
    sime[i]=(i+1)*(i+2)*(i+3)/6;
  }
  for(int i=0;i<=45;i++){
    kisi[i]=(4*i+1)*(4*i+2)*(4*i+3)/6;
  }
  vector<int> ans(1000001,100000),kians(1000001,100000);
  ans[0]=0;
  for(int i=1;i<=1000000;i++){
    for(int j=0;j<=180;j++){
      if(i-sime[j]>=0){
        ans[i]=min(ans[i],ans[i-sime[j]]+1);
      }
    }
  }
  kians[0]=0;
  for(int i=1;i<=1000000;i++){
    for(int j=0;j<=45;j++){
      if(i-kisi[j]>=0){
        kians[i]=min(kians[i],kians[i-kisi[j]]+1);
      }
    }
  }
  while(1){
    int n;
    cin >> n;
    if(n==0) return 0;
    cout << ans[n] SP kians[n] << endl;
  }
  return 0;
}



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

using namespace std;

int S(long long i){
  int tmp = 0;
  while(true){
    tmp += i % 10;
    i /= 10;
    if (i == 0) break;
  }
  return tmp;
}

long long next(long long tmp){

  int min_d = log(tmp);
  double amp;
  double min_tmp = tmp;
  long long aa;
  long long min_aa = tmp;
  for(int i = 0; i <= min_d; i++){
    aa = (tmp / long(pow(10, i)) + 1) * long(pow(10, i)) - 1;
    //cout << aa << endl;
    amp = double(aa) / double(S(aa));
    //cout << amp << endl;
    if (amp < min_tmp){
      min_tmp = amp;
      min_aa = aa;
      //cout << min_aa << endl;
    }
  }

  return min_aa;
}

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

  // for (long long i = 9; i < 10000; i += 10){
  //   int tmp = S(i);
  //   cout << i << " " << tmp << " " << double(i) / double(tmp) << endl;
  // }
  //cout << next(6) << endl;
  long long tmp = 1;
  for (int i = 0; i < K; i++){
    tmp = next(tmp);
    cout << tmp << endl;
    tmp++;
  }

  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
ll mod = 1000000007;
 
int main() {
    const int p = 1000000000;
    const ll k = 1000000000000000000; 
    ll s;
    cin >> s;
    if(s <= p) {
        cout << 0 << " " << 0 << " " << s << " " << 0 << " " << 0 << " " << 1 << endl;
        return 0;
    }
    else if(s == k) {
        cout << 0 << " " << 0 << " " << p << " " << 0 << " " << 0 << " " << p << endl;
        return 0;
    }
    else {
        ll a = s/p;
        ll b = s%p;
        cout << 0 << " " << 0 << " " << p << " " << p-b << " " << 1 << " " << a+1 << endl;
        return 0;
    }
}

Measured memory_bytes: 256
import sys
def main():
  _ord, _range = ord, range
  s = input()
  t = input()
  tset = set(t)
  slen = len(s)
  aord = _ord('a')
  if len(tset - set(s)) != 0:
      print(-1)
      sys.exit()
  s2t = [i - aord for i in (s + s).encode('ascii')]
  lut = [[-1 for _ in _range(slen)] for _ in _range(26)]
  for c in tset:
    b = _ord(c) - aord
    j = 0
    for i in _range(slen * 2 - 1, -1, -1):
      if s2t[i] == b:
        j = 0
      else:
        j += 1
      if i < slen:
        lut[b][i] = j
  p = 0
  for c in t:
    b = _ord(c) - aord
    p += lut[b][p % slen] + 1
  print(p)
main()

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


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int r,g,b,k;
    cin>>r>>g>>b>>k;
    while(g<=r && k) k--,g*=2;
    while(b<=g && k) k--,b*=2;
    if(b>g && g > r) cout<<"Yes";
    else cout<<"No";
}



Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a.at(i);
  sort(ALL(a));
  int l = a.back();
  a.pop_back();
  int mid = (l+1)/2;
  auto itr = lower_bound(ALL(a), mid);
  auto itr2 = itr;
  int r;
  if(itr != a.begin()) itr--;
  if(itr == a.end() || abs((*itr2 - mid) < abs(*itr - mid))){
    r = *itr2;
  }else{
    r = *itr;
  }
  cout << l << " " << r << endl;
  return 0;
}

Measured memory_bytes: 3680
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,k;
  cin>>a>>b>>k;
  int min;
  vector<int> c;
  c.push_back(1);
  if(a<b)
  {
    min=a;
  }
  else{
    min=b;
  }
  for(int i=2;i<=min;i++)
  {
    if(a%i==0 && b%i==0)
    {
      c.push_back(i);
    }
  }
  int l;
  l=c.size();
  l=l-k;
  cout<<c[l];
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    void solve(){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int x = scan.nextInt();
        int t = scan.nextInt();
        if(n % x == 0){
            System.out.println(n * t / x);
        }else{
            System.out.println((n / x + 1) * t);
        }
        scan.close();
    }

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

Measured memory_bytes: 35624