akhauriyash/Code-Regression huggingface dataset:
Scanf.scanf "%d %d" (fun n k ->
    let a = Array.init n (fun _ -> Scanf.scanf " %d" (fun a -> a)) in

    let next_step arr =
        let b = Array.make (n + 1) 0 in
        Array.iteri (fun i v ->
            let mi = max 0 (i - v) in
            let mx = min n (v + i + 1) in
            b.(mi) <- b.(mi) + 1;
            b.(mx) <- b.(mx) - 1;
        ) arr;
        let c = Array.make n b.(0) in
        for i = 1 to n - 1 do
            c.(i) <- c.(i - 1) + b.(i)
        done;
        c
    in
    let rec loop i arr =
        if i = k then arr else
            let arr2 = next_step arr in
            if arr2 = arr then arr else loop (i + 1) arr2
    in
    loop 0 a |> Array.iter (Printf.printf "%d ");
    print_newline ()
)

Measured memory_bytes: 30960
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())





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

	map<pair<int, int>, int> cnt;

	int n;
	int x[50], y[50];
	cin >> n;
	rep(i,n) {
		cin >> x[i] >> y[i];
	}
	rep(i,n) {
		rep(j,n) if(i != j){
			cnt[make_pair(x[i] - x[j], y[i] - y[j])]++;
		}
	}

	int ans = n;
	for(const auto &p : cnt) {
		int c = p.second;
		ans = min(ans, n - c);
	}
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>

int main(){
    int a;
    int b;
    int answer = 0;

    scanf("%d", &a);
    scanf("%d", &b);

    if(b * 2 >= a){
        answer = 0;
    }else{
        answer = a - b*2;
    }

    printf("%d", answer);

    return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<algorithm>
#define N 110000
using namespace std;
inline char gc(){
	static char now[1<<16],*S,*T;
	if (T==S){T=(S=now)+fread(now,1,1<<16,stdin);if (T==S) return EOF;}
	return *S++;
}
inline int read(){
	int x=0,f=1;char ch=gc();
	while (ch<'0'||ch>'9') {if (ch=='-') f=-1;ch=gc();}
	while (ch<='9'&&ch>='0'){x=x*10+ch-'0';ch=gc();}
	return x*f;
}
int a[N],n,k;
long long sum1[N],sum2[N];
int main(){
	//freopen("agc.in","r",stdin);
	n=read();k=read();long long ans=0;
	for (int i=1;i<=n;++i) {
		a[i]=read(),sum1[i]=sum1[i-1]+a[i];sum2[i]=sum2[i-1];if (a[i]>0) sum2[i]+=a[i];
	}ans=max(ans,sum1[n]);
	for (int i=1;i<=n-k+1;++i){
		long long tmp1=sum2[i-1];long long tmp2=sum2[n]-sum2[i+k-1];
		ans=max(ans,tmp1+tmp2);ans=max(ans,tmp1+tmp2+sum1[i+k-1]-sum1[i-1]);
	}
	printf("%lld",ans);
	return 0;
} 

Measured memory_bytes: 2176
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int inputN = Integer.valueOf(scanner.next());
		int[] height = new int[inputN+1];
		for(int i = 1; i <= inputN; i++) {
			height[i] = Integer.valueOf(scanner.next());
		}
		scanner.close();

		int result = 1;
		boolean flag = true;
		for(int i = 2; i <= inputN; i++) {
			// 西からi番目の旅館から海が眺められるか
			for(int j = 1; j <= i - 1; j++) {
				if(height[j] > height[i]) {
					flag = false;
				}
			}

			// 旅館から海が眺めることができるならカウンタを増やす
			if(flag == true) {
				result++;
			} else {
				flag = true;
			}
		}
		System.out.println(result);
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int(i)=1;i<=(n);i++)
typedef long long ll;

int main(){
  int n,now=1;ll k;cin>>n>>k;
  int b[200001],a[200001];
  REP(i,n) cin>>b[i];

  for(;k>0;k/=2){
    if(k%2) now=b[now];
    REP(i,n) a[i]=b[b[i]];
    REP(i,n) b[i]=a[i];
  }
  cout<<now;
}

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

using ll = long long;
using P = pair<int, int>;
using PP = pair<int, P>;
#define rep1(i,n) for (int i=1; i<=(n); i++)
#define rep0(i,n) for (int i=0; i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#ifdef _DEBUG
string _format(string args) { string r = "", t; istringstream s(args); while (getline(s, t, ',')) r += t+":%d "; return r + "\n"; }
#define debug(...) do{printf(_format(#__VA_ARGS__).c_str(), __VA_ARGS__);}while(0)
#define FAST_IOSTREAM() do{}while(0);
#else
#define debug(...) do{}while(0)
#define FAST_IOSTREAM() do{std::ios::sync_with_stdio(false); std::cin.tie(nullptr);}while(0)
#endif

