akhauriyash/Code-Regression huggingface dataset:
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
//const int inf = 1e9; //1(1倍)e(指数)9(10^9)
//const ll MX = 1e18; //1(1倍)e(指数)18(10^18)
//const ll MOD = 1e9 + 7; //1000000007で割った余りを聞かれたら使う
//加算代入演算子は+=
//int 2^31 10^9まで
//intは10桁、long longは18桁、doubleは308桁、long double は4932桁
//10^10くらいまででdoubleは誤差が発生しちゃう。なるべく整数にすること
//doubleからlong longにキャストするときは、+0.5で切り捨ての誤差を調整
//__int128()で128bit対応の整数（多倍長整数）
//||は片方が成り立つとき
int main()
{
    vector<int> bell(3);
    rep(i, 3) cin >> bell[i];
    sort(bell.begin(), bell.end());
    cout << bell[0] + bell[1] << endl;
    return 0;
}

Measured memory_bytes: 256
fn main() {
    let mut s = String::new();
    let mut t = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    std::io::stdin().read_line(&mut t).unwrap();
    let s = s.trim();
    let t = t.trim();
    let mut d = [None; 26];
    let mut e = [None; 26];
    let mut result = true;
    for (a, b) in s.bytes().zip(t.bytes()) {
        let (a, b) = (a as usize - 97, b as usize - 97);
        match (d[a], e[b]) {
            (Some(x), _      ) if x == b => {},
            (_      , Some(x)) if x == a => {},
            (Some(_), _      )           => result = false,
            (_      , Some(_))           => result = false,
            _                            => {},
        }
        d[a] = Some(b);
        e[b] = Some(a);
    }
    println!("{}", if result { "Yes" } else { "No" });
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
int gcd(int a, int b) {
    if (b > a) return gcd(b, a);
    else if (b == 0) return a;
    else return gcd(b, a % b);
}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int A[100010];
    rep(i, N) cin >> A[i];
    int G = A[0];
    rep(i, N - 1) G = gcd(G, A[i + 1]);
    cout << G << endl;

    return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long int t,a;
    t=1;
    while(t--)
    {
        cin>>a;
        cout<<a+pow(a,2)+pow(a,3)<<endl;
    }
	return 0;
}

Measured memory_bytes: 4304
#include <iostream>
#include <algorithm>
using namespace std;
main(){
  int n;
  cin >> n;
  int a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a,a+n);
  cout << (a[n-1]-a[0]) <<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	vector<int> v(n);
	for(int i = 0; i < n; i++)cin >> v[i];
	int res = 0;
	for(int i = 1; i <= n - 2; i++){
		if( (v[i] < v[i+1] && v[i] > v[i-1]) || (v[i] > v[i+1] && v[i] < v[i-1]) ){
			++res;
		}
	}
	cout << res << endl;

}

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

  using namespace std;

  int main() {
    string S;
    cin >> S;
  for(int i = 0; i < S.length(); i += 2) {
      if ( S[i] == 'R' || S[i]== 'U' || S[i] == 'D' ) {
      } else {
        cout << "No" << endl;
        return 0;
      }
    }
  for(int i = 1; i < S.length(); i += 2) {
      if ( S[i] == 'L' || S[i]== 'U' || S[i] == 'D' ) {
      } else {
        cout << "No" << endl;
        return 0;
      }
    }
    cout << "Yes" << endl;

    return 0;
  }


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) //std::cerr<< #x <<": "<<x<<"\n"
#define debug2(x,y) std::cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<"\n"
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

// cout vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size(); s << "\n";
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  s << "\n"; return s;
}

// cout 2-dimentional vector
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) { s << vv[i]; }
  return s;
}

int calc(int x) {
  for (int i = 0; ; ++i) {
    if ((x >> i) == 0) {
      return i;
    }
  }
}

int main() {
  int l;
  cin >> l;
  int n = calc(l);
  debug(n);
  vvi g;
  rep (i, n-1) {
    g.push_back((vi){i+1, i+2, 0});
    g.push_back((vi){i+1, i+2, (1 << i)});
  }
  debug(g);
  int ma = (1 << (n-1)) - 1;
  debug(ma);
  while (true) {
    int rest = l-1 - ma;
    if (rest == 0) {
      break;
    }
    int d = calc(rest);
    debug(d);
    g.push_back((vi){d, n, ma+1});
    ma += (1 << (d-1));
  }
  debug(g);

  int m = g.size();
  printf("%d %d\n", n, m);
  rep (i, m) {
    printf("%d %d %d\n", g[i][0], g[i][1], g[i][2]);
  }

  return 0;
}


Measured memory_bytes: 888
package main

import "fmt"

const mxW = 100000

var dp [mxW+1]int

var wt [100]int
var vals [100]int

func maxt(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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

	for i := 0; i < N; i++ {
		fmt.Scanf("%d %d", &wt[i], &vals[i])
	}

	for i := 0; i < N; i++ {
		for j := W; j >= wt[i]; j-- {
			dp[j] = maxt(dp[j], vals[i] + dp[j-wt[i]])
		}
	}

	fmt.Println(dp[W])
}


Measured memory_bytes: 1280
#include <iostream>

void call(int n){
    for(int i=1; i<=n; i++){
        int x = i;
        if(x%3==0){
            std::cout << " " << i;
        }else{
            do{
                if(x%10==3){
                    std::cout << " " << i;
                    break;
                }
                x/=10;
            }while(x);
        }
    }
    std::cout << std::endl;
}

int main(){
    int n = 0;
    std::cin >> n;
    call(n);
    return 0;
}



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

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define repr(i, j) for(int i = j; i >= 0; --i)
#define INF (1 << 25)
#define MOD 1e9 + 7

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<int, P> Pi;

