akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
inline void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
template<class T> inline void operator>>(istream& is,vector<T>& v) { for(int& i : v){ is>>i; } }
template<class T> inline void operator<<(ostream& os,const vector<T>& v) { for(int i : v){ os<<i<<" "; } os<<endl; }
const int inf = 1001001001;
const ll linf = 1001001001001001001;
const int mod = 1000000007;

template<typename T>
struct weight_unionfind {
    vi par,rank;
    vector<T> diff_weight;
    weight_unionfind(int n):par(n,-1),rank(n,0),diff_weight(n,0) {}
    int root(int x) {
        if(par[x] < 0) return x;
        else {
            int r = root(par[x]);
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = r;
        }
    }
    T weight(int x) {
        root(x);
        return diff_weight[x];
    }
    bool same(int x,int y) {
        return root(x) == root(y);
    }
    bool unite(int x,int y,T w) {
        w += weight(x); w -= weight(y);
        x = root(x); y = root(y);
        if(x == y) return false;
        if(rank[x] < rank[y]) swap(x,y),w = -w;
        if(rank[x] == rank[y]) rank[x]++;
        par[x] += par[y];
        par[y] = x;
        diff_weight[y] = w;
        return true;
    }
    T diff(int x,int y) {
        return weight(y)-weight(x);
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n,m;
    cin >> n >> m;
    weight_unionfind<int> uf(n);
    rep(_,m) {
        int l,r,d;
        cin >> l >> r >> d;
        l--; r--;
        if(uf.same(l,r)) {
            if(uf.diff(l,r) != d) {
                cout << "No" << endl;
                return 0;
            }
        } else {
            uf.unite(l,r,d);
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 1536
fun main(args : Array<String>) {
    val n = readLine()!!.toInt()
    val dd = Array(10) { Array(10) { 0 } }

    for (i in 1..n) {
        val firstD = i.toString()[0].toString().toInt()
        val endD = i % 10
        dd[firstD][endD]++
    }

    var cnt = 0L
    for (i in 1..9) {
        for (k in 0..9) {
            cnt += dd[i][k] * dd[k][i]
        }
    }

    println(cnt)
}

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

int main(){
	int n;
	cin>>n;
	int ans=n;
	if(ans<10){cout<<n<<endl;}
	else if(ans<100){cout<<9<<endl;}
	else if(ans<1000){cout<<(9+ans-99)<<endl;}
	else if(ans<10000){cout<<(10-1+1000-100)<<endl;}
	else if(ans<100000){cout<<(10-1+1000-100+ans-10000+1)<<endl;}
	else{cout<<(10-1+1000-100+100000-10000)<<endl;}
}

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

int main() {
  int n;
  cin >> n;
  vector<int>x(n);
  rep(i,n) cin >> x.at(i);
  ll ans = 10000000000;
  for(int j=0;j<100;j++){
    ll sum=0;
    rep(i,n) sum  += (x.at(i)-j)*(x.at(i)-j);
    if(ans>sum) ans = sum;
  }
  cout << ans << endl;
  return 0;
}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    string s, t; cin >> s >> t;
    if(s + t.back() == t) cout << "Yes" << endl;
    else cout << "No" << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 7752
#include <iostream>
using namespace std;
int main() {
  int n;
  while (cin >> n) {
    int x = 0;
    for (int a = 0; a <= 9; a++)
      for (int b = 0; b <= 9; b++)
        for (int c = 0; c <= 9; c++)
          for (int d = 0; d <= 9; d++) {
            if (a + b + c + d == n) x++;
          }
    cout << x << endl;
  }
}

Measured memory_bytes: 1164
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<sstream>
using namespace std;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    long long a,b;
    cin>>a>>b;
    int c=0,d=0;
    for(int i=0;i<a;i++){
        c=i+c;
    } 
    for(int i=0;i<b;i++){
        d=d+i;
    }
    int ans=0;
    ans=c+d;
    cout <<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const ll MOD=1e9+7;
const int INF=2e9;
const double PI=acos(-1);


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

    int n,k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int ans=(n-1)/(k-1);
    if ((n-1)%(k-1)>0) ++ans;
    cout << ans << endl;

    return 0;
}


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

int main(){
 int A,B,C,X,Y;
 cin >>A >>B >>C >>X >>Y; 
 int tmp1=A*X+B*Y,tmp2=0;
  
for (int c=0;c<=max(X,Y);c++){
    tmp2=2*c*C+max((X-c),0)*A+max((Y-c),0)*B;
if (tmp1>tmp2){
    tmp1=tmp2;
}
}
cout <<tmp1 <<endl;
return 0;


}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	static Scanner scan=new Scanner(System.in);
	static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
	static long lcm (int a, int b) {return a*b/gcd(a,b);}
	static int max(int a,int b) {return a>b?a:b;}
	static int min(int a,int b) {return a<b?a:b;}
	static long factorial(int i) {return i==1?1:i*factorial(i-1);}
	static int lower_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<=key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static int upper_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2)if(n%i==0){return false;}
		return true;
	}
	static int[] setArray(int a[]) {
		for(int i=0;i<a.length;i++) {
			a[i]=scan.nextInt();
		}
		return a;
	}
		public static void main(String[] args) {
			int a=scan.nextInt();
			int b[]=new int[a];
			b=setArray(b);
			int cnt=0;
			for(int i=1;i<a-1;i++) {
				if(b[i]>b[i-1]&&b[i]<b[i+1]||b[i]<b[i-1]&&b[i]>b[i+1]) {
					cnt++;
				}
			}
			System.out.println(cnt);
		}
}


