akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int N = in.nextInt();
            int R = in.nextInt();
            int ans = R;
            if (N < 10) ans += 100 * (10 - N);
            out.println(ans);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

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

    }
}



Measured memory_bytes: 21460
/*==========================================================================*/
/*
    AUTHOR:    BPZ
	CREATED:   30.08.2020 11:16:54
 
*/
/*--------------------------------------------------------------------------*/
#include<bits/stdc++.h>
using namespace std;
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
 	vector<int> a(n);
 	for (int i = 0; i < n; i++) {
 		cin >> a[i];
 	}
 	long long sum = 0;
 	for (int i = 1; i < n; i++) {
 		if (a[i] < a[i - 1]) {
 			sum += a[i - 1] - a[i];
 			a[i] = a[i - 1]; 
 		}
 	}
 	cout << sum << '\n';
  return 0;
}


Measured memory_bytes: 3988
#include <stdio.h>
#include <stdlib.h>
int main()
{
    int n, x[100], y[100], h[100], i, j, k, H, flag;
    scanf("%d", &n);
    for (i=0; i<n; i++)
    {
        scanf("%d %d %d", &x[i], &y[i], &h[i]);
    }

    for (i=0; i<=100; i++)
    {
        for (j=0; j<=100; j++)
        {
            flag = 0;
            for (k=0; k<n; k++)
            {
                if (h[k]>0) {
                    if (flag == 0) {
                        H = h[k] + abs(x[k]-i) + abs(y[k]-j);
                        flag = 1;
                    } else {
                        if (H != h[k] + abs(x[k]-i) + abs(y[k]-j)) {
                            flag = 2;
                            break;
                        }
                    }
                }
            }
            for (k=0; k<n; k++)
            {
                if (h[k] == 0) {
                    if (H > h[k] + abs(x[k]-i) + abs(y[k]-j)) {
                        flag = 2;
                        break;
                    }
                }
            }
            if (flag == 1) {
               printf("%d %d %d\n", i, j, H);
               return 0;
           }
        }
    }
}


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

ll solve() {
    ll N, K, a, b;
    cin >> N >> K;
    map<ll, ll> num;
    for ( int i = 0; i < N; i++ ) {
        cin >> a >> b;
        num[a] += b;
    }
    ll cnt = 0;
    for ( auto p : num ) {
        cnt += p.second;
        if ( cnt >= K ) {
            return p.first;
        }
    }
    return -1;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
template <class T, class U>ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T>ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
template <class T, class U>istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >>p.second ;
	return is;
}
template <class T>istream& operator>>(istream& is,  vector<T>& v) {
	rep(i, v.size()) {
		is >> v[i];
	}
	return is;
}
long long modpow(long long a, long long n, long long mod=(1LL<<62)){
	long long res = 1;
	while (n > 0){
		if (n & 1)
		res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
ll mod                = 1e9 + 7;
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	string s;
	ll ans=0LL;
	cin >>s;
	int pool = 0;
	V data(3,0LL);//a,ab,abc
	for (int i = 0; i < s.size();i++){
		switch(s[i]){
			case 'A':
				data[0] +=1*modpow(3,pool,mod);
				data[0] %= mod;
				break;
			case 'B':
				data[1] += data[0];
				data[1] %= mod;
				break;
			case 'C':
				data[2] += data[1];
				data[2] %= mod;
				break;
			case '?':
				data[2] *= 3;
				data[2] %= mod;
				data[2] += data[1];
				data[2] %= mod;

				data[1] *= 3;
				data[1] %= mod;
				data[1] += data[0];
				data[1] %= mod;

				data[0] *= 3;
				data[0] %= mod;
				data[0] += modpow(3,pool,mod);
				data[0] %= mod;
				/*
		
				
				*/
				pool++;
				break;
		}
	//	clog << data << endl;
	}
	 cout << data[2] << endl;
}
/*
A??C

4 2*2 2*2 3

AA 2
AB 1 2 1
AC 1 = 7




???
1 0 0

1
2 2 2
4 4 4 4 4 4 3 = 24 +3

AA 2
AB 1 2 1
AC 1
BA 1
CA 1 = 9

15 1 0
6 7 0
6 1 1

*/

/*
尺取り方
a,
ab
abc
*/

Measured memory_bytes: 3764
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=1000000007 ;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-10;
const long double epsA=1e-4;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	int n,e,t,i,j;cin>>n>>e>>t;t--;
	vector<int>cost(n,mod);
	priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>>que;
	for(i=0;i<n;i++){
		int w;cin>>w;
		if(w==1){que.push(mp(1,i));}
	}
	vector<pair<int,vector<int>>>rule(e);
	vector<int>zi(e);
	vector<vector<int>>gya(n);
	for(i=0;i<e;i++){
		int g,c;cin>>g>>c;g--;
		rule[i].fir=g;
		zi[i]=c;
		while(c--){
			int s;cin>>s;s--;
			gya[s].pub(i);
			rule[i].sec.pub(s);
		}
	}
	while(que.size()){
		int c,ter;tie(c,ter)=que.top();que.pop();
		if(ter==t){cout<<c<<endl;return 0;}
		if(!mineq(cost[ter],c)){continue;}
		for(auto it:gya[ter]){
			zi[it]--;
			if(zi[it]==0){
				//コスト計算
				int r=rule[it].sec.size();
				vector<int>aaa(r);
				for(j=0;j<r;j++){aaa[j]=cost[rule[it].sec[j]];}
				SO(aaa);REV(aaa);
				for(j=0;j<r;j++){aaa[j]+=j;}
				int sor=0;
				for(j=0;j<r;j++){maxeq(sor,aaa[j]);}
				que.push(mp(sor,rule[it].fir));
			}
		}
	}
	cout<<-1<<endl;
	return 0;
}



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

