akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int h,w;
	cin>>h>>w;
	vector<string> g(h);
	rep(i,h) cin>>g[i];
	vector<int> dx={1,-1,0,0},dy={0,0,1,-1};
	rep(i,h)rep(j,w){
		if(g[i][j]=='#'){
			bool flag=false;
			rep(k,4){
				int nx=i+dx[k],ny=j+dy[k];
				if(0<=nx && nx<h && 0<=ny && ny<w){
					if(g[nx][ny]=='#') flag=true;
				}
			}
			if(!flag){
				cout<<"No"<<endl;
				return 0;
			}
		}
	}
	cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
// stdin
macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}


// Test
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

#[allow(dead_code)]
fn gcd(x: i64, y: i64) -> i64 {
    if y == 0 {
        return x;
    }
    gcd(y, x % y)
}

#[test]
fn test_primes() {
    assert_eq!(primes(1), vec![1]);
    assert_eq!(primes(140), vec![1, 2, 2, 5, 7])
}

#[allow(dead_code)]
fn primes(num: i64) -> Vec<i64> {
    let mut ans = vec![1];
    let mut cur = num;
    for i in 2.. {
        if i * i > num { break; }
        if cur % i == 0 {
            while cur % i == 0 {
                ans.push(i);
                cur /= i;
            }
        }
    }
    if cur > 1 {
        ans.push(cur);
    }
    return ans;
}


test! {
r"RRS
" => r"2",

r"SSS
" => r"0",

r"RSR
" => r"1"
}

use proconio::{input, fastout};
use proconio::source::auto::AutoSource;

fn solve(src: &str) -> String {
    let source = AutoSource::from(src);
    input! {
       from source,
       s:String,
    }
    let s: String = s;
    // todo s can be str?

    let ans = if s.contains("RRR") {
        "3"
    } else if s.contains("RR") {
        "2"
    } else if s.contains("R") {
        "1"
    } else {
        "0"
    };

    format!("{}", ans.to_string())
}




fn main() {
    println!("{}", solve(&stdin!()));
}



Measured memory_bytes: 2136
import sys
input=sys.stdin.readline
n=int(input())
ans=0
cntA,cntB,cntAB=0,0,0
for _ in range(n):
    s=input().strip()
    ans+=s.count('AB')
    if s[0]=='B':
        cntB+=1
        if s[-1]=='A':
            cntAB+=1
    if s[-1]=='A':
        cntA+=1
ans+=min(cntA,cntB)
if cntA==cntB==cntAB and cntAB:
    ans-=1
print(ans)

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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set

using namespace std;

const ll MOD = 1000000007;
const ll INF = (1LL << 62);

int main() {
  // std::cout << std::fixed << std::setprecision(10);

  ll X;
  scanf("%lld", &X);

  ll c = 100;

  ll y = 0;
  for (;;) {
    y++;

    c = c + c * 0.01;
    if (c >= X) {
      break;
    }
  }

  cout << y << endl;
}


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

using namespace std;
const int MAXN = 2e5 + 5;
typedef long long ll;
const ll MOD = 998244353;
ll fact[MAXN];
ll Mminus1[MAXN];
ll b_pow(ll x, ll m) {
	if (m == 1LL) return x % MOD;
	if (m == 0LL) return 1LL;
	if (m % 2LL == 0LL) {
		return b_pow((x*x) % MOD, m / 2LL) % MOD;
	} else {
		return (x * b_pow((x*x) % MOD, m / 2LL)) % MOD;
	}
} 

ll inverse(ll x) {
	if (x == 0) return 1LL;
	return b_pow(x, MOD - 2) % MOD;
}
ll nCk(ll n, ll k) {
	return (((fact[n] % MOD) * inverse(fact[n-k]))% MOD * inverse(fact[k])) % MOD; 
}
void solve() {
	ll n, m, k;
	cin >> n >> m >> k;
	
	Mminus1[0] = 1;
	for (int i = 1; i < MAXN - 1; i++) {
		Mminus1[i] = (Mminus1[i-1] * (m - 1)) % MOD;
	}
	ll suma = 0;
	for (ll i = 0; i <= k; i++) {
		ll r = nCk(n - 1, i);
		r *= m;
		r %= MOD;
		r *= Mminus1[n-i-1];
		r %= MOD;
		//cout << i << " " << r << endl;
		suma += r;
		suma %= MOD;
	}
	cout << suma << endl;
}

int main(){
	fact[0] = 1;
	for (ll i = 1; i < MAXN - 1; i++) {
		fact[i] = fact[i-1] * i;
		fact[i] %= MOD;
	}

	solve();
}



Measured memory_bytes: 6764
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <chrono> 
using namespace std::chrono;
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_mset tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> 
#define fr(i,a,b) for (int i=(a); i<(b);++i)
#define frr(i,a,b) for(int i=(a-1);i>=(b);--i)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define ppb pop_back()
#define pf push_front
#define ppf pop_front()
#define F first
#define S second
#define pii pair<int,int> 
#define rev(a) reverse(a.begin(),a.end())
#define srt(a) sort(a.begin(),a.end())
#define rsrt(a) sort(a.begin(),a.end(),greater<int>())
#define sz(a) (ll)a.size()
#define endl "\n"
#define po(a,b) (ll)(pow(a,b)+0.5)
#define double long double
#define print(a) for(auto x:a)cout<<x<<" ";cout<<endl;
const ll M=1e9+7;
const int MaxM=501;



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

    int tt=1;
    //cin>>tt;
    while(tt--){

ll a;cin>>a;
cout<<a+a*a+a*a*a<<endl;
 
   
  }}