int main() {
    FAST_IOSTREAM();

    int n;
    cin >> n;
    string s;
    map<string, int> count;
    rep0(i,n) {
        cin >> s;
        count[s]++;
    }
 
    for (string s : {"AC","WA","TLE","RE"}) {
        cout << s << " x " << count[s] << endl;
    }
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

using Graph = vector<vector<int>>;

int main() {
    // 頂点数と辺数
    int N, M; cin >> N >> M;

    // グラフ入力受取 (ここでは無向グラフを想定)
    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        a--,b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    // BFS のためのデータ構造
    vector<int> dist(N, -1); // 全頂点を「未訪問」に初期化
    vector<int> ans(N, 1);
    queue<int> que;

    // 初期条件 (頂点 0 を初期ノードとする)
    dist[0] = 0;
    que.push(0); // 0 を橙色頂点にする

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int nv : G[v]) {
            if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[nv] = dist[v] + 1;
            // 親
            ans[nv] = v+1;
            que.push(nv);
        }
    }
    cout << "Yes" << endl;
    for (int v = 1; v < N; ++v) cout << ans[v] << endl;
    return 0;
}

Measured memory_bytes: 10720
#include <iostream>
#include <cstring>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;


int info[100000];
int to[100000] , done[100000] , re[100000];
int n,m;
int dfs(int x){
	if(~to[x]) return to[x];
	if(done[x]) return -2;
	else done[x] = true;
	return to[x] = info[x] == 0 ? x : dfs(x+info[x]);
}

int main(){
	while(cin >> n && n){
		for(int i = 0 ; i < n ; i++){
			cin >> info[i];
		}
		
		queue<int> Q;
		memset(re,-1,sizeof(re));
		memset(to,-1,sizeof(to));
		Q.push(0);
		//for(int i = 0 ; i < n ; i++) cout << dfs(i) << " "; cout << endl;
		re[0] = 0;
		while(Q.size()){
			int q = Q.front(); Q.pop();
			if(q == n-1){
				cout << re[q] << endl;
				break;
			}else{
				for(int i = 1 ; i <= 6 ; i++){	
					int next = dfs(min(q+i,n-1));
					if(next == -2) continue;
					if(re[next] == -1) Q.push(next),re[next] = re[q]+1;
				}
			}
		}
	}
}

Measured memory_bytes: 2252
#include<iostream>
#include<string>
#include <algorithm>

using namespace std;


int main(){
    int N;
    cin >> N;
    int* array;
    array = new int[N];
    int i;
    for(i = 0; i<N; i++){
        cin >> array[i];
    }
    int max;
    max = array[0];
    int counter = 1;
    for(i = 1; i<N; i++){
        if(array[i]>=max){
            counter++;
            max = array[i];
        }
    }
    cout << counter << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int x , y;
	cin >> x >> y;
	if (x > 12)
	{
		cout << y;
	}
	else if (x <= 12 && x >= 6)
	{
		cout << y / 2;
	}
	else
	{
		cout << "0";
	}
}

Measured memory_bytes: 256
N,M=map(int,input().split())

a=[list(map(int, input().split())) for i in range(N)]
c=[list(map(int, input().split())) for i in range(M)]
ans=[]

for i in range(N):
  dmin=2*10**8
  cnum=0
  for j in range(M):
    d=abs(a[i][0]-c[j][0])+abs(a[i][1]-c[j][1])
    if d<dmin:
      dmin=d
      cnum=j
  ans.append(cnum+1)
print(*ans)

Measured memory_bytes: 3064
#include <stdio.h>

int main(void) 
{
	int d, i;
	int area;

	while (scanf("%d", &d) != EOF) {
		area = 0;

		for (i = d; i < 600; i += d) 
			area += (i * i) * d;

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

Measured memory_bytes: 596
use std::collections::*;
use std::cmp::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        a: [[i64; 3]; n],
    };

    let mut dp = vec![[0; 3]; n+1];

    for i in 0..n {
        for j in 0..3 {
            for k in 0..3 {
                if j != k {
                    dp[i+1][j] = max(dp[i+1][j], dp[i][k] + a[i][j]);
                }
            }
        }
    }

    let mut res = 0;
    for i in 0..3 {
        res = max(res, dp[n][i]);
    }
    println!("{}", res);

}


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

/************************** definations *******************************/
#define pi              2*acos(0.0)
#define ll              long long int
#define sc1(a)          scanf("%lld",&a)
#define sc2(a,b)        scanf("%lld %lld",&a,&b)
#define pf1(a)          printf("%lld\n",a)
#define pf2(a,b)        printf("%lld %lld\n",a,b)
#define Case(a)         printf("Case %d: ",a)
#define Casel(a)        printf("Case %lld: ",a)
#define INF             1e9
#define INFL            1e18
#define XX              first
#define YY              second
#define PB              push_back
#define MP              make_pair
#define NL              cout << endl;
#define DONE            cerr << "Done" << endl
#define PAUSE           system("pause")
#define DEBUG(x)        cerr << #x << " = " << x << endl
#define READ            freopen("alu.txt", "r", stdin)
#define WRITE           freopen("vorta.txt", "w", stdout)
#define FASTIO          ios_base::sync_with_stdio(false);cin.tie(NULL)
#define M               10000007
#define mod             100000007
#define Mod             1000000007
#define N               1000000
/************************** definations *******************************/
int main()
{
    string s;
    cin >> s;
    if(s[2]==s[3] && s[4]==s[5]) cout << "Yes";
    else cout << "No";
}



Measured memory_bytes: 256
package main
import "fmt"

func main(){
    var n int
    fmt.Scan(&n)
    
    for ;;n++ {
        if isPrime(n) {
            fmt.Println(n)
            break
        }
    }
}

