akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define pb push_back
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ggdem=b;i<ggdem;++i)
#define SZ(x) ((int)x.size())
#define ALL(x) x.begin(),x.end()
#define mset(a,v) memset((a),(v),sizeof(a))
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;

int main(){FIN;
	ll n; cin>>n;
	ll a[n],b[n];
	fore(i,0,n)cin>>a[i]>>b[i];
	sort(a,a+n);
	sort(b,b+n);
	//fore(i,0,n)cout<<a[i]<<" "; cout<<"\n";
	//fore(i,0,n)cout<<b[i]<<" "; cout<<"\n";
	if(n%2==1){
		cout<<b[n/2]-a[n/2]+1;
	}
	if(n%2==0){
		cout<<b[n/2]+b[n/2-1]-a[n/2]-a[n/2-1]+1;
	}
	
	return 0;
}

Measured memory_bytes: 6784
#include<iostream>
#include<cstring>
#include<string>
#include<cstdio>
using namespace std;
int main(){
	int a[101][101]={0},n,m,p;
	char b[101][101];
	cin>>n>>m;
	for(int i=1;i<=n;++i){
		for(int j=1;j<=m;++j) cin>>b[i][j];
	}
	for(int i=1;i<=n;++i){
		for(int j=1;j<=m;++j){
			if(b[i+1][j]=='#') a[i][j]++;
			if(b[i-1][j]=='#') a[i][j]++;
			if(b[i+1][j+1]=='#') a[i][j]++;
			if(b[i-1][j-1]=='#') a[i][j]++;
			if(b[i+1][j-1]=='#') a[i][j]++;
			if(b[i-1][j+1]=='#') a[i][j]++;
			if(b[i][j+1]=='#') a[i][j]++;
			if(b[i][j-1]=='#') a[i][j]++;
		}
	}
	for(int i=1;i<=n;++i){
		for(int j=1;j<=m;++j){
			if(b[i][j]=='.') {
				p=a[i][j];
				cout<<p;
			}
			else cout<<b[i][j];	
		}
		cout<<endl;
	}
}



Measured memory_bytes: 256
import numpy as np
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

N,M=map(int,list(input().split(" ")))
mod=10**9+7
def factor(n):
    fct = []  
    b, e = 2, 0 
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct

fac=np.array(factor(M))
ans=1
for i in range(len(fac)):
    ans*=cmb(N+fac[i][1]-1,N-1)
print(ans%mod)

Measured memory_bytes: 14516
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  int N;
  string S;
  cin >> N >> S;
  int x_max = 0;
  int x = 0;
  rep(i, N) {
    if(S[i] == 'I') x++;
    else if(S[i] == 'D') x--;
    x_max = max(x_max, x);
  }
  cout << x_max << endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
const int N=2e3+5;
int n,a[N],p1,p2; 
vector<ii> res; 
int main()
{
	cin>>n;
	int mx=-1e9,mn=1e9; 
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];//mn=min(mn,a[i]),mx=max(mx,a[i]); 
		if(mx<a[i])
			mx=a[i],p1=i;
		if(mn>a[i])
			mn=a[i],p2=i;
	}
	if(mx>=abs(mn))
	{
		for(int i=1;i<=n;i++)
			if(a[i]<0)
				res.push_back(ii(p1,i));
		for(int i=2;i<=n;i++)
			res.push_back(ii(i-1,i));
	}
	else
	{
		for(int i=1;i<=n;i++)
			if(a[i]>=0)
				res.push_back(ii(p2,i));
		for(int i=n-1;i>=1;i--)
			res.push_back(ii(i+1,i));	
	}
	printf("%d\n",res.size());
	for(int i=0;i<res.size();i++)
		printf("%d %d\n",res[i].first,res[i].second);
	return 0;	
} 

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

using namespace std;

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

	vector<int> list(N);
	vector<int> process;

	for (int i = 0; i < N; i++)
	{
		cin >> list[i];
	}
	
	for (int i = 0; i < N; i++)
	{
		for (int k = list.size() - 1; k >= 0; k--)
		{
			if (list[k] == k + 1)
			{
				process.push_back(list[k]);
				list.erase(list.begin() + k);
				break;
			}
		}
	}

	
	if (process.size() != N)
	{
		cout << -1 << endl;
	}
	else
	{
		reverse(process.begin(), process.end());
		for (int i = 0; i < N; i++)
		{
			cout << process[i] << endl;
		}
	}
	
	return 0;
}

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

int main()
{
    int N;
    cin >> N;
    char S;
    bool flag = false;
    for (int i = 0; i < N; i++)
    {
        cin >> S;
        if (S == 'Y')
        {
            flag = true;
            break;
        }
    }
    if (flag)
        cout << "Four" << endl;
    else
        cout << "Three" << endl;
}


Measured memory_bytes: 3596
#include "bits/stdc++.h"

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#ifdef Debug
#define dump(x)  cerr << #x << " = " << (x) << endl
#else
#define dump(x)
#endif

char data[8][8];

void rot(){
	char tmp[8][8];
	for(int j=0;j<8;j++){
		for(int i=7;i>=0;i--){
			tmp[j][i]=data[7-i][j];
		}
	}

	rep(i,8)rep(j,8)data[i][j]=tmp[i][j];
}