Measured memory_bytes: 21716
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//ここまでテンプレ
int main(){
	int N,K;
	cin>>N>>K;
	ll zero=0,half=0;
	for(int i=1;i<=N;i++){
		if(i%K==0)
			zero++;
		else if((2*i)%K==0)
			half++;
	}
	cout<<zero*zero*zero+half*half*half<<endl;
	return 0;
}

Measured memory_bytes: 256
a=[0]*(200001)


N = list(map(int, input().split()))
x = [list(map(int, input().split())) for i in range(N[1])]


for i in x:
    if i[0]==1 :
        if a[i[1]]==1:
            print('POSSIBLE')
            quit()
        a[i[1]]=1
    if i[1]==N[0]:
        if a[i[0]]==1:
            print('POSSIBLE')
            quit()
        a[i[0]]=1

print('IMPOSSIBLE')
quit()

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

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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e8
#define INF_LL 1LL<<60
#define ll long long
#define MAX_V 100005

bool sosu(int k) {
    REPN(i, 2, sqrt(k)+1) {
        if(k % i == 0) return false;
    }
    //cout << k << endl;
    return true;
}

int eru(int k) {
    while(1) {
        if(sosu(k)) return k;
        else k++;
    }
}

int main() {
    int n;
    cin >> n;
    int kaisu = 0;
    int kijun = 2;
    int get;
    while(1) {
        while(1){
            get = eru(kijun);
            if(get % 5 == 1) break;
            else kijun = get + 1;
        }

        cout << get << " ";
        kaisu++;
        if(kaisu == n) break;
        kijun = get + 1;
    }
    cout << endl;

    return 0;
}
 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
  string S;
  cin >>S;
  if(S=="Sunny") {
cout << "Cloudy" << endl;
  }
else if(S=="Cloudy") {
cout << "Rainy" << endl;
  }
  else if(S=="Rainy") {
cout << "Sunny" << endl;
  }
}

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

int main(){
  int a,b;
  cin >> a >> b;
  
  if(a<b) cout << "a < b" << endl;
  if(a>b) cout << "a > b" << endl;
  if(a==b) cout << "a == b" << endl;
  
  
    
  return 0;
}



Measured memory_bytes: 3084
#include<iostream>
using namespace std;
#define MAX 100000
typedef long long llong;
int n, k;
llong T[MAX];
// 最大積載量 P の k 台のトラックで何個の荷物を積めるか? 
int check(llong P) {
    int i=0;
    for(int j=0;j<k;j++){
        llong s = 0; 
        while(s+T[i]<=P){
            s += T[i];
            i++;
            if ( i == n ) return n;    
        } 
    }
    return i;
}

int solve() {
    llong left=0;
    llong right=100000*10000;//荷物の個数×1個当たりの最大重量 
    llong mid;
    while(right-left>1){
        mid = (left + right) / 2;
        int v = check(mid); // mid == P を決めて何個積めるかチェック
        if(v>=n)right=mid;
        else left = mid;
    } 
    return right;
}

int main() {
    cin>>n>>k;
    for(int i=0;i<n;i++)cin>>T[i];
    llong ans = solve();
    cout << ans << endl;
    return 0;
}


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


