akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n, k;
    cin >> n >> k;
    int a;
    cin >> a;
    int mx = a;
    int g = a;
    REP(i, n - 1) {
        cin >> a;
        chmax(mx, a);
        g = __gcd(g, a);
    }
    if (k <= mx and k % g == 0) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
}


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

void dfs(vector<vector<int> > &map, int x, int y){
    map[x][y] = 0;
    for(int dx = -1; dx <= 1; dx++){
        for(int dy = -1; dy <= 1; dy++){
            int nx = x + dx, ny = y + dy;
            if(1 <= nx && nx <= map.size()-2 && 1 <= ny && ny <= map[dx].size()-2 && map[nx][ny] == 1) dfs(map, nx, ny);
        }
    }
}

int main(){
    while(1){
        int W, H;
        cin >> W >> H;
        if(W == 0) break;
    
        vector<vector<int> > map(H+2, vector<int>(W+2));
        for(int i = 1; i <= H; i++){
            for(int j = 1; j <= W; j++){
                cin >> map[i][j];
            }
        }
    
        int res = 0;
        for(int i = 1; i <= H; i++){
            for(int j = 1; j <= W; j++){
                if(map[i][j] == 1){
                    dfs(map, i, j);
                    res++;
                }
            }
        }
    
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 1520
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()

using namespace std;

const int MAX = 1010000;
const int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;

int dx[4] = { 0,0,1,-1 };
int dy[4] = { 1,-1,0,0, };
typedef pair<int, int>P;

int N;
vector<int>a, b;

signed main() {
	cin >> N;
	a.resize(N+2); b.resize(N+2);
	a[N] = -INF, a[N + 1] = INF, b[N] = INF, b[N + 1] = -INF;
	REP(i, N) {
		cin >> a[i];
	}
	REP(i, N) {
		cin >> b[i];
	}
	VSORT(a); VSORT(b);
	int ans = 1;
	int l = 1, r = 1;
	while (r < N+1) {
		//pe(l)pe(r)print(ans);
		if (a[r] < b[r + 1] && b[r] < a[r + 1]) {
			if (a[l] <= b[l]) {
				for (int i = r; i > l; i--) {
					auto itr = lb(b, a[i]);
					int id = itr - b.begin();
					ans *= (i - id + 1);
					ans %= MOD;
				}
			}
			else {
				for (int i = r; i > l; i--) {
					auto itr = lb(a, b[i]);
					int id = itr - a.begin();
					ans *= (i - id + 1);
					ans %= MOD;
				}
			}
			l = r+1;
		}
		r++;
	}
	print(ans%MOD);
}


Measured memory_bytes: 1792
N=int(input())



div=10**9+7
def po(x,n,M):
    res=1
    if n>0:
        
        res= po(x,n//2,M)
    if n%2==0:
        res=(res*res)%M
    else:
        res=(((res*res)%M)*x)%M
        
      
    return res

A=po(10,N,div)
B=po(9,N,div)
C=po(8,N,div)
ans=(A-2*B+C)%div
print(ans)

Measured memory_bytes: 61364
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)
vector<vector<int> > g;

int s[100010];

int dfs(int k){
    if(s[k]!=-1)return s[k];
    int mx = 0;
    for(auto x:g[k]){
        mx = max(mx,dfs(x)+1);
    }
    return s[k] = mx;
}

int main(){
    int n,m;
    cin >> n >> m;
    g.resize(n);
    rep(i,n)s[i] =-1;
    rep(i,m){
        int a,b;
        cin >> a >> b;
        a--;b--;
        g[a].PB(b);
    }
    int mx = 0;
    rep(i,n){
        mx = max(mx,dfs(i));
    }
    cout << mx << endl;
    return 0;
}

Measured memory_bytes: 8192
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,X;
    cin >> N >> X;
    vector<int> L(N+1), D(N+2);
    for(int i = 1; i < N+1; i++){
        cin >> L[i];
    }
    D[1] = 0;
    int count = 1;
    for(int i = 2; i <= N+1; i++){
        D[i] = D[i-1] + L[i-1];
        if(D[i] <= X) count++;
    }
    cout << count << endl;
}

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

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

  //cout << S.length() << T.length() << endl;

  if(S.length() +1 != T.length()){
    cout << "No" << endl;
    return 0;
  }

  //T[T.length()] = '\0';
  if(S.compare(0,S.length(),T,0,S.length()) == 0)
    cout << "Yes" <<endl;
  else
    cout << "No" << endl;


}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define debug(x) cout << '[' << #x << " is: " << x << "] " <<"\n";
#define sor(v) sort(v.begin(),v.end())
#define rsor(v) sort(v.rbegin(),v.rend())
#define rev(v) reverse(v.begin(),v.end())
#define print(v) for(auto f:v)cout<<f<<" ";
#define printpair(v) for(auto f:v)cout<<f.first<<" "<<f.second<<endl;
#define int long long
vector<int>wt , v ;
vector<vector<int>>dp(1e2 + 1 , vector<int> (1e5 + 1 , -1));
int n , w;
int calc(int idx , int c ){
    int res ;
    if(idx == 0 || c == 0)
        return dp[idx][c] = 0 ;
    if(dp[idx][c] != -1)return dp[idx][c];
    int firstc = -1 , secondc = -1 ;
    if(c < wt[idx])
        res = calc(idx - 1 , c) ;
    else {
        firstc = v[idx] + calc(idx - 1 , c - wt[idx] );
        secondc = calc(idx - 1 , c);
        res = max(firstc , secondc);
    }
    return  dp[idx][c] = res ;


}
int32_t main(){
     ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n >> w ;
    v.resize(n + 1) , wt.resize(n + 1);
   for(int x = 1 ; x <= n ; x++)
        cin >> wt[x] >> v[x] ;
    cout << calc(n  , w );

    return 0;
}


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

