akhauriyash/Code-Regression huggingface dataset:
import qualified Data.ByteString.Char8 as BS
import Control.Monad.ST
import Control.Applicative
import Control.Monad
import Data.Array.ST
import Data.Array
import Data.List
import Debug.Trace

main = do
  s <- getLine

  let
    len = length s
    a = len * (len-1) `div` 2
    b = (sum . map ((\x -> x*(x-1)`div`2) . length) . group . sort) s 

  print $ a - b + 1


Measured memory_bytes: 22780
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>

class UnionFindTree{
private:
  std::vector<int> parent;
  
public:
  UnionFindTree(int n) : parent(n){
    for(int i = 0; i < n; i++) parent[i] = i;
  }
  
  int find(int x){
    if(parent[x] == x) return x;
    else return parent[x] = find(parent[x]);
  }

  void unite(int x, int y){
    parent[find(x)] = find(y);
  }

  bool same(int x, int y){
    return find(x) == find(y);
  }
};

struct Road{
  int t1;
  int t2;
  int cost;

  bool operator>(const Road& r) const{
    return cost > r.cost;
  }
};

struct Town{
  int x;
  int y;
  int name;
};

int cost_of_road(Town t1, Town t2){
  return std::min(std::abs(t1.x - t2.x), std::abs(t1.y - t2.y));
}

int main(){
  int N;
  std::cin >> N;
  
  std::vector<Town> towns(N);
  std::priority_queue<Road, std::vector<Road>, std::greater<Road>> pq;
  for(int i = 0; i < N; i++){
    int x, y;
    std::cin >> x >> y;
    towns[i] = {x, y, i};
  }
  
  std::sort(towns.begin(), towns.end(), [](const Town& t1, const Town& t2){
    return t1.x < t2.x;
  });
  for(int i = 1; i < N; i++){
    pq.push({towns[i - 1].name, towns[i].name, cost_of_road(towns[i - 1], towns[i])});
  }
  
  std::sort(towns.begin(), towns.end(), [](const Town& t1, const Town& t2){
    return t1.y < t2.y;
  });
  for(int i = 1; i < N; i++){
    pq.push({towns[i - 1].name, towns[i].name, cost_of_road(towns[i - 1], towns[i])});
  }
  
  UnionFindTree tree(N);
  long long sum_cost = 0;
  
  while(!pq.empty()){
    Road r = pq.top();
    pq.pop();
    
    if(!tree.same(r.t1, r.t2)){
      tree.unite(r.t1, r.t2);
      sum_cost += r.cost;
    }
  }
  
  std::cout << sum_cost << std::endl;
  
  return 0;
}


Measured memory_bytes: 6004
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <functional>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define mk make_pair

template <class key, class cmp = std::less<key>>
using ordered_set = tree<key, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
const ll mod = 1e9 + 7;

void solve()
{
    ll k;
    cin >> k;

    queue<ll> q;
    for (int i = 1; i < 10; i++)
    {
        q.push(i);
    }

    while (true)
    {
        ll lol = q.front() % 10;
        if (lol)
        {
            q.push(lol+q.front() * 10 - 1);
        }
        q.push(lol + q.front() * 10 + 0);
        if(lol!=9)
        {
            q.push(lol + q.front() * 10 + 1);
        }
        k--;
        if(k==0)
        {
            cout<<q.front()<<endl;
            return;
        }
        q.pop();
    }
}

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

    // ll t;
    // cin >> t;

    // while (t--)
    // {
    //     solve();
    // }
    solve();
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define pb push_back
#define mp make_pair
#define fi first
#define se second

ll fac[1000010], facinv[1000010],inv[1000010];
ll N=1000000,P=1000000007;
ll choose(int n,int k)
{
	if(!(0<=k&&k<=n))return 0;
	return (((fac[n]*facinv[k])%P)*facinv[n-k])%P;
}

int main()
{
	int h,w,a,b;
	fac[0]=1;
	facinv[0]=1;
	inv[1]=1;
	for(int i=2;i<=N;i++)
	{
		inv[i]=P-(P/i)*inv[P%i]%P;
	}
	for(int i=1;i<=N;i++)
	{
		fac[i]=(fac[i-1]*i)%P;
		facinv[i]=(facinv[i-1]*inv[i])%P;
	}
	cin>>h>>w>>a>>b;
	h--;w--;a--;b--;
	ll sum=0;
	int k=h-a-1;
	for(int i=b+1;i<=w;i++)
	{
		
		ll x=choose(i+k,i)%P;
		// cout<<"x "<<x<<endl;
		ll y=choose(h-k+w-i,h-k)%P;
		// cout<<"y "<<y<<endl;
		ll xy=(x*y)%P;
		sum+=xy;
		sum%=P;
		k--;
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 23680
using System;

namespace Panasonic2020
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var sSplit = s.Split();

            var h = int.Parse(sSplit[0]);
            var w = int.Parse(sSplit[1]);
            Console.WriteLine(Problem2.GetAnswer(h, w));
        }
    }

    public class Problem2
    {
        public static long GetAnswer(int h, int w)
        {
            if (h == 1 || w == 1) { return 1; }

            var all = (long)h * w;
            var answer = all / 2;
            if (all % 2 == 1) { ++answer; }
            return answer;
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
  cin>>n;
  int arr[n];
  for ( int i=0;i<n-1;i++)
    cin>>arr[i];
	int total=0;
  total+=arr[0];
  for ( int i=1;i<n-1;i++)
    total+=std::min(arr[i],arr[i-1]);
  total+=arr[n-2];
  cout<<total<<'\n';
}

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

int main() {
	int A, B, K; std::cin >> A >> B >> K;
	int min = std::min(A, B);
	std::vector<int> X;
	for (auto i{ 1 }; i <= min; ++i) {
		if (A % i == 0 && B % i == 0)
			X.push_back(i);
	}
	std::reverse(X.begin(), X.end());
	std::cout << X.at(K - 1) << std::endl;

	return 0;
}


Measured memory_bytes: 3584
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		while(sc.hasNext()){
			int n=sc.nextInt();
			int ptr=0;
			int[] prime=new int[500000];
			prime[ptr++]=2;
			prime[ptr++]=3;
			for(int i=5;i<=n;i+=2){
				int j;
				double sqrtn=Math.sqrt(i);
				for(j=1;j<ptr;j++){
					if(i%prime[j]==0||prime[j]>sqrtn){
						break;
					}
				}
				if(prime[j]>sqrtn){
					prime[ptr++]=i;
				}
			}
			if(n<=1){
				System.out.println(0);
			}
			else if(n==2){
				System.out.println(1);
			}else if(n==3){
				System.out.println(2);
			}else{
				System.out.println(ptr);
			}
		}
	}
}