int main() {
	int n, m, d;
	cin >> n >> m >> d;
	double ans = (double)2 * (n-d) / n / n * (m-1);
	if (d == 0) ans /= 2;
	printf("%.15lf\n", ans);
	return 0;
}


Measured memory_bytes: 384
N = int(input())
A = list(map(int, input().split()))
A.sort()
B = []
if N % 2 == 0:
    i_max = N // 2
    for i in range(1, i_max + 1):
        B.append(2 * i - 1)
        B.append(2 * i - 1)
else:
    i_max = (N - 1) // 2
    B.append(0)
    for i in range(1, i_max + 1):
        B.append(2 * i)
        B.append(2 * i)

if A == B:
    ans = (2 ** i_max) % (10**9 + 7)
    print(ans)
else:
    print(0)

Measured memory_bytes: 13812
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <unordered_map>
#include <vector>
#include <cmath>
#include <algorithm>

typedef long long ll;
typedef long double ld;

using namespace std;
int main()
{
  int n, a[110];
  ld sum = 0;
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < n; ++i) sum += 1 / (ld)a[i];
  cout << fixed << setprecision(15) << 1 / (ld)sum;
}


Measured memory_bytes: 3744
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE TypeFamilies #-}
import           Data.Maybe
import           Data.Int
import           Data.List
import           Data.Char
  -- import qualified Data.Vector.Unboxing as VU
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as BS
import           Data.List (scanl')
import           Data.IORef
import           Control.Monad
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Control.Applicative
import           Debug.Trace
import           Text.Printf


readInt = BS.readInt . BS.dropWhile isSpace
getVector f = VU.unfoldr f <$> BS.getLine
getIntVector = getVector readInt
getBSVector = getVector BS.uncons

main = do
  (n,m) <- (\vec -> (vec VU.! 0, vec VU.! 1)) <$> getIntVector
  -- a -> a'
  as <- VU.map (`div` 2) <$>  getIntVector
  let initNum = VU.foldl1' lcm as

  print $ if VU.any (\val -> (initNum `div` val) `mod` 2 == 0) as
          then 0
          else m `div` initNum - m `div` (2 * initNum)


Measured memory_bytes: 6012
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int H, W, N;
    cin >> H >> W >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];

    int cur = 0;
    for (int i = 0; i < H; i++) {
        vector<int> tmp;
        for (int j = 0; j < W; j++) {
            tmp.push_back(cur + 1);
            a[cur]--;
            if (a[cur] == 0) cur++;
        }
        if (i % 2 == 0) for (int i = 0; i < W; i++) cout << tmp[i] << ((i == W - 1) ? '\n' : ' ');
        else for (int i = W - 1; i >= 0; i--) cout << tmp[i] << ((i == 0) ? '\n' : ' ');
    }
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<array>
#include<algorithm>
//#include <random>
//std::random_device seed_gen;
//std::mt19937 engine(seed_gen());
//std::uniform_int_distribution<> dD {0, 364};

unsigned long xor128() {
  static unsigned long x=123456789, y=362436069, z=521288629, w=88675123;
  unsigned long t=(x^(x<<11));
  x=y; y=z; z=w;
  return (w=(w^(w>>19))^(t^(t>>8)));
}

int const INF = 1e9;
int const M = 500;

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int D; std::cin >> D;
  int c[26];
  for(int& ci: c) std::cin >> ci;
  std::vector<std::array<int,26>> s(D);
  for(int d = 0; d < D; ++d) {
    for(int& si: s[d]) std::cin >> si;
  }
  
  // greedy
  std::vector<int> t(D);
  int ans = 0;
  int last[26];
  std::fill_n(last, 26, -1);
  for(int d = 0; d < D; ++d) {
    int ma = -INF;
    t[d] = 0;
    for(int T = 1; T <= 26; ++T) {
      int cur = s[d][T-1];
      int sv = last[T-1];
      last[T-1] = d;
      for(int cx = 0; cx < 26; ++cx) {
        cur -= (d-last[cx])*c[cx];
      }
      last[T-1] = sv;
      if(cur > ma) { ma = cur; t[d] = T; }
    }
    ans += ma;
    last[t[d]-1] = d;
  }
  
  auto score = [&]()->int {
    int ans = 0;
    int last[26];
    std::fill_n(last, 26, -1);
    for(int d = 0; d < D; ++d) {
      ans += s[d][t[d]-1];
      last[t[d]-1] = d;
      for(int cx = 0; cx < 26; ++cx) {
        ans -= (d-last[cx])*c[cx];
      }
    }
    return ans;
  };
  
  // modify
  for(int m = 0; m < M; ++m) {
    int d1 = xor128()%365, d2 = xor128()%365;
    int sv1 = t[d1], tx1 = 0;
    int sv2 = t[d2], tx2 = 0;
    for(int T1 = 1; T1 <= 26; ++T1) if(T1 != sv1) for(int T2 = 1; T2 <= 26; ++T2) if(T2 != sv2) {
      t[d1] = T1;
      t[d2] = T2;
      int new_ans = score();
      if(new_ans > ans) { ans = new_ans; tx1 = T1; tx2 = T2; }
    }
    if(tx1 == 0) { t[d1] = sv1; t[d2] = sv2; }
    else { t[d1] = tx1; t[d2] = tx2; }
  }
  for(int ti: t) std::cout << ti << "\n";
  
  return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  double l;
  cin >> l;
  
  cout << fixed << setprecision(8) 
    << (l/3)*(l/3)*(l/3) << endl;
    
  return 0;
}

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