int main(void){
   int a,b;
   cin >> a >> b;
   string s;
   cin >> s;
   
  if(s[a] != '-'){
      cout << "No" << endl;
      return 0;
  }
   
  for(int i = 0;i < s.size();i++){
      if(i == a)continue;
       
      if(!('0' <= s[i] && s[i] <= '9')){
          cout << "No" << endl;
          return 0;
      }
  }
  cout << "Yes" << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 998244353
#define INF63 1061109567
#define INF127 9187201950435737471
#define UINF 18446744073709551615
#define F first
#define S second
#define ll long long
#define N 200010
using namespace std;
ll n,m,l[N],r[N];
map<ll,ll> mp;
multiset<ll> ans;
int main(){
	ll i,pos,val;
	scanf("%lld%lld",&n,&m);
	for(i=0;i<n;i++)
	{
		scanf("%lld%lld",&l[i],&r[i]);
		l[i]--;
		r[i]--;
	}
	for(i=0;i<m;i++)
	{
		mp[i]=0;
		ans.insert(0);
	}
	for(i=0;i<n;i++)
	{
		if(r[i]+1<m)
		{
			map<ll,ll>::iterator it=mp.upper_bound(r[i]+1);
			if(it!=mp.begin())
			{
				it--;
				pos=it->first;
				val=it->second;
				if(pos!=r[i]+1)//couldn't be chosen before
				{
					mp[r[i]+1]=val+r[i]+1-pos;
					ans.insert(val+r[i]+1-pos);
				}
				else if(pos==r[i]+1&&mp[r[i]+1]>val)//have a better value (guess that this might not exist after all, but just in case)
				{
					ans.erase(ans.find(mp[pos]));
					mp[pos]=val;
					ans.insert(val);
				}
			}
		}
		map<ll,ll>::iterator it=mp.lower_bound(l[i]);
		while(it!=mp.end())
		{
			pos=it->first;
			val=it->second;
			if(pos>r[i])
			{
				break;
			}
			ans.erase(ans.find(val));
			it=mp.erase(it);
		}
		if(ans.empty())
		{
			puts("-1");
		}
		else
		{
			printf("%lld\n",i+1+(*ans.begin()));
		}
	}
	return 0;
}

Measured memory_bytes: 28712
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define PI  3.14159265358979323846
#define M   1000000007
ll gcd(ll a,ll b)
{
    if(a==0)
        return b;
    else
        return gcd(b%a,a);
}
ll fast(ll n,ll a,ll m)
{
    if(n==0)
        return 1;
    else if(n==1)
        return a;
    else
    {
        ll res=fast(n/2,a,m)%m;
        if(n%2==0)
            return (((res%m)*(res%m))%m);
        else
            return (((((res%m)*a)%m)*res)%m);
    }
}
ll lcm(ll a,ll b)
{
    ll p=a*b;
    p/=gcd(a,b);
    return p;
}
ll isprime(ll N)
{
    if(N==2||N==3)
    {
        return 1;
    }
    if(N%2==0||N%3==0)
    {
        return 0;
    }
    for(ll i=5;i*i<=N;i+=6)
    {
        if(N%i==0||N%(i+6)==0)
            return 0;
    }
    return 1;
}
ll f(ll N)
{
    if(N==1)
        return 1;
    else
        return 1+f(N/2);
}
int main()
{

   ll H;
   cin>>H;
   ll cnt=f(H);
   ll ans=1;
   for(ll i=1;i<=cnt;i++)
   {
       ans*=2;
   }
   ans--;
   cout<<ans;


}


Measured memory_bytes: 256
class Node:
	def __init__(self, k):
		self.k = k
		self.l = self.r = self.p = None
	def __str__(self):
		return str(self.k)

class BST:
	def __init__(self):
		self.root = None
	
	def insert(self, node):
		p = None
		cur = self.root
		while cur != None:
			p = cur
			if node.k < cur.k:
				cur = cur.l
			else:
				cur = cur.r
		node.p = p			
		if p == None:
			self.root = node
		elif node.k < p.k:
			p.l = node
		else:
			p.r = node
	
	def print(self):
		self.print_in_order()
		self.print_pre_order()
	
	def print_in_order(self):
		st = []
		cur = self.root
		while cur != None or len(st) != 0:
			if cur != None:
				st.append(cur)
				cur = cur.l
			else:
				cur = st.pop()
				print(' ' + str(cur), end='')
				cur = cur.r
		print()
		
	def print_pre_order(self):
		st = []
		st.append(self.root)
		while len(st) != 0:
			cur = st.pop()
			print(' ' + str(cur), end='')
			if cur.r != None:
				st.append(cur.r)
			if cur.l != None:
				st.append(cur.l)
		print()

m = int(input())
bst = BST()
for i in range(m):
	cmd = list(map(str, input().split()))
	if cmd[0] == 'insert':
		bst.insert(Node(int(cmd[1])))
	else:
		bst.print()



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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define INF 999999999
#define MAX_V 100000
#define llong long long

int main()
{
    string s;
    cin >> s;
    int rest = 15;
    int win = 0;
    rep(i, s.length())
    {
        rest--;
        if (s[i] == 'o')
        {
            win++;
        }
    }
    if (rest + win >= 8)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
N = int(input())
T, A = map(int, input().split())
H_list = list(map(int,input().split()))
ans = 0
temp = 10 ** 6
for i in range(N):
    t = T - H_list[i] * 0.006
    a = abs(A-t)
    if a < temp:
        ans = i + 1
        temp = a
print(ans)


Measured memory_bytes: 9256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#include "bits/stdc++.h"
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int P,Q,R;
	scan(P>>Q>>R);
	prin(P+Q+R-max(max(P,Q),R));
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# File              : a.py
# Author            : recurze
# Date              : 22:46 18.01.2019
# Last Modified Date: 22:49 18.01.2019

a, b = [int(x) for x in raw_input().split()]
print a + (b>>1)


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

int main(){
    int n,w;
    cin>>n>>w;
    int ws[n],v[n];
    int vmax=0;
    for(int i=0;i<n;i++){
        cin>>ws[i]>>v[i];
        vmax+=v[i];
    }

    long long dp[vmax+1];
    for(int i=0;i<vmax+1;i++) dp[i]=1e18;
    dp[0]=0;

    for(int i=0;i<n;i++){
        for(int j=vmax;j-v[i]>=0;j--){
            dp[j]=min(dp[j],dp[j-v[i]]+ws[i]);
        }
    }

    long long ans=0;

    for(int i=0;i<vmax+1;i++){
        if(dp[i]<=w) ans=i;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
import heapq

N, M = map(int, input().split())
price_list = list(map(int, input().split()))
price_list = [-1*i for i in price_list]

heapq.heapify(price_list)
for n in range(M):
    max_price = heapq.heappop(price_list)*(-1)
    devided_price = max_price // 2
    heapq.heappush(price_list, (-1)*devided_price)

print((-1)*sum(price_list))

Measured memory_bytes: 14180
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC089_D
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] strs = Console.ReadLine().Split(' ');
            int h = int.Parse(strs[0]);
            int w = int.Parse(strs[1]);
            int d = int.Parse(strs[2]);

            int hw = h * w;

            int[,] offset = new int[d, hw / d + 1];

            int[] row = new int[hw + 1];
            int[] column = new int[hw + 1];

            string[] strsTmp = new string[h];

            for (int i = 0; i < h; ++i)
            {
                string[] strs_ = Console.ReadLine().Split(' ');

                for (int j = 0; j < w; ++j)
                {
                    int tmp_ = int.Parse(strs_[j]);
                    column[tmp_] = j + 1;
                    row[tmp_] = i + 1;
                }
            }

            for (int i = 1; i < hw; ++i)
            {
                int next = i + d;
                if (next <= hw)
                {
                    offset[next % d, next / d] = Math.Abs(row[i] - row[next]) + Math.Abs(column[i] - column[next]) + offset[i % d, i / d];
                }
            }

            int q = int.Parse(Console.ReadLine());

            int[] ans = new int[q];

            for (int i = 0; i < q; ++i)
            {
                string[] strs3 = Console.ReadLine().Split(' ');
                int l = int.Parse(strs3[0]);
                int r = int.Parse(strs3[1]);

                ans[i] = Math.Abs(offset[l % d, l / d] - offset[r % d, r / d]);
            }

            for (int i = 0; i < q; ++i)
            {
                Console.WriteLine("{0}", ans[i]);
            }
        }
    }
}