int N;
int G[64][64];

int main() {
	while(scanf("%d", &N), N) {
		int mini = 10, maxi = -1;
		rep(i, 10) rep(j, 10) {
			if(i == j) G[i][i] = 0;
			else G[i][j] = INF;
		}
		rep(i, N) {
			int a, b, c;
			scanf("%d %d %d", &a, &b, &c);
			G[a][b] = c; G[b][a] = c;
			if(maxi < a) maxi = a;
			if(maxi < b) maxi = b;
			if(mini > a) mini = a;
			if(mini > b) mini = b;
		}
		FOR(k, mini, maxi + 1) FOR(i, mini, maxi + 1) FOR(j, mini, maxi + 1) {
			G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
		}
		int ans_num, ans_cost = INF;
		FOR(i, mini, maxi + 1) {
			int sum = 0;
			FOR(j, mini, maxi + 1) {
				sum += G[i][j];
			}
			if(ans_cost > sum) {
				ans_cost = sum;
				ans_num = i;
			}
		}
		printf("%d %d\n", ans_num, ans_cost);
	}
	return 0;
}

Measured memory_bytes: 3140
#include <iostream>
using namespace std;
int main() {
    string s; cin >> s;
    int k; cin >> k;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] != 'a' && k >= 'z' - s[i] + 1) { k -= 'z' - s[i] + 1; s[i] = 'a'; }
    }
    k %= 26;
    s[s.size() - 1] += k;
    cout << s << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(n); ++i)
#define repr(i, a, b) for (int i=a; i<(b); ++i)
#define reprev(i, n) for (int i=n-1; i>=0; --i)
#define reprrev(i, a, b) for (int i=b-1; i>=(a); --i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int INF = 1e7;
int N;
int A, B, C;
int l[8];

int dfs(int cur_n, int a, int b, int c) {
    if (cur_n == N) {
        // 全ての探索を終わった
        if (a == 0 || b == 0 || c == 0) {
            return INF;
        } else {
            return abs(A-a) + abs(B-b) + abs(C-c) - 30;
        }
    }
    int res1, res2, res3, res4;
    res1 = dfs(cur_n+1, a, b, c); // a, b, cに足さない
    // +10は合成魔法分 何もないところから足された+10分は最後に辻褄合わせ
    res2 = dfs(cur_n+1, a+l[cur_n], b, c) + 10;
    res3 = dfs(cur_n+1, a, b+l[cur_n], c) + 10;
    res4 = dfs(cur_n+1, a, b, c+l[cur_n]) + 10;
    return min({res1, res2, res3, res4});
}