using i64 = int64_t;

template <typename T, typename E> class SegmentTree {
  private:
    int n;
    std::vector<T> node;
    const std::function<T(T, T)> query_func;
    const std::function<T(T, E)> update_func;
    const T identity;

  public:
    SegmentTree() = default;

    SegmentTree(int size, std::function<T(T, T)> query_func,
                std::function<T(T, E)> update_func, T identity,
                std::vector<T> v = std::vector<T>())
        : query_func(query_func), update_func(update_func), identity(identity) {
        n = 1;
        while (n < size)
            n *= 2;
        node.resize(2 * n - 1, identity);
        if (size == v.size())
            build(size, v);
    }

    void build(int size, std::vector<T> v) {
        for (int i = 0; i < size; ++i)
            node[i + n - 1] = v[i];
        for (int i = n - 2; i >= 0; --i)
            node[i] = query_func(node[2 * i + 1], node[2 * i + 2]);
    }

    void update(int x, E val) {
        x += n - 1;

        node[x] = update_func(node[x], val);
        while (x > 0) {
            x = (x - 1) / 2;
            node[x] = query_func(node[2 * x + 1], node[2 * x + 2]);
        }
    }

    T query(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r < 0)
            r = n;

        if (r <= a || b <= l)
            return identity;

        if (a <= l && r <= b)
            return node[k];

        T vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
        T vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
        return query_func(vl, vr);
    }
};

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> v;
    for(int i=0;i<n;++i){
        int p;
        cin >> p;
        v.push_back(p);
    }
    SegmentTree<int, int> max_st(
        n,
        [](int a, int b){return max(a,b);},
        [](int a, int b){return b;},
        -1,
        v
    );
    SegmentTree<int, int> min_st(
        n,
        [](int a, int b){return min(a,b);},
        [](int a, int b){return b;},
        n,
        v
    );

    int ans = n - k + 1;
    for(int i=0;i+k<n;++i){
        int mini = min_st.query(i+1, i+k);
        int maxi = max_st.query(i+1, i+k);
        //cerr << mini << " " << maxi << endl;
        if(v[i] < mini && v[i+k] > maxi)ans--;
    }

    int len = 0, cnt = 0, maxi = -1;
    for(int i=0;i<n;++i){
        if(v[i] > maxi){
            maxi = v[i];
            len++;
        }else{
            if(len >= k)cnt++;
            maxi = v[i];
            len = 1;
        }
    }

    if(len >= k)cnt++;

    if(cnt > 1)ans -= (cnt - 1);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6740
N, M = map(int, input().split())
H = list(map(int, input().split()))

all_tenbo = list(range(1, N+1))
not_good = []

for i in range(M):
    A, B = map(int, input().split())
    if H[A-1] <= H[B-1]:
        not_good.append(A)
    if H[B-1] <= H[A-1]:
        not_good.append(B)

print(len(list(set(all_tenbo)-set(not_good))))

Measured memory_bytes: 29812
#include<stdio.h>
int main(){
 int i,n,x;
 fscanf(stdin,"%d",&n);
 for(i=1; i<=n; i++){
  x=i;
  if(x%3==0){
   printf(" %d",i);
   continue;
   }
   do{
    if(x%10==3){
     printf(" %d",i);
     break;
     }
     x/=10;
   }while(x);
  }
  printf("\n");
  return 0;
}


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

void spr(double,double,double,double,int);

int main(){
  double x1=0.0, y1=0.0, x2=100.0, y2=0.0;
  int d;
  cin >> d;

  spr(x1,y1,x2,y2,d);
  cout << fixed << x2 << ' ' << y2 << endl;

  return 0;
}

void spr(double x1,double y1,double x2,double y2,int d){
  assert(d>=0);  
  double sx,sy,ux,uy,tx,ty;

  if(d==0){
    cout << fixed << x1 << ' ' << y1 << endl;
  }else{
    sx=(2.0*x1+x2)/3.0;
    sy=(2.0*y1+y2)/3.0;
    tx=(x1+2.0*x2)/3.0;
    ty=(y1+2.0*y2)/3.0;

    //u-s=(s-p1)*exp(i??/3)
    //u=(s-p1)*(1/2+i???3/2)+s
    ux=(sx-x1)*(1.0/2.0)-(sy-y1)*(sqrt(3.0)/2.0)+sx;
    uy=(sx-x1)*(sqrt(3.0)/2.0)+(sy-y1)*(1.0/2.0)+sy;

    spr(x1,y1,sx,sy,d-1);
    spr(sx,sy,ux,uy,d-1);
    spr(ux,uy,tx,ty,d-1);
    spr(tx,ty,x2,y2,d-1);
  }  
}

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

typedef long long LL;

const double PI = acos(-1.0);

int a, b, k;