Measured memory_bytes: 19128
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
    char ch;
    char ans;
    while(cin>>noskipws>>ch){
        if(isalpha(ch)  &&  ch>='A'  &&  ch<='Z')
            ans=ch-'A'+'a';
      else  if(isalpha(ch)  &&  ch>='a'  &&  ch<='z')
            ans=ch-'a'+'A';
        else ans=ch;
            
            cout<<ans;
    }
}

Measured memory_bytes: 3072
#include <cstdio>
using LL = __int128;
int arr[200005];
LL sum[200005], ans = 1e30;
int main()
{
	// freopen("AGC027-B.in", "r", stdin);
	int n, val;
	scanf("%d%d", &n, &val);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", arr + i);
		sum[i] = (i ? sum[i - 1] : 0) + arr[i];
	}
	for (int i = 1; i <= n; i++)
	{
		LL res = (LL)val * (i + n);
		int pos = n - 1, coef = 3;
		while (pos >= 0)
		{
			res += (sum[pos] - (pos >= i ? sum[pos - i] : 0)) * (coef == 3 ? 5 : coef);
			pos -= i;
			coef += 2;
		}
		if (res < ans)
			ans = res;
	}
	printf("%lld\n", (long long)ans);
	return 0;
}


Measured memory_bytes: 4096
#include <stdio.h>
#include <iostream>
#include <string>
#include <map>
#include <fstream>

using namespace std;

map<char, char> mpSConv;
map<char, char> mpTConv;