int main() {
    cout << fixed << setprecision(10);
    
    // int N, A, B, C; 
    cin >> N >> A >> B >> C;
    // vector<int> l(N);
    rep(i, N) cin >> l[i];
    cout << dfs(0, 0, 0, 0) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


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

    ll A[N + 1];
    ll B[N + 1];
    ll C[N + 1];
    REP(i, N){
        cin >> A[i];
    }
    REP(i, N){
        cin >> B[i];
    }
    REP(i, N - 1){
        cin >> C[i];
    }

    ll lastMeal = -1;
    ll meal = -1;
    ll ans = 0;
    REP(i, N){
        lastMeal = meal;
        meal = A[i];
        ans += B[meal];
        if(meal - 1 == lastMeal){
            ans += C[lastMeal];
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
    int n;cin >> n;
    vector<pair<int,int> > v;
    for(int i=0;i<n;i++){
        int tmp;cin >> tmp;
        v.push_back(make_pair(tmp,i+1));
    }
    sort(v.begin(),v.end());
    for(int i=0;i<n;i++){
        cout << v[i].second << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1780
gets.to_i.times do
  l = gets
  line = l
  a,b = 1,1
  while line !~ /th(at|is)/
    line = l.unpack("C*").map{|n|
      n = (n >= 97 and n <= 122) ? (a*n+b)%26+97 : n
    }.pack("C*")
    b=(b+1)%26
    if b==0
      begin
        a+=1
      end while a.gcd(26) != 1
    end
  end
  puts line
end

Measured memory_bytes: 9984
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long inf=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)
#define ZERO(a) memset(a,0,sizeof(a))





//3111111111111111111111111111111
	
	int dp[310000];

	
	void solve(){


		ini(n);
		ini(n1);
		for (int i = 0; i < n+1; i++)
		{
			dp[i] = inf;
		}
		dp[0] = 0;
		FOR(i,0,n1){
			ini(x);
			if(x>n)continue;
			FOR(i1,0,n-x+1){
					dp[i1+x] = min(dp[i1+x],dp[i1]+1);
					//out(x,i1+x,dp[i1+x]);
			}
		}



		out(dp[n]);

		


		
		
	}























int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall

	solve();
	


	return 0;
}



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

int min(int a,int b){return a>b?b:a;} 
int max(int a,int b){return a<b?b:a;} 

int main() 
{   
	int n,i,j,res;   
	char f[1000][1001];   
	vector< vector<int> > m(1000);
	for(int i = 0; i < 1000; ++i)
	{
		m[i].resize(1000);
	}
	for(;;)
	{     
		scanf("%d",&n); 
		if(!n)break;     
		for(i=0;i<n;i++)scanf("%s",f[i]);     
		for(i=0;i<n;i++)
		{       
			m[0][i]=f[0][i]=='*'?0:1;       
			m[i][0]=f[i][0]=='*'?0:1;     
		}     
		res=0;     
		for(i=1;i<n;i++)
		{       
			for(j=1;j<n;j++)
			{         
				if(f[i][j]=='*')m[i][j]=0;         
				else
				{           
					m[i][j]=min(m[i-1][j-1],min(m[i][j-1],m[i-1][j]))+1;
					res=max(m[i][j],res);         
				}       
			}     
		}     
		printf("%d\n",res);   
	}   
	return 0; 
}

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

using namespace std;

int main(){
  while(true){
    int n;
    cin>>n;
    if(n==0){
      break;
    }
    vector<int> score(n);
    for(int i=0;i<n;i++){
      int x;
      cin>>x;
      score[i]=x;
    }
    sort(score.begin(),score.end());
    int ans=1000000;
    for(int i=0;i<n-1;i++){
      ans=min(ans,score[i+1]-score[i]);
    }
    cout<<ans<<endl;
  }
}



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

int main(){
    int n;
    int ac=0,wa=0,tle=0,re=0;
    char s[5];

    scanf("%d",&n);

    for(int i=0;i<n;++i){
        scanf("%s",s);

        if(strcmp(s,"AC")==0){
            ac++;
        }else if(strcmp(s,"WA")==0){
            wa++;
        }else if(strcmp(s,"TLE")==0){
            tle++;
        }else if(strcmp(s,"RE")==0){
            re++;
        }

    }

    printf("AC x %d\n",ac);
    printf("WA x %d\n",wa);
    printf("TLE x %d\n",tle);
    printf("RE x %d\n",re);

    return 0;
}


Measured memory_bytes: 1704
#include <iostream>
#include <vector>
using namespace std;
typedef pair<int, int> P;
int main(void){
    int n, k, kmax;
    vector<P> v;
    cin >> n >> k;
    kmax = (n-1) * (n-2) / 2;
    if(k > kmax){
        cout << -1 << endl;
        return 0;
    }
    for(int i=2;i<=n;i++){
        v.push_back(P(1, i));
    }
    for(int i=2;i<n&&k<kmax;i++){
        for(int j=i+1;j<=n&&k<kmax;j++){
            v.push_back(P(i, j));
            k++;
        }
    }
    cout << v.size() << endl;
    for(int i=0;i<v.size();i++){
        cout << v[i].first << " " << v[i].second << endl;
    }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
   #define PP pair<int,pair<int,int>>
const int MAX = 1000001;
const int MOD =1000000007;
const int INV2 = (MOD+1)/2;



     signed main(){
     int l,n=20,m=0;
     cin>>l;
      vector<pair<int,int>> hen[n];
      if((l>>19)){
        hen[0].push_back(make_pair(1,(1ll<<18)));
        hen[0].push_back(make_pair(1,0));
      }
      if(l&(1ll<<(18)))hen[0].push_back(make_pair(1,(l>>(19))<<(19)));
      for(int i=1;i<n-1;i++){
        hen[i].push_back(make_pair(i+1,(1ll<<(18-i))));
        hen[i].push_back(make_pair(i+1,0));
        if(l&(1ll<<(18-i)))hen[0].push_back(make_pair(i+1,(l>>(19-i))<<(19-i)));
      }
      for(int i=0;i<n;i++)m+=hen[i].size();
      cout<<n<<' '<<m<<endl;
      for(int i=0;i<n;i++){
        for(auto&& j : hen[i]){
          cout<<i+1<<' '<<j.first+1<<' '<<j.second<<endl;
        }
      }




        





}


        


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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> x(n);
  rep(i, n) cin >> x.at(i);
  ll res = 0;
  rep(i, n) {
    res += min(x.at(i), abs(k - x.at(i))) * 2;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3588
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  string s;
  cin >> s;

  ll n = s.size();
  ll ans = (n + 1) / 2;

  char val = s[n / 2];
  ll lidx = n / 2 - 1;
  ll ridx = (n + 1) / 2;
  while (lidx >= 0) {
    if (val != s[lidx] || s[lidx] != s[ridx]) break;
    ans++;
    lidx--, ridx++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 512
import java.util.*;
import java.io.*;

public class Main {

	List<Integer>[] graph;
	boolean[] mark;
	int ans = 0;
	
	void dfs(int u, int p) {
		for (int t = 0; t < graph[u].size(); t++) {
			int to = graph[u].get(t);
			if (to != p) {
				dfs(to, u);
			}
		}
		
		boolean first = true;
		for (int t = 0; t < graph[u].size(); t++) {
			int to = graph[u].get(t);
			if (to != p && !mark[to]) {
				if (first) {
					first = false;
					continue;
				} else {
					mark[to] = true;
					ans++;
				}
			}
		}
		
		for (int t = 0; t < graph[u].size(); t++) {
			int to = graph[u].get(t);
			if (to != p) {
				mark[u] |= mark[to];
			}
		}
		
	}
	
	void solve() {
		int n = in.nextInt();
		graph=  new List[n];
		for (int i = 0; i < n; i++) {
			graph[i] = new ArrayList<>();
		}
		for (int i = 0; i < n - 1; i++) {
			int from = in.nextInt();
			int to = in.nextInt();
			graph[from].add(to);
			graph[to].add(from);
		}
		int root = 0;
		for (int i = 1; i < n; i++) {
			if (graph[i].size() > graph[root].size()) {
				root = i;
			}
		}
		if (graph[root].size() < 3) {
			out.println(1);
			return;
		}
		mark = new boolean[n];
		dfs(root, -1);
		out.println(ans);
	}

	FastScanner in;
	PrintWriter out;

	void run() {
		in = new FastScanner();
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		public FastScanner(String s) {
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		public String nextToken() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
				}
			}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextToken());
		}

		public long nextLong() {
			return Long.parseLong(nextToken());
		}

		public double nextDouble() {
			return Double.parseDouble(nextToken());
		}
	}

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


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

int main() {
    int n, k, d1, a;
    int result = 0;
    int snack[100] = { 0 };
    cin >> n >> k;
    for (int i = 0; i < k; ++i) {
        cin >> d1;
        for (int j = 0; j < d1; ++j) {
            cin >> a;
            snack[a - 1]++;
        }
    }
    for (int i = 0; i < n; ++i) {
        if (snack[i] == 0)
            result++;
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define ll long long 
#define P pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int n,x;
string command;
deque<int> lst;

deque<int> deletex(deque<int> lst,int x){
    deque<int>::iterator it,l;
  	for(it=lst.begin(),l=lst.end();it!=l;++it){
      	if(*it == x){
          lst.erase(it);
          break;
        }
    }
    return lst;
}

int main(){
    cin >> n;
    rep(i,n){
        cin >> command;
        if(command == "insert"){
            cin >> x;
            lst.push_front(x);
        }
        if(command == "delete"){
            cin >> x;
            lst = deletex(lst,x);   
        }
        if(command == "deleteFirst"){
            lst.pop_front();
        }
        if(command == "deleteLast"){
            lst.pop_back();
        }
    }
  	deque<int>::iterator it,l;
  	
  	for(it=lst.begin(),l=--lst.end();it!=l;it++) cout << *it << " ";
    cout << *it << endl;
    return 0;
}




Measured memory_bytes: 9684
#include <stdio.h>
#define n 1000
int main()
{
  int N, A[n], i, v, j, p;

  scanf("%d",&N);
  for(i=0; i<N; i++) scanf("%d",&A[i]);
  
  for(i=1; i<N; i++){
    v = A[i];
    j = i - 1;
    for(p=1; p<=N; p++){
      if ( p > 1 ) printf(" ");
      printf("%d", A[p-1]);
    }
    printf("\n");
    while(j >= 0 && A[j] > v){
      A[j+1] = A[j];
      j--;
      A[j+1] = v;
    }
  }
  for(p=1; p<=N; p++){
    if ( p > 1 ) printf(" ");
    printf("%d", A[p-1]);
  }
  printf("\n");
  
  return 0;
}

Measured memory_bytes: 608
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
#define INF 100000000000000
using namespace std;
typedef long long llong;

//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());
//map<type, type> dict;で宣言
//グラフ理論用変数
//vector<vector<llong> > graph(N);

//ソート
//降順sort(v.begin(), v.end(), std::greater<Type>());

int main(){
    llong N,K;
    cin >> N >> K;
    vector<llong> P(N,0);
    for(int i=0; i<P.size(); i++){
        cin >> P[i];
    }
    sort(P.begin(), P.end());
    llong ans=0;
    for(int i=0; i<K; i++){
        ans = ans + P[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 3160
import scala.io.StdIn.{readLine,readInt}
import scala.language.postfixOps

object Main {
  var cnt = 0
  val l = new Array[Int](260000)
  val r = new Array[Int](260000)

  def merge(a:Array[Int],left:Int,mid:Int,right:Int) = {
    val n1 = mid-left
    val n2 = right-mid
    Array.copy(a,left,l,0,n1)
    l(n1) = Int.MaxValue
    Array.copy(a,mid,r,0,n2)
    r(n2) = Int.MaxValue
    var i=0
    var j=0
    for(k<-left until right) {
      if(l(i)<=r(j)){
        a(k) = l(i)
        i += 1
      } else  {
        a(k)=r(j)
        j += 1
      }
      cnt += 1
    }
  }

  def getSortIndex(n:Int):Iterator[IndexedSeq[(Int,Int)]] = {
    var w = n
    var h = 0
    while(w>1) {
      h += 1
      w /= 2
    }

    def scan(h:Int,l:List[IndexedSeq[(Int,Int)]]):List[IndexedSeq[(Int,Int)]] = {
      if(h==0) l
      else
        scan(h-1,(for(i<-l.head;j<-List((i._1,(i._2+i._1)/2),((i._2+i._1)/2,i._2))) yield j)::l)
    }
    scan(h-1,List(IndexedSeq((0,n/2),(n/2,n)))).to[Iterator]
  }

  def main(args:Array[String]) = {
    val n = readInt
    val a = readLine.split(" ").map(_.toInt)
    val l = getSortIndex(n)
    for(e2<-l) {
      for(e<-e2) {
        val mid = (e._2+e._1)/2
        if(e._2-e._1>1)
          merge(a,e._1,mid,e._2)
      }
    }
    merge(a,0,n/2,n)
    println(a.mkString(" "))
    println(cnt)
  }
}

Measured memory_bytes: 316688
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int K = int.Parse(str[0]);
            int X = int.Parse(str[1]);

            int min = X - (K - 1);
            int max = X + (K - 1);

            for(int i = min; i < max; i++)
            {
                Console.Write($"{i} ");
            }

            Console.WriteLine(max);

        }
    }
}


Measured memory_bytes: 13140
n = int(input())
a = [int(i) for i in input().split()]
q = int(input())
bc = []
for _ in range(q):
    bc.append([int(i) for i in input().split()])

a_dict = {}
for x in a:
    if x in a_dict:
        a_dict[x] += 1
    else:
        a_dict[x] = 1

s = 0
for k, v in a_dict.items():
    s += k*v

for b, c in bc:
    if b in a_dict:
        s += (c-b) * a_dict[b]
        print(s)
        if c in a_dict:
            a_dict[c] += a_dict[b]
        else:
            a_dict[c] = a_dict[b]
        a_dict[b] = 0
        
    else:
        print(s)
        pass


Measured memory_bytes: 34236
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define NUM 100005

struct Info{
	Info(){
		id = 0;
		value = 0;
	}
	Info(int arg_id,ll arg_value){
		id = arg_id;
		value = arg_value;
	}
	int id;
	ll value;
};

int N;
int boss[NUM],height[NUM];
ll diff[NUM];

Info get_boss(int id){
	if(boss[id] == id)return Info(id,0); //ボスの相対的重さは0
	else{
		Info ret = get_boss(boss[id]);

		diff[id] += ret.value;
		ret.value = diff[id];
		boss[id] = ret.id;

		return ret;
	}
}

bool is_same_group(int x,int y){

	Info boss_x = get_boss(x);
	Info boss_y = get_boss(y);

	return boss_x.id == boss_y.id;
}

void unite(int x,int y,ll tmp_diff){

	Info boss_x = get_boss(x);
	Info boss_y = get_boss(y);

	//既に同じグループなら、矛盾が発生するか調べる
	if(boss_x.id == boss_y.id){

		return;
	}

	//高さが高い方に吸収する
	if(height[boss_x.id] > height[boss_y.id]){

		diff[boss_y.id] = diff[x]+tmp_diff-diff[y];
		boss[boss_y.id] = boss_x.id;

	}else if(height[boss_x.id] < height[boss_y.id]){

		diff[boss_x.id] = diff[y]-tmp_diff-diff[y];
		boss[boss_x.id] = boss_y.id;

	}else{ //height[x] == height[y]

		diff[boss_y.id] = diff[x]+tmp_diff-diff[y];
		boss[boss_y.id] = boss_x.id;
	}
}

int main(){

	int num_query;

	scanf("%d %d",&N,&num_query);

	for(int i = 0; i < N; i++){

		boss[i] = i;
		height[i] = 0;
		diff[i] = 0; //ボスとの相対的な重さの差
	}

	int L,R;
	ll tmp_diff;

	for(int loop = 0; loop < num_query; loop++){

		scanf("%d %d %lld",&L,&R,&tmp_diff);
		L--;
		R--;

		if(is_same_group(L,R)){

			if(diff[R]-diff[L] != tmp_diff){

				printf("No\n");
				return 0;
			}

		}else{
			unite(L,R,tmp_diff);
		}
	}

	printf("Yes\n");

	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
const int N=15;
int n,m,ans,f[N][N];
char s[N][N];
void dfs(int x,int y,int z){
	if (z==ans){
		puts("Possible");
		exit(0);
	}
	if (s[x+1][y]=='#')dfs(x+1,y,z+1);
	if (s[x][y+1]=='#')dfs(x,y+1,z+1);
}
int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++)scanf("%s",s[i]+1);
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++)
			if (s[i][j]=='#')ans++;
	if (s[1][1]!='#'){
		puts("Impossible");
		return 0;
	}
	dfs(1,1,1);
	puts("Impossible");
}

Measured memory_bytes: 256
a = []
for i in range(3):
    a.append(list(map(int, input().split())))
n = int(input())
bingo = [[0 for i in range(3)] for i in range(3)]
for i in range(n):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if a[j][k] == b:
                bingo[j][k] = 1
if sum(bingo[0])==3 or sum(bingo[1])==3 or sum(bingo[2])==3 or (bingo[0][0] and bingo[1][0] and bingo[2][0]) or (bingo[0][1] and bingo[1][1] and bingo[2][1]) or (bingo[0][2] and bingo[1][2] and bingo[2][2]) or (bingo[0][0] and bingo[1][1] and bingo[2][2]) or (bingo[0][2] and bingo[1][1] and bingo[2][0]):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int h = sc.nextInt();
    int w = sc.nextInt();
    int[][] field = new int[h][w];
    for(int i = 0; i < h; i++){
      char[] str = sc.next().toCharArray();
      for(int j = 0; j < w; j++){
        if(str[j] == '#'){
          field[i][j] = 1;
        }
      }
    }
    //no problem found in the input phase
    
    int[][] way = new int[h][w];
    for(int i = 1; i < h; i++){
      if(field[i][0] - field[i - 1][0] == -1){
        way[i][0] = way[i - 1][0] + 1;
      }else{
        way[i][0] = way[i - 1][0];
      }
    }
    //no problem for this block
    for(int i = 1; i < w; i++){
      if(field[0][i] - field[0][i - 1] == -1){
        way[0][i] = way[0][i - 1] + 1;
      }else{
        way[0][i] = way[0][i - 1];
      }
    }
    //no prob
    int c;
    int r;
    for(int i = 1; i < h; i++){
      for(int j = 1; j < w; j++){

        if(field[i][j] - field[i - 1][j] == -1){
          c = way[i - 1][j] + 1;
        }else{
          c = way[i - 1][j];
        }

        if(field[i][j] - field[i][j - 1] == -1){
          r = way[i][j - 1] + 1;
        }else{
          r = way[i][j - 1];
        }

        way[i][j] = Math.min(c, r);
      }
    }
    if(field[h - 1][w - 1] == 1){
      way[h - 1][w - 1]++;
    }
    System.out.println(way[h - 1][w - 1]);
  }
}

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

int main() {
  int H, W;
  char c;
  cin >> H >> W;
  for (int i=0; i < W + 2; i++) {
    cout << '#';
    if (i == W + 1) {
      cout << endl;
    }
  }
  for (int j=0; j < H; j++) {
    for (int i=0; i < W + 2; i++) {
      if (i == 0 || i == W + 1) {
        cout << '#';
      }
      else {
        cin >> c; cout << c;
      }
      if (i == W + 1) {
        cout << endl;
      }
    }
  }
  for (int i=0; i < W + 2; i++) {
    cout << '#';
    if (i == W + 1) {
      cout << endl;
    }
  }
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int n,k,d;
	scanf("%d %d",&n,&k);
	int ar[n];
	for(int i=0;i<n;i++){
	    ar[i]=0;
	}
	while(k--){
	    scanf("\n%d\n",&d);
	    while(d--){
	        int x;
	        scanf("%d",&x);
	        ar[x-1]++;
	    }
	}
	int count=0;
	for(int i=0;i<n;i++){
	    if(ar[i]==0){
	        count++;
	    }
	}
	printf("%d",count);
	
	
	return 0;
}

Measured memory_bytes: 1724
n = int(input())
A = [*map(int, input().split())]
def solve():
    MAX_A = 10**6 + 1
    C = [0] * MAX_A
    for a in A: C[a] += 1
    pairwise = True
    for i in range(2, MAX_A):
        if sum(C[i:MAX_A:i]) > 1: pairwise = False
    if pairwise: return 'pairwise'
    from math import gcd
    g = 0
    for a in A: g = gcd(g, a)
    if g == 1: return 'setwise'
    return 'not'
print(solve(), 'coprime')


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

using namespace std;

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

    int ans = 0;
    for (int i = 1; i <= n; i += 2) {
        int cnt = 0;
        for (int j = 1; j <= i; j += 2) {
            if (i % j == 0) cnt++;
        }
        if (cnt == 8) ans++;
    }

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


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

static const int NIL = -1;

struct Node {
	int parent;
	int left;
	int right;
	Node(int parent = NIL, int left = NIL, int right = NIL): parent(parent), left(left), right(right) {}
};

vector<Node> T;
vector<int> D;
vector<int> H;

void setDepth(int u, int depth)
{
	if (u == NIL) return;
	D[u] = depth;
	setDepth(T[u].left, depth + 1);
	setDepth(T[u].right, depth + 1);
}

int setHeight(int u)
{
	int hl = 0, hr = 0;
	if (T[u].left != NIL){
		hl = setHeight(T[u].left) + 1;
	}
	if (T[u].right != NIL){
		hr = setHeight(T[u].right) + 1;
	}
	return H[u] = max(hl, hr);
}

int getSibling(int u)
{
	int par = T[u].parent;
	if (par == NIL) return NIL;
	if (T[par].left != u && T[par].left != NIL){
		return T[par].left;
	}
	if (T[par].right != u && T[par].right != NIL){
		return T[par].right;
	}
	return NIL;
}

void print(int u)
{
	stringstream res;
	int deg = 0;
	string type;
	
	if (T[u].left != NIL) deg++;
	if (T[u].right != NIL) deg++;
	
	if (T[u].parent == NIL) type = "root";
	else if (T[u].left == NIL && T[u].right == NIL) type = "leaf";
	else type = "internal node";
	
	res << "node " << u << ": ";
	res << "parent = " << T[u].parent;
	res << ", sibling = " << getSibling(u);
	res << ", degree = " << deg;
	res << ", depth = " << D[u];
	res << ", height = " << H[u];
	res << ", " << type;
	
	cout << res.str() << endl;
}

int main()
{
	int n;
	scanf("%d", &n);
	T.resize(n);
	D.resize(n);
	H.resize(n);
	
	for (int i = 0; i < n; i++){
		int v, l, r;
		scanf("%d %d %d", &v, &l, &r);
		T[v].left = l;
		T[v].right = r;
		if (l != NIL) T[l].parent = v;
		if (r != NIL) T[r].parent = v;
	}
	
	int root = 0;
	for (int i = 0; i < n; i++){
		if (T[i].parent == NIL) root = i;
	}
	
	setDepth(root, 0);
	setHeight(root);
	
	for (int i = 0; i < n; i++){
		print(i);
	}
	
	return 0;
}

Measured memory_bytes: 1244
import java.util.*; 

class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
      
        String s=sc.next();
		int ans=0;
  		String[] a=s.split("");
		for(int c=0;c<3;c++){
    		if(a[c].equals(a[c+1])){
            ans++;
            }
    	}
    
 	if(ans==0){
    		System.out.println("Good");
    	}else{
     		System.out.println("Bad");
   	 }

    	
    }
}