int work() {

    scanf("%d%d%d", &k, &a, &b );

    for (int i = a; i <= b; ++i) {
        if (i % k == 0) {
            printf("OK\n");
            return 0;
        }
    }

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

int main() {
    work();
    //while (~scanf("%d", &n)) work();
    //scanf("%d", &T); while (T--) work();

    return 0;
}


Measured memory_bytes: 3688
def main():
    A, B = list(map(int, input().strip().split()))
    
    n_taps = 0
    n_output = 1
    while n_output < B:
        n_output += (A - 1)
        n_taps += 1
    print(n_taps)


if __name__ == "__main__":
    main()


Measured memory_bytes: 38384
#include <stdio.h>

#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define STR(i,str) for(int i=0;(str)[i];i++)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX3(a,b,c) ((a)>(b)?(a)>(c)?(a):(c):(b)>(c)?(b):(c))
#define MIN3(a,b,c) ((a)<(b)?(a)<(c)?(a):(c):(b)<(c)?(b):(c))
#define RNG(a,b) ((a)>(b)?(a)-(b):(b)-(a))
#define RNG3(a,b,c) ((a)>(b)?(b)>(c)?(a)-(c):(c)>(a)?(c)-(b):(a)-(b):(b)>(c)?(c)>(a)?(b)-(a):(b)-(c):(c)-(a))
#define MAXS(a,b) {if((a)<(b))(a)=(b);}
#define MINS(a,b) {if((a)>(b))(a)=(b);}

bool bomb[55][55];
int ans[55][55];

int main(){
	int h, w;
	scanf("%d%d ", &h, &w);
	REP(i, h){
		char buf[55];
		fgets(buf, 55, stdin);
		REP(j, w){
			if(buf[j] == '#'){
				bomb[i][j] = true;
				if(i > 0 && j > 0) ans[i - 1][j - 1]++;
				if(i > 0) ans[i - 1][j]++;
				if(i > 0 && j < w - 1) ans[i - 1][j + 1]++;
				if(j > 0) ans[i][j - 1]++;
				if(j < w - 1) ans[i][j + 1]++;
				if(i < h - 1) ans[i + 1][j]++;
				if(i < h - 1 && j > 0) ans[i + 1][j - 1]++;
				if(i < h - 1 && j < w - 1) ans[i + 1][j + 1]++;
			}
		}
	}
	REP(i, h){
		REP(j, w){
			if(bomb[i][j]) putchar('#');
			else printf("%d", ans[i][j]);
		}
		putchar('\n');
	}
}

Measured memory_bytes: 128
N, M = map(int, input().split())
A = list(map(int, input().split()))

sum = 0
for i in A:
    sum += i
sum = sum/(4*M)

count = 0
for i in A:
    if i >= sum:
        count += 1

if count >= M:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int main()
{
    int N, v;
    cin >> N;
    queue<int> Q;
    for(int i=0;i<N;++i){
        cin >> v;
        Q.push(v);
    }

    int c=1, ans=0;
    while(!Q.empty()){
        v = Q.front();
        Q.pop();
        if(c == v){
            ++ans;
            ++c;
        }
    }

    if(ans == 0) cout << -1 << endl;
    else
        cout << N - ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
long long n,i,j,a[55],b[55],ans,dp[55][55];
bool check(long long x){
	memset(dp,0,sizeof(dp));
	long long i,j,k;
	for(i=0;i<=50;i++){
		dp[i][i]=1;
	}
	for(k=50;k>=1;k--)if((x>>k)&1){
		for(i=50;i>=0;i--){
			for(j=0;j<=50;j++) if(dp[i][j]){
				dp[i%k][j]=1;
			}
		}
	}
	for(i=1;i<=n;i++){
		if(!dp[b[i]][a[i]]) return 0; 
	}
	return 1;
}
int main(){
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>a[i];
	}
	for(i=1;i<=n;i++){
		cin>>b[i];
	}
	ans=(1ll<<51)-2;
	if(!check(ans)){
		puts("-1");
		return 0;
	}
	for(i=50;i>=1;i--){
		if(check(ans^(1ll<<i))){
			ans^=(1ll<<i);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cassert>
#include<ctime>
#include<climits>
#include<queue>
#include<fstream>
#include<deque>
#include<iomanip>
#include<list>
#include<stack>
#include<sstream>
#include<string>
#include<cctype>
#include<cstdio>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<map>
#include<set>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define EPS 1e-10
#define F first
#define S second
#define all(n) n.begin(),n.end()
#define pb push_back
#define insert(a,b,c,d) PP(P(a,b),P(c,d))
#define INF (1<<27)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<P,P> PP;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
const int LIM = 1900000;
bool prime[LIM+2];
vector<int> primes;
void eratos(){

  int p=0;
  for(int i=0;i<=LIM;i++)prime[i] = true;
  prime[0] = prime[1] = false;
  for(int i=2;i<=LIM;i++){
    if(prime[i]){
      for(int j=2*i;j<=LIM;j+=i)prime[j] = false;
    }
  }
 
  REP(i,2,LIM){
    if(prime[i]){
      primes.pb(i);
    }
  }
  // cout << primes.size() << endl;///////////////////////////////
}

int b_search(int key){
  if(key == 0)return 0;
  if(key == 1)return 0;
  int l=0,r=primes.size()-1;

  while(l <= r){
    int mid = (l+r)/2;
    if(key <= primes[mid] && primes[mid-1] < key)return mid;
    if(key < primes[mid])r = mid;
    else if(primes[mid] < key)l =mid+1;
    //cout << "r = "<< r << ", l = " << l << endl;
  }
  assert(false);
}

int main(){
  clock_t start,end;
  start = clock();
  eratos();
  end = clock();

  //cout << setiosflags(ios::fixed) << setprecision(10) << "eratos time = " <<(double)(end-start)/CLOCKS_PER_SEC << endl;
  int N,P;
  while(true){
   
    cin >> N >> P;
    if(N == -1 && P == -1)break;
   
    int index = b_search(N);
    if(prime[N])index++;
    //cout << "index = " << index << " " << primes[index] << endl;    
    vector<int> Set;
    for(int i=index;i<=index+P;i++){
      for(int j=i;j<=index+P;j++){
	Set.pb(primes[i]+primes[j]);
      }
    }
    sort(all(Set));
    cout << Set[P-1] << endl;
  }
return 0;
}

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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

int main(int argc, const char * argv[]) {
    
    // source code
  int n;
  cin >> n;
  cout << n*n;
}

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

int main(){
    string s;
    cin>>s;
    int n = s.length(), l=0,r=0;
    vector<int> ans(n,0);
    bool odd=true;

    for(int i=0;i<n;i++){
        if(s[i]=='R'){
            if(odd) l++;
            else r++;
            odd = !odd;
        }else{
            ans[i-1] += l;
            ans[i] += r;
            l=0,r=0;
            odd = true;
        }
    }

    for(int i=n-1;i>=0;i--){
        if(s[i]=='L'){
            if(odd) r++;
            else l++;
            odd = !odd;
        }else{
            ans[i+1] += r;
            ans[i] += l;
            l=0,r=0;
            odd = true;
        }
    }

    for(int i=0;i<n;i++){
        cout<<ans[i];
        if(i!=n-1)
            cout<<' ';
        else
            cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 1024
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 1e18
#define MOD 100000007
#define SIZE 10005
#define PI 	3.14159265358979323846

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;
    cin >> n >> k;
    REP(i,n){
        int a;
        cin >> a;
    }
    cout << ((n-1)%(k-1)?(n-1)/(k-1)+1:(n-1)/(k-1)) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REP1(i, n) for (ll i = 1; i <= n; i++)
#define RREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define RREP1(i, n) for (ll i = n; i >= 1; i--)
#define FOR(i, a, b, c) for (ll i = a; i <= b; i += c)
#define RFOR(i, a, b, c) for (ll i = a; i >= b; i -= c)
#define MAX(a, b) (a > b ? a : b)
#define MIN(a, b) (a < b ? a : b)
#define INF 1145141919
typedef long long ll;

int main() {
    int h, w;
    scanf("%d %d", &h, &w);
    REP(i, h) {
        char s[101];
        scanf("%s", s);
        printf("%s\n%s\n", s, s);
    }
    return 0;
}

Measured memory_bytes: 128
def insertionSort(n, a)
  n.times do |i|
    v, j = a[i], i - 1
    while j >= 0 && a[j] > v
      a[j + 1] = a[j]
      j -= 1
      a[j + 1] = v
    end
    puts a.join(' ')
  end
end
insertionSort(gets.to_i, gets.split.map(&:to_i))

Measured memory_bytes: 8896
#https://www.youtube.com/watch?v=3gFnZhZlAF8
#【競プロ実況】ABC172 AからD問題【かつっぱ】
#等差数列の和

n=int(input())
ans=0
for i in range(1,n+1):
    N=n//i #項数
    ans+=((i+i*N)*N)//2
print(ans)

Measured memory_bytes: 63180
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 1000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
llint gcd(llint a, llint b) {
	if (b > a)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
llint Tow(int m,int n) {//2のn乗
	if (n == 0)return 1;
	llint x = Tow(m,n / 2);
	x *= x;
	if (n % 2 == 1)x *= m;
	return x;
}
ll max(ll a, ll b) {
	if (a < b)return b;
	else return a;
}
struct edge { int to, cost; };


int main() {
	int a, b;
	cin >> a;
	b = 800 * a - (a / 15) * 200;
	cout << b << endl;
	return 0;
}

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

#define ll long long
#define pb push_back

int main(){

	int N, M, CapX, CapY;
	vector<int> X, Y;
	cin >> N >> M >> CapX >> CapY;
	for(int i = 0; i < N; i ++){
		int x;
		cin >> x;
		X.pb(x);
	}
	for(int i = 0; i < M; i ++){
		int y;
		cin >> y;
		Y.pb(y);
	}
	X.pb(CapX);
	Y.pb(CapY);
	sort(X.begin(), X.end());
	sort(Y.begin(), Y.end());
	if(X[X.size() - 1] < Y[0])cout << "No War" << endl;
	else cout << "War" << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<52;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const vi emp;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,-0};
const int DX[8]={-1,-1,-1,0,0,1,1,1},DY[8]={1,0,-1,1,-1,1,0,-1};

const int S=405;

int n,ma,mb;
vi a,b,c;

int main(){
	cin>>n>>ma>>mb;
	a=b=c=vi(n);
	for(int i=0;i<n;i++) cin>>a[i]>>b[i]>>c[i];
	vvi dp(S,vi(S,inf));
	dp[0][0]=0;
	for(int i=0;i<n;i++) for(int j=S-1;j>=0;j--) for(int k=S-1;k>=0;k--) if(j>=a[i]&&k>=b[i]) dp[j][k]=min(dp[j][k],dp[j-a[i]][k-b[i]]+c[i]);
	int ans=inf,k=1;
	while(max(ma,mb)*k<S){
		ans=min(ans,dp[ma*k][mb*k]);
		k++;
	}
	if(ans==inf) cout<<-1<<endl;
	else cout<<ans<<endl;
}

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

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int INF = 1e9;

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

	int n, m, r;
	cin >> n >> m >> r;

	int s[r];
	rep(i, r) {
		cin >> s[i];
		s[i]--;
	}

	int d[n][n];
	rep(i, n) rep(j, n) d[i][j] = i == j ? 0 : INF;

	rep(i, m) {
		int a, b, c;
		cin >> a >> b >> c;
		a--;
		b--;

		d[a][b] = c;
		d[b][a] = c;
	}
	
	// ワーシャルフロイド
	rep(k, n) rep(i, n) rep(j, n) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);

	int ans = INF;

	vector<int> v;
	rep(i,r) v.push_back(i);

	do{
		int t = 0;
		rep(i,r-1) t += d[s[v[i]]][s[v[i+1]]];
		ans = min(ans, t); 
	}while(next_permutation(v.begin(), v.end()));

	cout << ans << endl;
}

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

double pi = 3.141592653589793;

void solver() {
  double a, b, h, m;
  cin >> a >> b >> h >> m;

  double hDegree = 360.0 * ((h / 12.0) + (6.0  * (m / 60.0)));
  double mDegree = 360.0 * (m / 60.0);

  double rad = 2 * pi * (h / 12.0 + (m / 60.0) / 12.0 - (m / 60.0));

  double dist = sqrt((pow(a, 2) + pow(b, 2) - (2.0 * a * b * cos(rad))));

  cout << std::fixed << std::setprecision(15);
  cout << dist << "\n";
}

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


Measured memory_bytes: 4208
#include<iostream>
#include<cmath>
#include<cstdlib>
using namespace std;
struct coo{
	int x;
	int y;
	int h;
}c[110];
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>c[i].x;
		cin>>c[i].y;
		cin>>c[i].h;
	}
	int ch;
	int p=0;
	while(c[p].h==0) p++;
	for(int i=0;i<=100;i++)
	{
		for(int j=0;j<=100;j++)
		{
			int ch=c[p].h+abs(i-c[p].x)+abs(j-c[p].y);
			int f=0;
			for(int k=0;k<n;k++)
			{
				int hh=ch-abs(i-c[k].x)-abs(j-c[k].y);
				if(hh<0) hh=0;
				if(hh!=c[k].h)
				{
					f=1;
					break;
				}
			}
			if(!f)
			{
				cout<<i<<' '<<j<<' '<<ch<<endl; return 0;
			} 
		}
	}
}


Measured memory_bytes: 256
# coding: utf-8

import sys
input = sys.stdin.readline

def f(n, abc):
    dp = [[0] * 3 for _ in range(n + 1)]
    for i in range(1, n + 1):
        for j in range(3):
            dp[i][j] = max(dp[i - 1][k] + abc[i - 1][j] \
                for k in range(3) if k != j)
    return(max(dp[n]))

n = int(input())    # 1 <= n <= 10^5
abc = [list(map(int, input().rstrip().split())) for _ in range(n)]

print(f(n, abc))


Measured memory_bytes: 47336
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=1000000007,MAX=1000005,INF=1<<30;

ll dp[MAX][2][2];

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;cin>>N;
    dp[0][0][0]=1;
    
    for(int i=0;i<N;i++){
        for(int j=0;j<2;j++){
            for(int k=0;k<2;k++){
                dp[i+1][1][k]+=dp[i][j][k];
                dp[i+1][1][k]%=mod;
                
                dp[i+1][j][1]+=dp[i][j][k];
                dp[i+1][j][1]%=mod;
                
                dp[i+1][j][k]+=dp[i][j][k]*8;
                dp[i+1][j][k]%=mod;
            }
        }
    }
    
    cout<<dp[N][1][1]<<endl;
}


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

public class Main {
	public static void main(String[] args) throws IOException {
		InputReader in = new InputReader(System.in);
		int n = in.readInt(); 
		int min = 1001; 
		int max = -1; 
		for(int i = 0; i<n; i++) {
			int a = in.readInt(); 
			if(min > a) min = a; 
			if(max < a) max = a; 
		}
		System.out.println(max - min); 
	}
}
class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	
	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public String next() {
		return readString();
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}


Measured memory_bytes: 21204
# coding: utf-8
A, B, C, D = map(int, input().split())
l = [0 for i in range(101)]
for i in range(A, B):
    l[i] += 1
for i in range(C, D):
    l[i] += 1
ans = 0
for i in range(len(l)):
    if l[i] == 2:
        ans += 1
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
using namespace std;
#define LEN 100005

struct Queue{
  string name;
  int time;
};

int head, tail;
Queue Q[LEN];

Queue dequeue(){
  Queue q = Q[head];
  head = (head + 1) % LEN;
  return q;
}

void enqueue(Queue q){
  Q[tail] = q;
  tail = (tail + 1) % LEN;
}

int main() {
  int n, q, a, elaps = 0;
  Queue u;
  cin >> n >> q;
  head = 1, tail = n + 1;
  for (int i = 1; i <= n; i++){
    cin >> Q[i].name >> Q[i].time;
  }

  while (head != tail){
    u = dequeue();
    a = ( q < u.time ? q : u.time );
    u.time -= a;
    elaps += a;
    if ( u.time == 0 ){
      cout << u.name << " " << elaps << endl;
    } else {
      enqueue(u);
    }
  }
  return 0;
}


Measured memory_bytes: 6920
#include<stdio.h>
#include<stdlib.h>
#define INF 100000000
 
typedef struct state{
  int pos,cost;
} state;
 
state A[2000001];
int N=0;
  
int parent(int i){return i/2;}
int left(int i){return i*2;}
int right(int i){return i*2+1;}
  
void exchange(state* a,state* b){
  state tmp=*a;
  *a=*b;
  *b=tmp;
}
  
void minHeapify(int i){
  int l=left(i);
  int r=right(i);
  int small;
   
  if( l<=N && A[l].cost<A[i].cost )small=l;
  else small=i;
   
  if( r<=N && A[r].cost<A[small].cost)small=r;
   
  if(small!=i){
    exchange(&A[i],&A[small]);
    minHeapify(small);
  }
   
}
  
state heapExtractMin(){
  if(N<1)return (state){0,0};
  state min=A[1];
  A[1]=A[N];
  N--;
  minHeapify(1);
  return min;
}
 
  
void heapIncreaseKey(int i,state key){
  if(key.cost>A[i].cost)return;
  
  A[i]=key;
  while(i>1&&A[parent(i)].cost>A[i].cost){
    exchange(&A[i],&A[parent(i)]);
    i=parent(i);
  }
}
  
void minHeapInsert(state key){
  N++;
  A[N]=(state){INF,INF};
  heapIncreaseKey(N,key);
}
 
 
typedef struct edge{
  int to,cost;
} edge;
 
edge* G[10000];
int size[10000];
int n;
int d[10000];
edge e;
state s;
int main(){
  int i,j,a,b;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d %d",&a,&b);
    G[a] = malloc( sizeof( edge ) *b );
    size[a]=b;
    for(j=0;j<b;j++){
      scanf("%d %d",&G[a][j].to,&G[a][j].cost);
    }
    d[i]=INF;
  }
  d[0]=0;
  minHeapInsert( (state){0,0} );
  while(N!=0){
    s = heapExtractMin();
    if(s.cost>d[s.pos])continue;
    for(i=0;i<size[s.pos];i++){
      e=G[s.pos][i];
      if(d[e.to]<=d[s.pos]+e.cost)continue;
      d[e.to]=d[s.pos]+e.cost;
      minHeapInsert((state){e.to,d[e.to]});
    }
  }
  for(i=0;i<n;i++)
    printf("%d %d\n",i,d[i]);
   
  return 0;
}

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

typedef long long lint;
typedef unsigned long long ulint;
const int MOD=1000000007;

int main(){
    int N;
    cin >> N;
    lint T[1000],A[1000];
    for(int i=0;i<N;i++) cin >> T[i] >> A[i];

    lint tT=T[0],tA=A[0];
    for(int i=1;i<N;i++){
        lint minT=(tT+T[i]-1)/T[i];
        lint minA=(tA+A[i]-1)/A[i];
        lint min=minT>minA?minT:minA;
        tT=T[i]*min;
        tA=A[i]*min;
    }
    cout << (tT+tA) << endl;
    return 0;
}

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

using namespace std;

bool visited[100000];

int main(int argc, char *argv[]) {
	int K;
	cin >> K;

	deque<pair<int, long long>> q;

	q.push_front(make_pair(1, 1));
	while (!q.empty()) {
		auto e = q.front();
		q.pop_front();
		auto n = e.first;
		auto d = e.second;

		if (n == 0) {
			cout << d << endl;
			break;
		}

		if (visited[n]) continue;
		visited[n] = true;

		q.push_front(make_pair((n * 10) % K, d));
		q.push_back(make_pair((n + 1) % K, d + 1));
	}

	return 0;
}

Measured memory_bytes: 2048
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
	int c = 1, n, i, j, h, m[101][101], w;
	char v;
	cin >> h >> w;
	for (i = 0; i < h; i++)
	{
		for (j = 0; j < w; j++)
		{
			cin >> v;
			m[i][j] = -1;
			if (v == 'c')
				m[i][j] = 0;
		}
	}
	for (i = 0; i < h; i++)
	{
		c = 1;
		for (j = 0; j < w; j++)
		{
			if (m[i][j] == 0)
			{
				for (n = j; n < w; n++)
				{
					if (m[i][n] == 0)
						c = 1;
					if (m[i][n] == -1)
					{
						m[i][n] = c;
						c++;
					}
				}
			}
		}
	}
	for (i = 0; i < h; i++)
	{
		for (j = 0; j < w; j++)
		{
			if (j != w - 1)
				cout << m[i][j] << " ";
			else
				cout << m[i][j];
		}
		cout << endl;
	}
	return 0;
}

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