func isPrime(x int) bool {
    if x == 2 {
        return true
    }
    if x%2 == 0 || x == 1 {
        return false
    }
    
    for i:=3; i*i<=x; i+=2 {
        if x%i == 0 {
            return false
        }
    }
    return true
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for (ll i = 0; i < (ll)n; i++)
#define all(x) (x).begin(), (x).end()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end());

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

  printf("%d %d %d %d\n", x2 - dy, y2 + dx, x1 - dy, y1 + dx);
}

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

#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;
typedef double ld;

template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7ll;
const double PI=3.14159265358979323846;



int main() {
    int n; ll d; cin >> n >> d;
    d = d*d;
    int res = 0;   
    while(n--) {
        ll x, y;
        cin >> x >> y;
        ll z = x * x + y * y;
        if(z <= d) res ++;
    }
    cout << res << endl;
    return 0;

}

Measured memory_bytes: 3644
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

int main() {
    string s;
    cin >> s;
    string res = "";
    rep(i, s.size()) {
        if(i % 2 == 0) {
            res += s[i];
        }
    }
    cout << res << endl;
    return 0;
}

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

int main() {
  int n,cnt = 0;
  cin >> n;
  map<string,int>mp;
  vector<string>ans;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    mp[s]++;
  }
  for (auto& p : mp) {
    int s = p.second;
    cnt = max(cnt,p.second);
  }
  for (auto& p : mp) {
    if (p.second == cnt) {
      ans.push_back(p.first);
    }
  }  
  sort(ans.begin(),ans.end());
  for (int i = 0; i < ans.size(); i++) {
    cout << ans.at(i) << endl;
  }
}

Measured memory_bytes: 26868
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll mod = 1e9 + 7;
const int dx[] = {-1, 0, 1, 0}, dy[] = {0, -1, 0, 1};

int main() {
    ll n, k;
    cin >> n >> k;
    ll a = n % k;
    ll ans = min(a, k - a);
    cout << ans << endl;
}


Measured memory_bytes: 256
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll N, M;

int main() {
	scanf("%lld %lld", &N, &M);
	if(M == N) {
		printf("Yes\n");
	}	
	else {
		printf("No\n");
	}
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256
#include <iostream>
#include <atcoder/maxflow>
using namespace std;
using namespace atcoder;
#define rep(i, l, r) for (auto i = (l); i < (r); i++)
int main() {
  int n, m;
  cin >> n >> m;
  string grid[n];
  rep(i, 0, n) cin >> grid[i];
  vector<int> first_edges;
  mf_graph<int> graph(n * m + 2);
  vector<vector<int>> pos = {
    {0, 1}, {0, -1}, {1, 0}, {-1, 0}
  };
  rep(i, 0, n) rep(j, 0, m) if(grid[i][j] == '.') {
    if((i + j) % 2) {
      graph.add_edge(0, i * m + j + 2, 1);
      rep(k, 0, 4) {
        int _i = i + pos[k][0];
        int _j = j + pos[k][1];
        if (_i < 0 || _i >= n || _j < 0 || _j >= m || grid[_i][_j] != '.') continue;
        first_edges.push_back(graph.add_edge(i * m + j + 2, _i * m + _j + 2, 1));
      }
    } else {
      graph.add_edge(i * m + j + 2, 1, 1);
    }
  }

  int flow = graph.flow(0, 1);
  for (int edge : first_edges) {
    auto e = graph.get_edge(edge);
    if(e.flow == 0) continue;
    int i = (e.from-2)/m;
    int j = (e.from-2)%m;
    int k = (e.to-2)/m;
    int l = (e.to-2)%m;
    if(i + 1 == k) {
      grid[i][j] = 'v';
      grid[k][l] = '^';
    } else if(i - 1 == k) {
      grid[k][l] = 'v';
      grid[i][j] = '^';
    } else if(j + 1 == l) {
      grid[i][j] = '>';
      grid[k][l] = '<';
    } else if(j - 1 == l) {
      grid[k][l] = '>';
      grid[i][j] = '<';
    } else {
      cout << "!? " << i << " " << j << " " << k << " " << l << endl;
    }
  }

  cout << flow << '\n';
  rep(i, 0, n) cout << grid[i] << '\n';

  return 0;
}


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

using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using f80 = __float80;

template<typename C>
i64 Size(const C& c) { return static_cast<i64>(c.size()); }

template<typename C>
void Sort(C &c) { std::sort(c.begin(), c.end()); }

template<typename C>
void SortR(C &c) { std::sort(c.rbegin(), c.rend()); }

template<typename T, typename U, typename Comp=std::less<>>
bool ChMax(T& x_max, const U& x, Comp comp={}) {
  if(comp(x_max, x)) {
    x_max = x;
    return true;
  }
  return false;
}

template<typename T, typename U, typename Comp=std::less<>>
bool ChMin(T& x_min, const U& x, Comp comp={}) {
  if(comp(x, x_min)) {
    x_min = x;
    return true;
  }
  return false;
}

struct ProconInit {
  static constexpr int IOS_PREC = 15;
  static constexpr bool AUTOFLUSH = false;

  ProconInit() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(IOS_PREC);
    if (AUTOFLUSH) std::cout << std::unitbuf;
  }
} PROCON_INIT;