Measured memory_bytes: 3636
/*Author- Soumak Poddar*/

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

#define ll long long int
#define ull unsigned long long int
#define um unordered_map
#define mp make_pair
#define pb push_back

void solve();
int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);

   #ifndef ONLINE_JUDGE
      freopen("input.txt", "r", stdin);
      freopen("error.txt", "w", stderr);
      freopen("output.txt", "w", stdout);
   #endif
   
   int t=1;
   //cin>>t;
   while(t--)
   {
      solve();
      cout<<"\n";
   }
   cerr<<"Time Taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
   return 0;
}
void solve()
{
   string s,pat;
   cin>>s;
   cin>>pat;
   int m=s.length();
   int n=pat.length();
   int dp[m+1][n+1];
   for(int i=0;i<=m;i++)
   {
      for(int j=0;j<=n;j++)
      {
         if(i==0 or j==0)
            dp[i][j]=0;
         else if(s[i-1]==pat[j-1])
            dp[i][j]=1+dp[i-1][j-1];
         else
            dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
      }
   }
   int ind=dp[m][n];
   char lcs[ind+1];
   lcs[ind]='\0';
   int i=m,j=n;
   while(i>0 and j>0)
   {
      if(s[i-1]==pat[j-1])
      {
         lcs[ind-1]=s[i-1];
         i--;
         j--;
         ind--;
      }
      else if(dp[i-1][j]>dp[i][j-1])
         i--;
      else
         j--;
   }
   cout<<lcs;
}

Measured memory_bytes: 38904
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;

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

    vl s(n);
    rep(i, n) {
        cin >> s[i];
    }
    vl t(m);
    rep(i, m) {
        cin >> t[i];
    }

    vvl dp(n+1, vl(m+1));  // dp[i+1][j+1] : s[i]までとt[j]までで、s[i]とt[j]を使うときの場合の数
    vvl rui(n+1, vl(m+1));  // rui[i][j] : Σ dp[x][y] (0 <= x <= i, 0 <= y <= j)
    dp[0][0] = 1;
    rep(i, n+1) {
        rui[i][0] = 1;
    }
    rep(j, m+1) {
        rui[0][j] = 1;
    }
    rep(i, n) {
        rep(j, m) {
            if(s[i] == t[j]) {
                dp[i+1][j+1] = rui[i][j];
            } 
            rui[i+1][j+1] = (rui[i+1][j] + rui[i][j+1] + mod - rui[i][j] + dp[i+1][j+1])%mod;
        }
    }
    
    out(rui[n][m]);
    re0;
}

Measured memory_bytes: 66020
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <typename T> bool chmax(T &a, const T &b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T> bool chmin(T &a, const T &b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
const long long INFLL = 1LL << 60;
const long long MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<int> A(100000);
    ll ans = 0;
    int a;
    rep(i, N) {
        cin >> a;
        A[a - 1]++;
        ans += a;
    }
    int Q, b, c;
    cin >> Q;
    rep(i, Q) {
        cin >> b >> c;
        ans += (c - b) * A[b - 1];
        A[c - 1] += A[b - 1];
        A[b - 1] = 0;
        cout << ans << endl;
    }
}


Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
int main(){
  int h,w;
  cin >> h >> w;
  vector<vector<char>> s(h+2,vector<char>(w+2));
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> s[i+1][j+1];
    }
  }
  bool can=true;
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      if(s[i][j]=='#'){
        if(s[i-1][j]!='#'&&s[i][j-1]!='#'&&s[i][j+1]!='#'&&s[i+1][j]!='#'){
          can=false;
        }
      }
    }
  }
  if(can){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

    int h(const vector<vector<int>> &x) {
        const int C = 997;      // ???f??????
        size_t t = 0;
        for (int i = 0; i != x.size(); ++i) {
            for (int j = 0; j < x[i].size(); ++j) {
                t = t * 2 + x[i][j];
            }
        }
        return t;
    }

vector<map<int,int>>memo(6);
 
int N; 
int solve(const vii &field){
    if(memo[field.size()].find(h(field))==memo[field.size()].end()){
        for(int y=0;y<field.size();++y){
            for(int x=0;x<field[y].size();++x){
                if(field[y][x]){
                int ans=100;
                    for(int xsz=1;xsz<=N-x;++xsz){
                        for(int ysz=1;ysz<=N-y;++ysz){
                            vii nextfield(field);
                            for(int dy=0;dy<ysz;++dy){
                                for(int dx=0;dx<xsz;++dx){
                                    int nexty=y+dy;
                                    int nextx=x+dx;
                                    nextfield[nexty][nextx]=!nextfield[nexty][nextx];
                                }
                            }
                            ans=min(ans,1+solve(nextfield));
                        }
                    }
                 return memo[field.size()][h(field)]=ans;
                }
            }
        }
        return memo[field.size()][h(field)]=0;
    }
    return memo[field.size()][h(field)];
}
int main(){
    while(true){
        cin>>N;
        if(!N)break;
        vii field(N,vector<int>(N));
        for(int i=0;i<N;++i){
            for(int j=0;j<N;++j){
                cin>>field[i][j];
            }
        }
        int ans=solve(field);
        for(int i=0;i<ans;++i){
            cout<<"myon";
        }
        cout<<endl;
 
    }
    return 0;
 
}

Measured memory_bytes: 39212
#include<iostream> 
#include<algorithm>
#include<string>
using namespace std;
string s;
char c[26];
bool u[26];
int main()
{
	int i=0;
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		c[i]=s[i];
	    u[s[i]-'a']=true;
	}    
	if(s.size()<26)
	{
		cout<<s;
		for(int i=0;i<26;i++)
		    if(!u[i])
		    {
		    	cout<<(char)(i+'a');
		    	return 0;
			}
	}
	if(next_permutation(c,c+s.size()))
	{
		for(int i=0;i<s.size();i++)
		{
			cout<<c[i];
			if(s[i]!=c[i])
			    return 0;
		}
	}
	cout<<-1;
	return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
ps = [list(map(str, input().split())) for _ in range(m)]

wa = [0 for _ in range(n)]
ac = set()

for i, j in ps:
    if j == "AC":
        ac.add(i)
    else:
        if i not in ac:
            wa[int(i) - 1] += 1

for k in range(n):
    if str(k + 1) not in ac:
        wa[k] = 0

print(len(ac), sum(wa))


Measured memory_bytes: 39144
n=int(input())
a=list(map(int,input().split()))

print(' '.join(map(str,a)))

for i in range(1,n):
	v=a[i]
	j=i-1
	while j>=0 and a[j]>v:
		a[j+1]=a[j]
		j=j-1
	a[j+1]=v
	print(' '.join(map(str,a)))


Measured memory_bytes: 5596
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)

	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &a[i])
	}

	var sum int
	prev := a[0]
	for i := 1; i < len(a); i++ {
		diff := prev - a[i]
		if diff > 0 {
			sum += diff
		} else {
			diff = 0
		}
		prev = diff + a[i]
	}
	fmt.Println(sum)
}