Measured memory_bytes: 53872
#include <bits/stdc++.h>
using namespace std;
#define int long long
int MAX=1000000007;



signed main() {
 int n,x;
 cin>>n>>x;
 int ans=1;
 int d=0,l;
 for(int i=0;i<n;i++){
     cin>>l;
     d+=l;
     if(d<=x)ans++;
 }
 cout<<ans;


 
   

      return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
using namespace __gnu_pbds;
using namespace std;
/*
int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
*/
#define ull unsigned long long int
#define ll long long int
#define MAX 1000000007
//1e9+7
#define pll pair<ll,ll>
#define pii pair<int,int>
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FO ifstream fin("a.in");ofstream fout("a.out");
#define TEST int testcase;cin>>testcase;while(testcase--)
#define all(x) (x).begin(),(x).end()
#define mset0(x) memset((x), 0, sizeof((x)));
#define mset1(x) memset((x), -1, sizeof((x)));
#define endl "\n"
typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
int fa[301],sizes[301];
int root(int node){
    while(node!=fa[node]){
        fa[node]=fa[fa[node]];
        node=fa[node];
    }
    return(node);
}
void link(int i,int j){
    i=root(i);j=root(j);
    if(i==j) return;
    if(sizes[i]>sizes[j]) swap(i,j);
    sizes[j]+=sizes[i];
    fa[i]=j;
    return;
}
void solve(){
    double n,k;
    cin>>n>>k;
    double ans=0;
    for(double face=1.000;face<=n;face++){
        if(face>=k){
            ans++;
            continue;
        }
        double p=ceil(log2(k/face));
        double q=pow(0.5000,p);
        //cout<<p<<" "<<q<<endl;
        ans+=q;
    }
    ans=ans/(n);
    cout<<setprecision(13)<<ans;
    return;
}
int main(){
    IO
    //TEST
    solve();
    return(0);
}


Measured memory_bytes: 384
r, g, b, n = map(int, input().split())

lst = [r, g, b]
lst.sort()
r = lst[2]
g = lst[1]
b = lst[0]

rlim = n//r
glim = n//g

cnt = 0

for i in range(rlim+1):
    glim = (n-i*r)//g
    for j in range(glim+1):
        if (n-i*r-j*g) % b == 0:
            cnt += 1
print(cnt)


Measured memory_bytes: 40300
#[allow(unused_imports)]
use std::cmp;
use std::io::Write;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
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:tt ]) => {{
    let len = read_value!($iter, usize);
    (0..len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  }};

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

fn main() {
  let out = std::io::stdout();
  let mut out = std::io::BufWriter::new(out.lock());
  macro_rules! puts {
    ($($format:tt)*) => (write!(out,$($format)*).unwrap());
  }
  input! {
    n: usize,
    aa: [i64; n],
  }
  let all: i64 = aa.iter().sum();
  let mut acc = 0;
  let mut ans = 1 << 60;
  for &a in &aa {
    acc += a;
    ans = cmp::min(ans, (all - 2 * acc).abs());
  }

  puts!("{}\n", ans);
}


Measured memory_bytes: 9464
/*jai_ganeshdeva*/

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pu push  //  adds the value to the last of the queue 
#define lld long long int
#define ins insert /// used in set to insert the values 
#define adv advance  /// used to increment the iterator
#define mp make_pair
#define fi first
#define se second
#define all(c) c.begin(),c.end()
#define PI 3.1415926
#define INF (lld)1e18
#define vl  vector<long long int >
#define vpll vector< pair<lld ,lld> >
#define vvl vector<vector<lld> > 
#define pll pair <lld,lld>
#define modA(cccc,bbbb ,p) (((cccc+bbbb)%p+p)%p)
#define modS(cccc,bbbb ,p) (((cccc-bbbb)%p+p)%p)
#define modM(cccc,bbbb ,p) ((((cccc%p)*(bbbb%p))%p+p)%p)

long long int modp(lld a,lld p,lld n)
{
    lld d[100];
    lld i,j,k,l;
    if(n==0) return 1;
    for(i=0;n>=1;i++)
    {
        d[i]=n%2;
        n/=2;
    }
    l=i;
    long long int e=1;
    if(d[0]==1) e*=(a%p);
    for(i=1;i<l;i++)
    {
        a*=a;
        a=a%p;
        if(d[i]==1) 
        {
            e*=a;
            e=e%p;
        }
    }
    return e%p;
}
lld modInverse(lld n, lld p) 
{ 
    return modp(n, p, p-2); 
}

/*lld fac[100001]; 

void getfac(lld p)
{
    fac[0] = 1; 
    for (lld i=1 ; i<=100000; i++) 
        fac[i] = fac[i-1]*i%p; 
}    

long long int nCrmodp(lld n, lld r,lld p) 
{ 
   // Base case 
   if (r==0) 
      return 1; 
     
    return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
}*/


lld gcd(lld a,lld b)
{
    if(a>b) return gcd(b,a);
    if(b%a==0) return a;
    else return gcd(b%a,a);
}

lld p1=1e9 + 7,p2=998244353;
lld l,r,mid,ans;
lld n,i,j,k,g,m;
lld x,y,n1,n2,h,z,c;
lld aa=1;



void solve()
{
    cin>>x>>y;
    x+=y;
    cout<<6-x;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lld t=1;
    
    //cin>>t;
    //cout<<t;
   //  getfac(p2);
    //check the value by which modulo is to be taken
    lld ans=0;
    for(int i=0;i<t;i++)
    {
   //     cout<<"Case #"<<i+1<<": ";
                  solve();
        cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define MAX(a,b) a=a>b?a:b
#define MIN(a,b) a=a<b?a:b
#define REP(i,x,n) for(int i=x;i<n;i++)
#define REPR(i,x,n) for(int i=n-1;i>=x;i--)
#define pb  push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLr(obj) (obj).rbegin(), (obj).rend()
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const double PI=3.14159265358979323846;



int main(){
   ll n,k,cnt=0;;
   string s;
   ll a[202020],b=1,c;
   cin>>n>>k;;
   rep(i,n){
       cin>>a[i];
        
        if(i+1>k){
            if(a[i-k]<a[i])cout<<"Yes"<<endl;
            else cout<<"No"<<endl;
            
        }
        
   }

   
}


Measured memory_bytes: 5204
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
	string s;
	cin>>s;
	int p=0;
	for(int i=0;i<s.size();i++)if(s[i]=='p')p++;
	cout<<s.size()/2-p<<endl;
	return 0;
}


Measured memory_bytes: 512
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ENDL '\n'
#define print(i) std::cout << (i) << '\n'

#define int long long // at least int64 > 9*10^18
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	int x,y;
	std::cin >> x >> y;
	if(std::abs(x-y)<=1) print("Brown");
	else print("Alice");
	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys,itertools
import numpy as np
input = sys.stdin.readline
h, w, k = map(int, input().split())
c_ = []
for i in range(h):
  cc = input().split()
  c_.append([0 if s=='.' else 1 for s in cc[0]])
# print(c_)
c = np.array(c_)
# print(c)
# print(c[1,:])
# print(c[:,2])
h_s = []
for i in range(2**h):
  lis_h = []
  for j in range(h):
    if (i>>j) &1==1:
      lis_h.append(j)
  h_s.append(lis_h)
  
w_s = []
for i in range(2**w):
  lis_w = []
  for j in range(w):
    if (i>>j) &1==1:
      lis_w.append(j)
  w_s.append(lis_w)
# print(h_s,w_s)
count = 0
# if np.sum(c)==k:
#  count+=1
for hh in h_s:
  for ww in w_s:
    c_copy = c.copy()
    c_copy[hh,:]=0
    c_copy[:,ww]=0
    # print(c_copy)
    if np.sum(c_copy)==k:
      count+=1
print(count)

Measured memory_bytes: 27284
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i=0; i<(n); ++i)
using ll = long long;
using P = pair<int, int>;
 
int main() {
  int r;
  cin >> r;
  printf("%.5f\n", 2 * r * M_PI);
  return 0;
}


Measured memory_bytes: 3724
#include <cstdio>
#include <algorithm>
#include <vector>
#define ll long long 
using namespace std;
const ll INF=1e18;
int n,p1,p2;
ll ans,ex=INF;
int siz[100010],mx[100010];
vector<pair<int,int> >E[100010];
void dfs1(int u,int fa=0){
    siz[u]=1;
    for(int i=0;i<(int)E[u].size();i++){
        int v=E[u][i].first;
        if(v==fa) continue;
        dfs1(v,u);
        siz[u]+=siz[v];
        mx[u]=max(mx[u],siz[v]);
    }
    mx[u]=max(mx[u],n-siz[u]);
    if(mx[u]<=n/2){
        if(!p1) p1=u;
        else p2=u;
    }
}

void dfs2(int u,int fa=0,ll sum=0){
    ans+=2*sum;
    for(int i=0;i<(int)E[u].size();i++){
        int v=E[u][i].first,val=E[u][i].second;
        if(v==fa) continue;
        dfs2(v,u,sum+val);
        if(v==p2||(!p2&&u==p1)) ex=min(ex,1ll*val);
    }
}

int main(){
    scanf("%d",&n);
    for(int i=1;i<n;i++){
        int u,v,val;
        scanf("%d%d%d",&u,&v,&val);
        E[u].push_back(make_pair(v,val));
        E[v].push_back(make_pair(u,val));
    }
    dfs1(1);
    dfs2(p1);
    printf("%lld",ans-ex);
}

Measured memory_bytes: 11904
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
long mod=1e9+7;
int N,M,S[2];
vector<pair<int,int> >G[1<<17];
long d[2][1<<17],w[2][1<<17];
main()
{
	cin>>N>>M>>S[0]>>S[1];
	for(int i=0;i<M;i++)
	{
		int u,v,d;cin>>u>>v>>d;
		G[u].push_back(make_pair(v,d));
		G[v].push_back(make_pair(u,d));
	}
	for(int _=0;_<2;_++)
	{
		for(int i=0;i++<N;)d[_][i]=1e18;
		priority_queue<pair<long,int> >P;
		d[_][S[_]]=0;
		w[_][S[_]]=1;
		P.push(make_pair(0,S[_]));
		while(!P.empty())
		{
			long c=-P.top().first;
			int u=P.top().second;
			P.pop();
			if(d[_][u]<c)continue;
			for(pair<int,int>p:G[u])
			{
				int v=p.first;
				long nxt=c+p.second;
				if(d[_][v]>nxt)
				{
					d[_][v]=nxt;
					w[_][v]=w[_][u];
					P.push(make_pair(-d[_][v],v));
				}
				else if(d[_][v]==nxt)(w[_][v]+=w[_][u])%=mod;
			}
		}
	}
	int T=S[1];
	long ans=w[0][T]*w[0][T]%mod;
	for(int i=0;i++<N;)
	{
		if(2*d[0][i]==d[0][T])
			(ans-=w[0][i]*w[0][i]%mod*w[1][i]%mod*w[1][i])%=mod;
		for(pair<int,int>p:G[i])
		{
			int v=p.first;
			if(2*d[0][i]<d[0][T]&&2*d[0][v]>d[0][T]&&d[0][i]+d[1][v]+p.second==d[0][T])
				(ans-=w[0][i]*w[0][i]%mod*w[1][v]%mod*w[1][v])%=mod;
		}
	}
	cout<<(ans+mod)%mod<<endl;
}

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Ti = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

#define MAX 8008

bool dpX[2][MAX*2];
bool dpY[2][MAX*2];

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  string s;
  cin >> s;
  int n = s.size();
  int x, y;
  cin >> x >> y;
  vector<int> vec[2];
  int idx = 0, cnt = 0;
  rep(i, n) {
    if(s[i] == 'F') cnt++;
    else {
      vec[idx].push_back(cnt);
      cnt = 0;
      idx = 1-idx;
    }
  }
  vec[idx].push_back(cnt);
  /*
  rep(i, vec[0].size()) cout << vec[0][i] << " ";
  cout << endl;
  rep(i, vec[1].size()) cout << vec[1][i] << " ";
  cout << endl;
  */
  bool isX = false, isY = false;
  {
    bool* curr = dpX[0];
    bool* next = dpX[1];
    int l = vec[0][0]+MAX;
    int u = vec[0][0]+MAX;
    curr[vec[0][0]+MAX] = true;
    reps(i, 1, vec[0].size()) {
      rep(j, MAX*2) next[j] = false;
      reps(j, l, u+1) {
	if(curr[j]) {
	  next[j-vec[0][i]] = true;
	  next[j+vec[0][i]] = true;
	  chmin(l, j-vec[0][i]);
	  chmax(u, j+vec[0][i]);
	}
      }
      swap(curr, next);
    }
    isX = curr[x+MAX];
  }
  {
    bool* curr = dpY[0];
    bool* next = dpY[1];
    int l = MAX;
    int u = MAX;
    curr[MAX] = true;
    rep(i, vec[1].size()) {
      rep(j, MAX*2) next[j] = false;
      reps(j, l, u+1) {
	if(curr[j]) {
	  next[j-vec[1][i]] = true;
	  next[j+vec[1][i]] = true;
	  chmin(l, j-vec[1][i]);
	  chmax(u, j+vec[1][i]);
	}
      }
      swap(curr, next);
    }
    isY = curr[y+MAX];
  }
  //cout<<isX<<" "<<isY<<endl;
  cout << (isX && isY ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 384
while True:
    n,x = map(int,raw_input().split())
    if n == 0 and x == 0:
        break

    count = 0 

    for i in range(1,n-1):
        for j in range(i+1,n):
            for k in range(j+1,n+1):
                if i+j+k == x:
                    count += 1
    print('{0}'.format(count))

Measured memory_bytes: 6368
#include<bits/stdc++.h>
using namespace std;
#define vite ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tst lli T; cin>>T; while(T--)
#define mod 1000000007
#define MAX 1e9
#define MIN -1e9
#define lli long long int
#define vt vector
#define pb push_back
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    lli n;
    cin >> n;
    if(n>=30)
        cout << "Yes";
    else
        cout << "No";
    cout<< endl;
    // cout<< fixed << 1.0 * clock() / CLOCKS_PER_SEC << setprecision(10);
    return 0;
}

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

int main(){
    int n, i, a, u = -1, d = 10000;
    cin >> n;
    for(i=0; i<n; i++){
        cin >> a;
        u = max(u, a);
        d = min(d, a);
    }
    cout << u-d;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define vll vector<ll>
#define endl "\n"
#define pll pair<ll,ll>
#define int long long
using namespace std;
 
const ll N = 1e6+2;
const ll MOD = 1e9+7;
const ll INF = 1e15;
bool occ[10];
void solve(){
	ll n;
	cin>>n;
	ll a[n+1];
	for(int i=1;i<=n;i++)cin>>a[i];
	ll gg[n+1];
	gg[0]=0;
	for(int i =1;i<=n;i++)gg[i]=__gcd(gg[i-1],a[i]);
	ll ggs[n+1];
	ggs[n] = a[n];
	for(int i =n-1;i>=1;i--)ggs[i]=__gcd(ggs[i+1],a[i]);
	ll ans =0;
	for(int i =1;i<=n-1;i++){
		ans = max(ans,__gcd(gg[i-1],ggs[i+1]));
	}
	ans =max(ans,gg[n-1]);
	cout<<ans<<endl;
}

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	
	ll t=1;
	
	while(t--){
		solve();
	}
	
//	return 0;
}


Measured memory_bytes: 2560
#include <stdio.h>

int main()
{
    int num;
    int l, r;
    int roop;
  	int i;

    scanf("%d", &roop);
//    printf("num:%d \n",roop);
    num = 0;
    for (i = 1; i <= roop; i++)
    {
        scanf("%d %d", &l, &r);
        num += r - l + 1;
    }
    printf("%d",num);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()
{
	char S[6];
	for(int i = 0; i<6; i++){
		cin >> S[i];
	}

	if(S[2]==S[3] && S[4]==S[5])
		cout << "Yes";
	else
		cout << "No";

	cin >> S[1];

	return 0;
}

Measured memory_bytes: 256
from collections import deque
from heapq import heappush,heappop
import re
def int_raw():
    return int(input())

def ss_raw():
    return input().split()

def ints_raw():
    return list(map(int, ss_raw()))

INF = 1<<29

N = int_raw()
ss = []
cs = []
end_A = []
start_B = []
both_AB = []
for _ in range(N):
    s = input()
    end_A.append(s[-1]=="A")
    start_B.append(s[0]=="B")
    both_AB.append(end_A[-1] and start_B[-1])
    cs.append(s.count("AB"))
    ss.append(s)


def main():
    n_both_AB = sum(both_AB)
    n_endA = sum(end_A)-n_both_AB
    n_startB = sum(start_B)-n_both_AB
    #n_minAB = min(n_startB,n_endA)
    #n_maxAB = max(n_startB,n_endA)
    ans =0
    is_last_A = False
    while (n_both_AB+n_endA+n_startB)>0:
        if is_last_A:
            if n_both_AB>0:
                n_both_AB-=1
                ans+=1
                is_last_A=True
            elif n_startB>0:
                n_startB-=1
                ans+=1
                is_last_A=False
            else:
                 break
        else:
            if n_endA >0:
                n_endA-=1
                is_last_A=True
            elif n_both_AB>0:
                n_both_AB-=1
                is_last_A=True
            else:
                break
        
        
    return sum(cs)+ans
    """if n_minAB+n_both_AB <n_maxAB:
        return sum(cs)+n_minAB+n_both_AB
    else:
        return sum(cs)+(n_minAB+n_maxAB+n_both_AB)//2"""

print(main())


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

int main()
{
	long N, W; cin>>N>>W;
	vector<vector<long>> a(4, vector<long>(1, 0));
	long w0;
	for(int i=0; i<N; ++i) {
		int w, v; cin>>w>>v;
		if (i==0) w0=w;
		a[w-w0].push_back(v);
	}
	for(auto& e: a) {
		sort(begin(e), end(e));
		reverse(begin(e)+1, end(e));
	}

	long res=0;
	long w[4]={}, v[4]={};
#define rep(i, n) \
	for(int i=0; i<a[n].size(); ++i) { \
		w[n]=i*(w0+n); \
		v[n]=0; \
		for(int t=0; t<=i; ++t) v[n]+=a[n][t];

	rep(i, 0) rep(j, 1) rep(k, 2) rep(l, 3)
		if (w[0]+w[1]+w[2]+w[3]<=W)
			res=max(res, v[0]+v[1]+v[2]+v[3]);
	}}}}
	cout<<res<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