int main(){
	rep(i,8)rep(j,8)cin>>data[i][j];

	rep(i,3){
		cout<<(i+1)*90<<endl;
		rot();

		rep(j,8){
			rep(k,8)cout<<data[j][k];
			cout<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1136
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#include<iomanip>
#include<map>
#define int long long
using namespace std;

signed main() {
	int N,M;
	cin >> N >> M;
	int cnt = M * 1900 + (N - M) * 100;
	cout << cnt * pow(2.0,M * 1.0) << endl;
}

Measured memory_bytes: 256
import bisect
import sys
input = sys.stdin.readline

n = int(input())
colors_maxs = []

colors_maxs.append(int(input()) *(-1) )
for _ in range(n-1):
    a = int(input()) * (-1)
    if colors_maxs[-1] <= a:
        colors_maxs.append(a)
    else:
        ind = bisect.bisect_right(colors_maxs, a) # -> 4
        colors_maxs[ind] = a

print(len(colors_maxs))

Measured memory_bytes: 7076
#include<iostream>
using namespace std;
#include<vector>
#include<algorithm>
#include<cmath>
#define int long long int
vector<int> vec;
int32_t main()
{
   int n,k,c;
   cin>>n>>k>>c;
   char str[n+1];
   int j;
   for(j=1;j<=n;j++)
   {
	   cin>>str[j];
   }
   if(c==0)
   {
	   int count=0;
	   for(j=1;j<=n;j++)
	   {
		   if(str[j]=='o')
		     count++;
	   }
	   if(count>k)
	   {
		   
	   }
	   else
	   {
		   for(j=1;j<=n;j++)
		   {
			   if(str[j]=='o')
			   {
				   cout<<j<<endl;
			   }
		   }
	   }
	   exit(0);
   }
   int prefix[n+1]={0};
   int suffix[n+1]={0};
   for(j=1;j<=n;j++)
   {
	   if(str[j]=='o')
	   {
		   prefix[j]++;
		   j=j+c;
	   }
	   else
	   {
		   continue;
	   }
   }
   for(j=1;j<=n;j++)
   {
	   prefix[j]+=prefix[j-1];
   }
   for(j=n;j>=1;j--)
   {
	   if(str[j]=='o')
	   {
		   suffix[j]++;
		   j-=c;
	   }
	   else
	   {
		   continue;
	   }
   }
   for(j=n-1;j>=0;j--)
   {
	   suffix[j]+=suffix[j+1];
   }
   for(j=1;j<=n;j++)
   {
	   if(str[j]=='o')
	   {
		   bool result=false;
		   int i;
		   for(i=j-1;i>=j-c;i--)
		   {
			   int ptr1=i;
			   int ptr2=i+c+1;
			   int x=0,y=0;
			   if(ptr1>=1)
			   {
				   x=prefix[ptr1];
			   }
			   if(ptr2<=n)
			   {
				   y=suffix[ptr2];
			   }
			   if(x+y>=k)
			   {
				   result=true;
				   break;
			   }
		   }
		   for(i=j+1;i<=j+c;i++)
		   {
			   if(result)
			     break;
			   int ptr1=i;
			   int ptr2=i-c-1;
			   int x=0,y=0;
			   if(ptr1==j)
			     ptr1++;
			   if(ptr2==j)
			     ptr2--;
			   if(ptr2>=1)
			   {
				   x=prefix[ptr2];
			   }
			   if(ptr1<=n)
			   {
				   y=suffix[ptr1];
			   }
			   if(x+y>=k)
			   {
				   result=true;
				   break;
			   }
		   }
		   if(!result)
		   {
			   vec.push_back(j);
		   }
	   }
   }
   for(int z:vec)
     cout<<z<<endl;
   cout<<endl;
}


Measured memory_bytes: 3840
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

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

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input!(a: [i32; 3]);
    let sum: i32 = a.iter().sum();
    puts!("{}\n", if sum >= 22 { "bust" } else { "win" });
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
//		List<String> divisor = new ArrayList<>();
//		int[] in = Stream.of(sc.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
		int N = Integer.parseInt(sc.next());
//		int S = Integer.parseInt(sc.next());
//		String[] S = sc.next().split("");
		
//		for (int i = 1; i <= N; i++) {
//		}
		
		long mod = 1_000_000_007;
		int[] n = new int[N+1];
		for(int i = 1;i <= N; i++) {
			int num = i;
			for(int j = 2;j <=num; j++) {
				while(num % j == 0) {
					n[j]++;
					num /= j;
				}
			}
		}
		
		long res = 1;
		for(int i = 0; i <= N; i++) 
			res = (res*(n[i]+1)) % mod ;
		
		System.out.println(res);		
	}
}


Measured memory_bytes: 21460
n = int(raw_input())
for i in range(n):
	Y, M, d = map(int, raw_input().split(" "))
	day_total = 0
	if Y % 3 == 0:
		day_sub = (M-1) * 20 + d - 1
	else :
		small_M = (M - 1) / 2
		day_sub = (M - 1 - small_M) * 20 + small_M * 19 + d - 1 
	for y in range(Y,1000):
		if y % 3 == 0:
			day_total += 10 * 20
		else :
			day_total += (20 + 19) * 5
	print day_total - day_sub

Measured memory_bytes: 4232
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  n = n%10;
  if(n == 2 || n==4 || n==5 || n==7 || n==9)
    cout<<"hon";
  else if(n == 0 || n==1 || n==6 || n==8)
    cout<<"pon";
  else if(n == 3)
    cout<<"bon";
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <random>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using Pt = pair<int, int>;

int main()
{
	int N;
	cin >> N;
	vi X(N + 1);
	for(int x = 1; x * x <=N; ++x )
	{
		for (int y = 1; y * y <= N; ++y)
		{
			for (int z = 1; z * z <= N; ++z)
			{
				int c = x * x + y * y + z * z + x * y + y * z + z * x;
				if(c <= N)
					++X[c];
			}
		}
	}
	for (int i = 1; i <= N; ++i)
		cout << X[i] << endl;
	return 0;
}


Measured memory_bytes: 3576
#include<iostream>
#include<deque>
#include<algorithm>
#include<numeric>
using namespace std;
int main()
{
	int n,s;
	while(cin>>n,n)
	{
		deque<int>d(n);
		while(n--)cin>>s,d[n]=s;
		sort(d.begin(),d.end());
		d.pop_back(),d.pop_front();
		cout<<accumulate(d.begin(),d.end(),0)/d.size()<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vpii;

int main() {
  ll N;
  cin >> N;
  vi A(N);
  for (ll i = 0; i < N; i++) {
    cin >> A[i];
  }

  {
    vi v(A);
    unordered_map<ll, ll> t;
    sort(v.begin(), v.end());
    for (ll i = 0; i < N; i++) {
      t[v[i]] = i;
    }
    for (ll i = 0; i < N; i++) {
      A[i] = t[A[i]];
    }
  }

  ll ans = 0;
  for (ll i = 0; i < N; i++) {
    ans += (A[i] - i + (1ll << 30)) % 2;
  }

  cout << ans / 2 << endl;
}

Measured memory_bytes: 5924
using System;

class Program
{
    static void Main(string[] args)
    {
        int A = int.Parse(Console.ReadLine());
        int B = int.Parse(Console.ReadLine());
        int C = int.Parse(Console.ReadLine());
        int X = int.Parse(Console.ReadLine());

        int count = 0;
        for (int i = 0; i <= A; i++)
            for (int j = 0; j <= B; j++)
                for (int k = 0; k <= C; k++)
                    if(500 * i + 100 * j + 50 * k == X)
                        count++;

        Console.WriteLine(count);
    }
}

Measured memory_bytes: 11092
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

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

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll N;
  string S, T;
  cin >> N >> S >> T;

  REP(i, 0, N + 1) {
    if (S.substr(i, S.size()) == T.substr(0, T.size() - i)) {
      cout << N + i << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define x first
#define y second
int n, m;
int par[100010];
int r(int x){ return (x==par[x])?x:(par[x]=r(par[x])); }
priority_queue<int> pq[100010];
bool join(int a, int b){
	a=r(a); b=r(b);
	if(a==b) return 0;
	par[a]=b;
	if(pq[a].size()>pq[b].size()) swap(pq[a], pq[b]);
	while(pq[a].size()){
		pq[b].push(pq[a].top()); pq[a].pop();
	}
	return 1;
}
int pc[100010];
inline void dame(){ puts("Impossible"); exit(0); }
int main()
{
	read(n, m);
	for(int i=0; i<n; ++i){
		par[i]=i;
		int x; read(x);
		pq[i].push(-x);
	}
	for(int i=1; i<=m; ++i){
		int a, b; read(a, b); join(a, b);
	}
	priority_queue<pp> qb;
	int ones = 0;
	int bigs = 0;
	ll ans = 0;
	for(int i=0; i<n; ++i) if(par[i] == i){
		int s = pq[i].size();
		if(s > 1){
			ans += pq[i].top(); pq[i].pop(); ++pc[i];
			if(pq[i].size()){
				qb.emplace(pq[i].top(), i);
			}
			++bigs;
		} else {
			ans += pq[i].top();
			++ones;
		}
	}
	
	if(ones + bigs == 1){ puts("0"); return 0; }
	
	if(bigs == 0){
		if(ones > 2) dame();
		printf("%lld\n", -ans);
		return 0;
	}
	
	if(ones > (n-ones-2*(bigs-1))) dame();

	for(int i=0; i<bigs-2+ones; ++i){
		if(qb.empty()) dame();
		int a = qb.top().second; qb.pop();
		ans += pq[a].top(); pq[a].pop();
		++pc[a];
		if(pq[a].size()){
			qb.emplace(pq[a].top(), a);
		}
	}
	printf("%lld\n", -ans);
	return 0;
}


Measured memory_bytes: 8188
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pi = pair<int, int>;
const int MAXN = 100005;
const int mod = 998244353;

int main(){
	lint n, p;
	cin >> p >> n;
	if(p == 1){
		cout << n << endl;
		return 0;
	}
	lint ret = 1;
	for(lint i=2; i*i<=n; i++){
		int cnt = 0;
		while(n % i == 0){
			n /= i;
			cnt++;
		}
		cnt /= p;
		for(int j=0; j<cnt; j++) ret *= i;
	}
	cout << ret << endl;
}

/*
lint dp[MAXN][2][32];
int arr[MAXN][5];

int getbit(int x, int y){ return (x >> y) & 1; }

bool compat(int pos, int msk){
	for(int i=0; i<5; i++){
		if(arr[pos][i] == -1) continue;
		if(getbit(msk, i) != arr[pos][i]) return 0;
	}
	return 1;
}

lint solve(int n){
	for(int i=0; i<32; i++){
		for(int j=0; j<32; j++){
			bool valid = compat(0, i) && compat(1, j);
			if(valid) dp[1][i >> 4][j]++;
		}
	}
	for(int i=1; i<n-1; i++){
		for(int j=0; j<2; j++){
			for(int k=0; k<32; k++){
				dp[i][j][k] %= mod;
				int idx1 = getbit(k, 4);
				for(int idx2 = 0; idx2 < 32; idx2++){
					if(compat(i + 1, idx2) && (j + getbit(idx2, 0) + getbit(k, 2)) % 2 == 0 && 
						(getbit(k, 2) + getbit(k, 3) + getbit(idx2, 1) + getbit(idx2, 2)) % 2 == 0){
						dp[i+1][idx1][idx2] += dp[i][j][k];
					}
				}
			}
		}
	}
	lint ret = 0;
	for(int i=0; i<2; i++){
		for(int j=0; j<32; j++){
			ret += dp[n-1][i][j];
		}
	}
	ret %= mod;
	ret *= (mod + 1) / 2;
	return ret % mod;
}

lint ipow(lint x, lint p){
	lint ret = 1, piv = x;
	while(p){
		if(p & 1) ret = ret * piv % mod;
		piv = piv * piv % mod;
		p >>= 1;
	}
	return ret;
}

int main(){
	int n, m;
	map<pi, int> mp;
	scanf("%d %d",&n,&m);
	memset(arr, -1, sizeof(arr));
	arr[0][0] = arr[0][1] = arr[1][0] = 0;
	arr[n-1][3] = arr[n-1][4] = arr[n-2][4] = 0;
	for(int i=0; i<m; i++){
		int x, y, z;
		scanf("%d %d %d",&x,&y,&z);
		x--; y--;
		if(abs(x - y) <= 2){
			arr[x][y-x+2] = z;
		}
		else{
			if(x > y) swap(x, y);
			if(mp.find(pi(x, y)) != mp.end()){
				if(mp[pi(x, y)] != z){
					puts("0");
					return 0;
				}
			}
			else mp[pi(x, y)] = z;
		}
	}
	lint free = 0;
	for(int i=1; i<=n; i++){
		free += max(0, n - 2 - i);
	}
	free -= mp.size();
	cout << solve(n) * ipow(2, free) % mod << endl;
}*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(lli i=a;i<b;i++)
#define initialize(array,size,value) for(lli i=0;i<size;i++) array[i]=value
#define couta(array,size) for(lli i=0;i<size;i++) cout<<array[i]<<" "
#define vl vector<lli>
#define vp vector< pair <lli,lli> >
#define sl set<lli>
#define msp multiset < pair < long long , long long > > S;
#define pll pair<lli, lli>
#define mll map<lli, lli>            //for( map<lli, lli>::iterator i=temp.begin();i!=temp.end();i++)cout<<i->fi<<" "<<i->se<<endl;
#define mvl map<lli, vl>
#define umll unordered_map<lli, lli>
#define vt vector<pair<lli, pll >  >
#define vf vector<pair<pll,pll > >
#define qu queue<lli>
#define pq priority_queue<lli>
#define dq deque <lli>
#define ptr vector<lli>::iterator
#define bs(array,x) binary_search(array.begin(),array.end(),x) // also valid for set and multiset
#define lb(array,x) lower_bound(array.begin(),array.end(),x)
#define ub(array,x) upper_bound(array.begin(),array.end(),x)
#define nobw(array,i,j) upper_bound(array.begin(), array.end(), j)-lower_bound(array.begin(), array.end(), i) //number of numbers between i & j
#define vc clear()
#define endl '\n'
#define sp system("pause");
#define INF 9223372036854775807
#define MINF -9223372036854775808
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
int main()
{
 //	ios::sync_with_stdio(0);
 //   cin.tie(0);
    char a;
    cin>>a;
    if(a=='A')cout<<"T";
    if(a=='T')cout<<"A";
    
    if(a=='C')cout<<"G";
    if(a=='G')cout<<"C";
    
    return 0;
}


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

int main() {
	int N, M; cin >> N >> M;
	int arrL[M], arrR[M];
	for(int i = 0; i < M; ++i) {
    	int L, R; cin >> L >> R;
		arrL[i] = L; arrR[i] = R;
    }
	int ans = *min_element(arrR, arrR+M) - *max_element(arrL, arrL+M) + 1;
	cout << ((ans < 0) ? 0 : ans) << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<string>
#include<math.h>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<map>
#include<numeric>
#include<stack>
#include<queue>
#include<functional>
#include<cassert>
#include<set>
#define rep(a,b) for(ll a=0;a<b;++a)
#define REP(a,b,c,d) for(ll a=b;a<c;a+=d)
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define mod 1000000007
using namespace std;
using ll = long long;
using p_i = pair<int, int>;
int main() {
	double T, X; cin >> T >> X;
	cout << T / X << endl;
	cin >> T;
}

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


def solve(S: str):
    N  = len(S)
    RN = S.count('0')
    BN = N - RN
    print(min(RN,BN)*2)

    return


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

if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
import numpy as np

n=1000
X = int(input())

a = np.array(range(n))
ex = np.full(n, 5)

m = a*n+a.reshape(n,1)

b = np.power(a, ex)

plus = b + b.reshape(n,1)
minus = b - b.reshape(n,1)

plus = plus==X
minus = minus==X

if np.count_nonzero(plus):
  c = m[plus][0]
  ans = int(c/n), -int(c%n)
else:
  c = m[minus][0]
  ans = int(c/n), int(c%n)
  
print(ans[0], ans[1], sep=' ')

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

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

void Rec( int L, int R );
void Solve();

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

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

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

Measured memory_bytes: 3132
#include <iostream>
using namespace std;
int main(void){
   int a,b;
   cin>>a;
   cin>>b;
   
   
   if (a<b)
       cout  <<"a < b";
    
   
   else if (a>b)
       cout<<"a > b";
    
   
   else if(a==b)
       cout<<"a == b";
    
   cout<<endl;


}


Measured memory_bytes: 3080
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>

using namespace std;
typedef long long ll;

const ll modint = 1000000007;

int main()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    ll sum = 0;
    for (int i = 0; i < n; i++)
    {
        sum += a[i];
    }
    ll ans = 0;
    for (int i = 0; i < n; i++)
    {
        sum -= a[i];
        ans += a[i] * (sum % modint);
        ans %= modint;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4840
n, x = map(int, input().split())
line = input().split()
pos = [0]
for i in range(n):
	l = int(line[i])
	pos.append(pos[i]+l)

cnt = 0
for p in pos:
	if p <= x:
		cnt += 1
	else:
		break
print(cnt)


Measured memory_bytes: 3060
#define DEBUG 0

#include <bits/stdc++.h>
using namespace std;

#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}

// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
    public:
        template<typename T>
        _Debug& operator,(T val) {
            cout << val << endl;
            return *this;
        }
};
#define debug _Debug(),
#else
#define printLine(l)
#define printLine2(l,c)
#define printVar(n)
#define printArr(a,l)
#define print2dArr(a,r,c)
#define print2dArr2(a,r,c,l)
#define debug
#endif

// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
#define mp make_pair
#define pb push_back

// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;

// ---------- END OF TEMPLATE ----------

int A[100000];
int main() {
    int i;
    int N,M,V,P;
    scanf("%d %d %d %d",&N,&M,&V,&P);
    for (i = 0; i < N; i++) scanf("%d",&A[i]);
    sort(A,A+N);

    int l = 0,r = N-1;
    while (l < r) {
        int m = (l+r) / 2;
        int poss = 0;
        if (m >= N-P) poss = 1;
        else {
            vi v;
            for (i = 0; i < N; i++) {
                if (i != m) v.pb(A[i]);
            }
            printVar(m);
            printArr(v,v.size());
            int z = 0;
            for (i = 0; i < v.size(); i++) {
                if (v[i] > A[m]+M) z++;
            }
            if (z < P) {
                z = 0;
                LLI c = 0;
                for (i = (int) v.size()-1; i >= 0; i--) {
                    int x = A[m]+M-v[i];
                    if (z < P-1) {
                        c += M;
                        if (v[i]+M > A[m]+M) z++;
                    }
                    else {
                        if (x < 0) c = -1e18;
                        c += min(x,M);
                    }
                }
                if (c >= (LLI) (V-1)*M) poss = 1;
            }
        }
        if (poss) r = m;
        else l = m+1;
    }
    printf("%d\n",N-l);

    return 0;
}



Measured memory_bytes: 1596
N, Y = map(int, input().split())
for x in range((Y // 10000) + 1):
    for y in range((Y // 5000) + 1):
        z = N - (x + y)
        if z < 0:
            continue
        if (10000 * x) + (5000 * y) + (1000 * z) == Y:
            print(x, y, z)
            break
    else:
        continue
    break
else:
    print(-1, -1, -1)


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

vector<int> v;

main()
{
	int n,c;
	scanf("%d %d",&n,&c);
	for(int i=0;i<n;i++)
	{
		int a;
		scanf("%d",&a);
		v.push_back(a);
	}
	int ans=0;
	sort(v.begin(),v.end());
	for(int i=0;i<n;i++)
	{
		if(c>=v[i])
		{
			c-=v[i];
			ans++;
		}
		else
		{
			break;
		}
	}
	if(ans==n)
	{
		if(c>0)
			ans--;
	}
	printf("%d",ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <string>

using namespace std;

int main() {
    map<string, int> freq;
    int modecnt = 0;
    string mode;
    string longest;
    string str;
    while(cin >> str) {
        if(modecnt < ++freq[str]) {
            modecnt = freq[str];
            mode = str;
        }
        if(str.size() > longest.size()) longest = str;
    }
    cout << mode << ' ' << longest << endl;
    return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define db double
#define pint pair<int,int>
#define mk(x,y) make_pair(x,y)
#define fir first
#define sec second
#define Rep(x,y,z) for(int x=y;x<=z;x++)
#define Red(x,y,z) for(int x=y;x>=z;x--)
using namespace std;
const int MAXN=5e5+5,Mod=998244353;
char buf[1<<12],*pp1=buf,*pp2=buf,nc;int ny;
inline char gc() {return pp1==pp2&&(pp2=(pp1=buf)+fread(buf,1,1<<12,stdin),pp1==pp2)?EOF:*pp1++;}
//inline char gc(){return getchar();}
inline int read(){
	int x=0;for(ny=1;nc=gc(),(nc<48||nc>57)&&nc!=EOF;)if(nc==45)ny=-1;if(nc<0)return nc;
	for(x=nc-48;nc=gc(),47<nc&&nc<58&&nc!=EOF;x=(x<<3)+(x<<1)+(nc^48));return x*ny;
}int n,m,Fac[MAXN],iFac[MAXN],ans;
inline int Fp(int x,int k){int ans=1;for(;k;k>>=1,x=1ll*x*x%Mod)if(k&1)ans=1ll*ans*x%Mod;return ans;}
inline void pre(int n){
	Fac[0]=1;Rep(i,1,n)Fac[i]=1ll*Fac[i-1]*i%Mod;
	iFac[n]=Fp(Fac[n],Mod-2);Red(i,n,1)iFac[i-1]=1ll*iFac[i]*i%Mod;
}
inline int C(int n,int m){return n<0||m<0||n<m?0:1ll*Fac[n]*iFac[m]%Mod*iFac[n-m]%Mod;}
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	n=read(),m=read(),pre(5e5);if(n<m)swap(n,m);
	for(int i=0,opt=1;i<=m;i++,opt=Mod-opt)ans=(ans+1ll*C(n,i)*C(m,i)%Mod*Fac[i]%Mod*Fp(n+1,m-i)%Mod*Fp(m+1,n-i)%Mod*opt)%Mod;
	cout<<ans<<'\n';
	return 0;
}




Measured memory_bytes: 7504
import java.util.Scanner; 

class Main{

 public static void main(String[] args){

 Scanner scan = new Scanner(System.in);

 int A = scan.nextInt();
 int B = scan.nextInt();
 int C = scan.nextInt();
 int D = scan.nextInt();
   
 while (C>0 && A>0){
   C = C-B;
     if (C<=0){
       System.out.println("Yes");
     }
     else{
      A = A-D;
       if (A<=0){
         System.out.println("No");
       }
     }
   }
 }
}

Measured memory_bytes: 35688
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef vector<bool> vbool;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<llint> vllint;
typedef vector<vllint> vvllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;
#define Pi 3.1415926535897932384626
#define coutans rep(i, ans.size())cout << ans[i] << endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(int a, int b) {
	return a > b;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//aCbを1000000007で割った余りを求める
llint convination(llint a, llint b) {
	llint ans = 1;
	for (llint i = 0; i < b; i++) {
		ans *= a - i;
		ans %= 1000000007;
	}
	for (llint i = 1; i <= b; i++) {
		ans *= modinv(i, 1000000007);
		ans %= 1000000007;
	}
	return ans;
}

int main() {
	int n;
	cin >> n;
	int a, b;
	a = b = 0;
	rep(i, n) {
		string s, t;
		cin >> s >> t;
		if (s < t)b += 3;
		if (s > t)a += 3;
		if (s == t) {
			a++; b++;
		}
	}
	cout << a << " " << b << endl;
	return 0;
}


Measured memory_bytes: 3060
#include <stdio.h>
#include <vector>

using namespace std;

int main(void){
	while(true){
		int n, m, t1, t2;
		scanf("%d\n%d", &n, &m);
		if(n == 0 && m == 0) return 0;

		vector< vector<int> > G;

		for(int i = 0;i < n;++i){
			vector<int> V;
			G.push_back(V);
		}

		for(int i = 0;i < m;++i){
			scanf("%d %d", &t1, &t2);
			G[t1-1].push_back(t2-1);
			G[t2-1].push_back(t1-1);
		}

		vector<int> guests(n, 0);

		for(int i = 0;i < G[0].size();++i){
			guests[G[0][i]] = 1;
			for(int j = 0;j < G[G[0][i]].size();++j){
				guests[G[G[0][i]][j]] = 1;
			}
		}

		int c = 0;
		for(int i = 1;i < n;++i){
			c += guests[i];
		}

		printf("%d\n", c);
	}
}


Measured memory_bytes: 2892
"use strict";
function main(input) {
  let kari = input[0].trim().split(" ").map(i => parseInt(i));
  const n = kari[0];
  const m = kari[1];
  if(n===0 && m ===0){
    console.log(0);
  }else{
    console.log((n*(n-1)/2) + (m*(m-1)/2));
  }

}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"));

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

int main(){
    
    int N;
    cin>>N;
    vector<int> S(N);
    int sum=0;
    for(int i=0;i<N;i++){
        cin>>S[i];
        sum+=S[i];
        S[i]*=N;
    }
    int www=100000,ans;
    for(int i=0;i<N;i++){
        if(abs(S[i]-sum)<www){
            www=abs(S[i]-sum);
            ans=i;
        }
    }
    cout<<ans<<endl;
}


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

using ll = long long;

ll cal(vector<ll>&A,ll tar)
{
    if(A.empty())return 0;
    ll p1 = 0,p2 = A.size()-1;
    ll res = 0;
    do
    {
        while(p1 < p2 && A[p1] * A[p2] > tar) p2--;
        res += p2 - p1;
        p1++;
    }while(p1 < p2);
    return res;
}

ll cal2(vector<ll>&A,vector<ll>&B,ll tar)
{
    if(A.empty()||B.empty())return 0;
    ll p1=0, p2 = B.size()-1;
    ll res = 0;
    do
    {
        while(p1 < A.size() && A[p1]*B[p2] <= tar ) p1++;
        res += A.size() - p1;
        p2--;
    }while(p1 < A.size() && p2 >= 0);
    return res;
}


void solve(ll N,ll K,vector<ll>A)
{
    sort(A.begin(),A.end());
    ll negNum = lower_bound(A.begin(),A.end(),0)-A.begin();
    ll zeroNum = upper_bound(A.begin(),A.end(),0)-lower_bound(A.begin(),A.end(),0);
    ll posNum = N-negNum-zeroNum;

    ll posProdNum = posNum*(posNum-1)/2 + negNum*(negNum-1)/2;
    ll zeroProdNum = zeroNum*(zeroNum-1)/2 + zeroNum * (negNum + posNum);
    ll negProdNum = N*(N-1)/2 - posProdNum - zeroProdNum;

    if(K > negProdNum && K <= negProdNum + zeroProdNum)
    {
        cout<<0<<endl;
        return;
    }


    vector<ll> posData,negData;
    for(auto x:A)
    {
        if(x<0)negData.push_back(-x);
        if(x>0)posData.push_back(x);
    }

    sort(negData.begin(),negData.end());
    if(K > negProdNum + zeroProdNum)
    {
        K -= negProdNum + zeroProdNum;
        ll l = 0, r = 1e18+10;
        while(l < r)
        {
            ll mid = (l+r)/2;
            ll index = cal(negData,mid) + cal(posData,mid);
            if(index >= K)
            {
                r = mid;
            }else
            {
                l = mid + 1;
            }
        }
        cout<<l<<endl;
        return;
    }

    ll l = 0, r = 1e18+10;

    while(l < r)
    {
        ll mid = (l+r)/2;
        ll index = cal2(posData,negData,mid);
        if(index >= K)
        {
            l = mid + 1;
        }else
        {
            r = mid;
        }
    }

    cout<<-l<<endl;

}

int main(){
    ll N,K;
    cin>>N>>K;
    vector<ll>A(N);
    for(int i=0;i<N;++i)cin>>A[i];
    solve(N,K,move(A));
    return 0;
}


Measured memory_bytes: 4084
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int n,m,x,ans=2e9+7;
int c[15],a[15][15],post[15];
int main()
{
cin>>n>>m>>x;
for(int i=1;i<=n;i++)
{
	cin>>c[i];
	for(int j=1;j<=m;j++)
	cin>>a[i][j];
}
while(post[0]==0)
{
	int in[15]={0},money=0;
	for(int i=1;i<=n;i++)
	{
		if(post[i]==1)
		{
			money+=c[i];
			for(int j=1;j<=m;j++)
			in[j]+=a[i][j];
		}
	}
	int flag=1;
	for(int i=1;i<=m;i++)
	{
		if(in[i]<x)
		{
			
			flag=0;
			break;
		}
	}
	if(flag)
	ans=min(ans,money);
	for(int i=n;i>=0;i--)
	{
		if(post[i]==1)
		post[i]=0;
		else
		{
			post[i]=1;
			break;
		}
		
	}
}
if(ans!=2e9+7)
cout<<ans;
else
cout<<-1;
return 0;

}

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

int main(void)
{
    int N;
    cin >> N;
    vector<pair<int, int>> A(N);
    vector<vector<ll>> dp(N+1, vector<ll>(N+1, 0ll));
    for(int i=0;i<N;i++){
        int a;
        cin >> a;
        A[i] = make_pair(a, i);
    }
    sort(A.begin(), A.end());
    for(int total=1;total<=N;total++){
        for(int r=0;r<=total;r++){
            int l = total - r;
            int i = N - total;
            ll to_r = r-1<0 ? -1 : dp[r-1][l] + ll(abs(A[i].second - r+1))*ll(A[i].first);
            ll to_l = l-1<0 ? -1 : dp[r][l-1] + ll(abs(A[i].second - (N-1-l+1)))*ll(A[i].first);
            dp[r][l] = max(to_l, to_r);
        }
    }
    ll ans = 0;
    for(int r=0;r<=N;r++){
        int l = N - r;
        ans = max(ans, dp[r][l]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 34676
A,B=map(int,input().split())

def solve(A):
    ret=0
    res=1
    if A%4==1 or A%4==2:
        ret+=res
    dig=A%2
    res<<=1
    A>>=1
    while A>0:
        if dig==0 and A%2==1:
            ret+=res
        res<<=1
        A>>=1
    return ret

print(solve(B)^solve(A-1))


Measured memory_bytes: 9188
N,M,Q = map(int,input().split())
m = [[0 for i in range(N+1)] for i in range(N+1)]
for i in range(M):
  l,r = map(int,input().split())
  m[l][r] += 1
for i in range(N+1):
  for j in range(N):
    m[i][j+1] += m[i][j]
for i in range(N):
  for j in range(N+1):
    m[i+1][j] += m[i][j]    

p = [0]
q = [0]
for i in range(Q):
  a,b = map(int,input().split())
  p.append(a)
  q.append(b)


for i in range(1,Q+1):
  print(m[q[i]][q[i]]+m[p[i]-1][p[i]-1]-m[q[i]][p[i]-1]-m[p[i]-1][q[i]])

Measured memory_bytes: 18396
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) (V).begin(),(V).end()

int main(){
	string S;
	cin >> S;
	if (S == "Sunny")cout << "Cloudy" << endl;
	if (S == "Cloudy")cout << "Rainy" << endl;
	if (S == "Rainy")cout << "Sunny" << endl;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define mod 1000000007
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

template <class T>
void warshall_floyd(vector< vector<T> > & cost, int N) {
  for (ll k = 0; k < N; ++k) {
    for (ll i = 0; i < N; ++i) {
      for (ll j = 0; j < N; ++j) {
        cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
      }
    }
  }
}

/* END */

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

  vector< vector<long long> > cost(10, vector<long long>(10));

  for (int i = 0; i < 10; ++i)
    for (int j = 0; j < 10; ++j)
      cin >> cost[i][j];

  int wall[h][w];
  for (int i = 0; i < h; ++i)
    for (int j = 0; j < w; ++j)
      cin >> wall[i][j];

  floyd_wardhall(cost, 10);

  ll ans = 0;
  for (int i = 0; i < h; ++i) for (int j = 0; j < w; ++j) {
    if (wall[i][j] == -1 or wall[i][j] == 1) continue;
    ans += cost[wall[i][j]][1];
  }

  cout << ans << endl;
}*/

// 二部マッチング
bool graphColoring(vector<vector<int>> const& G, vector<int>& V, int const C, int const parent, int const now) {
  if (V[now] == 0) V[now] = C;

  // これから塗る色は-C
  int ret = true;
  for (auto v : G[now]) {
    if (v == parent) continue;

    if (V[v] == 0) {
      V[v] = -C;
      ret &= graphColoring(G, V, -C, now, v);
    } else if (V[v] != 0 && V[v] != -C) {
      return false;
    }
  }

  return ret;
}

// 隣あっている辺を選ぶ？
// 最初から全部の点が選ばれているとしたら？

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

  int N;
  cin >> N;
  vector<string> S(N);
  vector<vector<int>> cost(N+1, vector<int>(N+1));
  vector<vector<int>> G(N+1);
  repr(i, N, 0) {
    cin >> S[i];
    for (int j = 0; j < N; ++j) {
      cost[i][j] = S[i][j] - '0';
      if (cost[i][j] == 1) {
        G[i].push_back(j);
      } else if (cost[i][j] == 0 && i != j) {
        cost[i][j] = 100000;
      }
    }
  }

  vector<int> V(N+1);
  auto isColoring = graphColoring(G, V, 1, -1, 0);
  if (!isColoring) {
    cout << -1 << endl;
    return 0;
  }

  warshall_floyd(cost, N);
  int d = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      chmax(d, cost[i][j]);
    }
  }

  cout << d + 1 << endl;
}

Measured memory_bytes: 3968
/*input

*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int long long 
#define double long double
#define f first
#define s second
#define mp make_pair
#define pb push_back

#define RE(i,n) for (int i = 1; i <= n; i++)
#define RED(i,n) for (int i = n; i > 0; i--)
#define REPS(i,n) for(int i = 1; (i*i) <= n; i++)
#define REP(i,n) for (int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)

#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;
#define debug(x) cout << x << endl;
#define debug2(x,y) cout << x << " " << y << endl;
#define debug3(x,y,z) cout << x << " " << y << " " << z << endl;

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

const int INF = 1e18+1;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

int raise(int a,int n,int m = MOD){
  if(n == 0)return 1;
  if(n == 1)return a;
  int x = 1;
    x *= raise(a,n/2,m);
    x %= m;
    x *= x;
    x %= m;
    if(n%2)x*= a;
    x %= m;
    return x;
}

int floor1(int n,int k){
    if(n%k == 0 || n >= 0)return n/k;
    return (n/k)-1;
}

int ceil1(int n,int k){
    return floor1(n+k-1,k);
}

void solve(){
 	int x;
 	cin >> x;
 	if(x < 30)cout << "No" << endl;
 	else cout << "Yes" << endl; 
}

signed main(){
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  //freopen(".in","r",stdin);freopen(".out","w",stdout);
  int t = 1;
  //cin >> t;
  while(t--){
    solve();
  }
  return 0;
}

Measured memory_bytes: 3644
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n, a, b; cin >> n >> a >> b;
  cout << min(a * n, b) << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a, b;
	scanf("%d %d", &a, &b);
	if (a == b)
		printf("a == b\n");
	if (a < b)
		printf("a < b\n");
	if (a > b)
		printf("a > b\n");
	return 0;
}

Measured memory_bytes: 580
//#include <bits/stdc++.h>
#include<iostream>
#include<stdio.h>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;


int main(void) {
	
	while (1) {
		int n;
		int maxi = 0;
		bool flag = false;

		cin >> n;
		if (n == 0) {
			break;
		}
		vector<string> s(n + 1);
		vector<int> count(n + 1, 0);
		FOR(i, 1, n) {
			cin >> s[i];
			if (i != 1) {
				RFOR(j, s[i].size() - 1, 0) {
					if (s[i][j] == '.') {
						count[i] = j + 1;
						break;
					}
				}
			}
			
			if (maxi < count[i]) {
				maxi = count[i];
			}
		}

		FOR(i, 0, maxi-1) {
			FOR(j, 1, n) {
				flag = false;

				FOR(k, j+1, n) {
					//cout << j << "  " << k << endl;
					if (count[j] > count[k]) {
						break;
					}
					if (count[j] == count[k]) {
						s[j][count[j] - 1] = '+';
						s[k][count[k] - 1] = '+';
						FOR(l, j+1, k-1) {
							//cout << l << endl;
							if (count[j] - 1 <= s[l].size()) {
								if (s[l][count[j] - 1] == '.') {
									s[l][count[j] - 1] = '|';
								}
							}
							
							
						}
						flag = true;
						break;
					}
				}

				if (flag == false&&count[j]!=0) {
					//cout << j << " " << count[j] - 1 << endl;
					s[j][count[j] - 1] = '+';
				}
			}
		}
		
		FOR(i, 1, n) {
			FOR(j, 0, count[i]-1) {
				if (s[i][j] == '.') {
					s[i][j] = ' ';
				}
			}
		}
		FOR(i, 1, n) {
			cout << s[i] << endl;
		}


	}
	return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <stack>
#include <queue>
#define llong long long
#define INF (__INT32_MAX__ / 2)

using namespace std;
typedef pair<int, int> ipair;

int main(int argc, char **argv) {
    int A, B, T;
    cin >> A >> B >> T;

    int res = B * (T / A);
    
    cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define speed ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define watch(x) cout << (#x) << " is " << (x) << endl
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define F first
#define S second
#define si set <int>

using namespace std;

int main(){speed;
	int n , k;
	cin >> n >> k;
	int a[n];
	for(int i = 0; i < n; ++i ){
		cin >> a[i];
	}
	int cnt = 0;
	for(int i = 0; i < n; ++i ){
		if(a[i] >= k) cnt++;
	}
	cout << cnt;
}

Measured memory_bytes: 640