void solve() {
  i64 a; std::cin >> a;
  i64 b; std::cin >> b;
  i64 c; std::cin >> c;
  i64 d; std::cin >> d;

  i64 t1 = (c / b) + ((c % b != 0) ? 1 : 0);
  i64 t2 = (a / d) + ((a % d != 0) ? 1 : 0);

  std::cout << ((t2 < t1) ? "No" : "Yes") << "\n";
}

signed main() {
  solve();

  return 0;
}


Measured memory_bytes: 3616
#include <stdio.h>

int makeCombination(int ,int );

int num,S[2000];

int main ()
{

  int i,m,q;

  scanf("%d",&num);

  for(i=0;i<num;i++)
    {
      scanf("%d",&S[i]);
    }

  scanf("%d",&q);

  for(i=0;i<q;i++)
    {
      scanf("%d",&m);
    
  if( makeCombination (0,m)) printf("yes\n");

  else printf("no\n");
    }
  return 0;

}

int makeCombination(int x ,int y )
{
  int res;
  if(x >= num)  return 0;
  if(S[x] == y) return 1;
  if(makeCombination(x+1,y)) return 1;
  if(makeCombination(x+1,y-S[x]))return 1;
  return 0;
}

Measured memory_bytes: 580
#include<iostream>
using namespace std;
int main(){
	int a, b, c;
	cin >> a >> b >> c ;
	if (a <= b && b <= c)
	{
		cout << a << " " << b << " " << c << endl;
	}
	else if (a <= c && c <= b)
	{
		cout << a << " " << c << " " << b << endl;
	}
	else if (b <= a && a <= c)
	{
		cout << b << " " << a << " " << c << endl;
	}
	else if (b<=c &&c<=a)
	{
		cout << b << " " << c << " " << a << endl;
	}
	else if (c<=a &&a<=b)
	{
		cout << c << " " << a << " " << b << endl;
	}
	else if (c<=b &&b<=a)
	{
		cout << c << " " << b << " " << a << endl;
	}
	return 0;






}




Measured memory_bytes: 3104
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <iostream>
#include <numeric>
#include <random>
#include <vector>
#include <chrono>
#include <fstream>

using namespace std;

#define LOCAL 1

#if LOCAL
#define pv(val) cerr << #val << '=' << (val) << endl
#define pvn(name, val) cerr << name << '=' << (val) << endl
#define pl cerr << '@' << __LINE__ << endl
#else
#define pv(val)
#define pvn(name, val)
#define pl
#endif

template <class T>
ostream &operator<<(ostream &os, vector<T> const &vec)
{
    if (vec.empty())
    {
        os << "{}";
    }
    else
    {
        os << '{';
        for (size_t i = 0; i < vec.size() - 1; i++)
            os << vec[i] << ", ";
        os << vec.back() << '}';
    }
    return os;
}

template <class T, size_t S>
ostream &operator<<(ostream &os, array<T, S> const &arr)
{
    if (arr.empty())
    {
        os << "{}";
    }
    else
    {
        os << '{';
        for (size_t i = 0; i < arr.size() - 1; i++)
            os << arr[i] << ", ";
        os << arr.back() << '}';
    }
    return os;
}

uint64_t hoge(uint64_t a)
{
    uint64_t ans = 0;
    while (a > 0)
        ans += a--;
    return ans;
}

int main(void)
{
    int N;
    cin >> N;
    vector<int64_t> A(N), s(N + 1);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }

    s[0] = 0;

    for (int i = 1; i < N + 1; i++)
    {
        s[i] = s[i - 1] + A[i - 1];
    }

    sort(s.begin(), s.end());
    int64_t ans = 0;
    int64_t n = 1;
    for (int i = 1; i < N + 1; i++)
    {
        if (s[i - 1] != s[i])
        {
            ans += hoge(n - 1);
            n = 0;
        }
        n++;
    }

    ans += hoge(n - 1);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3328
N = int(input())

dp = list(range(N+1))

def calc(unit_base):
    unit = unit_base
    while unit <= amount:
        dp[amount] = min(dp[amount], dp[amount-unit]+1)
        unit *= unit_base

for amount in range(6, N+1):
    calc(6)
    calc(9)

print(dp[N])

Measured memory_bytes: 6900
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;

int main()
{
    int N;
    cin >> N;
    vector<vector<ll>> A(N, vector<ll>(N)), dp(N, vector<ll>(N, INF));

    ll ans = 0;
    rep(i, N) {
        rep(j, N) {
            ll a;
            cin >> a;
            A[i][j] = a;
            dp[i][j] = a;
        }
    }

    bool flag = true;

    rep(k, N) {
        rep(i, N) {
            rep(j, N) {
                if (i != k && j != k) {
                    if (dp[i][k] + dp[k][j] == dp[i][j]) {
                        A[i][j] = 0;
                    }
                    else if (dp[i][k] + dp[k][j] < dp[i][j]) {
                        flag = false;
                    }
                }
            }
        }
    }

    rep(i, N) {
        repd(j, i + 1, N) {
            ans += A[i][j];
        }
    }
    cout << (flag ? ans : -1) << endl;
    return 0;
}


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

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

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