#include <utility>
#include <cstring>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define repll(i,n) for(long long int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
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 int INF = INT_MAX;
const long long LLINF = 1LL<<60;
template <typename T_char>
char ToUpper (char cX) { return toupper(cX); }
//g++ -std=c++1z temp.cpp
//./a.exe
ll digit(ll a){
    ll count = 0;
    for (ll i = 0; i < a; i++)
    {   if (a == 0)
        {
            break;
        }else
        {
            a = a/10;
            count++;
        }
    }
    return count;
}
//桁数のカウント
//pow(x,n) == x^n
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a,   b) * b;}



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


string s;
cin >> s;
int strsize = s.length();

while(strsize--) cout << 'x';

//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define int long long
using namespace std;

typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);



signed main(){

    int H, W;
    cin >> H >> W;

    vector<string> S(H);
    REP(i, H){
        cin >> S[i];
    }

    int ans = 0;
    REP(i, H){
        REP(j, W){
            if(S[i][j] == '.') ans++;
        }
    }

    vector<vector<int>> n(H, vector<int>(W, -1));
    queue<Pii> que;
    n[0][0] = 1;
    que.push(Pii(0, 0));

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

    while(!que.empty()){
        Pii tmp = que.front();
        que.pop();
        int x = tmp.first;
        int y = tmp.second;
        if(x == H - 1 && y == W - 1) break;

        REP(i, 4){
            int x0 = x + dx[i];
            int y0 = y + dy[i];
            if(0 <= x0 && x0 < H && 0 <= y0 && y0 < W){
                if(S[x0][y0] == '.' && n[x0][y0] == -1){
                    que.push(Pii(x0, y0));
                    n[x0][y0] = n[x][y] + 1;
                }
            }
        }
    }

    if(n[H - 1][W - 1] > 0){
        ans -= n[H - 1][W - 1];
    }else{
        ans = -1;
    }

    cout << ans;
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
typedef long long ll;
const int INF = 1000000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007ll;

int main(){
	ll n,tm;
	std::cin >> n>>tm;
	vector<ll>t(n);
	rep(i,n)std::cin >> t[i];
	ll ans=0;
	rep(i,n-1){
		ans+=min(t[i+1]-t[i],tm);
	}
	ans+=tm;
	std::cout << ans << std::endl;
}







Measured memory_bytes: 1792
// コッホ曲線
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<algorithm>
#include<iostream>
#include<cmath>

using namespace std;

typedef struct st
{
    double x;
    double y;
}st_Coordinate;

void Koch_curve(st_Coordinate p1, st_Coordinate p2, int n);

int main(void)
{
    int n;
    st_Coordinate st_start, st_end;

    st_start.x = 0; st_start.y = 0;
    st_end.x = 100; st_end.y = 0;

    scanf("%d", &n);

    if( n > 0 )
    {
        // コッホ曲線の作成
        Koch_curve(st_start, st_end, n);
        // 求めた点の2重表示を防ぐため、最後の点だけ別に表示
        printf("%lf %lf\n", st_end.x, st_end.y);
    }
    else
    {
        printf("%lf %lf\n", st_start.x, st_start.y);
        printf("%lf %lf\n", st_end.x, st_end.y);
    }

    return 0;
}

// コッホ曲線を作成する関数
// p1 : 左端の点の座標
// p2 : 右端の点の座標
// count : 関数のcall回数
void Koch_curve(st_Coordinate p1, st_Coordinate p2, int n)
{
    double split_x, split_y;
    st_Coordinate s, t, u;

    if( n <= 0 )
    {
        // call回数が規定値に到達した
        return;
    }

    // 線分を3等分する
    split_x = ( p2.x - p1.x ) / 3.0;
    split_y = ( p2.y - p1.y ) / 3.0;

    // 左端の座標
    s.x = p1.x + split_x;
    s.y = p1.y + split_y;
    // 右端の座標
    t.x = p2.x - split_x;
    t.y = p2.y - split_y;

    // 正三角形の頂点の座標 ( t を s の周りに60°だけ回転させる)
    u.x = ( cos( M_PI / 3.0 ) * ( t.x - s.x ) )
            + ( ( -1 ) * sin( M_PI / 3.0 ) * ( t.y - s.y ) ) + s.x;

    u.y = ( sin( M_PI / 3.0 ) * ( t.x - s.x ) )
            + ( cos( M_PI / 3.0 ) * ( t.y - s.y ) ) + s.y;

    // nの減算
    n--;

    if( n > 0 )
    {
        // 各線分でコッホ曲線を作成する
        Koch_curve(p1, s, n);
        Koch_curve(s, u, n);
        Koch_curve(u, t, n);
        Koch_curve(t, p2, n);
    }
    else
    {
        // 座標の表示
        printf("%.8f %.8f\n", p1.x, p1.y);
        printf("%.8f %.8f\n", s.x, s.y);
        printf("%.8f %.8f\n", u.x, u.y);
        printf("%.8f %.8f\n", t.x, t.y);
        //printf("%lf %lf\n", p2.x, p2.y);
    }

    return;
}



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

#define ll long long
#define ull unsigned long long 
#define endl '\n'
#define pii pair<int, int>

int main(){
    int a, b;
    cin >> a >> b;

    int ans=0;
    for(int i=a; i<=b; ++i){
        string s = to_string(i);
        string k = s;
        reverse(s.begin(), s.end());
        if(k==s)
            ans++;
    }
    cout << ans;
}


Measured memory_bytes: 3692
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define DEBUG true
#ifdef ONLINE_JUDGE
#undef DEBUG
#define DEBUG false
#endif 

using namespace std;

#define MAXN ((int)2e5+5)
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9 + 9)
#define ll long long
#define _ << " " <<
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define TRACE(x) if(DEBUG) cerr << #x << " = " << x << endl;
#define TRACE2(x,y) if(DEBUG) cerr << #x << " = " << x << " | " << #y << " = " << y << endl;
#define pb push_back
#define all(x) x.begin(), x.end()
#define endl "\n"
#define pii pair<int,int>
#define mid ((l+r)/2)