int main(){
  int h,w,k;
  std::cin >> h >> w>> k;

  std::vector<std::vector<char> > area(h,std::vector<char>(w));
  rep(i,h)rep(j,w)std::cin >> area[i][j];

  int ans=0;


  for (int i = 0; i < (1<<h); i++) {

    for (int j = 0; j < (1<<w); j++) {



      std::vector<std::vector<char> > temp(h,std::vector<char>(w));
      temp=area;

        for (int i2 = 0; i2 < h; ++i2) {
            if (i & (1<<i2)) {
                for (int p = 0; p < w; p++) {
                  temp[i2][p]='r';
                }
            }
        }

        for (int j2 = 0; j2 < w; ++j2) {
            if (j & (1<<j2)) {
                for (int p = 0; p < h; p++) {
                  temp[p][j2]='r';
                }
            }
        }

        int now=0;
        rep(p,h){
          rep(m,w){
            if(temp[p][m]=='#')now++;
          }
          // std::cout << '\n';
        }



        // std::cout << i<<":"<<j << '\n';
        // std::cout << "" << '\n';
        if(now==k){
          // std::cout << " "<<now << '\n';

          ans++;
        }


    }


  }

  std::cout << ans << '\n';


  return 0;
}


Measured memory_bytes: 3632
using System;