Measured memory_bytes: 23124
#include<iostream>
#include <string>
using namespace std;
int main(){
string s;
cin>>s;
if(s.compare("Sunny")==0)cout<<"Cloudy"<<endl;
else if(s.compare("Cloudy")==0)cout<<"Rainy"<<endl;
else cout<<"Sunny"<<endl;

	return 0;
}

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

using namespace std;

#define print(s) cout << (s) << endl;
#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n) 
#define all(a) (a).begin(), (a).end()
#define inf 10000000
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin>>n;
    int y = 200*(n/15);
    int x = 800*n;
    cout<<x-y<<endl;
return 0;
}

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

using namespace std;

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    ll a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    for(i=0;i<=n-1;i++){
        if(a-b>=-d*i+c*(n-1-i) && a-b<=-c*i+d*(n-1-i)){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    long long w, h, x, y;
    double maxs;
    int ok = 0;
    cin >> w >> h >> x >> y;
    maxs = w * h / 2.0;
    if(w == 2*x && h == 2*y) ok = 1;
    cout << maxs << " " << ok << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>

using namespace std;

typedef unsigned long long ullong;

ullong power(ullong x, ullong n, int num) {
	ullong res = 1;
	if (n > 0) {
		res = power(x * x % num, n / 2, num);
		if (n % 2 != 0)
			res = res * x % num;
	}
	return res;
}

int main() {

	ullong num = 1000000007;
	int m, n;
	scanf("%d %d", &m, &n);

	ullong p = power(m, n, num);

	cout << p % num << endl;

	return 0;
}

Measured memory_bytes: 3204
#include <iostream>

using namespace std;

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

	int count = 0;

	for(int i=0;i<a+1;i++){
		for(int j=0;j<b+1;j++){
			for(int k=0;k<c+1;k++){
				if(x == 500*i + 100*j + 50*k){
					count++;
				}
			}
		}
	}

	cout << count << endl;

	
	return 0;
}

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

int main()
{
    int N;
    string A, B, C;

    cin >> N;
    cin >> A;
    cin >> B;
    cin >> C;

    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        int x = 0;
        if (A[i] == B[i])
        {
            x++;
        }
        if (B[i] == C[i])
        {
            x++;
        }
        if (C[i] == A[i])
        {
            x++;
        }

        if (x == 0)
        {
            ans += 2;
        }
        else if (x == 1)
        {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
using System;

public class Example {
    public static void Main() {
        while (true) {
            int[] size = Array.ConvertAll<string, int>(Console.ReadLine().Split(' '), delegate(string value) {
                return int.Parse(value);
            });
            if (size[0] == 0 && size[1] == 0) break;
            for (int i = 0; i < size[0]; i++) {
                for (int j = 0; j < size[1]; j++) {
                    Console.Write(i == 0 || i == size[0]-1 || j == 0 || j == size[1]-1 ? "#" : ".");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 8896
#include<bits/stdc++.h>
using namespace std;
#define maxn 200005
struct Card
{
	int x,y;
	inline friend bool operator < (Card a,Card b)
		{
			if(a.x==b.x) return a.y<b.y;
			return a.x<b.x;
		}
}card[maxn];
int Rmax,Rmin,Bmax,Bmin,maxpos,minpos;
int main()
{
	int n;
	scanf("%d",&n);
	if(n==1)
	{
		puts("0");
		return 0;
	}
	for(int i=1;i<=n;++i)
	{
		scanf("%d%d",&card[i].x,&card[i].y);
		if(card[i].x>card[i].y) swap(card[i].x,card[i].y);
	}
	sort(card+1,card+n+1);
	int maxy=card[1].y,minx=card[1].x;
	for(int i=1;i<=n;++i)
	{
		if(card[i].x<=minx&&card[i].y>=maxy)
		{
			maxpos=minpos=i;
			minx=card[i].x,maxy=card[i].y;
		}
		else if(card[i].x<minx)
		{
			minpos=i;
			minx=card[i].x;
		}
		else if(card[i].y>maxy)
		{
			maxpos=i;
			maxy=card[i].y;
		}
	}
	Rmax=maxy,Bmin=minx;
	Rmin=card[minpos].y,Bmax=card[maxpos].x;
	for(int i=1;i<=n;++i)
	{
		Rmin=min(Rmin,card[i].y);
		Bmax=max(Bmax,card[i].x);
	}
	long long ans=1ll*(Rmax-Rmin)*(Bmax-Bmin);
	if(maxpos!=minpos)
	{
		Bmax=maxy,Bmin=minx;
		Rmax=max(card[n].x,card[1].y);
		int premin=card[1].y;
		Rmin=min(card[1].y,card[2].x);
		int tmp=Rmax-Rmin;
		for(int i=2;i<n;++i)
		{
			Rmax=max(card[i].y,Rmax);
			Rmin=min(min(card[i].y,premin),card[i+1].x);
			premin=min(premin,card[i].y);
			if(Rmax-Rmin<tmp) tmp=Rmax-Rmin;
		}
		ans=min(ans,1ll*tmp*(Bmax-Bmin));
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
using namespace std;
typedef long long LL;
bool tri(int a, int b, int c) {
    return a <= b + c && b <= c + a && c <= a + b;
}

double calc(double a, double b, double c, double l, double m, double n) {
    a *= a;
    b *= b;
    c *= c;
    l *= l;
    m *= m;
    n *= n;
    double tmp =
        +a*l*(-a+b+c-l+m+n)
        +b*m*(a-b+c+l-m+n)
        +c*n*(a+b-c+l+m-n)
        -l*b*c-a*m*c-a*b*n-l*m*n;
    if(tmp < 0) return 0;
    return sqrt(tmp) / 12;
}

int main(){
    int num;
    while(cin >> num && num > 0) {
        vector<int> v(num);
        REP(i, num) cin >> v[i];
        double ans = 0.0;
        REP(i, num) REP(j, i) REP(k, j) {
            int l = v[i], m = v[j], n = v[k];
            if(!tri(l, m, n)) continue;
            REP(p, num) if(p != i && p != j && p != k) 
            REP(q, num) if(q != p && q != i && q != j && q != k)
            REP(r, num) if(r != q && r != p && r != i && r != j && r != k) {
                int a = v[p], b = v[q], c = v[r];
                if(!tri(a, b, n)) continue;
                if(!tri(b, c, l)) continue;
                if(!tri(c, a, m)) continue;
                ans = max(ans, calc(a, b, c, l, m, n));
            }
        }
        printf("%.12f\n", ans);
    }
    return 0;
}

Measured memory_bytes: 1220
def solve(k, a, b):
    if b <= a + 2:
        return 1 + k
    # init
    c = 0
    k += 1
    # c = a ?
    if k < a + 2:
        return k
    c = 0
    k -= a + 1
    num_iter, rest = divmod(k, 2)
    if rest == 0:
        # ends (2)
        c += (num_iter - 1) * (b - a)
        c += b + 1
    else:
        c += num_iter * (b - a) + b
    return c


def main():
    k, a, b = (int(z) for z in input().split())
    res = solve(k, a, b)
    print(res)


if __name__ == "__main__":
    main()

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

int H, W; string S[1000];

int main() {
	cin >> H >> W;
	for (int i = 0; i < H; i++)cin >> S[i];
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			int dx[8] = { 1,1,1,0,-1,-1,-1,0 }, dy[8] = { -1,0,1,1,1,0,-1,-1 };
			int R = 0;
			for (int k = 0; k < 8; k++) {
				int ex = i + dx[k], ey = j + dy[k];
				if (ex < 0 || ey < 0 || ex >= H || ey >= W)continue;
				if (S[ex][ey] == '#')R++;
			}
			if (S[i][j] == '#')cout << "#";
			else cout << R;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
use std::collections::HashMap;
#[derive(Default)]
//NOTE
//declare variables to reduce the number of parameters for dp and dfs etc.
struct Solver {}

impl Solver {
    fn solve(&mut self) {
        let stdin = std::io::stdin();
        let mut scn = Scanner {
            stdin: stdin.lock(),
        };
        let n: usize = scn.read();
        let a: Vec<i32> = scn.vec(n);
        let mut cnts = HashMap::new();
        //(j - i) = (ai + aj)
        //(ai + i) = (j - aj)
        let mut result = 0;
        for (idx, &a) in a.iter().enumerate().rev() {
            let x = (idx + 1) as i32;
            if let Some(cnt) = cnts.get(&(x + a)) {
                result += cnt
            }
            *cnts.entry(x - a).or_insert(0) += 1_u64;
        }
        //eprintln!("{:?}", cnts);
        println!("{}", result);
    }
}

fn main() {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024) // 64MB
        .spawn(|| {
            let mut solver = Solver::default();
            solver.solve()
        })
        .unwrap()
        .join()
        .unwrap();
}
pub mod utils {
    const DYX: [(isize, isize); 8] = [
        (0, 1),   //right
        (1, 0),   //down
        (0, -1),  //left
        (-1, 0),  //top
        (1, 1),   //down right
        (-1, 1),  //top right
        (1, -1),  //down left
        (-1, -1), //top left
    ];

    pub fn try_adj(y: usize, x: usize, dir: usize, h: usize, w: usize) -> Option<(usize, usize)> {
        let ny = y as isize + DYX[dir].0;
        let nx = x as isize + DYX[dir].1;
        if ny >= 0 && nx >= 0 {
            let ny = ny as usize;
            let nx = nx as usize;
            if ny < h && nx < w {
                Some((ny, nx))
            } else {
                None
            }
        } else {
            None
        }
    }
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_line(&mut self) -> String {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b'\n' || b == b'\r')
            .take_while(|&b| b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 8372
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <cmath>
#include <ios>
#include <ctype.h>
#include <stack>
#include <istream>
#include <stdio.h>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <functional>
#include <bitset>
#include <list>
#include <deque>
#include <time.h>
#include <random>
#include <iomanip>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define pint pair<int,int>
const int INF = 1000000007;
const long double EPS = 1e-15;
const long double PI = acos(-1);
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
using Graph_weighted = vector<vector<pair<int,int>>>;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll ceil(const ll a, const ll b) { return (a + b - 1) / b; }
ll comb(ll a,ll b){
  ll ret = 1,r = 1;
  for(int i = 1; i <= b; i++)ret = ret * (a - i + 1) / i;
  return ret;
}
int main(){
  int n,p;
  cin >> n >> p;
  ll g = 0,k = 0;
  rep(i,n){
    int tmp;
    cin >> tmp;
    if(tmp % 2)k++;
    else g++;
  }
  ll A = pow(2,g),B = 0;
  if(p == 0){
    for(int i = 2;i <= k; i += 2)B += comb(k,i);
    cout << A + B + (A - 1) * B;
  }
  else{
    for(int i = 1; i <= k; i += 2)B += comb(k,i);
    cout << B + (A - 1) * B << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#define _DEBUG 1
#define _GLIBCXX_DEBUG

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

using ll = long long;

#ifdef _DEBUG
#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                     \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z \
       << endl
#define check(s) cerr << s << endl
#else
#define dump(x)
#define dump2(x, y)
#define dump3(x, y, z)
#define check(s)
#endif

#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 all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

const ll LINF = 2e18;
const int INF = 1e9;

ll solve(ll N, std::vector<ll> A) {
  vector<ll> B(N + 1);
  B.at(0) = 1 - A.at(0);
  if (B.at(0) < 0) return -1;

  ll result = A.at(0) + B.at(0);
  ll asum = 0;
  rep(j, N + 1) { asum += A.at(j); }
  FOR(i, 1, N + 1) {
    ll d = B.at(i - 1) * 2;
    asum -= A.at(i - 1);
    d = min(B.at(i - 1) * 2, asum);
    B.at(i) = d - A.at(i);

    if (A.at(i) < 0 || B.at(i) < 0) return -1;
    result += A.at(i) + B.at(i);
  }
  return result;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  ll N;
  scanf("%lld", &N);
  std::vector<ll> A(N - 0 + 1);
  for (int i = 0; i < N - 0 + 1; i++) {
    scanf("%lld", &A[i]);
  }
  ll result = solve(N, std::move(A));
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 4824
N = int(input())
a = list(map(int, input().split()))
 
set_a = set(a)
cnt = [0] * (max(a)+1)
ans = 0
 
for i in a:
    cnt[i] += 1
 
if len(cnt) == 1:
    print(cnt[0])
else:
    for i in range(1, max(a)):
        ans = max(ans, cnt[i-1]+cnt[i]+cnt[i+1])

    print(ans)

Measured memory_bytes: 13964
print((lambda p: sum([1 if sum([sum([1 if p[2][j][k+1]-1==i else 0 for k in range(p[2][j][0])]) for j in range(p[0])])==p[0] else 0 for i in range(p[1])]))((lambda a: [a[0],a[1],[list(map(int,input().split())) for i in range(a[0])]])(list(map(int,input().split())))))

Measured memory_bytes: 3064
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <cctype>
#include <cstdio>
#include <vector>
using namespace std;

int main()
{
    int r, g;
    cin >> r >> g;
    cout << 2*g-r;
    
    return 0;
}

Measured memory_bytes: 256