map <string, int> mp;

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);
	string s;
	cin >> s;
	mp["SUN"] = 7;
	mp["MON"] = 6;
	mp["TUE"] = 5;
	mp["WED"] = 4;
	mp["THU"] = 3;
	mp["FRI"] = 2;
	mp["SAT"] = 1;

	cout << mp[s] << endl;



}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cassert>
using namespace std;
#define MOD 1000000007

long long bipow(long long n, long long m) {
    if (m == 0) return 1;
    if (m % 2 == 0) {
        n = (n * n) % MOD;
        return bipow(n, m / 2) % MOD;
    } else
        return (n * bipow(n, m - 1)) % MOD;
}

void set_table(int N, vector<long long> &fact_num, vector<long long> &fact_den){
    fact_num.resize(N+1, 0);
    fact_den.resize(N+1, 0);
    vector<long long> fact_denpow(N+1, 0);

    fact_num[0] = 1;
    for(int i=1; i<=N; i++) fact_num[i] = (fact_num[i-1] * i) % MOD;

    for(int i=0; i<=N; i++) fact_denpow[i] = bipow(i, MOD-2);
    fact_den[0] = 1;
    for(int i=1; i<=N; i++) fact_den[i] = (fact_den[i-1] * fact_denpow[i]) % MOD;
}