namespace ABC064
{
    class A
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int r = int.Parse(input[0]);
            int g = int.Parse(input[1]);
            int b = int.Parse(input[2]);

            if ((100 * r + 10 * g + b) % 4 == 0) Console.WriteLine("YES");
            else Console.WriteLine("NO");
        }
    }
}


Measured memory_bytes: 11092
#include<stdio.h>

int main (void){
	int n,u,k,v;
	int d[100][100]={0};
	int i,j;	

	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d",&u,&k);
		for(j=0;j<k;j++){
			scanf("%d",&v);
			d[u-1][v-1]=1;
		}
	}
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			printf("%d%c",d[i][j],j==n-1?'\n':' ');
		}
	}
	return 0;
}

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

using namespace std;
typedef long long ll;

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

    int sum = 0;
    for(int i=0; i < n; i++) {
        int val;
        cin >> val;

        if(val >= k) {
            sum++;
        }
    }

    cout << sum;
}

Measured memory_bytes: 256
using System;

class Program
{
    static void Main()
    {
        string[] s = Console.ReadLine().Split(' ');
        int a = int.Parse(s[0]);
        int b = int.Parse(s[1]);

        int[] ret = new int[2];
        ret[0] = a * b;
        ret[1] = (a + a) + (b + b);

        Console.WriteLine(string.Format("{0} {1}", ret[0], ret[1]));
    }
}


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