Measured memory_bytes: 6496
while True:
    m,f,r = map(int,raw_input().split())
    if m==-1 and f==-1 and r==-1:
        break 
    mfsum = m+f
    if m==-1 or f==-1:
        print "F"
    elif mfsum >=80:
        print "A"
    elif mfsum >= 65 and mfsum <80:
        print "B"
    elif mfsum >= 50 and mfsum < 65:
        print "C"
    elif mfsum >=30 and mfsum < 50:
        if r >= 50:
            print "C"
        else: 
            print "D"
    else:
        print "F"

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

int keta(int n){
    int cnt = 0;
    while(n){
        n/=10;
        cnt++;
    }
    return cnt;
}


int main()
{
    int n,m;
    std::cin>>n;
    m = keta(n);
    int ans = 0;

    for(int i=0;i<m;i++){
        for(int j=0;j<m;j++){
            for(int k=0;k<m;k++){
                std::string s;
                for(int a=0;a<i;a++){
                    s.push_back('3');
                }
                for(int a=0;a<j;a++){
                    s.push_back('5');
                }
                for(int a=0;a<k;a++){
                    s.push_back('7');
                }
                std::vector<bool> abc(3);
                for(int a=0;a<(int)s.size();a++){
                    if(s[a] == '3')abc[0] = true;
                    if(s[a] == '5')abc[1] = true;
                    if(s[a] == '7')abc[2] = true;
                }
                if(abc[0]&&abc[1]&&abc[2]&&(int)s.size() <= 10){
                        do{
                            long long number = std::stol(s);
                            if(number <= n) ans++;
                        }while(std::next_permutation(s.begin(),s.end()));
                }
                
                
            }
        }
    }
    std::cout<<ans<<std::endl;

}

Measured memory_bytes: 384
#pragma region include
#include "bits/stdc++.h"
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#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,n,m) for(int i = (int)(n); i < int(m); i++)
#define MOD (int)(1e9+7)
#define INF (int)(1e9)
#define LLINF (int)(4e18)
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
void input() {}
template<typename... R> void input(int& f, R&... r) { scanf("%d", &f); input(r...); }
template<typename... R> void input(double& f, R&... r) { scanf("%lf", &f); input(r...); }
template<typename... R> void input(ll& f, R&... r) { scanf("%lld", &f); input(r...); }
template<typename... R> void input(char& f, R&... r) { scanf("%c", &f); input(r...); }
template<typename... R> void input(string& f, R&... r) { cin >> f; input(r...); }
template<typename T, typename... R> void input(vector<T>& f, R&... r) { REP(i, f.size())input(f[i]); input(r...); }
#pragma endregion
    
int main() {
    int N; input(N);
    vector<int> a(N);
    int cntodd = 0, cntfour = 0;
    REP(i, N) {
        input(a[i]);
        if (a[i] % 2 == 1) cntodd++;
        else if (a[i] % 4 == 0) cntfour++;
    }
    if (cntodd <= cntfour) puts("Yes");
    else if (cntodd - cntfour == 1 && N - cntodd - cntfour == 0) puts("Yes");
    else puts("No");
    getchar(); getchar();
}

Measured memory_bytes: 640
#include<cstdio>
#include<bitset>
using namespace std;
int n,x,s;
bitset<2000005> ans;
void fr(int &num){
	num=0;char c=getchar();int p=1;
	while(c<'0'||c>'9') c=='-'?p=-1,c=getchar():c=getchar();
	while(c>='0'&&c<='9') num=num*10+c-'0',c=getchar();
	num*=p;
}
int main(){
	fr(n);ans[0]=1;
	while(n--) fr(x),ans|=(ans<<x),s+=x;
	for(n=s+1>>1;n<=s;n++)
		if(ans[n]) printf("%d\n",n),n=s+1;
	return 0;
}


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