long long comb(const vector<long long> &fact_num, const vector<long long> &fact_den, long long m, long long n){
    return ((fact_num[m] * fact_den[n]) % MOD * fact_den[m-n]) % MOD;
}

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

    vector<long long> fact_num, fact_den;
    set_table(2*N, fact_num, fact_den);
    long long ans = 0;
    for(long long M=N; M<2*N; M++){
        long long tmp0, tmp1, tmp2, tmp3, tmp4, tmp;
        tmp0 = comb(fact_num, fact_den, M-1, N-1);
        tmp1 = (bipow(A, N) * bipow(B, M-N)) % MOD;
        tmp2 = (bipow(B, N) * bipow(A, M-N)) % MOD;
        tmp3 = (100*M * bipow(100-C, MOD-2)) % MOD;
        tmp4 = bipow(bipow(A+B, M), MOD-2);

        tmp = tmp0;
        tmp = (tmp * (tmp1 + tmp2) % MOD) % MOD;
        tmp = (tmp * tmp3) % MOD;
        tmp = (tmp * tmp4) % MOD;
        ans = (ans + tmp) % MOD;
    }
    cout << ans << endl;
    return 0;
}

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

#define ALL(x) x.begin(), x.end()

using namespace std;

typedef long long ll;
typedef vector<int> vi;