int main() {
    int n, ans = 0;;
    cin >> n;
    vector<int> v(n), c(n);
    rep(i,n) cin >> v[i];
    rep(i,n) cin >> c[i];
    rep(i,n) {
        if(v[i] - c[i] > 0) ans += v[i] - c[i];
    }
    
    cout << ans << endl;
   
    return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#define MAX 100000

using namespace std;

int A[MAX];

int partition(int p, int r){
    int x = A[r];
    int i = p - 1;
    int tmp;
    for(int j = p; j < r; j++){
        if(A[j] <= x){
            i++;
            tmp = A[i];
            A[i] = A[j];
            A[j] = tmp;
        }
    }
    tmp = A[i+1];
    A[i+1] = A[r];
    A[r] = tmp;
    return i+1;
}

int main(){
    int n, i, p;
    cin >> n;
    for(i = 0; i < n; i++) cin >> A[i];
    p = partition(0, n-1);
    for(i = 0; i < n-1; i++){
        if(i == p) cout << "[" << A[i] << "] ";
        else cout << A[i] << " ";
    }
    if(i == p) cout << "[" << A[i] << "]" << endl;
    else cout << A[i] << endl;
    return 0;
}


Measured memory_bytes: 3388
import numpy as np

n, m = map(int, input().split())
v_list = list(map(int, input().strip().split()))
v_ar = np.array(v_list)
total = v_ar.sum()
th = total/(4 * m)
print('Yes' if m <= np.count_nonzero(v_ar >= th) else 'No')


Measured memory_bytes: 21520
import math

n = int(input())

a = 1
for x in range(1, math.floor(math.sqrt(n)) + 1):
  if n % x == 0:
    a = x

b = n / a
res = 1
for i in reversed(range(11)):
  if b >= 10 ** i:
    res = i + 1
    break

print(res)


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


ll com_2(long int a){
    ll c;
    c=a*(a-1)/2;
    return c;
}

int main (){
    
    int n;
    ll ans =0;
    cin >> n;
    vector <ll> vec(n+1);
    vec[0]=0;
    rep(i,n){
        ll p;
        cin >>p;
        vec[i+1]=vec[i]+p;
    }
    map<ll,int> mp;
    rep(i,n+1) mp[vec[i]]++;
    for(auto &p:mp){
        ll a=p.second;
        ans+=com_2(a);
    }

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


Measured memory_bytes: 14336
b=[1]*500000
for i in range(3,999,2):
 if b[i//2]:b[i*i//2::i]=[0]*len(b[i*i//2::i])
def p(x):
 if x<5*1e5:return b[x]
 x=2*x+1
 for i in range(3,int(x**.5+1),2):
  if x%i==0:return 0
 return 1
print(sum(p(int(input()))for _ in[0]*int(input())))


Measured memory_bytes: 11808
#include <iostream>
#include <algorithm>
#define llint long long
using namespace std;

llint n, a, b;
llint x[100005];

int main(void)
{
  cin >> n >> a >> b;
  for(int i = 1; i <= n; i++) cin >> x[i];
  sort(x+1, x+n+1);
  
  llint ans = 0;
  for(int i = 1; i < n; i++){
    ans += min((x[i+1]-x[i])*a, b);
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 1024
package main

import(
	"fmt"
)

func main() {
		var a int
		var b int
		var c int
		var x int
		var count int
		count = 0

		fmt.Scan(&a)
		fmt.Scan(&b)
		fmt.Scan(&c)
		fmt.Scan(&x)

		for i := 0; i < a+1; i++ {
				for s := 0; s < b+1; s++ {
						for t := 0; t < c+1; t++ {
								if (500*i + 100*s + 50*t) == x {
										count++
								}
						}
				}
		}
		fmt.Println(count)
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+20;
const ll inf=1e16+1000;
ll a[N];
int n;
int main()
{
	while(cin>>n)
	{
		ll sum=0;
		for(int i=1;i<=n;i++)
			cin>>a[i],sum+=a[i];
		ll l=sum-n*(n-1),r=sum;
		for(ll k=l;k<=r;k++)
		{
			if(k<0)	continue;
			ll res=0;
			bool ok=true;
			for(int i=1;i<=n;i++)
			{
				ll x=(a[i]+k+1)/(n+1);
				res+=x;
			}
			if(res==k)
			{
				cout<<res<<endl;
				break;
			}
		}
	}
	return 0;
}
//25720164523
//154320986863
//500000000000000000

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i, n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i, n) for(ll i=(ll)(n-1);i>=0;i--)
#define FOR(i, a, b) for(ll i=(ll)(a); i<=(ll)(b); i++)
#define RFOR(i, a, b) for(ll i=(ll)(a);i>=(ll)(b); i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

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


Measured memory_bytes: 3548
from collections import deque
n = int(input())
a = list(input().split())
ans = deque()
for i in range(n):
    if i%2==0: ans.append(a[i])
    else: ans.appendleft(a[i])
ans = list(ans)
if n%2==0:
    print(" ".join(ans))
else:
    print(" ".join(ans[::-1]))


Measured memory_bytes: 33184
import sys
a,b,k=input().strip().split()
a=int(a)
b=int(b)
k=int(k)

if a<k:
  k-=a
  a=0
else:
  a-=k
  k=0

if b<k:
  k-=b
  b=0
else:
  b-=k
  k=0

print(str(a)+" "+str(b))

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

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

  if (a % 2 == 0 || b % 2 == 0) {
    cout << "Even" << endl;
  }
  // a or bが偶数ならEven
  

   else {
    cout <<"Odd" << endl;
  }
   
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<set>
#include<list>
#include<queue>
#include<cmath>
#include<functional>
#include<algorithm>
#define INF (1<<29)
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;


int m,n[300];
int a[6];
int s,g;

int dis[300];


int dest(int pos,int d){
	if(pos+d<0||m<=pos+d)return -1;
	pos+=d+n[pos+d];
	if(pos<0||m<=pos)return -1;
	return pos;
}
void calc(){
	queue<int> q;
	rep(i,m)dis[i]=INF;
	q.push(g);
	dis[g]=0;
	while(!q.empty()){
		int p=q.front();
		q.pop();
		rep(i,m){
			if(dis[i]!=INF)continue;
			rep(j,6){
				if(dest(i,a[j])==p || dest(i,-a[j])==p){
					dis[i]=dis[p]+1;
					q.push(i);
					break;
				}
			}

		}
	}
}
void solve(){
	int pos=s;
	while(pos!=g){
		int dice;
		cin>>dice;
		dice--;
		//dice=rand()%6;
		int x,y,z;
		x=dest(pos,-a[dice]);
		y=pos;
		z=dest(pos,a[dice]);
		int p,q,r;
		p=(x!=-1?dis[x]:INF);
		q=dis[y];
		r=(z!=-1?dis[z]:INF);
		if(p<=q&&p<=r){
			cout<<-1<<endl;
			pos=x;
		}else if(q<=p&&q<=r){
			cout<<0<<endl;
			pos=y;
		}else{
			cout<<1<<endl;
			pos=z;
		}
	}
}
int main(){
	cin>>m;
	rep(i,6)cin>>a[i];
	cin>>s>>g;
	s--;g--;
	rep(i,m){
		cin>>n[i];
	}
	calc();
	solve();
	return 0;
}

Measured memory_bytes: 1304
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fill fill_n
#define pf push_front
#define pb push_back
#define FOR(i,l,r) for(int i=l;i<r;i++)
#define ROF(i,r,l) for(int i=r;i>=l;i--)
#define comp(v) (v).begin(),(v).end()
#define ff first
#define ss second
#define infile freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
typedef vector<int> vi;
typedef vector<ll> vli;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvli;
const int M = 1e9+7;
const int N = 2e5;
ll po(int,int);


void solve(){
    int n;cin>>n;
    int ans=0;
    FOR(i,1,n+1){
        int x;
        cin>>x;
        if(abs(x%2)==1 && i%2==1) ans++;
    }
    cout<<ans<<"\n";
    
}





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


ll po(int a,int b){
    if(b==0) return 1;
    ll ans=1;
    if(b%2==0){
        ans = po(a,b/2)%M;
        ans=(ans%M * ans%M)%M;
    }
    else{
        ans = po(a,(b-1)/2)%M;
        ans = (ans%M * ans%M * a)%M;
    }
    return ans%M;
}


Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;
ll n,k,ans;
void f(ll x){
    if(n<x)return;
    ll lim=(n-x)/k+1;
    ans+=lim*lim*lim;
}
int main(){
    cin>>n>>k;
    f(k);
    if(k%2==0)f(k/2);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        int x, y, i=0, max=3000;
        Scanner s = new Scanner(System.in);
        do{
            x = s.nextInt();
            y = s.nextInt();
            if ((x==0) && (y==0)) break;
            if (x<=y) System.out.println(x+" "+y);
            else System.out.println(y+" "+x);
            i++;
        }while(i<max);
    }
}


Measured memory_bytes: 35840
n = int(raw_input())
a = list(map(float, raw_input().split()))
 
dp = [[0]*(n+1) for i in xrange(n+1)]
dp[0][0] = 1
 
for i in xrange(1,n+1):
  dp[0][i] = 0
  dp[i][0] = dp[i-1][0] * (1 - a[i-1])
  
for i in xrange(1, n+1):
  for j in xrange(1, n+1):
    dp[i][j] = dp[i-1][j-1] * a[i-1] + dp[i-1][j] * (1 - a[i-1])
ans = 0
for i in xrange(n // 2 + 1 , n+1):
  ans += dp[n][i]

print ans

Measured memory_bytes: 161948