int main() {
    ll N, A, B; cin >> N >> A >> B;
    if(A>B){
        cout << 0 << endl;
        return 0;
    }  
    if (N==1){
        if(B==A){
            cout << 1 << endl;
        } else {
            cout << 0 << endl; 
        }
        return 0;
    }
    ll b = B * (N-1) + A;
    ll a = A * (N-1) + B;
    cout << 1ll + b - a << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <limits.h>

using namespace std;

typedef long long LL;

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define dumpMap(m) { for (auto it: m) cout << it.first << "=>" << it.second << ' '; }

const int MOD = 1000000007;

double dp[301][301][301]; // dish with 3 sushi's - dish with 2 sushi's - dish with 1 sushi => expected # of moves

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

    vector<int> s(4);
    rep(i, N) {
        int a;
        cin >> a;
        ++s[a];
    }

    double dN = (double) N;

    dp[0][0][0] = 0;
    for (int i = 1; i <= N; ++i) {
        dp[0][0][i] = dp[0][0][i-1] + dN / i;
        // cout << "dp[0][0][" << i << "] = " << dp[0][0][i] << endl;
    }

    for (int j = 1; j <= N; ++j) {
        for (int i = 0; i+j <= N; ++i) {
            dp[0][j][i] = dp[0][j-1][i+1] * j / (i+j) + dN / (i+j);
            if (0 < i) {
                dp[0][j][i] += dp[0][j][i-1] * i / (i+j);
            }
            // cout << "dp[0][" << j << "][" << i << "] = " << dp[0][j][i] << endl;
        }
    }

    for (int k = 1; k <= s[3]; ++k) {
        for (int j = 0; j+k <= N; ++j) {
            for (int i = 0; i+j+k <= N; ++i) {
                dp[k][j][i] = dp[k-1][j+1][i] * k / (i+j+k) + dN / (i+j+k);
                if (0 < j) {
                    dp[k][j][i] += dp[k][j-1][i+1] * j / (i+j+k);
                }
                if (0 < i) {
                    dp[k][j][i] += dp[k][j][i-1] * i / (i+j+k);
                }
                // cout << "dp[" << k << "][" << j << "][" << i << "] = " << dp[k][j][i] << endl;
            }
        }
    }


    cout << setprecision(12) << dp[s[3]][s[2]][s[1]] << endl;

    return 0;
}


Measured memory_bytes: 213248
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<iostream>
#include<algorithm>//next_permutation

using namespace std;
using ll = unsigned long long int;

int main() {
	ll H, W;
	cin >> H >> W;
	if (H == 1 || W == 1) {
		cout << 1 << endl;
		return 0;
	}
	if (H % 2 == 0) {
		ll countcount = H * W / 2;
		cout << countcount << endl;
	}
	else {
		ll count;
		count = (H - 1) * W / 2;
		ll WW;
		if (W % 2 == 0) WW = W / 2;
		else WW = W / 2 + 1;
		count += WW;
		cout << count << endl;
	}
}







Measured memory_bytes: 256
i,v,s[5000],m,*p;main(n){for(;~scanf("%d",&n);n&&printf("%d\n",m))for(memset(s,i=0,n*4),m=-1e5;i++<n;)for(scanf("%d",&v),p=s+i;p---s;m=*p>m?*p:m)*p+=v;                                                                                                                                                  }

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


int main() {
	int n,x,ans=0;
	cin>>n>>x;
	vector<int>v(n);
	for(int i=0;i<n;i++){
		cin>>v.at(i);
		x-=v.at(i);
		if(x>=0){
			ans++;
		}
	}
	sort(v.begin(),v.end());
	while(x>=v.at(0)){
		x-=v.at(0);
		ans++;
	}
	cout<<ans<<endl;
		return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int gcd(int a, int b) {
	return b == 0 ? a : gcd(b, a % b);
}

int lcm(int a, int b) {
	return a * (b / gcd(a, b));
}

int main() {
	int n;

	scanf("%d", &n);
	printf("%d\n", lcm(n, 2));
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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

	
	int A, B, C;
	cin >> A >> B >> C;
	
	int saidai = max(A, max(B, C));

	if (saidai == A + B + C - saidai) co("Yes");
	else co("No");

	Would you please return 0;
}

Measured memory_bytes: 256
# ABC098 Xor Sum 2
f=lambda:map(int,input().split())
N=int(input())
A=list(f())

sumA,xorA=[0],[0]
tmp_s=0
tmp_x=0
for a in A:
    tmp_s+=a
    tmp_x=tmp_x^a
    sumA.append(tmp_s)
    xorA.append(tmp_x)

def check(l,r):
    if r>N:
        return False
    return sumA[r]-sumA[l]==xorA[r]^xorA[l]


l,r=0,0
res=0
while 1:
    if check(l,r):
        if r<=N:
            r+=1
            continue
    res+=r-l-1
    if l<=N-1:
        l+=1
    if r>N and l>=N:
        break
print(res)

Measured memory_bytes: 114572
#include <bits/stdc++.h>
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define INTXT std::ifstream in ("input.txt"); std::cin.rdbuf(in.rdbuf());
#define INF 1e9

using namespace std;
typedef long long ll;
static const ll MOD = 1000000007LL;

signed main() {
  IOS
  ll r, d, x;
  cin >> r >> d >> x;

  REP(i, 10){
    x = r * x - d;
    cout << x << endl;
  }
}


Measured memory_bytes: 256
from collections import Counter
N = int(input())
if N == 1:
	print(1)
else:
	l = [[int(arr) for arr in input().split()] for i in range(N)]
	l.sort()
	tmp = [[b - a for a, b in zip(l[j],l[k])] for j in range(N-1) for k in range(j+1,N)]
	c = Counter(map(tuple, tmp))
	m = c.most_common(1)[0][1]
	print(N-m)

Measured memory_bytes: 3692
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint N, R; cin >> N >> R;
    cout << (N >= 10 ? R : R + 100 * (10 - N)) << "\n";
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
   int a,b,c,d;
   scanf("%d %d %d %d",&a,&b,&c,&d);
   while(a>0||c>0){
      c -=b;
      if(c<=0){
         printf("Yes");
         break;
      }
      a -=d;
      if(a<=0){
         printf("No");
         break;
      }
   }
   
   return 0;
}