int main()
{
	vector<pair<int, int>> vec;

	int n;
	cin >> n;

	while (n--)
	{
		int a, b;
		cin >> a >> b;

		vec.push_back(make_pair(a, b));
	}

	sort(vec.begin(), vec.end());

	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i].first << " " << vec[i].second << endl;
	}

	return 0;
}


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

int main() {
  long long A, B, C, K;
  cin >> A >> B >> C >> K;
  if (abs(A - B) > 1000000000000000000) cout << "Unfair" << endl;
  else if (K % 2 == 0) cout << A - B << endl;
  else cout << B - A << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N,K; cin>>N>>K;
    vint cnt(N);
    REP(i,N){
        int a; cin>>a;
        cnt[a-1]++;
    }
    sort(ALL(cnt));

    int ans=0;
    REP(i,N-K) ans+=cnt[i];
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
import java.util.*;

class Main{

    char[] in;
    int p;

    void solve(){
	Scanner sc = new Scanner(System.in);

	while(true){
	    String line = sc.next();
	    if(line.equals(".")) break;
	    
	    in = new char[line.length()];
	    p = 0;
	    
	    int cnt = 0;
	    for(int P=0; P<=2; P++){
		for(int Q=0; Q<=2; Q++){
		    for(int R=0; R<=2; R++){
			
			for(int i=0; i<line.length(); i++){
			    in[i] = line.charAt(i);
			    if(in[i]=='P') in[i] = (char)(P+'0');
			    if(in[i]=='Q') in[i] = (char)(Q+'0');
			    if(in[i]=='R') in[i] = (char)(R+'0');
			}
			p = 0;
			int ans = formula();
			//System.out.println(Arrays.toString(in)+" "+ans);
			if(ans==2) cnt++;
			
		    }
		}
	    }
	    
	    System.out.println(cnt);
	}
    }

    int formula(){
	int res = 0;
	if(p<in.length && Character.isDigit(in[p])){
	    res = in[p] - '0';
	    p++;
	}else if(p<in.length && in[p]=='-'){
	    p++;
	    res = mai(formula());
	    //p++;
	}else if(p<in.length && in[p]=='('){
	    p++;
	    int a = formula();
	    //p++;
	    boolean boo = false;
	    if(in[p]=='+') boo = true;
	    p++;
	    int b = formula();
	    //System.out.println(a+" "+b);
	    p++;
	    if(boo) res = plus(a, b);
	    else res = mul(a, b);
	}
	return res;
    }

    int[] c1 = {2,1,0};
    int[][] c2 = {{0,0,0},{0,1,1},{0,1,2}};
    int[][] c3 = {{0,1,2},{1,1,2},{2,2,2}};
    int mai(int x){ return c1[x]; }
    int mul(int x, int y){ return c2[x][y]; }
    int plus(int x, int y){ return c3[x][y]; }

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

	       

Measured memory_bytes: 28100
#!venv/bin/python
#from collections import defaultdict 
from itertools import combinations
from collections import defaultdict
from pprint import pprint
import math
import datetime
import sys

A, B = [int(x) for x in input().split()]

if (A + B) % 2 == 0:
    print((A+B)//2)
else:
    print("IMPOSSIBLE")



Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll n, m;
    cin >> n >> m;

    vll k(m);
    vvll s(m);
    ll c;
    REP(i, m){
        cin >> k[i];
        REP(j, k[i]){
            cin >> c;
            c--;
            s[i].push_back(c);
        }
    }
    vll p(m);
    REP(i, m) cin >> p[i];

    ll ans = 0;

    for(int i = 0; i < (1LL<<n); i++){
        vll on(n);
    	for(int j = 0; j < n; j++){
      		if(i>>j & 1){
                on[j] = 1;
            }
      	}
        ll res = 0;
        REP(i, m){
            ll tmp = 0;
            REP(j, k[i]){
                if(on[s[i][j]]) tmp++;
            }
            if(tmp % 2 == p[i]) res++;
        }
        if(res == m) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()
import bisect
def make_LIS(L):
    LIS=[L[0]]
    for i in range(1,len(L)):
        if L[i]>=LIS[-1]:#広義単調増加なら>=に
            LIS.append(L[i])
        else:
            LIS[bisect.bisect_right(LIS,L[i])]=L[i]
    return len(LIS)
def main():
    n=int(input())
    A=[int(input())for _ in range(n)]
    print(make_LIS(A[::-1]))

if __name__=='__main__':
    main()

Measured memory_bytes: 8608
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();

        for(int i=1; i<=x; i++) {
            if(y == (i*2)+((x-i)*4)) {
                System.out.println("Yes");
                return;
            }
        }
        for(int i=1; i<=x; i++) {
            if(y == (i*4)+((x-i)*2)) {
                System.out.println("Yes");
                return;
            }
        }
        for(int i=1; i<=x/2; i++) {
            if(y == i*2) {
                System.out.println("Yes");
                return;
            }
        }
        for(int i=1; i<=x/4; i++) {
            if(y == i*4) {
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    }
}

Measured memory_bytes: 35664
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]

use std::cmp::*;

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

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

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

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

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

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

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

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
macro_rules! chmax {
    ($x:expr, $e:expr) => {
        $x = max($x, $e);
    };
}
macro_rules! chmin {
    ($x:expr, $e:expr) => {
        $x = min($x, $e);
    };
}

fn main() {
    input!{
        N: usize,
        abc: [(i64, i64, i64); N],
    }
    let mut dp = vec![vec![0; 3]; N+1];
    dp[0][0] = 0;
    dp[0][1] = 0;
    dp[0][2] = 0;
    for i in 1..(N + 1) {
        let (a, b, c) = abc[i-1];
        for yest in 0..3 {
            match yest {
                0 => {
                    chmax!(dp[i][yest], dp[i-1][1] + a);
                    chmax!(dp[i][yest], dp[i-1][2] + a);
                },
                1 => {
                    chmax!(dp[i][yest], dp[i-1][0] + b);
                    chmax!(dp[i][yest], dp[i-1][2] + b);
                },
                2 => {
                    chmax!(dp[i][yest], dp[i-1][1] + c);
                    chmax!(dp[i][yest], dp[i-1][0] + c);
                },
                _ => panic!("error"),
            }
        }
    }
    if let Some(ans) = vec![dp[N][0], dp[N][1], dp[N][2]].iter().max() {
        println!("{}", ans);
    }
}


Measured memory_bytes: 16636
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include<iomanip>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60

int p[20];

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

	int N; cin >> N;
	for (int i = 0; i < N; i++)cin >> p[i];

	int ans = 0;
	for (int i = 1; i < N - 1; i++) {
		int num[3];
		num[0] = p[i - 1];
		num[1] = p[i];
		num[2] = p[i + 1];
		sort(num, num + 3);
		if (num[1] == p[i]) ans++;
	}

	cout << ans << endl;

	return 0;
}

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

int main(){
    ll X;
    cin >> X;
    ll cnt = 0;
    ll m = 100;
    while(X > m){
        cnt++;
        m += m * 0.01;
    }
    cout << cnt <<  endl;
}

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

using namespace std;

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

    int N;
    cin >> N;

    int x[N], y[N], h[N];
    for (int i = 0; i < N; ++i) {
        cin >> x[i] >> y[i] >> h[i];
    }

    for (int X = 0; X <= 100; ++X) {
        bool pass = true;
        for (int Y = 0; Y <= 100; ++Y) {
            int H = 0;
            for (int i = 0; i < N; ++i) {
                if (h[i]) {
                    H = abs(X - x[i]) + abs(Y - y[i]) + h[i];
                    break;
                }
            }
            for (int i = 0; i < N; ++i) {
                if (h[i] == 0) {
                    pass &= H - abs(X - x[i]) - abs(Y - y[i]) <= 0;
                } else {
                    pass &= h[i] == H - abs(X - x[i]) - abs(Y - y[i]);
                }
            }
            if (pass) {
                printf("%d %d %d", X, Y, H);
                return 0;
            }
            pass = true;
        }
    }

    return 0;
}


Measured memory_bytes: 256
def remain(pos,length):
  p=pos
  for c,d in moves:
    if s[p]==c:
      if d=='L':
        p-=1
      if d=='R':
        p+=1
    if p<0 or p>=length:
      return False
  return True

n,q=map(int,input().split())
s=input()
moves=[list(map(str,input().split())) for _ in range(q)]
l=-1
r=n
while r-l!=1:
  mid=(l+r)//2
  if remain(mid,n)==True:
    r=mid
  else:
    l=mid
remain_left=r
if remain_left==n:
  print(0)
  exit()
l=remain_left
r=n
while r-l!=1:
  mid=(l+r)//2
  if remain(mid,n)==True:
    l=mid
  else:
    r=mid
remain_right=l
print(remain_right-remain_left+1)

Measured memory_bytes: 120296
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int N;
    cin >> N;
    int P[N];
    for(int i = 0; i < N; i++) cin >> P[i];
    sort(P, P+N);
    P[N-1] /= 2;
    int sum = 0;
    for(int i = 0; i < N; i++) sum += P[i];
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<int> w;
vector<long long> v;
vector<vector<long long> > m;
long long f(int n,int W){
	if(n==w.size()){
		return 0;
	}
	if(m[n][W]!=-1){
		return m[n][W];
	}
	m[n][W]=f(n+1,W);
	if(W-w[n]>=0){
		m[n][W]=max(m[n][W],f(n+1,W-w[n])+v[n]);
	}
	return m[n][W];
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,W;
	cin>>n>>W;
	w.resize(n);
	v.resize(n);
	m.resize(n,vector<long long>(W+1));
	for(int i=0;i<n;i++){
		for(int j=0;j<=W;j++){
			m[i][j]=-1;
		}
	}
	for(int i=0;i<n;i++){
		cin>>w[i]>>v[i];
	}
	cout<<f(0,W);
}


Measured memory_bytes: 79488
var stdin = function() {
	if (require('os').type().toString().match('Windows')) return 0;
	else return '/dev/stdin';
}();
var ab = require('fs').readFileSync(stdin).toString().split(/ /).map(Number);
var a = ab[0], b = ab[1];
console.log(a * b, 2 * (a + b));


Measured memory_bytes: 15220
n,m,l = map(int,input().split())
l1 = []; l2 =[]
for i in range(n):
    tmp = list(map(int,input().split()))
    l1.append(tmp)
    tmp = []

for i in range(m):
    tmp = list(map(int,input().split()))
    l2.append(tmp)
    tmp = []

for i in range(n):
    for j in range(l):
        cx = 0
        for k in range(m):
            cx += l1[i][k]*l2[k][j]    
        if j!=l-1:
            print(cx,end = ' ')
        else:
            print(cx)
   # print()


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

int main()
{
  int N ;
  cin>>N ;
  vector<pair<int,int>>Aka(N),Ao(N) ;
  for(int i=0;i<N;i++) cin>>Aka.at(i).first>>Aka.at(i).second ;
  for(int i=0;i<N;i++) cin>>Ao.at(i).first>>Ao.at(i).second ;
  sort(Aka.begin(),Aka.end()) ;
  sort(Ao.begin(),Ao.end()) ;
  
  int ans=0 ;
  for(int i=0;i<N-ans;i++){
    int max_y=-1,max_j=-1 ;
    for(int j=0;j<N-ans;j++){
      if(Ao.at(i).first>Aka.at(j).first&&Ao.at(i).second>Aka.at(j).second){
        if(Aka.at(j).second>max_y){
          max_j=j ;
          max_y=Aka.at(j).second ;
        }
      }
    }
    if(max_j!=-1){
      ans++ ;
      Aka.erase(Aka.begin()+max_j) ;
      Ao.erase(Ao.begin()+i) ;
      i-- ;
    }
  }
  cout<<ans<<endl ;
  
  return 0 ;
}


Measured memory_bytes: 256
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseFloat(x::SubString{String}) = parse(Float64, x)
parseFloat(x::Char) = parse(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n,m=parseMap(split(readline()))
    a=[chomp(readline()) for i in 1:n]
    b=[chomp(readline()) for i in 1:m]
    ans="No"
    for i1 in 0:n-m,i2 in 0:n-m
        res=true
        for j1 in 1:m,j2 in 1:m
            if a[i1+j1][i2+j2]!=b[j1][j2]
                res=false
                break
            end
        end
        if res
            ans="Yes"
            break
        end
    end
    println(ans)
end
main()

Measured memory_bytes: 116056
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define sz(v) ((int)(v).size())
#define INF (1e12)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int a,b,c;
	char ch;
	cin>>a>>ch>>b>>ch>>c;
	if(a<2019) cout<<"Heisei";
	else if(a>2019) cout<<"TBD";
	else if(b<4) cout<<"Heisei";
	else if(b>4) cout<<"TBD";
	else if(c<=30) cout<<"Heisei";
	cout<<"\n";
	return 0;
}

Measured memory_bytes: 256
// Problem : A - Air Conditioner
// Contest : AtCoder - AtCoder Beginner Contest 174
// URL : https://atcoder.jp/contests/abc174/tasks/abc174_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

// It's something that is not good
// & i'm trying right just nothing
// dont't know what god is upto
// but i shall tryna make it come.
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define el "\n"

ll tests=1;
int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    //cin>>tests;
    while(tests--){
        ll n; cin>>n;
        if(n>=30) cout<<"Yes"<<el;
        else cout<<"No"<<el;
    }
}