using namespace std;

int i,m,n;
long long s;

int main()
{
	scanf("%d%d",&n,&m);
	for (i=m+1;i<=n;i++)
	{
		s=s+1LL*(n/i)*(i-m);
		s=s+max(n%i-m+1,0);
		if (! m)
			s--;
	}
	printf("%lld",s);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>
#include<climits>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<complex>
#include<algorithm>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<sstream>
#include<bitset>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()

using namespace std;

typedef long long ll;
#define IINF INT_MAX
#define LLINF LLONG_MAX

int N;
vector<int> a,b;

void compute() {
  b = a;
  sort(a.begin(),a.end());
  rep(i,N) {
    int ans = lower_bound(ALL(a),b[i]) - a.begin();
    ans *= 3;
    ans += ( upper_bound(ALL(a),b[i]) - lower_bound(ALL(a),b[i]) - 1);
    cout << ans << endl;
  }
  return;
  map<int,int> mp;
  int prev = -1;
  rep(i,N) {
    if( prev != a[i] ) {
      prev = a[i];
      mp[prev] += i * 3;
    } else ++mp[prev];
  }
  rep(i,N) cout << mp[b[i]] << endl;
}

int main(){
  cin >> N;
  assert( 2 <= N && N <= 100000 );
  a.resize(N);
  rep(i,N) {
    double tmp;
    cin >> tmp; a[i] = (int)round(tmp * 1000);
    assert( 0 <= a[i] && a[i] <= 4000 );
  }
  compute();
  return 0;
}

Measured memory_bytes: 3844
#include <stdio.h>

int main(void){
        int num,num1,num3;
        scanf("%d %d",&num,&num1);
        if(num<11){
                num3=100*(10-num);
                num3=num1+num3;
                printf("%d",num3);
        }else{
                printf("%d",num1);
        }       
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define maxn 120000
using namespace std;
typedef long long LL;
LL h[maxn], f[maxn]; 
int main(){
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	for(int i = 1; i <= N; i += 1) cin >> h[i];
	f[2] = abs(h[2] - h[1]);
	for(int i = 3; i <= N; i += 1) f[i] = min(f[i - 1] + abs(h[i] - h[i - 1]), f[i - 2] + abs(h[i] - h[i - 2]));
	cout << f[N];
} 

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

int main(){
  int n,m;
  cin >> n >> m;
  vector<pair<int,int>> ab(n);
  for(int i=0;i<n;++i){
    int a,b;
    cin >> a >> b;
    ab[i] = make_pair(a,b);
  }

  sort(ab.begin(),ab.end());
  priority_queue<int> kouho;
  ll ans=0;
  int j=0;
  for(int i=1;i<=m;++i){
    while(ab[j].first<=i && j<n){
      kouho.push(ab[j].second);
      j++;
    }
    if(kouho.size()){
      ans+=kouho.top();
      kouho.pop();
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4536
#include<iostream>
#include<string.h>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> pii;

int main()
{
  int i,j,k;
  int h,w;
  int dx[4]={0,1,0,-1};
  int dy[4]={1,0,-1,0};
  bool used[25][25];
  char c[25][25];

  while(1){

    cin>>w>>h;
    if(w==0 && h==0)break;

    int sum=1;
    rep(i,25)rep(j,25)
      used[i][j]=false;

    rep(i,h)
      scanf("%s",c[i]);

    queue<pii> q;
    rep(i,h)rep(j,w)
      if(c[i][j]=='@'){
	q.push(pii(i,j));//y,x
	used[i][j]=true;
	break;
      }

    while(q.size()){
      i=q.front().first;
      j=q.front().second;
      q.pop();
      rep(k,4){
	int y=i+dy[k];
	int x=j+dx[k];
	if(y>=0 && y<h && x>=0 && x<w && used[y][x]==false && c[y][x]=='.'){
	    q.push(pii(y,x));
	    used[y][x]=true;
	    sum++;
	  }
      }
    }

    cout<<sum<<endl;

  }
}

Measured memory_bytes: 3228
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
#include<set>
using namespace std;


const long long int mod=1000000007;
const long long int INF=99999999999999999;


//階乗先に計算
class Kaizyou{
    public:
    long long int *kaizyou;
    Kaizyou(){};
    Kaizyou(long long int n,long long int mod){
        kaizyou=new long long int[n+1];
        kai(1,n,mod);
        return;
    }

    long long int kai(long long int a, long long int b, long long int mod) {
        long long int tmp = 1;
		kaizyou[0]=1;
        for (long long int i = a; i <= b; i++) {
            tmp *= i;
            tmp %= mod;

            kaizyou[i] = tmp;
        }
        return tmp;
    }
};

//累乗(繰り返し2乗法)　aのb乗(mod)を求める。
class Ruizyou{
    public:
    long long int rui(long long int a, long long int b, long long mod) {
        int memo[65] = {};
        long long int A[65] = {};
        long long int tmp = 1;
        for (int i = 0; i < 65; i++) {
            memo[i] = b % 2;
            b /= 2;
        }

        A[0] = a;
        A[0] %= mod;

        for (int i = 1; i < 65; i++) {
            A[i] = A[i - 1] * A[i - 1];
            A[i] %= mod;
        }
        for (int i = 0; i < 65; i++) {
            if (memo[i] == 1) {
                tmp *= A[i];
                tmp %= mod;
            }
        }
        tmp %= mod;
        return tmp;
    }
};
//コンビネーション計算
class Combination{
    public:
        Kaizyou * Kaizyou_Instance;
        Ruizyou Ruizyou_Instance;
    Combination(long long int n,long long int mod){
        Kaizyou_Instance=new Kaizyou(n,mod);
    }
    long long int comb(long long int n, long long int r, long long int mod) {
        long long int tmp;
		if(r>n){return 0;}
        tmp = (Kaizyou_Instance->kaizyou[n] * Ruizyou_Instance.rui(Kaizyou_Instance->kaizyou[r], mod - 2, mod)) % mod;
        tmp *= Ruizyou_Instance.rui(Kaizyou_Instance->kaizyou[n - r], mod - 2, mod);
        tmp %= mod;
        if (tmp < 0) { tmp = (mod - tmp) % mod; }
        return tmp;
    }
};	

string N;
long long int r1,r2,c1,c2,res=0;

int main() {
	cout << fixed << setprecision(18);
	cin>>r1>>c1>>r2>>c2;
	Combination Comb(2000005,mod);
	
	cout<<(Comb.comb(r2+1+c2+1,c2+1,mod)-Comb.comb(r2+1+c1,c1,mod)-Comb.comb(r1+c2+1,c2+1,mod)+Comb.comb(r1+c1,c1,mod)+10*mod)%mod;
} 

Measured memory_bytes: 15872
import math

N, D = map(int, input().split())
X, Y = [], []
for i in range(N):
  li = list(map(int,input().split()))
  X.append(li[0])
  Y.append(li[1])

ans = 0

for i in range(N):
  dis = math.sqrt(X[i] ** 2 + Y[i] ** 2)
  if dis<=D:
    ans += 1

print(ans)


Measured memory_bytes: 96776
#include <iostream>
#include <vector>

using namespace std;

void solve()
{
	int n;
	while(cin >> n, n)
	{
		vector<int> prize;
		bool ok_flag = false;
		for(int i = 0; i < n; ++i)
		{
			int k;
			cin >> k;
			if(k == 0)
			{
				continue;
			}
			if(k >= 2)
			{
				ok_flag = true;
			}
			prize.push_back(k);
		}
		if(!ok_flag)
		{
			cout << "NA" << endl;
		}
		else
		{
			cout << prize.size() + 1 << endl;
		}
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1316
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long int n;
    cin>>n;
    vector<long long int> sieve(n+1);
    for(long long int i=1;i<=n;i++){
        for(long long int j=i;j<=n;j+=i){
            sieve[j]++;
        }
    }
    long long tot=0;
    for(long long int i=1;i<=n;i++){
        tot+=(sieve[i]*i);
    }
    cout<<tot;
    return 0;
}


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

const ll mod=1e9+7;

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

/*-------------------------------------------*/


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

    int k;
    cin>>k;

    vector<int>d(k,INT_MAX);
    deque<int>deq{1};
    d[1]=1;

    while(!deq.empty()){
        int x=deq.front();
        deq.pop_front();
        if(chmin(d[(x*10)%k],d[x]))deq.push_front((x*10)%k);
        if(chmin(d[(x+1)%k],d[x]+1))deq.push_back((x+1)%k);
    }
    cout<<d[0]<<endl;
}

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

ll H, W, D, Q;
vector<vector<ll>> A;
vector<ll> L, R;
vector<pair<ll, ll>> g;

void solve() {
  vector<ll> S(H * W + 1, 0);
  for (int i = 1; i <= D; i++) {
    for (int j = 0; i + (j + 1) * D <= H * W; j++) {
      int p_old = i + j * D, p_new = i + (j + 1) * D;
      ll dx = abs(g[p_new].first - g[p_old].first);
      ll dy = abs(g[p_new].second - g[p_old].second);
      S[p_new] = S[p_old] + dx + dy;
    }
  }

  for (int i = 0; i < Q; i++) {
    cout << S[R[i]] - S[L[i]] << "\n";
  }
}

int main() {
  cin >> H >> W >> D;
  A.resize(H, vector<ll>(W));
  g.resize(H * W + 1);
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> A[i][j];
      g[A[i][j]].first = i;
      g[A[i][j]].second = j;
    }
  }
  cin >> Q;
  L.resize(Q);
  R.resize(Q);
  for (int i = 0; i < Q; i++) {
    cin >> L[i] >> R[i];
  }
  solve();
  return 0;
}


Measured memory_bytes: 5504
import sys

N, M = map(int, input().split())
A = list(map(int, sys.stdin.readline().rsplit()))
BC = [list(map(int, sys.stdin.readline().rsplit())) for _ in range(M)]
A.sort()
BC.sort(reverse=True, key=lambda x: x[1])
C = []

for b, c in BC:
    if len(C) >= N:
        break
    for _ in range(b):
        C.append(c)

C.sort(reverse=True)

res = 0
lenC = len(C)
for i in range(N):
    if i < lenC and A[i] < C[i]:
        res += C[i]
    else:
        res += A[i]
print(res)


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


#include "boost/multiprecision/cpp_int.hpp"
#include "boost/multiprecision/cpp_dec_float.hpp"
namespace mp = boost::multiprecision;
typedef mp::cpp_int LL;
typedef mp::number<mp::cpp_dec_float<1024>> DD;// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)

 
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define rrep(i,r,l) for(ll i=r;i>=l;i--)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-12;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"  //インタラクティブで消す！！！！！！！！！！！！！！！！！！！！！
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T,class S>
inline bool chmax(T &a, S b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T,class S>
inline bool chmin(T &a, S b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

void mod_print(ll k){
    ll P=50000;
    rep(y,1,P){
        ll x=mod(y*k);
        
        if(abs(x)<=P||x+P>=i_7){
            if(x+P>=i_7){
                x-=i_7;
            }
            cout<<x<<"/"<<y<<endl;
            //cout<<setprecision(5)<<(dd)x/(dd)y;
            return;
        }
    }
    cout<<"nun"<<endl;
}
#define all(c) c.begin(),c.end()
typedef vector<ll> vl;
//////////////////////////



int main(){fastio
    ll h,w,m;cin>>h>>w>>m;
    ll a[h+1],b[w+1];memset(a,0,sizeof(a));memset(b,0,sizeof(b));
    map<l_l,ll>mp;
    rep(zz,1,m){
        ll x,y;cin>>x>>y;
        a[x]++;
        b[y]++;
        mp[{x,y}]++;
    }
    ll mxa=0,mxb=0;
    rep(i,1,h)chmax(mxa,a[i]);
    rep(i,1,w)chmax(mxb,b[i]);
    vector<ll>va,vb;
    rep(i,1,h)if(mxa==a[i])va.pb(i);
    rep(i,1,w)if(mxb==b[i])vb.pb(i);
    ll ans=mxa+mxb;
    ll ca=va.size();ll cb=vb.size();
    if(ca*cb>m){
        cout<<ans<<endl;
        return 0;
    }
    for(auto x:va){
        for(auto y:vb){
            if(mp[{x,y}]==0){
                cout<<ans<<endl;
                return 0;
            }
        }
    }
    cout<<ans-1<<endl;
    
    return 0;
}


Measured memory_bytes: 35048
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr int mod = 1e9+7;
int main(){
  int n;
  cin >> n;
  vector<vector<int>> a(n,vector<int>(n));
  rep(i,n) rep(j,n) cin >> a[i][j];
  vector<int> dp(1<<n,0);
  dp[0] = 1;
  for (int i = 0; i < n; i++) {
    auto next = dp;
    for (int bit = 0; bit < (1 << n); bit++) {  
      if (!dp[bit]) continue;
      for (int j = 0; j < n; j++) {
        if (!(bit & (1 << j)) && a[i][j]) (next[bit|(1<<j)] += dp[bit]) %= mod;
      }
    }
    dp = next;
  }
  cout << dp[(1<<n)-1] << endl;
  return 0; 
} 

Measured memory_bytes: 16640
#include <bits/stdc++.h>
using namespace std;
 
int main () {
    string s; cin >> s;
    bool ans = true;
 
    for (int i = 0; i < s.length(); i++) {
        if (i % 2 == 0) {
            if (s[i] != 'R' && s[i] != 'U' && s[i] != 'D') ans = false;
        }
        else if (i % 2 != 0) {
            if (s[i] != 'L' && s[i] != 'U' && s[i] != 'D') ans = false;
        }
    }
    if (s.length() == 0) cout << "No" << endl;
    else if (ans == false) cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
  int a,b;
  cin>>a>>b;
  if((a==1 && b==2) || (a==2 && b==1))
  {
    cout<<3;
  }
  else if((a==2 && b==3) || (a==3 && b==2))
  {
  	cout<<1;
  }
  else if((a==1 && b==3) || (a==3 && b==1))
    	cout<<2;
  return 0;
}


Measured memory_bytes: 256
x = int(input())
if x == 2:
    print('2')
    exit()
ans = 0
while ans == 0:
    for i in range(2, x):
        if x % i == 0:
            break
        if i == x - 1 and x % i != 0:
            print(x)
            exit()
    x += 1

Measured memory_bytes: 2940
h, w = gets.split.map(&:to_i)
ch, cw = gets.split.map(&:to_i)
dh, dw = gets.split.map(&:to_i)

c = [?., ?#]
cc = Array.new(w+3, c[1])
s = [cc]
h.times do
    s << [c[1]]
    s[-1] += gets.chars + [c[1]]
end
s.push(cc, cc)

move = [[1,0], [-1,0], [0,1], [0,-1]]
warp = (-2..2).to_a.product((-2..2).to_a) - move - [[0,0]]

init = 1 << 30
d = Array.new(h+3) {Array.new(w+3, init)}
d[ch][cw] = 0
t = [[ch, cw]]

(0..).each do |k|
    break if t.empty? || d[dh][dw] < init
    u = []

    while (x,y = t.pop)
        move.each do |i,j|
            xx = x + i
            yy = y + j
            if s[xx][yy] == c[0] && d[xx][yy] > k
                d[xx][yy] = k
                t << [xx, yy]
            end
        end

        warp.each do |i,j|
            xx = x + i
            yy = y + j
            if s[xx][yy] == c[0] && d[xx][yy] > k + 1
                d[xx][yy] = k + 1
                u << [xx, yy]
            end
        end
    end

    t = u
end

p d[dh][dw] == init ? -1 : d[dh][dw]


Measured memory_bytes: 105256
import java.util.*;

public class Main {

    static class DSU {
        private int n;
        private int[] parentOrSize;

        public DSU(int n) {
            this.n = n;
            this.parentOrSize = new int[n];
            java.util.Arrays.fill(parentOrSize, -1);
        }

        int merge(int a, int b) {
            if (!(0 <= a && a < n))
                throw new IndexOutOfBoundsException("a=" + a);
            if (!(0 <= b && b < n))
                throw new IndexOutOfBoundsException("b=" + b);

            int x = leader(a);
            int y = leader(b);
            if (x == y) return x;
            if (-parentOrSize[x] < -parentOrSize[y]) {
                int tmp = x;
                x = y;
                y = tmp;
            }
            parentOrSize[x] += parentOrSize[y];
            parentOrSize[y] = x;
            return x;
        }

        boolean same(int a, int b) {
            if (!(0 <= a && a < n))
                throw new IndexOutOfBoundsException("a=" + a);
            if (!(0 <= b && b < n))
                throw new IndexOutOfBoundsException("b=" + b);
            return leader(a) == leader(b);
        }

        int leader(int a) {
            if (parentOrSize[a] < 0) {
                return a;
            } else {
                parentOrSize[a] = leader(parentOrSize[a]);
                return parentOrSize[a];
            }
        }

        int size(int a) {
            if (!(0 <= a && a < n))
                throw new IndexOutOfBoundsException("" + a);
            return -parentOrSize[leader(a)];
        }

        java.util.ArrayList<java.util.ArrayList<Integer>> groups() {
            int[] leaderBuf = new int[n];
            int[] groupSize = new int[n];
            for (int i = 0; i < n; i++) {
                leaderBuf[i] = leader(i);
                groupSize[leaderBuf[i]]++;
            }
            java.util.ArrayList<java.util.ArrayList<Integer>> result = new java.util.ArrayList<>(n);
            for (int i = 0; i < n; i++) {
                result.add(new java.util.ArrayList<>(groupSize[i]));
            }
            for (int i = 0; i < n; i++) {
                result.get(leaderBuf[i]).add(i);
            }
            result.removeIf(java.util.ArrayList::isEmpty);
            return result;
        }
    }


    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);

        int n = scan.nextInt();
        int m = scan.nextInt();

       DSU dsu = new DSU(n);

        for(int i = 0; i < m; i++){
            int A = scan.nextInt()-1;
            int B = scan.nextInt()-1;

            dsu.merge(A,B);
        }

        System.out.println(dsu.groups().size()-1);



    }
}

Measured memory_bytes: 61720
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <list>
#include <cmath>
#include <limits>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;


int main() {
    ll N, W;
    cin >> N >> W;
    vector<vector<ll>> dp(N+2, vector<ll>(100000+10, 1e13));
    vector<ll> v(N+2), w(N+2);
    rep(i, N) cin >> w[i] >> v[i];
    dp[0][0] = 0;
    for(ll i = 0; i < N; i++) {
        for(ll j = 0; j < 100005; j++) {
            dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
            if(dp[i][j] + w[i] <= W) {
                dp[i+1][j+v[i]] = min(dp[i+1][j+v[i]], dp[i][j] + w[i]);
            }
        }
    }

    ll ans = 0;

    rep(i, 100000+10) if(dp[N][i] <= W) ans = max(ans, (ll)i);

    cout << ans << endl;
}


Measured memory_bytes: 81024
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import qualified Data.Vector.Unboxed as VU

main :: IO ()
main = do
  n <- unsafeTextToInt <$> T.getLine :: IO Int
  as <- VU.map pred . VU.fromList . map unsafeTextToInt . T.words <$> T.getLine :: IO (VU.Vector Int)
  let
    ls = VU.unsafeAccumulate (+) (VU.replicate n 0) . VU.map (flip (,) 1) $ as :: VU.Vector Int
    m = VU.sum . VU.map comb $ ls :: Int
  VU.mapM_ print . VU.map ((m -) . pred . (ls VU.!)) $ as

comb :: Int -> Int
comb l = (l * pred l) `div` 2

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 14972
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;
int main(){
    int n,m,x,y;
    cin>>n>>m>>x>>y;
    vector<int> xv(n);
    vector<int> yv(m);
    for(int i=0;i<n;i++){
        cin>>xv[i];
    }
    for(int i=0;i<m;i++){
        cin>>yv[i];
    }
    sort(xv.begin(),xv.end());
    sort(yv.begin(),yv.end());
    for(int i=xv.back()+1;i<=yv.front();i++){
       if(x<i&i<=y){
            cout<<"No War";
            return 0;
        } 
    }
    cout<<"War";
    
    return 0;
}

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

int main(){
    int x;
    cin>>x;
    int ans=1,j=1;
    int flg=true;
    while(flg){
        if(x<=j) flg=false;
        else{
            ans++;
            j+=ans;
        }
    }
    
    cout<<ans<<endl;
    
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {

  public static void main(String[] args) {

      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      int M = sc.nextInt();
      List<List<Integer>> list = new ArrayList<>();
      for (int i = 0; i < N; i++) {
          int key = sc.nextInt();
          int value = sc.nextInt();
          List<Integer> temp = Arrays.asList(key, value);
          list.add(temp);
      }
      list = list.stream().sorted((o1, o2) -> o1.get(0).compareTo(o2.get(0))).collect(Collectors.toList());
      int current = 0;
      int num = M;
      long result = 0;
      while(true) {
          if (list.get(current).get(1) < num) {
              result += (long) list.get(current).get(0) * (long) list.get(current).get(1);
              num -= list.get(current).get(1);
              current++;
          } else {
              result += (long) list.get(current).get(0) * (long) num;
              break;
          }
      }
      System.out.println(result);
  }
}

Measured memory_bytes: 101168
#include<stdio.h>
int main(){
	int k,n,i,j,t;
	scanf("%d",&k);
	if(k==1){
		printf("1\n1");
		return 0;
	}
	n=(k+3)/4*2;
	printf("%d\n",n);
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			t=(i+j)%n+(i&1)*n;
			if(t>=k)t-=n;
			printf("%d ",t+1);
		}
		printf("\n");
	}
}

Measured memory_bytes: 1152
#include <stdio.h>
#include <stdlib.h>

int
frac(int n)
{
    int i;
    int r=1;

    for (i=1; i<=n; i++)
        r*=i;
    return r;
}

void
solver(int n, int *p, int *q)
{
    int pn, qn;
    int i, j;

    pn = qn = 0;
    for (i=0; i<n; i++) {
        pn += (p[i]-1)*frac(n-i-1);
        for(j=i+1; j<n; j++) {
            if (p[i]<p[j])
                p[j]--;
        }
    }
    for (i=0; i<n; i++) {
        qn += (q[i]-1)*frac(n-i-1);
        for(j=i+1; j<n; j++) {
            if (q[i]<q[j])
                q[j]--;
        }
    }
    printf("%d\n", abs(pn-qn));
}

int
main(int argc, char *argv[])
{
    int N;
    int P[8];
    int Q[8];
    int i;

    scanf("%d", &N);
    for (i=0; i<N; i++)
        scanf("%d", P+i);
    for (i=0; i<N; i++)
        scanf("%d", Q+i);

    solver(N, P, Q);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define Cout(s) cout << s << endl;
using ll = long long;
using P = pair<int, int>;

const ll INF = 1ll << 60;
ll MOD = 1e9 + 7;

int main()
{

    //    int b, c, d, e, k;
    int k;
    vector<int> a(5);
    REP(i, 5)
    cin >> a[i];
    cin >> k;
    for (int i = 0; i < 5; ++i)
    {
        for (int j = 0; j < 5; ++j)
        {
            if (abs(a[i] - a[j]) > k)
            {
                cout << ":(";
                return 0;
            }
        }
    }

    cout << "Yay!";
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#include <cassert>

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using namespace std;

int main() {
    uint64_t N;
    cin >> N;
    vector<uint64_t> A(N);
    rep(i, N) {
        cin >> A[i];
    }

    sort(A.begin(), A.end());
    vector<uint64_t> accum = A;
    rep(i, N-1) {
        accum[i+1] += accum[i];
    }
    int64_t ret = 0;
    rep(i, N-1) {
        if(accum[i]*2 >= A[i+1]) {
            ret++;
        } else {
            ret = 0;
        }
    }
    ret++;
    cout << ret << endl;

    return 0;
}


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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int h,w,n;
    Scd3(n,h,w);
    printf ("%d\n", (n-w+1)*(n-h+1));

    return 0;
}



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

using namespace std;


int main()
{
  int r,c;
  int data[100+1][100+1] = {};

  cin >> r >> c;

  for(int i = 0;i < r;i++)
    {
      for(int j = 0;j < c;j++)
	{
	  cin >> data[i][j];
	}
    }

  for(int i = 0;i < r;i++)
    {
      for(int j = 0;j < c;j++)
	{
	  data[r][c] += data[i][j];
	}
    }

  for(int i = 0;i < r;i++)
    {
      for(int j = 0;j < c;j++)
	{
	  data[i][c] += data[i][j];
	}
    }
  
  for(int j = 0;j < c;j++)
    {
      for(int i = 0;i < r;i++)
	{
	  data[r][j] += data[i][j];
	}
    }

  for(int i = 0;i <= r;i++)
    {
      for(int j = 0;j <= c;j++)
	{
	  if(j) cout << " ";
	  cout << data[i][j]; 
	}
      cout << endl;
    }
    return 0;
}



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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }
template <class T1, class T2, class Pred = std::less<T2> >
struct sort_pair_second {
    bool operator()(const std::pair<T1,T2>&left, const std::pair<T1,T2>&right) {
        Pred p;
        return p(left.second, right.second);
    }
};

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

    string S; cin >> S;
    int N = S.size();
    bool f = true;
    rep(i, (N - 1) / 2) {
        if (S[i] != S[(N - 1) / 2 - i - 1]) {
            f = false;
        }
    }
    REP(i, (N + 2) / 2, N) {
        if (S[i] != S[N - i - 1]) {
            f = false;
        }
    }
    rep(i, N) {
        if (S[i] != S[N - i - 1]) {
            f = false;
        }
    }
    if (f) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

def main():
    N = int(input())
    a = [list(map(int,input().split())) for _ in range(N)]
    MOD = 10**9+7
    
    dp = [1] + [0 for _ in range(1<<N)]

    for i in range(N):
        use = [0 for _ in range((1<<N)+1)]
        for s in range(1<<N):
            if dp[s] == 0:
                continue
            for j in range(N):
                jb = 1<<j
                if not (s&jb) and a[i][j]:
                    use[s|jb] += dp[s]
        dp = use
    
    print(dp[(1<<N)-1]%MOD)

if __name__ == "__main__":
    main()


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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

ll gcd(ll a, ll b) {
  if (a < b) {
    swap(a, b);
  }
  // printf("%d %d\n", a, b);
  ll r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  // ll sum_c = 0;
  // for (ll i = a / c; (i * c) <= b; ++i) {
  //   if (i * c >= a) {
  //     sum_c++;
  //   }
  // }
  ll sum_c = b / c - (a - 1) / c;
  ll sum_d = b / d - (a - 1) / d;
  ll cd_gcd = gcd(c, d);
  // printf("%d\n", cd_gcd);
  ll sum_cd = b / (c * d / cd_gcd) - (a - 1) / (c * d / cd_gcd);
  // for (ll i = a / d; (i * d) <= b; ++i) {
  //   if (i * d >= a) {
  //     sum_d++;
  //     if (i * d % c == 0) {
  //       sum_cd++;
  //     }
  //   }
  // }
  // printf("%d %d %d %d\n", (b - a + 1), sum_c, sum_d, sum_cd);
  cout << (b - a + 1) - sum_c - sum_d + sum_cd << endl;
  // ll sum = 0;
  // for (ll i = a; i <= b; ++i) {
  //   if (i % c != 0 && i % d != 0) {
  //     sum++;
  //   }
  // }
  // cout << sum << endl;
  return 0;
}


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

int main() {
  int a,b;
  cin >> a >> b;
  if(a == b){
    cout << "Draw" << endl;
  }
  else if(a == 1 || (a > b && b != 1)){
    cout << "Alice" << endl;
  }
  else{
    cout << "Bob" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
vector<int>a;
int main()
{
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='0')
			a.push_back(0);
		if(s[i]=='1')
			a.push_back(1);
		if(s[i]=='B'&&a.size()>0)
			a.pop_back();
	}
	for(int i=0;i<a.size();i++)
		cout<<a[i];	
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int n,m;cin>>n>>m;
  int box[n];
  bool can[n];
  for(int i = 0; n > i; i++){
    box[i] = 1;
    if(!i)can[i] = true;
    else can[i] = false;
  }
  for(int i = 0; m > i; i++){
    int x,y;cin>>x>>y;x--;y--;
    if(can[x]){
      can[y] = true;
    }
    box[x]--;
    box[y]++;
    if(!box[x]){
      can[x] = false;
    }
  }
  int ans = 0;
  for(int i = 0; n > i; i++){
    if(can[i]){
      ans++;
    }
  }
  cout << ans <<endl;
}

Measured memory_bytes: 768
#include <bits/stdc++.h> 
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x,y,z) max((x),max((y),(z)))
#define tmin(x,y,z) min((x),min((y),(z)))
typedef long long ll;ll MM = 1000000000;ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
typedef vector<ll> lvec;typedef vector<double> dvec;typedef vector<string> svec;
ll GCD(ll x, ll y) {if (y == 0) return x;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x / GCD(x, y) * y;}
//cout << fixed << setprecision(10);

int main(){
  ll k,s,ans=0;
  cin>>k>>s;
  rep(i,k+1){
    rep(j,k+1){
      if(0<=(s-i-j)&&(s-i-j)<=k)ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	var a []int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var i int
		fmt.Scan(&i)
		a = append(a, i)
	}

	sum := 0
	for _, v := range a {
		sum += v - 1
	}
	fmt.Println(sum)
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N, M;
    cin >> N >>M;
    int H[N];
    vector<int> connected_max_height (N, -1);
    for (int i = 0;i < N;i++) {
        cin >> H[i];
    }
    for (int i = 0;i < M;i++) {
        int A, B;
        cin >> A >> B;
        A--;B--;
        connected_max_height[A] = max(H[B] ,connected_max_height[A]);
        connected_max_height[B] = max(H[A] ,connected_max_height[B]);
    }
    int count = 0;
    for (int i = 0;i < N;i++) {
        if (H[i] > connected_max_height[i]) count++;
    }
    cout << count << endl;
}


Measured memory_bytes: 3996
import java.util.Scanner;

class Main {
   public static void main(String[] args) {
      int a,b,c,d;
      Scanner sc = new Scanner(System.in);
      a = sc.nextInt();
      b = sc.nextInt();
      c = a*b;
      d = 2*(a+b);
      System.out.println( c + " " + d );
   }
}


Measured memory_bytes: 26216