Measured memory_bytes: 1728
//header{{{
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <boost/hana/functional/fix.hpp>
#include <boost/sort/spreadsort/spreadsort.hpp>
//#include <boost/graph/adjacency_list.hpp>
//#include <boost/graph/dijkstra_shortest_paths.hpp>
//#include <boost/graph/graph_utility.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
  
using namespace std;
//using namespace boost::multiprecision;
//using namespace boost::math;

/*
typedef boost::adjacency_list<boost::listS, boost::vecS, boost::undirectedS,
        boost::no_property, boost::property<boost::edge_weight_t, int> > Graph;
*/


#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(12)
#define FixPoint boost::hana::fix
#define bsort boost::sort::spreadsort::spreadsort
#define int int_fast64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
  
inline int square(int a){ return a * a;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }

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

struct negrightshift {
    inline int operator() (const int &x, const unsigned offset) {
        return -(x >> offset);
    }
};
//}}}


signed main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout.setf(ios_base::fixed);
    cout.precision(10);

    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
 
    vector<int> p(a), q(b), r(c);
 
    rep(i,a){
        cin >> p[i];
    }
 
    rep(i,b){
        cin >> q[i];
    }
 
    rep(i,c){
        cin >> r[i];
    }
 
    boost::sort::spreadsort::integer_sort(all(p), negrightshift(), greater<>());
    boost::sort::spreadsort::integer_sort(all(q), negrightshift(), greater<>());
 
    min_heap<int> pq;
 
    rep(i,x){
        pq.emplace(p[i]);
    }
 
    rep(i,y){
        pq.emplace(q[i]);
    }
 
    rep(i,c){
        if(pq.top() < r[i]){
            pq.pop();
            pq.emplace(r[i]);
        }
    }
 
    int res = 0;
    while(!pq.empty()){
        res += pq.top();
        pq.pop();
    }
 
    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 7680
/* https://atcoder.jp/contests/abc097/tasks/arc097_a */

#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>

bool comp_str(std::string a, std::string b)
{
  int a_len = a.length();
  int b_len = b.length();
  int str_len = std::min(a_len, b_len);

  for (int i = 0; i < str_len; ++i) {
    char sub_a = a.at(i);
    char sub_b = b.at(i);
    if (sub_a != sub_b) {
      return sub_a < sub_b;
    }
  }

  return a_len < b_len;
}

std::string solve(const std::string s, const int K)
{
  int s_len = s.length();
  std::set<std::string> sub_s;

  for (int i = 1; i <= K; ++i) {
    for (int j = 0; j+i-1 <= s_len; ++j) {
      std::string sub = s.substr(j, i);
      sub_s.insert(sub);
    }
  }

  std::vector<std::string> sub_s_vec(sub_s.begin(), sub_s.end());

  std::sort(sub_s_vec.begin(), sub_s_vec.end(), [&](std::string a, std::string b) { return comp_str(a, b); });

  return sub_s_vec.at(K);
}

int main(int argc, char *argv[])
{
  // Input
  std::string s;
  int K;

  std::cin >> s >> K;

  // Output
  std::cout << solve(s, K) << std::endl;

  return 0;
}


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

int main(){
    int n, m;
    cin >> n >> m;

    vector<int> a(n);    
    priority_queue<int> pq;
    for(int i=0; i<n; i++){
        cin >> a[i];
        pq.push(a[i]);
    }
    
    while(m > 0){
        int max = pq.top();
        pq.pop();
        max /= 2;
        m--;
        pq.push(max);
    }

    long long int sum = 0;
    for(int i=0; i<n; i++){
        sum += pq.top();
        pq.pop();
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1276
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}

var mod int

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := intScanner()
	k := intScanner()
	as := intSliceScanner(n)
	m := max(as)
	x := as[0]
	for i := 1; i < n; i++ {
		x = gcd(x, as[i])
	}
	if m >= k && k%x == 0 {
		fmt.Println("POSSIBLE")
	} else {
		fmt.Println("IMPOSSIBLE")
	}
}
func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}


Measured memory_bytes: 3072
N, M = map(int, input().split())
left= []
right = []
for _ in range(M):
    L, R = map(int, input().split())
    left.append(L)
    right.append(R)

min_right = min(right)
max_left = max(left)
if min_right < max_left:
    print(0)
else:
    print(min_right - max_left + 1)


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