Measured memory_bytes: 3600
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<set>
using namespace std;
typedef long long ll;
const ll P=1000000007;
const int MAXN=4000+7;
ll n,k,dp[MAXN];
ll qPow(ll x,ll y){
	ll res=1;
	while(y){
		if(y&1) res=res*x%P;
		x=x*x%P; y>>=1;
	}
	return res%P;
}
int main(){
	cin>>n>>k;
	dp[0]=1ll;
	for(register ll i=1;i<n;i++){
		for(register ll j=i;j>=1;j--){
			dp[j]=(dp[j-1]+dp[j+1])%P;
		}
		dp[0]=dp[1];
	}
	ll ans=(dp[n-k]*qPow(2ll,max(0ll,n-k-1)))%P;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	int n, l;
	int a[55];
	cin >> n >> l;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int m = 0;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n; j++) {
			if (i + j > n || i + j > l) {
				continue;
			}
			vector<int> v;
			for (int k = 0; k < i; k++) {
				v.emplace_back(a[k]);
			}
			for (int k = n - 1; k >= n - j; k--) {
				v.emplace_back(a[k]);
			}
			sort(v.begin(), v.end());
			int sum = 0;
			for (int k = 0; k < v.size(); k++) {
				sum += v[k];
			}
			for (int k = 0; k < v.size(); k++) {
				if (i + j + k > l) {
					continue;
				}
				if (sum > m) {
					m = sum;
				}
				sum -= v[k];
			}
		} 
	}
	cout << m << endl;
	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MOD	1000000007