const int MX = 2e5;

vector<ll> dp(MX, INT_MAX);

void solve(void) {

	ll n, w;
	cin >> n >> w;
	dp[0] = 0; // dp[i] = min weight to reach total value of i

	for(int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		for(int j = MX-1; j >= b; j--) {
			dp[j] = min(dp[j], dp[j-b] + a);
		}
	}

	ll ans = 0;
	for(int i = 0; i < MX; i++) {
		if(dp[i] <= w) {
			ans = i;
		}
	}

	cout << ans << '\n';


}

int main(void) {

	solve();
	return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>

int main()
{
    int d, t;
    int sum, a, rem;
    int i;
    sum=0;

    scanf("%d %d", &d,&t);

    for(i=1; i<=t; i++){
        scanf("%d", &a);
        sum+=a;
    }
    rem=d-sum;
    if(rem>-1)
    {
        printf("%d\n", rem);
    }
    else
    {
        printf("-1\n");
    }

    return 0;
}


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

int n,W,dp[100010],w[110],v[110];

signed main()
{
	ios::sync_with_stdio(false);
	cin>>n>>W;
	for(int i=1;i<=n;i++) cin>>w[i]>>v[i];
	for(int j=1;j<=n;j++){
		for(int i=W;i>=1;i--){
			if(i>=w[j]) dp[i]=max(dp[i],dp[i-w[j]]+v[j]);
		}
	}
	int ans=0;
	for(int i=1;i<=W;i++) ans=max(ans,dp[i]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

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

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍

int main(){
    ll a,b,c; cin>>a>>b>>c;
    cout << 1110-a << ednl;
}


Measured memory_bytes: 256
N=int(input())
A=str(input())
B=str(input())
C=str(input())

s = 0
for i in range(N):
    s+=1 if A[i]!=B[i] else 0
    s+=1 if B[i]!=C[i] else 0
    s+=1 if C[i]!=A[i] else 0
    s+=1 if A[i]==B[i] and B[i]==C[i] else 0
    s-=1
print(s)

Measured memory_bytes: 3064
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def gcd(a, b):
    # a,bの最大公約数D
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    # a,bの最小公倍数
    return a * b // gcd(a, b)


def main():
    N = int(input())
    T = [int(input()) for _ in range(N)]

    result = T[0]
    for i in range(1, N):
        result = lcm(result, T[i])

    print(result)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
import numpy
 
N,K=map(int,input().split())
p=list(map(int,input().split()))
ans = 0
tmp = [0]*(N-K+1)

for i in range(K):
  tmp[0] = tmp[0]+p[i]

for i in range(1,N-K+1):
  tmp[i]=tmp[i-1]-p[i-1]+p[i+K-1]

max_index=numpy.argmax(tmp)
for i in range(max_index,max_index+K):
  ans=ans+float(((p[i]*(p[i]+1))/2)*1/p[i])
print(ans)

Measured memory_bytes: 33904
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define pb push_back
using namespace std;
typedef long long ll;

int main(){
  double r;
  cin>>r;
  double ans = 2*r*3.141592;
  cout << ans << endl;
}

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

int main(){

  int dice[6];

  int a,up,down,n[4];

  char str[150];

  for(a=0;a<=5;a++){

    scanf("%d ",&dice[a]);

    }
 
  scanf("%s",&str);

  int b;

  up=dice[0];
  n[0]=dice[4];
  n[1]=dice[3];
  n[2]=dice[1];
  n[3]=dice[2];
  down=dice[5];

  int sub;

  for(b=0;b<=strlen(str)-1;b++){

    if(str[b]=='N'){

      sub=n[0];
      n[0]=up;
      up=n[2];
      n[2]=down;
      down=sub;

    }else if(str[b]=='S'){

      sub=n[2];
      n[2]=up;
      up=n[0];
      n[0]=down;
      down=sub;

    }else if(str[b]=='W'){

      sub=n[1];
      n[1]=up;
      up=n[3];
      n[3]=down;
      down=sub;

    }else{

      sub=n[3];
      n[3]=up;
      up=n[1];
      n[1]=down;
      down=sub;

    }

  }

  printf("%d\n",up);

  return 0;

}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
using lli = long long int;
using ulli = unsigned long long int;
#define debug(x) cerr << #x << " : " << x << endl

namespace atcoder {
	template<typename T>
	T ncr(T left, T right) {
		right = min(left - right, right);
		T ans = 1;
		for (T i = 1; i <= right; i++) {
			ans = ans * (left - right + i) / i;
		}
		return ans;
	}

	const int LIMIT = 1000000007;
	const int tenfive = 100000;
}

using namespace atcoder;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, h, w;
	cin >> n >> h >> w;
	cout << (n + 1 - h) * (n + 1 - w) << endl;
	return 0;
}

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

int main() {
	int x, y, z, k; cin >> x >> y >> z >> k;
	vector<ll> a(x), b(y), c(z);
	for (int i = 0; i < x; ++i)
	{
		cin >> a[i];
	}
	for (int i = 0; i < y; ++i)
	{
		cin >> b[i];
	}
	for (int i = 0; i < z; ++i)
	{
		cin >> c[i];
	}
	vector<ll> ab;
	for (int i = 0; i < x; ++i)
	{
		for (int j = 0; j < y; ++j)
		{
			ab.push_back(a[i]+b[j]);
		}
	}
	sort(ab.begin(), ab.end(), greater<ll>());
	vector<ll> abc;
	for (int i = 0; i < min(k, x*y); ++i)
	{
		for (int j = 0; j < z; ++j)
		{
			abc.push_back(ab[i]+c[j]);
		}
	}
	sort(abc.begin(), abc.end(), greater<ll>());
	for (int i = 0; i < k; ++i)
	{
		cout << abc[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 43368
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

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

    string S;
    cin >> S;

    --K;

    if (S[K] == 'A') {
        S[K] = 'a';
    } else if(S[K] == 'B') {
        S[K] = 'b';
    } else if(S[K] == 'C') {
        S[K] = 'c';
    }

    cout << S << endl;

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var ABC = Sarray();
            var diff = ABC.Sum(a => ABC.Max() - a);
            WriteLine((diff + 1) / 2 + (diff % 2 == 0 ? 0 : 1));
        }

        static long Mod = 998244353;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 28188
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#define mem(a,b) memset(a,b,sizeof (a))
#define gcd(a,b) __gcd(a,b)
#define all(a) a.begin(),a.end()
#define sz(s) s.size()
#define endl '\n'
#define pb push_back
typedef long long ll;
const int maxn=200010;
const int inf=1e9;
const ll mod=998244353;
const double pi=3.14159265358979;
const double ep=0.0;
using namespace std;
int a[2*maxn],b[maxn],c[2*maxn];
int main()
{
    int n;
    cin>>n;
    int xora=0,xorb=0;
    for (int i=0;i<n;i++)
    {
        cin>>a[i];
        a[i+n]=a[i];
        xora^=a[i];
    }
    for (int i=0;i<n;i++)
    {
        cin>>b[i];
        xorb^=b[i];
    }
    c[0]=a[0];
    for (int i=1;i<2*maxn;i++)
        c[i]=c[i-1]^a[i];
    vector<pair<int,int>>vec;
    for (int i=0;i<n;i++)
    {
        set<int>se;
        int t=20,r=xora^xorb;
        while (t--)
        {
            int x=rand()%n;
            se.insert(x);
        }
        map<int,int>ma;
        for (auto j:se)
        {
            ma[a[i+j]^b[j]]++;
            if (sz(ma)>1)
                break;
        }
        if (sz(ma)==1&&r==0)
            vec.pb(make_pair(i,(*(ma.begin())).first));
        else if (sz(ma)==1&&(*(ma.begin())).first==r)
            vec.pb(make_pair(i,r));
    }
    for (auto i:vec)
        cout<<i.first<<' '<<i.second<<endl;
    return 0;
}


Measured memory_bytes: 9072
n, a, b = map(int, input().split())
ans = [max(a-1, b-1), max(n-a, n-b)]
dis = abs(a-b)
if dis % 2 == 0:
    ans.append(dis//2)
else:
    if abs(a-b) > 2:
        cto = min(a, b)
        ans.append((dis-1)//2+cto)
        ctn = min(n-a, n-b)
        ans.append((dis-1)//2+ctn+1)
print(min(ans))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=200010;
const ll mod=1e9+7;


int main(){  
  string s;
  cin >> s;
  int sz = s.size();
  int ans=-1;
  rep(i,(sz-1)/2){
    if(s.substr(0,i+1)==s.substr(i+1,i+1)){ ans=(i+1)*2; }
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

bool ok(int x, int d){
    int res = 0;
    while (x % 100 == 0) res++, x /= 100;
    return res == d;
}

int main()
{
    int d, n; scanf("%d %d", &d, &n);

    int res = 0;
    while(n){
        res++;
        if (ok(res, d)) n--;
    }

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


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

ll MOD = 1e9+7;


int main() {
    int R, G, B, N; cin >> R >> G >> B >> N;
    ll ans = 0;
    for(int i = 0; i <= 3000; i++){
        for(int j = 0; j <= 3000; j++){
            int b = N - R*i - G*j;
            if(0 <= b && b % B == 0) {
                ans++;
                //cout << i <<"  " << j << "   "<<b << endl;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int selectionSort(int A[],int N){
  int i,j,t,sw=0,minj;
  for(i=0;i<N-1;i++){
    minj=i;
    for(j=i;j<N;j++){
      if(A[j]<A[minj])minj=j;
    }
    t=A[i]; A[i]=A[minj]; A[minj]=t;
    if(i != minj)sw++;
  }
  return sw;
}

int main(){
  int A[100],N,i,sw;
  
  scanf("%d",&N);
  for(i=0;i<N;i++)scanf("%d",&A[i]);
  
  sw=selectionSort(A,N);
  for(i=0;i<N;i++){
    if(i>0)printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
  printf("%d\n",sw);

  return 0;
}



Measured memory_bytes: 2080
/*
        |___Arshit Mangukiya___|
        |___DA-IICT____|
        |___201801173____|
*/
        //__WRITE  YOUR  CODE  HERE___//
#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;            
typedef long double ld;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppl;
typedef vector<pll> vpl;
#define ff first
#define ss second
#define pi acos(-1)
#define mr_ad_0501 ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
#define all(a)      a.begin(),a.end()
#define f(i,a,n) for(ll i=a;i<n;i++)
#define MOD 1000000007
#define MAX 200007
#define LM LLONG_MAX
#define sz size()
#define p(x)        cout<< x << " ";
#define pe(x)       cout<< x << endl ;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
const int N=1e5+5;
        /*  bool fun(pair<int,int>a , pair<int,int>b)
            {
                if(a.ff == b.ff)    return a.ss < b.ss;
                else            return a.ff < b.ff;
            }*/
 /*void bfs(ll x)
 {
    queue<ll> q;
    q.push(x);
    while(!q.empty())
    {
        ll k=q.front();
        q.pop();
        for(auto X:v[k])
        {
            if(!vis[X])
            {
                l[X]=l[k]+1;
                vis[X]=1;
                q.push(X);
            }
        }
    }
 }*/
ll i,j;
void solve()
{
	ll l,r,d,c=0;
	cin>>l>>r>>d;
	f(i,l,r+1)
	{
		if(i%d==0)c++;
	}
	cout<<c;
}
    
int32_t main(){
    mr_ad_0501;
    ll t=1;
    //cin >> t;
    while(t--)
    {
        solve();
    }
    
}    	

Measured memory_bytes: 3644
#include<iostream>
#include<math.h>
using namespace std;

int main(void) {
	int n, t, a, h, ans = 1;
	double d = 1000000000;
	cin >> n >> t >> a;
	double th = 0;
	for (int i = 1;i <= n;i++) {
		cin >> h;
		th = (double)t - h*0.006;
		if (d > fabs(th - a)) {
			d = fabs(th - a);
			ans = i;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
P = [int(input()) for i in range(N)]
maxprice = max(P)
sum = 0
ticket = True
for i in P:
    if(i != maxprice):
        sum += i
    elif(ticket):
        sum += i / 2
        ticket = False
    else:
        sum += i
print(int(sum))

Measured memory_bytes: 38256