int getm(int n) {
  return n / 100 * 60 + n % 100;
}

int show[24 * 60 + 10];
int cm[24 * 60 + 10];

int main() {
  for(;;) {
    int N, start, end;
    cin >> N >> start >> end;
    if( N == 0 ) break;

    start = getm(start);
    end = getm(end);
    
    memset(show, 0, sizeof(show));
    
    for(int i = 0; i < N; i++) {
      int K; cin >> K;

      memset(cm, 0, sizeof(cm));
      for(int j = 0; j < K; j++) {
        int a, b; cin >> a >> b;
        a = getm(a);
        b = getm(b);
        for(int t = a; t < b; t++) cm[t] = 1;        
      }
      
      for(int t = 0; t < 24 * 60 + 10; t++)
        if( cm[t] == 0 ) show[t] = 1;      
    }

    show[end] = 0;
    int ans = 0;
    int len = 0;
    for(int i = start; i <= end; i++) {
      if( show[i] ) {
        len++;
      } else {
        ans = max(ans, len);
        len = 0;
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 0
def is_prime(x):
    m = 2
    while m * m <= x:
        if x % m == 0:
            return False
        m += 1

    return True


def main():
    n = int(input())
    p = [i for i in range(2, n+1) if is_prime(i)]
    cnt = [0 for i in range(len(p))]

    for i in range(2, n+1):
        idx = 0
        while idx < len(p) and p[idx] <= i:
            a = i
            while a % p[idx] == 0:
                cnt[idx] += 1
                a //= p[idx]

            idx += 1

    factor = 1
    for i in cnt:
        if i == 0:
            continue

        factor *= i + 1
        if factor >= 10 ** 9 + 7:
            factor %= 10 ** 9 + 7

    print(factor)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main()
{
  int W, H, N;
  int x[110], y[110], a[110];

  cin >> W >> H >> N;

  int lowerLeftX = 0;
  int lowerLeftY = 0;
  int upperRightX = W;
  int upperRightY = H;

  for (int i = 0; i < N; i++)
    cin >> x[i] >> y[i] >> a[i];

  for (int i = 0; i < N; i++)
  {
    switch (a[i])
    {
    default:
      break;
    case 1:
      if (lowerLeftX < x[i])
        lowerLeftX = x[i];
      break;
    case 2:
      if (upperRightX > x[i])
        upperRightX = x[i];
      break;
    case 3:
      if (lowerLeftY < y[i])
        lowerLeftY = y[i];
      break;
    case 4:
      if (upperRightY > y[i])
        upperRightY = y[i];
      break;
    }
  }
  
  if ((upperRightY - lowerLeftY) >= 0 && (upperRightX - lowerLeftX) >= 0)
  {
    int area = (upperRightY - lowerLeftY) * (upperRightX - lowerLeftX);
    cout << area << endl;
  }
  else cout << 0 << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
  public class Main{
    public static void main(String args[]){
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      int Max = 0;
      int sum1 = 0;
      int sum2 = 0;
      int[] X = new int[N];

      for(int i=0;i<N;i++){
        X[i] = sc.nextInt();
        if(Max<X[i]){
          Max=X[i];
        }
      }
      sc.close();
      sum1 = pow(1,N,X);
      for(int j=2;j<=Max;j++){
          sum2 = pow(j,N,X);
          if(sum1>sum2){
            sum1=sum2;
          }
      }
      System.out.println(sum1);
    }
    private static int pow(int n1,int N,int array[]){
      int sum = 0;
      for(int k=0;k<N;k++){
        sum+=Math.pow(array[k]-n1,2);
      }
      return sum;
    }
  }

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

int main()
{
	string s, t;
	cin >> s >> t;
	int length = s.length(), flag;
	for(int i = 0; i < length; i++){
        flag = 0;
        if(s.substr(i, length - i) + s.substr(0, i) != t){
            flag = 1;
        }
        else{
            cout << "Yes" << endl;
            break;
        }
	}
	if(flag == 1){
        cout << "No" << endl;
	}
	return 0;
}


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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

// 0:R????????°????????§???, 1:L????????°????????§???
int dp[2001][2001][2];
const string LR="LR";

void calc(string s, int K)
{
    int S=s.size();
    memset(dp,0,sizeof(dp));
    rep(i,S)rep(j,K+1)rep(k,2)
    {
        // ??????????????????
        dp[i+1][j][k] = max(dp[i+1][j][k], dp[i][j][k]+(s[i]==LR[(j%2+k+1)%2]));
        // ????????????
        if(j<K) dp[i+1][j+1][k] = max(dp[i+1][j+1][k], dp[i][j][k]+(s[i]==LR[(j%2+k)%2]));
    }
}

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

    string s;
    int K;
    cin >>s >>K;

    string x="",y="";
    rep(i,s.size())
    {
        if(s[i]=='L' || s[i]=='R') x+=s[i];
        else y+=(s[i]=='U')?'L':'R';
    }

    int X=x.size(), Y=y.size();
    // 0:R????????°????????§???, 1:L????????°????????§???
    int dx[2001]={};
    // 0:D????????°????????§???, 1:U????????°????????§???
    int dy[2001]={};

    calc(x,K);
    rep(i,K+1) dx[i]=max(2*dp[X][i][0]-X, 2*dp[X][i][1]-X);
    calc(y,K);
    rep(i,K+1) dy[i]=max(2*dp[Y][i][0]-Y, 2*dp[Y][i][1]-Y);

    int ans=0;
    rep(i,K+1)rep(j,K+1)if(i+j<=K) ans=max(ans,dx[i]+dy[j]);

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

Measured memory_bytes: 34468
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define all(a)      (a).begin(),(a).end()
#define debug_array(a,n) for (ll bccc=(0); bccc<(n); bccc++) cout<<a[bccc]<<" "<<"\n"
#define debug_vector(a) for(ll bccc=(0); bccc<(a.size());bccc++) cout<<a[bccc]<<" "<<"\n"
#define F           first
#define S           second
#define debug_set(s) for(auto p:s) cout<<p<<" "
#define debug_map(m) for(auto p:m) cout<<p.F<<" "<<p.S<<"\n"
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<pair<ll,ll>,null_type,less<pair<ll,ll> >,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;

/* ll t = 0;
ordered_multiset me;
...
me.insert({x, t++});
me.erase(me.lower_bound({x, 0}));
cout << me.order_of_key({x, 0}) << "\n";

///////////   t is insertion time
*/
//#pragma GCC optimize("Ofast")  // works very well
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
typedef long double lld;
lld pi=3.14159265358;
ll powr(ll a,ll b)
{
    ll c=1;
    ll kjk;
    for(kjk=0;kjk<b;kjk++)
        c*=a;
    return c;
}
ll hell=1000000007;
//ll hell=998244353   ;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
// to generate random number , use rng() ... eg cout<<rng();
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    ll d;
    cin>>d;
    lld dd=(lld)d;
    lld ans=dd*dd*dd;
    lld div=(lld)(27.000000000000);
    ans/=div;
    cout<<fixed<<setprecision(10)<<ans;
    return 0;
}


Measured memory_bytes: 256
#include "iostream"

using::std::cin;
using::std::cout;
using::std::endl;



int main()
{
	long H = 0;
	long W = 0;

	cin >> H >> W;
  if (H == 1 || W == 1) {
    cout << 1 << endl;
  }
  else {
	cout << (H * W + 1) / 2 << endl;
  }
  
  
  
  return 0;
}

Measured memory_bytes: 256
import bisect

SList = []
TList = []
QList = []
minpos = -1*(10**10)
maxpos = 10*(10**10)

def ans(x):
    index = bisect.bisect_left(SList,x)
    s = [SList[index-1],SList[index]]

    index = bisect.bisect_left(TList,x)
    t = [TList[index-1],TList[index]]

    min1 = abs(x-s[0])+abs(t[0]-s[0])
    diff = abs(x-s[0])+abs(t[1]-s[0])
    if diff < min1:
        min1 = diff
    diff = abs(x-s[1])+abs(t[0]-s[1])
    if diff < min1:
        min1 = diff
    diff = abs(x-s[1])+abs(t[1]-s[1])
    if diff < min1:
        min1 = diff
    diff = abs(x-t[0])+abs(s[0]-t[0])
    if diff < min1:
        min1 = diff
    diff = abs(x-t[0])+abs(s[1]-t[0])
    if diff < min1:
        min1 = diff
    diff = abs(x-t[1])+abs(s[0]-t[1])
    if diff < min1:
        min1 = diff
    diff = abs(x-t[1])+abs(s[1]-t[1])
    if diff < min1:
        min1 = diff
    return min1

A,B,Q = map(int,input().split())
for _ in range(A):
    SList.append(int(input()))
for _ in range(B):
    TList.append(int(input()))
for _ in range(Q):
    QList.append(int(input()))

SList.insert(0,minpos)
SList.append(maxpos)
TList.insert(0,minpos*2)
TList.append(maxpos*2)
for q in QList:
    print(ans(q))


Measured memory_bytes: 16168
s=int(input())
s=list(str(s))
k=int(input())
i=0
while True:
  if i==len(s):
    print(1)
    break
  if s[i]!="1":
    print(s[i])
    break
  else:
    i=i+1
  if i==k:
    print(1)
    break

Measured memory_bytes: 3060
main :: IO ()
main = interact $ show.(\[n, x] -> solve n x).map read.words

solve :: Int -> Int -> Int
solve 0 0 = 0
solve 0 _ = 1
solve _ 0 = 0
solve _ 1 = 0
solve n x
    | x <= l = solve (n - 1) (x - 1)
    | otherwise = patty !! (n - 1) + 1 + solve (n - 1) (x - l - 1)
  where
    l = (len !! n) `div` 2

len :: [Int]
len = iterate (\x -> 2 * x + 3) 1

patty :: [Int]
patty = iterate (\x -> 2 * x + 1) 1


Measured memory_bytes: 508
#include <iostream>
#include <iomanip>
using namespace std;
int main(void){
    char b;
    int a,c;
    while(1){
        cin>>a>>b>>c;
        if(b=='?'){
            break;
        }
        if(b=='+'){
            cout<<a+c<<endl;
        }else if(b=='-'){
            cout<<a-c<<endl;
        }else if(b=='*'){
            cout<<a*c<<endl;
        }else{
            cout<<a/c<<endl;
        }
    }
}



Measured memory_bytes: 3080