#define int	long long
#define pii pair<int,int> 
#define vi vector<int>
using namespace std;

int32_t main(){
	string s;
	cin >> s;
	
	for(int i = 0; i < s.size(); i++)
		cout << 'x';
		
	

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef int Int;
typedef pair<Int,Int> pii;
typedef pair<Int,double> pid;
typedef pair<double,double> pdd;
typedef pair<Int,pii> pip;
typedef pair<double,Int> pdp;
#define A first
#define B second
#define pb(x) push_back(x)
#define ALL(x) x.begin(),x.end()
#define SZ(x) (x).size()
#define CLR(x) memset(x,0,sizeof x)
#define pdebug() printf("%d\n",__LINE__)
#define Itype(a) typeof(a.begin()) 
#define REP(i,a,b) for(int i = (a);i <= (b);i++)
#define FORO(i,n) REP(i,0,(int)n-1)
#define FORI(i,n) REP(i,1,(int)n)
#define FORIT(i,t) for(Itype(t) i = t.begin();i != t.end();i++)
#define eps 1e-6
#define sqr(x) ((x)*(x))
#define dist(_a,_b) sqrt(sqr(_a.A-_b.A)+sqr(_a.B-_b.B))
#define norm(_a) sqrt(sqr(_a.A)+sqr(_a.B))
template<typename T>void getMin(T &a,T b) { if(a > b) a = b; }
template<typename T>void getMax(T &a,T b) { if(a < b) a = b; }
const int MOD = 1000000007;

ll f(ll a) {
    return (a + 1LL) % 2LL ? ((((a + 1LL)/2LL)%2LL) ^ a) : (((a + 1LL)/2LL)%2LL);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll A, B;
    cin >> A >> B;
    //cout << f(B) << endl;
    cout << (f(B) ^ f(A - 1LL)) << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


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

    ll a,p;
    cin >> a >> p;
    cout << (a*3 + p)/2 << endl;

    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <map>
#include <set>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;


int main(){
  int A,B;
  cin>>A>>B;
  if(B%A==0){
    cout<<A+B<<"\n";
  }
  else{
    cout<<B-A<<"\n";
  }
return 0;
}


Measured memory_bytes: 256
/*
"Won't stop until I'm phenomenal."
- Phenomenal, Eminem
 */
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define ff first
#define Shazam ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL);
#define ss second
#define all(c) c.begin(),c.end()
#define endl "\n"
#define test() int t; cin>>t; while(t--)
#define fl(i,a,b) for(int i = a ; i <b ;i++)
#define get(a) fl(i,0,a.size())  cin>>a[i];
#define pra(a) fl(i,0,a.size()) cout<<a[i]<<" ";	cout<<endl;
#define pr(a,n) fl(i,0,n) cout<<a[i]<<" ";	cout<<endl;
const ll INF = 2e18;
const int inf = 2e9;
const int mod1 = 1e9 + 7;



int main(){
    Shazam;
    string s; cin>>s;
    int n = s.size();
    vector<vector<int>> table(63,vector<int> (n,-1));
    for(int i = 0; i < n; i++){
        table[0][i] = i + ((s[i]=='R')?1:-1);
    }

    for(int bit = 1; bit < 63; bit++){
        for(int i = 0; i < n ; i++){
            if(table[bit-1][i]!=-1){
                table[bit][i] = table[bit-1][table[bit-1][i]];
            }
        }
    }

    vector<int> cnt(n);
    for(int i =0 ; i < n; i++){
        cnt[table[62][i]]++;
    }
    pra(cnt);
    return 0;
}

Measured memory_bytes: 28544
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int A[3];
    for(int i=0;i<3;i++) cin >> A[i];
    sort(A,A+3);
    cout << (A[2] - A[1]) + (A[1] - A[0]) << endl;
}

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

int main() {
	
	long long int n, ct=0;
	cin>>n;
	int arr[n];
	int left[n];
	
	for (int i=0;i<n;i++) {
		cin>>arr[i];
		if (i==0) {
			left[i] = arr[i];
		} else {
			
			if (left[i-1] < arr[i]) {
				left[i] = arr[i];
			} else {
				left[i] = left[i-1];	
				ct += left[i] - arr[i];
			}
			
		}
	}
	
	cout<<ct;
		
	// 5
	// 2 1 5 4 3 
	// 2 2 5 5 5 
	// 5 5 5 4 3 
	 
		
	return 0;
}

Measured memory_bytes: 5180
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const int MOD = 1000000007;

int main()
{   int N;cin>>N;
    vector<ll> a(N);
    REP(i,N) cin>>a[i];
    ll result = std::accumulate(a.begin(), a.end(), 0);
    std::cout << result - N << '\n';
}

Measured memory_bytes: 256
// ABC 62 C

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

typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long INF = 1LL<<60;

ll pattern12(ll w, ll h) {
  if (w < 3) {
    return INF;
  } else if (w % 3 == 0) {
    return 0;
  } else {
    return h;
  }
}

ll pattern34(ll w, ll h) {
  ll w1, tmp;
  ll area1, area2, area3;
  ll ans = INF;

  int h2 = h / 2;
  int h3 = h - h2;

  // w1 が 1/3 が最適とは限らないので力技で探索
  for (int i = 1; i < w; i++) {
    w1 = i;
    tmp = w - w1;
    area1 = w1 * h;
    area2 = tmp * h2;
    area3 = tmp * h3;
    chmin(ans, max({area1, area2, area3}) - min({area1, area2, area3}));
  }

  return ans;
}

int main() {
  ll h, w;
  cin >> h >> w;

  ll ans = INF;

  // Pattern 1
  chmin(ans, pattern12(w, h));

  // Pattern 2
  chmin(ans, pattern12(h, w));

  // pattern3
  chmin(ans, pattern34(w, h));

  // pattern4
  chmin(ans, pattern34(h, w));

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
program ya
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: n,i,ans=0
    integer(int32), allocatable:: a(:),b(:),c(:)

    read*, n
    allocate(a(n), b(n), c(n-1))
    read*, a(:)
    read*, b(:)
    read*, c(:)

    do i=1,n
        ans=ans+b(a(i))
    end do
    do i=1,n-1
        if (a(i)+1==a(i+1)) ans=ans+c(a(i))
    end do
    print'(i0)', ans
end program ya

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <bitset>  
using namespace std;

//======================================================
#define for1(i,n)  for (int i = 0; i < (int)(n); ++i)
#define for2(i,n)  for (int i = 1; i <=(int)(n); ++i)
#define forr1(i,n)  for (int i = n - 1 ;i <= 0; --i)
#define forr2(i,n)  for (int i = n  ;i < 0; --i)
#define all(v)	   ((v).begin()), ((v).end())
#define allr(v)	   ((v).rbegin()), ((v).rend())
#define clr(v,d)   memset(v, d, sizeof(v))
#define ull        unsigned long long
#define MP(a,b)	   make_pair(a,b)
#define S          second
#define F          first
#define PI         3.14159265359
#define ll         long long
#define sz(v)	   v.size()
#define pb         push_back
#define pp         pop_back
#define bgn        begin
#define N          100000+5
#define	MOD        1e9+7
#define inf        1e18
//======================================================
int dx[] = { 0,  0, 1, -1 ,  1,  -1,  1,  -1 };
int dy[] = { 1, -1, 0,  0 , -1,   1,  1,  -1 };
//======================================================
ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
ll power(ull a, ull b, ull ret = 1LL) {
	while (b--) ret = (ret * a);
	return ret;
}
//======================================================

int a[100000+5];
int b[100000+5];
int c[100000+5];


int main()
{
	int n;
	cin >> n;
	for (size_t i = 0; i < n; i++)
	{
		int ai , bi,ci;
		cin >> ai >> bi >> ci;
		a[i] = ai;
		b[i] = bi;
		c[i] = ci;
	}


	for (size_t i1 = 1; i1 < n; i1++)
	{
		for (size_t i2 = 0; i2 < 3; i2++)
		{
			if (i2 == 0)
			{
				a[i1] = max(b[i1-1], c[i1-1]) +a[i1];
			}
			if (i2 == 1)
			{
				b[i1] = max(a[i1 - 1], c[i1 - 1])+b[i1];

			}
			if (i2 == 2)
			{
				c[i1] = max(a[i1 - 1], b[i1 - 1] )+c[i1];

			}

		}
	}
	cout << max(a[n - 1] , max( b[n - 1], c[n - 1]));


}




Measured memory_bytes: 4308
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
struct dot{int x,y;}a[1010];
int n;
unsigned dis(dot a,dot b){
	return abs(a.x-b.x)+abs(a.y-b.y);
}
dot U(dot a,int len){
	a.y+=len;
	return a;
}
dot D(dot a,int len){
	a.y-=len;
	return a;
}
dot L(dot a,int len){
	a.x-=len;
	return a;
}
dot R(dot a,int len){
	a.x+=len;
	return a;
}
void go(int i,int z,dot &x){	
	unsigned x1=dis(a[z],U(x,1<<i)),x2=dis(a[z],D(x,1<<i)),x3=dis(a[z],L(x,1<<i)),x4=dis(a[z],R(x,1<<i));
	if (x1<=x2&&x1<=x3&&x1<=x4){
		putchar('U');
		x=U(x,1<<i);
	}
	else if (x2<=x3&&x2<=x4){
		putchar('D');
		x=D(x,1<<i);
	}
	else if (x3<=x4){
		putchar('L');
		x=L(x,1<<i);
	}
	else {
		putchar('R');
		x=R(x,1<<i);
	}
}
int main(){
	cin>>n;
	for (int i=1;i<=n;i++)scanf("%d%d",&a[i].x,&a[i].y);
	for (int i=2;i<=n;i++){
		if ((a[i].x+a[i].y&1)!=(a[1].x+a[1].y&1)){
			cout<<-1<<endl;
			return 0;
		}
	}
	int dlim=!((a[1].x+a[1].y)%2);
	cout<<31-dlim+2<<endl;
	for (int i=30;i>=dlim;i--)printf("%d ",1<<i);
	printf("1 1");
	cout<<endl;
	for (int z=1;z<=n;z++){
		dot x=(dot){0,0};
		for (int i=30;i>=dlim;i--)go(i,z,x);
		go(0,z,x);go(0,z,x);
		putchar('\n');
	}
}

Measured memory_bytes: 384
N, K = list(map(int, input().split()))
sunukes = [0]*N
for i in range(K):
  d = input()
  A = list(map(int, input().split()))
  for snack in A:
    sunukes[snack-1] += 1
ans=0
for total in sunukes:
  if total == 0:
    ans+=1
print(ans)

Measured memory_bytes: 9224
import math

n = int(input())
x = list(map(int, input().split()))
avg1 = int(math.ceil(sum(x) / n))
avg2 = int(math.floor(sum(x) / n))
ans1 = 0
ans2 = 0
for i in x:
  ans1 += (i - avg1) ** 2
  ans2 += (i - avg2) ** 2
print(min(ans1,ans2))

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

int main(void) {
    string S, T;
    cin >> S >> T;

    if ((S.size() + 1 == T.size()) && (S.substr(0) == T.substr(0, S.size()))) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

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

using namespace std;

int k;
typedef pair<int, int> pi;
vector<pi> adjlist[200050];
int dist[200050];
int main(){
	cin >> k;
//	k = 79992;
	memset(dist, -1, sizeof dist);
	for(int i=0; i<k; i++){
		adjlist[i].push_back(pi((i*10)%k,0));
		adjlist[i].push_back(pi((i+1)%k, 1));
	}
	deque<pi> q;
	q.push_back(pi(1,1));
	dist[1] = 1;
	while(!q.empty()){
		int node = q.front().second, d = q.front().first;
		q.pop_front();
		if(d > dist[node]) continue;
		for(auto i : adjlist[node]){
			if(dist[i.first] == -1 or dist[i.first] > dist[node] + i.second){
				dist[i.first] = dist[node] + i.second;
				if(i.second == 0){
					q.push_front(pi(dist[i.first], i.first));
				}else{
					q.push_back(pi(dist[i.first], i.first));
				}
			}
		}
	}
	cout << dist[0];
}


Measured memory_bytes: 9216
l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(l[k - 1])


Measured memory_bytes: 2940