int main()
{

#ifdef FOR_IDE
	ifstream in("input.txt");
  cin.rdbuf(in.rdbuf());
#endif


	string strS,strT;
	int max_loop;
	bool judge = true;

	cin >> strS;
	cin >> strT;

	max_loop = strS.length();
	
	for(int strIdx = 0; strIdx <= max_loop; strIdx++){
		
		char str_buf = strS[strIdx];
		auto iter = mpSConv.find(str_buf);
		
		if(iter == mpSConv.end()){
			mpSConv[str_buf] = strT[strIdx]; 
		} else {
			if(mpSConv[str_buf] != strT[strIdx]){
				judge = false;
				break;
			}
		}
		
		str_buf = strT[strIdx];
		iter = mpTConv.find(str_buf);

		if(iter == mpTConv.end()){
			mpTConv[str_buf] = strS[strIdx];
		} else {
			if(mpTConv[str_buf] != strS[strIdx]){
				judge = false;
				break;
			}	
		}
	
	}

	if(judge == true){
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}



Measured memory_bytes: 776
class cmb():
    def __init__(self, p=10**9+7, N=10**5+1):
        self.p = p
        self.N = N
        self.fact = [1, 1]
        self.factinv = [1, 1]
        inv = [0, 1]
        for i in range(2, self.N+1):
            self.fact.append((self.fact[-1] * i) % p)
            inv.append((-inv[p%i] * (p//i)) % p)
            self.factinv.append((self.factinv[-1] * inv[-1]) % p)
    def run1(self, a, b):
        return (self.fact[a+b] * self.factinv[a] * self.factinv[b]) % self.p
    def run2(self, n, r):
        return (self.fact[n] * self.factinv[r] * self.factinv[n-r]) % self.p
mod = 10**9+7
def fur(n, r):
    p,q = 1,1
    for i in range(r):
        p = p*(n-i)%mod
        q = q*(i+1)%mod
    return p*pow(q,mod-2,mod)%mod
n, a, b = map(int, input().split())
c = cmb()
work = pow(2, n, 10**9+7)
result = (work - fur(n, a) - fur(n, b) - 1) % (10**9+7)
print(result)

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

#define int long long 

int32_t main() {
    int k, n; cin >> k >> n;
    int A[n];
    for (int i = 0; i < n; i++) {
        cin >> A[i];
    }

    sort(A, A+n);
    int mx = -1;
    for (int i = 0; i < n-1; i++) {
        mx = max(mx, A[i+1] - A[i]);
    }

    mx = max(mx, (k - A[n-1]) + A[0]);
    cout << k - mx << endl;

}

Measured memory_bytes: 1792
import sys

import math
def gcd(a,b):
	if a == 0:
		return b
	return gcd(b%a,a)

def solve(n):
	return n%9

def main():
	n = int(input())
	c= 0
	arr = list(map(int,input().split()))
	for i in range(1,n):
		if arr[i]<arr[i-1]:
			c+=arr[i-1]-arr[i]
			arr[i] = arr[i-1]
	print(c)

if __name__ == "__main__":
	main()


	


Measured memory_bytes: 94192
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int x = sc.nextInt();
		int sum = 0;
		int count = 0;

		for(int i = 0; i <= a; i++){
			for(int t = 0; t <= b; t++){
				for(int s = 0; s <= c; s++){
					sum = 500*i + 100*t + 50*s;
					if(sum == x){
						count++;
					}
				}
			}
		}
		System.out.println(count);
	}
}


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

#define ll long long int
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define MOD 998244353

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	int n;	cin>>n;
	int happy[n][3],dp[n][3]; //max happiness on day i if activity j on that day
	for(int i=0;i<n;i++)
		for(int j=0;j<3;j++){
			cin>>happy[i][j];
			if(i==0) dp[i][j]=happy[i][j];
			else{
				int cmax[3];
				for(int k=0;k<3;k++)
					cmax[k]=dp[i-1][k]+happy[i][j];
				cmax[j]=0;
				dp[i][j]=max(cmax[0],max(cmax[1],cmax[2]));
			}
		}
	
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
	return 0;
}


Measured memory_bytes: 2560
#include<cstdio>
#include<cstring>
#define inlien inline
#define retrun return
#define cpnst const
typedef long long ll;
const ll mod=998244353;
int k,n;
ll C[4444][4444],Lim[2222][2222];
ll ans[6666];
inline ll qpow(ll x,ll k)
{ll r=1;for(;k;k>>=1,(x*=x)%=mod)if(k&1)(r*=x)%=mod;return r;}
inline ll solve(int v)
{
	register int i;
	ll ret=0; 
	for(i=0;i<n;i++)
		(ret+=Lim[v-1][i]*C[n+k-v-i][n-i])%=mod;
	retrun(ret+Lim[v-1][n])%mod;
}
int main()
{
	scanf("%d%d",&k,&n);
	register int i,ii;
	for(i=0;i<=4040;i++)C[i][0]=C[i][i]=1;
	for(i=0;i<=2020;i++)Lim[i][0]=1;
	for(i=1;i<=4040;i++)
		for(ii=1;ii<i;ii++)
			C[i][ii]=(C[i-1][ii-1]+C[i-1][ii])%mod;
	for(i=1;i<=2020;i++)
		for(ii=1;ii<=2020;ii++)
		{
			if(i&1)Lim[i][ii]=(Lim[i-1][ii-1]+Lim[i-1][ii])%mod;
			else Lim[i][ii]=(Lim[i-1][ii]+Lim[i][ii-1])%mod;
		}
	for(i=2;i<=k+1;i++)ans[i]=solve(i);
	for(i=k+2;i<=k*2;i++)ans[i]=ans[k*2+2-i];
	for(i=2;i<=k*2;i++)printf("%lld\n",ans[i]);
}
/*
Giving the world a better yourself is giving yourself a better world. 
*/

Measured memory_bytes: 180352
/*In the name of Allah*/
#include <bits/stdc++.h>
using namespace std;
#define inf 1000000111
#define MAX 505
#define mod 1000000007
#define ll long long
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int x,k;
	cin>>k>>x;
	for(int i = max(-1000000,x - k + 1); i < min(1000000,x + k) ; i++)cout<<i<<" ";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
///////////////////////////////////////////
const long long int INF = INT32_MAX;
const long long int Mod = 1000000007;
const long long int mod = 100000;//10^5
using ll = long long int; //long long int は64bit
using ci = const int; using vi = vector<int>; using Vi = vector<long long int>; using pii = pair<int,int>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(int i=0;i<N;i++)
#define np nullptr
template<class T>bool chmax(T &former, const T &b) { if (former<=b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define fill(x,num) memset(x,num,sizeof(x));
typedef vector<vector<ll> > matrix;
//       cin.tie(0);ios::sync_with_stdio(false);
void cinit(){cin.tie(0);ios::sync_with_stdio(false);}
//////////////////////////^^ *Emile ^^^//////////////////////////////////////////////////////

int main(){
	ll n;vi v;ll aaa;
	cin>>n;
	ll ans = 0;
	ll tmp = 0;ll ct=1;
	rep(i,n){cin>>aaa;v.pb(aaa);}
	tmp = v[0];
	rep(i,n-1){
		if(v[i+1]==tmp){
			ct++;
		}else{
			tmp = v[i+1];
			ans += ct/2;
			ct = 1;
		}
	}
	ans += ct/2;
	cout<<ans<<endl;
	return 0;
}

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

    #define mod 1000000007
    #define ll long long int

    int main()
    {
        ll d,n;
        cin>>d>>n;
        if(d==0)
        {
            if(n==100)cout<<n+1;
            else cout<<n;
        }
        else if(d==1)
        {
            if(n==100)cout<<((n+1)*100);
            else cout<<n*100;
        }
        else if(d==2)
        {
            if(n==100)cout<<((n+1)*10000);
            else cout<<n*10000;
        }
            


    }




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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int n, t[60];
  string s[60];
  cin>>n;
  int ans=0;
  REP(i, n){
    cin>>s[i]>>t[i];
  }
  string x;
  cin>>x;
  // DEBUG(ans);
  bool ok=false;
  REP(i, n){
    if(ok){
      ans+=t[i];
    }
    if(s[i]==x){
      ok=true;
    }
  }
  cout<<ans<<'\n';
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main(){
    double A,B,C,D,E,F;cin>>A>>B>>C>>D>>E>>F;
    pl ans=mp(A*100,0);
    repl(i,1,F+1){
        if(i%100)continue;
        ll p=i/100;bool check=1;
        rep(j,(p+(int)A-1)/(int)A+1){
            if((p-j*(int)A)%(int)B==0){
                check=0;
                break;
            }
        }
        if(check)continue;
        rep(j,F-i+1){
            check=1;
            rep(k,(j+(int)C-1)/(int)C+1){
                if((j-k*(int)C)%(int)D==0){
                    check=0;
                    break;
                }
            }
            if(check)continue;
            if(i/100*E>=j){
                if(ans.se*(i+j)<ans.fi*j)ans=mp(i+j,j);
            }
        }
    }
    cout<<ans.fi<<" "<<ans.se<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int N;
  string S;
  cin>>N>>S;
  int k=0;
  for(int i=1;i<=(N-1)/2;i++)
    for(int j=0;j+i*2<N;j++)
      if(S[j]!=S[j+i] && S[j]!=S[j+i*2] && S[j+i]!=S[j+i*2])
        k++;
  map<int,int> A;
  for(char c:S)
    A[c]++;
  cout<<A['R']*A['G']*A['B']-k<<endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
using Point = pair<int,int>;

//int point[5001][5001] = {0};

vector<bool> used(200000,false);


void bfs(vector<vector<int>> &data,vector<long long> &ans,int t)
{
    used[t] = true;
    //ans[t].first = time;
    for(int i=0;i<data[t].size();i++)
    {
        if(!used[data[t][i]])
        {
        ans[data[t][i]] += ans[t];
        bfs(data,ans,data[t][i]);
        }
    }
    
    
    //ans[t].second = time;
}


int main()
{
    int N,Q;
    cin >> N >> Q;
    string t;
    getline(cin,t);
    
    vector<vector<int>> data(N);
    vector<long long> ans(N,0);
    for(int i=0;i<N-1;i++)
    {
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        data[a].push_back(b);
        data[b].push_back(a);
    }
    for(int i=0;i<Q;i++)
    {
        int a;
        long long b;
        cin >> a >> b;
        a--;
        ans[a] += b;
    }
    //used[0] = true;
    
    bfs(data,ans,0);
    for(int i=0;i<N;i++)
    {
        cout << ans[i] << endl;
    }
    //cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 27392
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>


int main(void) {
	int n, k,l[50];
	int i,j,temp,sum=0;
	scanf("%d%d", &n, &k);

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

	for (i = 0; i < n - 1; i++) {
		for (j = i + 1; j < n; j++) {
			if (l[i] < l[j]) {
				temp = l[i];
				l[i] = l[j];
				l[j] = temp;
			}
		}
	}
	for (i = 0; i < k; i++) {
		sum += l[i];
	}
	printf("%d", sum);

	return(0);
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<ctime>
using namespace std;
typedef long long lt;
typedef double dd;
#define eps 1e-6
#define sqr(x) ((x)*(x))

int read()
{
    int f=1,x=0;
    char ss=getchar();
    while(ss<'0'||ss>'9'){if(ss=='-')f=-1;ss=getchar();}
    while(ss>='0'&&ss<='9'){x=x*10+ss-'0';ss=getchar();}
    return f*x;
}

const int maxn=10010;
int n;
struct point{dd x,y;}p[maxn],O;
dd R;

dd getd(point a,point b){ return sqrt(sqr(a.x-b.x)+sqr(a.y-b.y));}
point getO(point p1,point p2,point p3)
{
    point res;
    dd a=p2.x-p1.x,b=p2.y-p1.y,c=p3.x-p2.x,d=p3.y-p2.y;
    dd e=sqr(p2.x)+sqr(p2.y)-sqr(p1.x)-sqr(p1.y);
    dd f=sqr(p3.x)+sqr(p3.y)-sqr(p2.x)-sqr(p2.y);
    res.x=(f*b-e*d)/(c*b-a*d)/2.0;
    res.y=(a*f-e*c)/(a*d-b*c)/2.0;
    return res;
}

void mincir()
{
    O=p[1]; R=0;
    for(int i=1;i<=n;++i)
    if(getd(p[i],O)-R>eps)
    {
        O=p[i]; R=0;
        for(int j=1;j<i;j++)
        if(getd(p[j],O)-R>eps)
        {
            O=(point){(p[i].x+p[j].x)/2.0,(p[i].y+p[j].y)/2.0};
            R=getd(p[i],p[j])/2.0;

            for(int k=1;k<j;++k)
            if(getd(p[k],O)-R>eps)
            {
                O=getO(p[i],p[j],p[k]);
                R=getd(p[i],O);
            }
        }
    }
}

int main()
{
    n=read();
    for(int i=1;i<=n;++i)
    scanf("%lf%lf",&p[i].x,&p[i].y);

    random_shuffle(p+1,p+1+n);

    mincir();
    printf("%.18f",R);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

int main()
{
    int N , M;
    cin >> N >> M;
    vector<int> A(N);

    int atotal = 0;
    for (int i = 0; i < N; ++i)
    {
        int a;
        cin >> a;
        A[i] = a;
        atotal += a;
    }
    float l = (1.0 * atotal) / (4.0 * M);
    int cnt = 0;
    for (int i = 0; i < N; ++i)
    {
        if (A[i] >= l)
        {
            ++cnt;
        }
    }

    if (cnt >= M)
    {
        cout << "Yes\n";
        return 0;
    }

    cout << "No\n";
    return 0;
}


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

#define all(x) (x).begin(), (x).end()
#define li long long
#define itn int

using namespace std;

inline int nxt(){
	int n;
	scanf("%d", &n);
	return n;
}

const int N = 111 * 111 / 3;
int dp[N][N];

int main(){

	int n = nxt(), m = nxt();
	vector<string> a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];

	int posX = 0, posY = 0;
	for (int i = 0; i < n; i++){
		for (int j = 0; j < m; j++){
			if (a[i][j] == 'E'){
				posX = i;
				posY = j;
			}
		}
	}

	vector<int> i1, i2, j1, j2;
	for (int i = 0; i <= posX; i++){
		for (int j = posX; j < n; j++){
			i1.push_back(i);
			i2.push_back(j);
		}
	}
	for (int i = 0; i <= posY; i++){
		for (int j = posY; j < m; j++){
			j1.push_back(i);
			j2.push_back(j);
		}
	}

	vector<vector<int>> prefX(n, vector<int>(m + 1, 0)), prefY(n + 1, vector<int>(m, 0));
	for (int i = 0; i < n; i++){
		for (int j = 0; j < m; j++){
			prefX[i][j + 1] = prefX[i][j] + (a[i][j] == 'o' ? 1 : 0);
		}
	}
	for (int i = 0; i < n; i++){
		for (int j = 0; j < m; j++){
			prefY[i + 1][j] = prefY[i][j] + (a[i][j] == 'o' ? 1 : 0);
		}
	}

	int q = i1.size(), w = j1.size();
	vector<vector<int>> pos1(posX + 1, vector<int>(n - posX));
	for (int i = 0; i < q; i++)
		pos1[i1[i]][i2[i] - posX] = i;
	vector<vector<int>> pos2(posY + 1, vector<int>(m - posY));
	for (int i = 0; i < w; i++)
		pos2[j1[i]][j2[i] - posY] = i;

	dp[pos1[posX][0]][pos2[posY][0]] = 0;
	for (int i = posX; i >= 0; i--){
		for (int ii = 0; ii < n - posX; ii++){
			for (int j = posY; j >= 0; j--){
				for (int jj = 0; jj < m - posY; jj++){
					int l = j, r = jj + posY, u = i, d = ii + posX;
					int actl = jj, actr = m - 1 - (posY - j), actu = ii, actd = n - 1 - (posX - i);
					// if (l == posY && r == posY && u == posX && d == posX)
					// 	continue;
					int& res = dp[pos1[i][ii]][pos2[j][jj]];
					if (r > posY)
						res = max(res, dp[pos1[i][ii]][pos2[j][jj - 1]] + (r > actr ? 0 : prefY[min(d, actd) + 1][r] - prefY[max(u, actu)][r]));
					if (l < posY)
						res = max(res, dp[pos1[i][ii]][pos2[j + 1][jj]] + (l < actl ? 0 : prefY[min(d, actd) + 1][l] - prefY[max(u, actu)][l]));
					if (d > posX)
						res = max(res, dp[pos1[i][ii - 1]][pos2[j][jj]] + (d > actd ? 0 : prefX[d][min(r, actr) + 1] - prefX[d][max(l, actl)]));
					if (u < posX)
						res = max(res, dp[pos1[i + 1][ii]][pos2[j][jj]] + (u < actu ? 0 : prefX[u][min(r, actr) + 1] - prefX[u][max(l, actl)]));
				}
			}
		}
	}

	int ans = 0;
	for (int i = posX; i >= 0; i--){
		for (int ii = 0; ii < n - posX; ii++){
			for (int j = posY; j >= 0; j--){
				for (int jj = 0; jj < m - posY; jj++){
					// cerr << i << " " << ii + posX << " " << j << " " << jj + posY << " " << dp[pos1[i][ii]][pos2[j][jj]] << "\n";
					ans = max(ans, dp[pos1[i][ii]][pos2[j][jj]]);
				}
			}
		}
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 35968
using System;
class Program
{
    static void Main()
    {
        string[] In = Console.ReadLine().Split(' ');
        int n = int.Parse(In[0]);
        int k = int.Parse(In[1]);
        bool[] S = new bool[n];
        int d = 0;
        for(int i=0; i<k; i++)
        {
            d = int.Parse(Console.ReadLine());
            string[] In2 = Console.ReadLine().Split(' ');
            for(int j=0; j < d; j++)
            {
                S[int.Parse(In2[j]) - 1] = true;
            }
        }
        int cnt = 0;
        for(int i=0; i < n; i++)
        {
            if (S[i] == false) cnt++;
        }
        Console.WriteLine(cnt);
    }
}

Measured memory_bytes: 27808
#include <stdio.h>

int main() {
  char t[4];
  int sum = 700;

  scanf("%c%c%c", &t[0], &t[1], &t[2]);
  
  if (t[0] == 'o') {
    sum += 100;
  }
  if (t[1] == 'o') {
    sum += 100;
  }
  if (t[2] == 'o') {
   sum += 100;
  }

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

  return 0;
}


Measured memory_bytes: 128
//Algorithm Visualizer
#include<bits/stdc++.h>
#define f(i,a,b) for(int i=a; i<b; i++)
#define F first;
#define S second;
using namespace std;
typedef long long ll;

void solve()
{
    int n;
    cin>>n;
    int a[n],dp[n];
    for(int i=0; i<n; i++){
        cin>>a[i];
    }
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    for(int i=2; i<n; i++){
        dp[i]=min(abs(a[i-1]-a[i])+dp[i-1],abs(a[i-2]-a[i])+dp[i-2]);
    }
    cout<<dp[n-1];
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    t=1;
    while(t--){
        solve();
        cout<<endl;
    }
}




Measured memory_bytes: 4376
import java.util.*;
import java.io.*;
public class Main {
	static final int NONUM=-1;
	
	public static void main(String[] args)throws IOException{
		final Scanner sc=new Scanner(System.in);
		int num = sc.nextInt();
		NODE[] n = new NODE[num];
		
		for(int i=0;i<n.length;i++){
			int id=sc.nextInt();
			n[id]=new NODE();
			n[id].id=id;
			n[id].k=sc.nextInt();
			n[id].p=NONUM;
			n[id].t="leaf";
			if(n[id].k>0){
				n[id].c=new int[n[id].k];
				for(int j=0;j<n[id].k;j++){
					n[id].c[j]=sc.nextInt();
				}
				n[id].t="internal node";
			}
		}
		
	     for(int i=0; i<num; i++){
	    	 for(int k=0; k<n[i].k; k++){
	    		 n[n[i].c[k]].p = n[i].id;
	         }
	     }
		
		for(int i=0;i<num;i++){
			if(n[i].p==NONUM){
				n[i].t="root";
				for(int j=0;j<n[i].k;j++){
				getdepth(n,n[i].c[j],1);
				}
			}
		}
		
		for(int i=0;i<num;i++){
			System.out.print("node "+n[i].id+": parent = "+n[i].p+ ", depth = "+n[i].d+", "+n[i].t+", [");
			for(int j=0;j<n[i].k;j++){
				if(j==0) System.out.print(n[i].c[j]);
				else System.out.print(", "+n[i].c[j]);
			}
			System.out.println("]");
		}
	}
	

	
	
	static void getdepth(NODE[] n,int i,int d){

		n[i].d=d;
		d++;
		for(int j=0;j<n[i].k;j++){
			getdepth(n,n[i].c[j],d);
		}
	}		
}

class NODE{
	int id;
	int k;
	int[] c;
	int p;
	int d;
	String t; 
}

Measured memory_bytes: 124840
import itertools as it

n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))

r = list(it.permutations(range(1, n+1)))

a = 0
b = 0
for i in range(len(r)):
    if r[i] == p:
        a = i
    if r[i] == q:
        b = i

print(abs(a-b))


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

inline void ioThings() {
  ios::sync_with_stdio(0);
  cin.tie(0);
#ifdef LOCAL
  freopen("io\\in.txt", "r", stdin);
  freopen("io\\out.txt", "w", stdout);
#define debug(x) cerr << #x << ": <" << (x) << ">\n"
#else
#define debug(x)
#endif
}

#define rep(i, n) for (int i = 0; i < n; i++)
#define dotc()    int tcs; if (cin >> tcs) rep(tc, tcs)
#define sz(x)     (int)x.size()
#define eb        emplace_back
#define pb        push_back
#define mp(x, y)  make_pair(x, y);
#define all(x)    x.begin(), x.end()
#define rall(x)   x.rbegin(), x.rend()
#define fi        first
#define se        second
#define mod       1000000007

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using si = set<int>;
using ii = pair<int, int>;
using vii = vector<ii>;

int main() {
  ioThings();

  int n;
  cin >> n;

  vi a(n);
  map<int, int> b;
  rep(i, n) {
    int x;
    cin >> x;
    a[i] = x;
    b[x - i]++;
  }

  ll cnt = 0;
  rep(i, n) {
    if (b.count(-a[i] - i)) cnt += b[-a[i] - i];
  }

  cout << cnt;

  return 0;
}


Measured memory_bytes: 12648
import Control.Arrow
import Control.Monad
import Data.Bits
import qualified Data.ByteString.Char8 as BC
import Data.Char
import Data.List
import Data.Maybe

main :: IO ()
main = do
  _ <- getInt
  s <- getString
  let ws = init $ scanl (\a c -> if c == 'W' then a + 1 else a) 0 s
  let es = tail $ scanr (\c a -> if c == 'E' then a + 1 else a) 0 s
  print . minimum $ zipWith (+) ws es

getInt :: IO Int
getInt = readLn

getString :: IO String
getString = getLine


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

using namespace std;

#define ll long long
#define X first
#define Y second
#define all(x) x.begin(), x.end()

const int MX = (int)1e5 + 10;
const int mod = (int)1e9 + 7;

int main(){

    cin.tie(0); cout.tie(0);
    ios_base::sync_with_stdio(0);

    int a, b;
    cin >> a >> b;

    if(a <= 9 && b <= 9) cout << a * b;
    else cout << -1;

    return 0;
}

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

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) ll(x.size()) //sizeをsize_tからllに直しておく
#define LEN(x) ll(x.length()) //lengthをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB emplace_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set

int main(){
    ll h, w, m;
    cin >> h >> w >> m;
    vector<ll> hi(m), wi(m);
    REP(i, m) cin >> hi[i] >> wi[i];
    vector<ll> cnt_h(h+1), cnt_w(w+1);
    REP(i, m){
        cnt_h[hi[i]]++;
        cnt_w[wi[i]]++;
    }
    ll maxh = 0, maxw = 0;
    vector<ll> x, y;
    REP(i, h){
        if(maxh < cnt_h[i+1]){
            maxh = cnt_h[i+1];
            x.clear();
            x.PB(i+1);
        }
        else if(maxh == cnt_h[i+1]){
            x.PB(i+1);
        }
    }
    REP(i, w){
        if(maxw < cnt_w[i+1]){
            maxw = cnt_w[i+1];
            y.clear();
            y.PB(i+1);
        }
        else if(maxw == cnt_w[i+1]){
            y.PB(i+1);
        }
    }
    vector<bool> is_x(h+1, false), is_y(w+1, false);
    REP(i, SIZE(x)) is_x[x[i]] = true;
    REP(i, SIZE(y)) is_y[y[i]] = true;
    ll num = SIZE(x) * SIZE(y);
    REP(i, m){
        if(is_x[hi[i]] && is_y[wi[i]]) num--;
    }
    if(num > 0) cout << maxh + maxw;
    else cout << maxh + maxw - 1;
    return 0;
}

Measured memory_bytes: 20896
package main

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

var s = bufio.NewScanner(os.Stdin)

func getInt() int {
	s.Scan()
	a, _ := strconv.Atoi(s.Text())
	return a
}

func main() {
	s.Split(bufio.ScanWords)
	a, b, t := getInt(), getInt(), getInt()

	ans := b * (t / a)

	fmt.Println(ans)

}


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

int main(){
  int a, b, ans;

  cin >> a >> b;
  if(a == b){
    ans = a * 2;
  }else if(a > b){
    ans = a + a -1;
  }else{
    ans = b + b -1;
  }

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


Measured memory_bytes: 256