akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

int main (void) {
    int N,M;
    cin>>N>>M;
    vector<pair<int,int>> G(M);
    REP(i,M) {
        int a,b;
        cin>>a>>b;
        G[i] = make_pair(a-1,b-1);
    }
    int ans = 0;
    REP(i,M) {
        int unuse = i;
        UnionFind uf (N);
        REP(j,M) {
            if (j == unuse) continue;
            uf.unite(G[j].fi,G[j].se);
        }
        for (int i=1;i<N;i++) {
            if (uf.find(i) != uf.find(i-1)) {
                ans++;
                break;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding utf-8 -*-

MOD = 10 ** 9 + 7
MAX = 10 ** 6

X, Y = map(int, input().split())

def comb(n, r):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % MOD

g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]
for i in range( 2, MAX + 1 ):
    g1.append( ( g1[-1] * i ) % MOD )
    inverse.append( ( -inverse[MOD % i] * (MOD//i) ) % MOD )
    g2.append( (g2[-1] * inverse[-1]) % MOD )


if (X+Y) % 3 == 0:
    n = (2 * Y - X)//3
    m = (2*X - Y)//3
    ans = comb(n + m, n)
else:
    ans = 0
print(ans)



Measured memory_bytes: 122048
#include <vector>
#include <iostream>
#include <algorithm>

typedef char                SINT8;
typedef unsigned char       UINT8;
typedef short               SINT16;
typedef unsigned short      UINT16;
typedef int                 SINT32;
typedef unsigned int        UINT32;
typedef long long           SINT64;
typedef unsigned long long  UINT64;
typedef double              DOUBLE;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

using namespace std;

int main() {

	SINT32 N = 0;
	SINT32 MAXANS = 0;
	SINT32 ANS = 0;
	cin >> N;

	vector<SINT32> DATA(N);
	
	for (SINT32 i = 0; i < N; i++) {
		cin >> DATA[i];
		MAXANS = MAX(MAXANS,DATA[i]);
		ANS += DATA[i];
	}

	ANS -= MAXANS/2;

	cout << ANS << endl;
	return 0;
}

//	sort(DATA.begin(),DATA.end());
//	sort(DATA.begin(),DATA.end(),std::greater<SINT32>());
//	__gcd(ANS,DATA[i]);

/*
	SINT32 M = 3;
	vector<pair<SINT32,SINT32>> DATA2(M);
	for (SINT32 i = 0; i < M; i++) {
		cin >> DATA2[i].first;
		cin >> DATA2[i].second;
	}
	sort(DATA2.begin(),DATA2.end());
	cout << DATA2[0].first << endl;
	cout << DATA2[0].second << endl;
*/

//		APOSI = lower_bound(ADATA.begin(),ADATA.end(),QDATA[i]) - ADATA.begin();
//		BPOSI = lower_bound(BDATA.begin(),BDATA.end(),QDATA[i]) - BDATA.begin();

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2017/12/04  Problem: codefestival2017_team_relay B / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N,Q;

LL ans = 0LL;

void kim(VL & a,LL val){
	while(val){
		a.push_back(val);
		val = (val-1)/N;
	}
	a.push_back(val);
}

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

	cin >> N>>Q;
	FOR(i,0,Q){
		LL v,w;
		cin>> v >> w;
		if(N==1){
			ans=min(v,w);
		}else {
			v--;w--;
			VL a,b;
			kim(a,v); kim(b,w);
			int kima = SZ(a);
			int kimb = SZ(b);
			int depmin = min(kima,kimb);
			int k=1 ;
			while(k<depmin&&a[kima-1-k] == b[kimb-1-k]){
				k++;
			}
			ans=a[kima-k]+1;
		}
		
		cout << ans << "\n";
	}

	return 0;
}


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

using namespace std;

void fail() {
  cout << -1 << endl;
  exit(0);
}

int main() {
  int N;
  cin >> N;
  string A[500], C[500];
  uint64_t B[500], D[500];
  int H = N, W = N;
  for(int i = 0; i < N; i++) {
    int x;
    cin >> x;
    if(x == 0) A[i] = "and";
    else A[i] = "or";
  }

  for(int i = 0; i < N; i++) {
    int x;
    cin >> x;
    if(x == 0) C[i] = "and";
    else C[i] = "or";
  }
  for(int i = 0; i < N; i++) {
    cin >> B[i];
  }
  for(int i = 0; i < N; i++) {
    cin >> D[i];
  }

  uint64_t ans[500][500] = {{}};
  for(int i = 0; i < 64; i++) {
    vector< vector< int > > decide(H, vector< int >(W, -1));
    vector< pair< int, int > > latte, malta;

    for(int j = 0; j < H; j++) {
      if(A[j] == "and") {
        if((B[j] >> i) & 1) for(int k = 0; k < W; k++) decide[j][k] = 1;
        else latte.emplace_back(j, 0);
      } else {
        if((~B[j] >> i) & 1) for(int k = 0; k < W; k++) decide[j][k] = 0;
        else latte.emplace_back(j, 1);
      }
    }
    for(int j = 0; j < W; j++) {
      if(C[j] == "and") {
        if((D[j] >> i) & 1) {
          for(int k = 0; k < H; k++) if(decide[k][j] == 0) fail();
          for(int k = 0; k < H; k++) decide[k][j] = 1;
        } else malta.emplace_back(j, 0);
      } else {
        if((~D[j] >> i) & 1) {
          for(int k = 0; k < H; k++) if(decide[k][j] == 1) fail();
          for(int k = 0; k < H; k++) decide[k][j] = 0;
        } else malta.emplace_back(j, 1);
      }
    }

    if(min(latte.size(), malta.size()) >= 2) {
      for(int j = 0; j < latte.size(); j++) {
        for(int k = 0; k < malta.size(); k++) {
          decide[latte[j].first][malta[k].first] = (j + k) & 1;
        }
      }
    } else if(latte.size() == 1) {
      for(auto &p : malta) {
        bool ex = false;
        for(int j = 0; j < H; j++) ex |= decide[j][p.first] == p.second;
        decide[latte[0].first][p.first] = ex ? latte[0].second : p.second;
      }
      bool f = false;
      for(int k = 0; k < W; k++) f |= decide[latte[0].first][k] == latte[0].second;
      if(!f) fail();
    } else if(malta.size() == 1) {
      for(auto &p : latte) {
        bool ex = false;
        for(int k = 0; k < W; k++) ex |= decide[p.first][k] == p.second;
        decide[p.first][malta[0].first] = ex ? malta[0].second : p.second;
      }
      bool f = false;
      for(int j = 0; j < H; j++) f |= decide[j][malta[0].first] == malta[0].second;
      if(!f) fail();
    } else {
      for(auto &p : latte) {
        bool f = false;
        for(int k = 0; k < W; k++) f |= decide[p.first][k] == p.second;
        if(!f) fail();
      }
      for(auto &p : malta) {
        bool f = false;
        for(int j = 0; j < H; j++) f |= decide[j][p.first] == p.second;
        if(!f) fail();
      }
    }
    for(int j = 0; j < H; j++) {
      for(int k = 0; k < W; k++) {
        ans[j][k] |= ((uint64_t) (decide[j][k] & 1)) << i;
      }
    }
  }

  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) cout << ans[i][j] << " ";
    cout << endl;
  }
}


Measured memory_bytes: 8508
n = int(input())
p = list(map(int, input().split()))
cnt = 0
for i in range(1,n-1):
    if max(p[i-1], p[i], p[i+1]) != p[i] and min(p[i-1], p[i], p[i+1]) != p[i]:
        cnt += 1
print(cnt)

Measured memory_bytes: 38464
#include <iostream>
#include <string>
#include <set>
using namespace std;

int main()
{
    int n;
    cin >> n;
    string a, b, c;
    cin >> a >> b >> c;
    int ans = 0;
    for(int i = 0; i < n; i++){
        set<int> st;
        st.insert(a[i]);
        st.insert(b[i]);
        st.insert(c[i]);
        ans += (int)st.size() - 1;
    }
    cout << ans << endl;
}

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

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

  int DP[N+1][W+1];

  for(int j=0; j<=W; j++){
    DP[0][j]=0;
  }

  for(int i=1; i<=N; i++){
    for(int j=0; j<=W; j++){
      if(j<w[i-1]){
        DP[i][j] = DP[i-1][j];
      }else{
        if(DP[i-1][j] > DP[i][j-w[i-1]]+v[i-1]){
          DP[i][j] = DP[i-1][j];
        }else{
          DP[i][j] = DP[i][j-w[i-1]]+v[i-1];
        }
      }
    }
  }

  cout << DP[N][W] << endl;

  return 0;
}


Measured memory_bytes: 7008
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#define ALL(X) X.begin(), X.end()
#define SZ(A) int((A).size())
#define RALL(X) X.rbegin(), X.rend()
#define FOR(B) for (size_t i = 0; i < B; i++)
#define FORE(B) for (size_t i = 1; i <= B-1; i++)
#define FORC(A, B) for (size_t i = A; i < B; i++)
#define PRINT(X) cout << X << endl
#define PRINTALL(E, X) { FOR(X) {cout << E[i] << endl; } }
#define READALL(V, N) FOR(N) {int x; cin >> x; V.push_back(x); }
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL>VLL;
typedef vector<PII> VPII;
typedef map<int, int> MII;
typedef map<string, int> MSI;


int main() {
   int a = 0, b = 0;
   cin >> a >> b;
   cout << (a - 1) * (b - 1) << endl;
}

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

int main() {
  vector<vector <int>> A(3, vector<int>(3));
  vector<vector <int>> B(3, vector<int>(3));

  for (int i = 0; i < 3; i++){
    for (int j = 0; j < 3; j++){
      cin >> A.at(i).at(j);
    }
  }
  int N;

  cin >> N;
  int b;

  for (int i = 0; i < 3; i++){
    for (int j = 0; j < 3; j++){
      B.at(i).at(j) = false;
    }
  }

  for (int k = 0; k < N; k++){
    cin >> b;
    for (int i = 0; i < 3; i++){
      for (int j = 0; j < 3; j++){
        if (b == A.at(i).at(j)){
          B.at(i).at(j) = true;
        }
      }
    }
  }

  bool bingo = false;

  for (int i = 0; i < 3; i++){
    vector<bool> flag_yoko = {false, false, false};
    vector<bool> flag_tate = {false, false, false};

    for (int j = 0; j < 3; j++){
      if(B.at(i).at(j)){
        flag_yoko.at(j) = true;
      }
    }

    for (int j = 0; j < 3; j++){
      if(B.at(j).at(i)){
        flag_tate.at(j) = true;
      }
    }
    
    if(flag_yoko.at(0) && flag_yoko.at(1) && flag_yoko.at(2)){
      bingo = true;
      break;
    }else if(flag_tate.at(0) && flag_tate.at(1) && flag_tate.at(2)){
      bingo = true;
      break;
    }
  }

  if(B.at(0).at(0) && B.at(1).at(1) && B.at(2).at(2)){
    bingo = true;
  }else if(B.at(2).at(0) && B.at(1).at(1) && B.at(0).at(2)){
    bingo = true;
  }

  if(bingo){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


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

using namespace std;
int w[105],v[105];
long long dp[105][100005];
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		cin>>w[i]>>v[i];
	}
	dp[0][0]=0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(j<w[i]){
				dp[i][j]=dp[i-1][j];
			}
			else{
				dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
			}		
		}
	}
	cout<<dp[n][m];
	return 0;
}

Measured memory_bytes: 79360
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <math.h>
#include <climits>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <map> 
#include <set>
#include <string>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
const ll MD = 1000000007;

/* sample input

*/

int main()
{
	ll n;
	ll *a;
	ll *b;
	ll answer = 0;
	cin >> n;
	a = new ll[n];
	for (ll i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);


	ll temp=0;
	ll count = 0;
	for (ll i = 0; i < n; i++) {
		if (a[i] != temp) {
			if (count != temp) {
				if (count > temp) {
					answer += count - temp;
				}
				else {
					answer += count;
				}
			}
			temp = a[i];
			count = 1;

		}
		else {
			count++;
		}
	}
	if (count != temp) {
		if (count > temp) {
			answer += count - temp;
		}
		else {
			answer += count;
		}
	}
	cout << answer;


	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <math.h>

int main(void)
{
  double r, c, s;

  while(scanf("%lf", &r) != EOF)
  {
    
    c = 2.0 * r * M_PI;
    s = r * r * M_PI;
  
    printf("%.6lf %.6lf\n", s, c);
  }

  return 0;
}

Measured memory_bytes: 0
// Package main provides
//
// File:  c.go
// Author: ymiyamoto
//
// Created on Fri Dec 28 15:48:15 2018
//
package main

import (
	"fmt"
	"sort"
)

func main() {
	arr := make([]int, 3)
	for i := range arr {
		fmt.Scan(&arr[i])
	}
	sort.Ints(arr)

	ans := arr[2] - arr[1]
	diff := arr[2] - (arr[0] + ans)
	if diff%2 == 0 {
		fmt.Println(ans + diff/2)
	} else {
		fmt.Println(ans + (diff+1)/2 + 1)
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    string s;
    cin >> s;
    map<string, ll> mp;
    mp["SUN"] = 7;
    mp["MON"] = 6;
    mp["TUE"] = 5;
    mp["WED"] = 4;
    mp["THU"] = 3;
    mp["FRI"] = 2;
    mp["SAT"] = 1;

    cout << mp[s] << endl;
}


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

int64_t sum(vector<int> vec)
{
  int ret = 0;
  for (int v : vec)
    ret += v - 1;

  return ret;
}

int main()
{
  int n;
  int64_t ans = 0;
  cin >> n;
  vector<int> A(n);
  for (int i = 0; i < n; ++i)
    cin >> A[i];
  ans = sum(A);

  cout << ans << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    ll n;
    cin >> n;
    Vi sum(n);
    Vi a(n);
    rp(i,n){
        cin >> a.at(i);
        if(i==0) sum[0]=a[0];
        else sum[i]=sum[i-1]+a[i];
    }
    ll ans=INF;
    //ll dai,syou;
    repi(i,2,n-1){
        ll fr,ba;
        ll frmax,frmin,bamax,bamin;
        fr=sum[i-1]; ba=sum[n-1]-fr;
        ll ok=0,ng=i-1,mid=(ok+ng)/2;
        while(ng-ok>1){
            if(sum[mid]*2<=fr) ok=mid;
            else ng=mid;
            mid=(ok+ng)/2;
        }
        if(fr-sum[ok]*2>sum[ng]*2-fr){
            frmax=sum[ng]; frmin=fr-sum[ng];
        }else{
            frmax=fr-sum[ok]; frmin=sum[ok];
        }
        if(frmin>frmax) swap(frmin,frmax);
        ok=i; ng=n-1; mid=(ok+ng)/2;
        while(ng-ok>1){
            if((sum[mid]-sum[i-1])*2<=ba) ok=mid;
            else ng=mid;
            mid=(ok+ng)/2;
        }
        if(ba-(sum[ok]-sum[i-1])*2>(sum[ng]-sum[i-1])*2-ba){
            bamax=sum[ng]-sum[i-1]; bamin=ba-sum[ng]+sum[i-1];
        }else{
            bamax=ba-sum[ok]+sum[i-1]; bamin=sum[ok]-sum[i-1];
        }
        if(bamax<bamin) swap(bamin,bamax);
        chmin(ans,max(frmax,bamax)-min(frmin,bamin));
    }
    print(ans);
    //cout << dai << " " << syou << endl;
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 3328
num = int(input())

a = 1
b = 1
c = 1
for i in range(num):
    a *=10
    a %=1000000007
    b *=9
    b %=1000000007
    c *=8
    c %=1000000007

res = (a-2*b+c)%1000000007
print(res)

Measured memory_bytes: 9172
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;
    cin>>N;
    
    int cnt=0;
    while(N>0){
        if(N%10==2) cnt++;
        N/=10;
    }
    cout1(cnt)
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#define ll long long
#define faltu ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define binary(x) std::string binary = std::bitset<25>(x).to_string(); //to binary
#define inf 1000000007
#define mod 1000000007
#define pi pair<int,int>
#define lpi pair<int,int>
#define mp make_pair
#define pb push_back
#define vi vector<int>
#define lvi vector<long long int>
#define pie 3.14159265358979323846
ll int MMM=inf;
int pw(int x,int y){int z=1;for(;y;y>>=1,x=1ll*x*x%MMM)if(y&1)z=1ll*z*x%MMM;return z;}
using namespace std;
vi pm;
void prm(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));
    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
              prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p]) pm.pb(p);
}
bool sortbysecdesc(const pair<ll int,ll int> &a,const pair<ll int,ll int> &b)
{
    return a.first>b.first;
}
bool cmp(int x,int y){return x>y;}
#define inf 1e18
long long int n,ww;
long long v[105],w[105];
long long dp[105][100005];
int main(){
	cin>>n;
	cin>>ww;
	int sum[n];
	for(int i=0;i<n;i++){
		cin>>w[i]>>v[i];
		if(i>0)sum[i]=sum[i-1]+v[i];
		else sum[i]=v[i];
	}
	for(int i=0;i<n;i++)for(int j=0;j<=sum[n-1];j++){
		if(j==0)dp[i][j]=0;
		else dp[i][j]=inf;
	}
	dp[0][v[0]]=w[0];
	for(int i=1;i<n;i++){
		for(int j=0;j<=sum[i];j++)dp[i][j]=dp[i-1][j];
		for(int j=0;j<=sum[i];j++){
			if(j==0)dp[i][v[i]]=min(dp[i][v[i]],w[i]);
			else dp[i][j+v[i]]=min(dp[i-1][j+v[i]],w[i]+dp[i-1][j]);
		}
	}
	for(int i=sum[n-1];i>=0;i--){
		if(dp[n-1][i]<=ww){
			cout<<i;
			return 0;
		}
	}
}








Measured memory_bytes: 80128
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		String[] tok = in.readLine().split(" ");
		int A = Integer.parseInt(tok[0]);
		int B = Integer.parseInt(tok[1]);
		System.out.println(A * B);
	}

	void calc() {
	}

	void showResult() {
	}
}

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

using namespace std;

#define fastio cin.tie(NULL);cout.tie(NULL);ios_base::sync_with_stdio(0);
#define debug(x) cout << x << endl;
#define endl '\n'
#define MAXN 5005
#define INF 0x3f3f3f3f
#define LOG 20
#define pb push_back

typedef long long ll;
typedef pair <ll, ll> pii;
typedef vector <int> vi;
typedef vector <pii> vii;

int32_t main(){
    fastio
    string a, b;
    cin >> a >> b;
    string c = b + a;
    cout << c << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [int(input()) for i in range(n)]

ruiseki1 = [0] * (n+1)
ruiseki2 = [0] * (n+1)

for i in range(n):
    ruiseki1[i+1] = max(ruiseki1[i], a[i])
for i in range(n)[::-1]:
    ruiseki2[i] = max(ruiseki2[i+1], a[i])   


for i in range(n):
    print(max(ruiseki1[i], ruiseki2[i+1]))

Measured memory_bytes: 72536
n,m=map(int,raw_input().split())
check=[]
for i in  xrange(m):
    s=map(int,raw_input().split())
    s.pop(0)
    check.append(s)
ans=0
p=map(int,raw_input().split())
for i in xrange(0,pow(2,n)):
    switch=[0 for j in xrange(n)]
    j=0
    k=i
    while j < n:
        switch[j]=k%2
        k=k/2
        j += 1
    #print switch
    flag=0
    ###########
    ###########
    odd=0
    even=0
    for j in switch:
        if j ==0:
            even += 1
        else:
            odd += 1
    kk=0
    for j in check:
        onn=0
        off=0
        for k in j:
            if switch[k-1]==0:
                off += 1
            else:
                onn += 1
        if p[kk]%2==0:
            if onn%2==1:
                flag=-1
        else:
            if onn%2==0:
                flag=-1
        kk += 1
    if flag == -1:
        ans += 0
    else:
        ans += 1
print ans
        

Measured memory_bytes: 33384
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <deque>
#include <queue>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <set>
#define INF 1000000000000
#define MOD 1000000007
using namespace std;
using ll = long long;
int main() {
    ll n;
    cin >> n;
    ll tempx,tempy;
    for(ll i=0;i<n;i++){
        ll x,y;
        cin >> x >> y;
        if(i==0){
            tempx = x;
            tempy = y;
        }else{
            ll inc = 1;
            if(tempx>x*inc||tempy>y*inc){
                 inc=max(tempx/x,tempy/y);
                 if(tempx>x*inc||tempy>y*inc){
                     inc++;
                 }
             }
             tempx = x*inc;
             tempy = y*inc;
        }
    }
    cout << tempx+tempy << endl;
}

Measured memory_bytes: 256
import sys
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

from collections import deque

h, w = na()
s = [ns() for _ in range(h)]
m = [[s[i][j] for j in range(w)] for i in range(h)]
inf = 1 << 60
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

def bfs():
    q = deque()
    q.append((0, 0))
    d = [[inf] * w for _ in range(h)]
    d[0][0] = 0
    while len(q):
        p = q.popleft()
        if p[0] == w-1 and p[1] == h-1:
            break
        for i in range(4):
            nx = p[0] + dx[i]
            ny = p[1] + dy[i]
            if 0 <= nx and nx < w and 0 <= ny and ny < h and m[ny][nx] != '#' and d[ny][nx] == inf:
                q.append((nx, ny))
                d[ny][nx] = d[p[1]][p[0]] + 1
    return d[h-1][w-1]

b = 0
for y in range(h):
    for x in range(w):
        if m[y][x] == '#':
            b += 1

k = bfs()
if k == inf:
    res = -1
else:
    res = (h * w) - b - (k + 1)
print(res)

Measured memory_bytes: 3316
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int r = sc.nextInt();
    int g = sc.nextInt();
    int b = sc.nextInt();
    int n = 100*r + 10*g + b;
    if(n % 4 == 0){
      System.out.println("YES");
    }else{
      System.out.println("NO");
    }
  }
}

Measured memory_bytes: 20052
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<cmath>
#include<iomanip>
#include<set>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;


int main() {
    int a, b; cin >> a >> b;
    cout << (a * b % 2 == 0 ? "Even" : "Odd") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define sd(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define pd(n) printf("%d",n)
#define pl(n) printf("%lld",n)
#define sf(n) scanf("%f",&n)
#define pf(n) printf("%.12f",n)
#define psp printf(" ")
#define endc printf("\n")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;

const int maxn = 1e5 + 7; 
const int inf = 1e9 + 7;

pii a[maxn];
int af[maxn];
ll ans[maxn];
ll sum[maxn];
int bit[maxn];

int qry(int x) {
	int ans = inf;
	while (x > 0) { ans = min(ans, bit[x]); x -= x & (-x); }
	return ans;
}

void upd(int x, int z) {
	while (x < maxn) { bit[x] = min(bit[x], z); x += x & (-x); }
}

inline bool rev(pii x, pii y) {
	if (x.first != y.first) return x.first > y.first;
	return x.second < y.second;
}

int main() {
	int n; sd(n);
	for (int i = 1; i <= n; i++) {
		sd(a[i].first); a[i].second = i;
	}

	sort(a+1, a+n+1, rev); fill(bit, bit+maxn, n+1); a[n+1].first = 0;
	fill(ans, ans+maxn, 0); sum[0] = 0;
	
	for (int i = n; i >= 1; i--) {
		af[i] = qry(a[i].second); upd(a[i].second, i);
		//cout<<a[i].first<<";"<<a[i].second<<" ;; "<<af[i]<<endl;
	}
	
	int i = 1;
	while (i <= n) {
		int nx = af[i], cur = a[i].second, occ = a[i].first, nxo = a[nx].first;
		ans[cur] = (occ - nxo) * 1ll * i;
		for (int j = i + 1; j < nx; j++) 
			ans[cur] += a[j].first - nxo;
		i = nx;
	}

	for (int i = 1; i <= n; i++) {
		pl(ans[i]); endc;
	}
}

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

#define NREP() for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define IPT(x) ll t; cin >> t; x.push_back(t);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<string> vvs;

const static ll MOD = 1e9 + 7;

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

    MSG(fixed << setprecision(15) << 2*r*3.14159265358979323846)
}


Measured memory_bytes: 3748
l = gets.chomp.split
s = []

l.each do |x|
  case x
  when '+', '-', '*', '/'
    b = s.pop
    a = s.pop
    case x
    when '+'
      s.push(a + b)
    when '-'
      s.push(a - b)
    when '*'
      s.push(a * b)
    when '/'
      s.push(a / b)      
    end
  else
    s.push(x.to_i)
  end
end

puts s



Measured memory_bytes: 6872
#include<bits/stdc++.h>
using namespace std;
string keiro[100000];
void tansaku(int J,int Y,string now);
int j,y;
main(){
  cin>>j>>y;
  tansaku(0,0,"");
}
void tansaku(int J,int Y,string now){
  if(J==j&&Y==y){
    cout<<now<<endl;
    return;
  }
  if(J>j || Y>y)
    return;
  
  if(Y<5||(Y==5&&J==4)){
    tansaku(J+1,Y,now+"A");
  }
  
  if(J<5||(J==5&&Y==4)){
    tansaku(J,Y+1,now+"B");
  }
  return;
}

Measured memory_bytes: 1984
import sys

def sieve(n):
    N = n + 1
    ints = [False if i % 2 == 0 or i % 3 == 0 or i % 5 == 0 else True for i in range(N)]
    try:
        ints[0] = ints[1] = False
        ints[2] = ints[3] = ints[5] = True
    except IndexError:
        pass
    sqrt = N ** 0.5

    for i in range(3, N, 2):
        if i >= sqrt:
            break
        for m in range(i ** 2, N, i):
            ints[m] = False
    return ints

prime1m = sieve(1000000)

for line in sys.stdin:
    print(prime1m[:int(line) + 1].count(True))

Measured memory_bytes: 24064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <tuple>
#include <map>
#define rep(i,n) for (int i = 0; i <= int(n); i++)
typedef long long ll;
using namespace std;

int main() {
	int n, wg;
	cin >> n;
	wg = 0;
	vector <int> p(n);
	for (int i = 0; i < n; i++) {
		cin >> p.at(i);
	}
	for (int i = 0; i < n; i++) {

		if (p.at(i) != i + 1)
			wg++;
	}


	if (wg <= 2)
		cout << "YES" << endl;
	else

		cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF 100000000
#define fi first
#define sc second
using namespace std;
typedef pair<int,int> P;
 
int n;
int a[100000];
int to[100000];
int d[100000];
vector<int> e[100000];
 
void dijkstra(){
    priority_queue<P,vector<P>,greater<P> > que;
    fill(d,d+n,INF);
    d[0] = 0;
    que.push(P(0,0));
    while(!que.empty()){
        P p = que.top(); que.pop();
        if(p.fi > d[p.sc]) continue;
        rep(i,e[p.sc].size()){
            if(d[e[p.sc][i]] > d[p.sc]+1){
                d[e[p.sc][i]] = d[p.sc]+1;
                que.push(P(d[e[p.sc][i]],e[p.sc][i]));
            }
        }
    }
}
 
int main(){
    scanf("%d",&n);
    rep(i,n) scanf("%d",a+i);
    memset(to,-1,sizeof(to));
    rep(i,n){
        if(to[i] != -1) continue;
        int j = i;
        set<int> s;
        vector<int> v;
        s.insert(j);
        v.push_back(j);
        while(a[j] != 0){
            j = j+a[j];
            if(to[j] != -1){
                j = to[j];
                break;
            }
            if(s.count(j)){
                j = -2;
                break;
            }
            s.insert(j);
            v.push_back(j);
        }
        rep(k,v.size()) to[v[k]] = j;
    }
    rep(i,n){
        for(int j = 1; j <= 6; j++){
            if(i+j >= n) break;
            if(to[i+j] == -2) continue;
            e[i].push_back(to[i+j]);
        }
    }
    dijkstra();
    cout << d[n-1] << endl;
}

Measured memory_bytes: 9444
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define ll int64_t
#define _GLIBCXX_DEBUG
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
//約数列挙(√N)
vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}
//素因数分解(√N)
map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}
//素数テーブル(NloglogN)
vector< bool > prime_table(int n) {
  vector< bool > prime(n + 1, true);
  if(n >= 0) prime[0] = false;
  if(n >= 1) prime[1] = false;
  for(int i = 2; i * i <= n; i++) {
    if(!prime[i]) continue;
    for(int j = i + i; j <= n; j += i) {
      prime[j] = false;
    }
  }
  return prime;
}
//二項係数(K)
template< typename T >
T binomial(int64_t N, int64_t K) {
  if(K < 0 || N < K) return 0;
  T ret = 1;
  for(T i = 1; i <= K; ++i) {
    ret *= N--;
    ret /= i;
  }
  return ret;
}
//二項係数テーブル(N^2)
template< typename T >
vector< vector< T > > binomial_table(int N) {
  vector< vector< T > > mat(N + 1, vector< T >(N + 1));
  for(int i = 0; i <= N; i++) {
    for(int j = 0; j <= i; j++) {
      if(j == 0 || j == i) mat[i][j] = 1;
      else mat[i][j] = mat[i - 1][j - 1] + mat[i - 1][j];
    }
  }
  return mat;
} 
int main(){
  int n,m,k;
  cin >> n >> m >> k;
  vector<ll> sa(n+1),sb(m+1),a(n),b(m);
  rep(x,n)
    cin >> a.at(x);
  rep(x,m)
    cin >> b.at(x);
  rep(i,n){
    sa.at(i+1)+=sa.at(i);
    sa.at(i+1)+=a.at(i);
  }
  rep(i,m){
    sb.at(i+1)+=sb.at(i);
    sb.at(i+1)+=b.at(i);
  }
  int ans=0;
  rep(i,n+1){
    int h=lower_bound(all(sb),k-sa.at(i)+1)-sb.begin();
    if(h==0)continue;
    ans=max(ans,h+i-1);
  }
  cout << ans << endl;
}


Measured memory_bytes: 9532
<?php
// 3????????°
// 3???????????° ??? 1,10,100??§?????£???????????????3???????????°??????
$n = trim(fgets(STDIN));
for($i = 3; $i <= $n; $i++)
{
    if($i % 3 == 0)
    {
        echo " ";
        echo $i;
    }
    else
    {
        for($j = 1; $j < 10000; $j *= 10)
        {
            if(($i / $j) % 10 == 3)
            {
                echo " ";
                echo $i;
                break;
            }
        }
    }
}
echo "\n";

Measured memory_bytes: 15192
#include <bits/stdc++.h>
#define rep(i,n) for (int i= 0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const long long INF = 1LL << 60;
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; }

int main(){
    int a;cin>>a;
    int b =a*a;
    int c = a*a*a;
    cout<<a+b+c<<endl;

}

Measured memory_bytes: 3588
package main

import (
	"fmt"
)

// main is...
func main() {
	var n int
	fmt.Scan(&n)

	var listB = make([]int, n-1)

	for i := 0; i < len(listB); i++ {
		fmt.Scan(&listB[i])
	}

	ret := 0
	// first
	ret += listB[0]
	// last
	ret += listB[len(listB)-1]
	for i := 1; i < len(listB); i++ {
		if listB[i] < listB[i-1] {
			ret += listB[i]
			continue
		}
		ret += listB[i-1]
	}

	fmt.Println(ret)

}



Measured memory_bytes: 512
N=int(input())
A,B=map(int,input().split())
plist=list(map(int,input().split()))

#plist.sort()
alist=[]
blist=[]
clist=[]
for p in plist:
  if p<=A:
    alist.append(p)
  elif p<=B:
    blist.append(p)
  else:
    clist.append(p)
    
print(min(len(alist),len(blist),len(clist)))

Measured memory_bytes: 3064
// بِسمِ اللہِ  الرَّحم?نِ  الرَّ حِیم
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define MOD 1000000007
#define ll long long
#define pb push_back
#define all(v) v.begin(),v.end()
#define INF 1e18
#define N 1001000
typedef pair<ll,ll> pll;
ll power(ll a,ll b)
{
    if(b==1)return a;
    if(b==0)return 1;
    ll temp=power(a,b/2);
    ll ans=temp*temp;
    if(b&1)
        ans*=a;
    return ans;
}
ll power(ll a,ll b,ll p)
{
    a=a%p;
    if(b==1)return a;
    if(b==0)return 1;

    ll temp=power(a,b/2,p);
    ll ans=(temp*temp)%p;
    if(b&1)
        ans=(a*ans)%p;
    return ans%p;
}
ll inv(ll a,ll m)
{
    return power(a,m-2,m);
}
//code begins
ll binary(ll a[],ll n,ll key)
{
    ll l=0,r=n-1,mid;
    while(l<=r)
    {
        mid=(l+r)/2;
        if(a[mid]==key)
            return mid;
        else if(a[mid]>key)
            r=mid-1;
        else
            l=mid+1;
    }
    return -1;
}
ll lowerbound(ll a[],ll n,ll key)
{
    ll l=0,r=n-1,mid,ans=-1;
    while(l<=r)
    {
        mid=(l+r)/2;
        if(a[mid]==key)
        {
            r=mid-1;
            ans=mid;
        }
        else if(a[mid]<key)
            l=mid+1;
        else
            r=mid-1;
    }
    return ans;
}
ll upperbound(ll a[],ll n,ll key)
{
    ll l=0,r=n-1,mid,ans=-1;
    while(l<=r)
    {
        mid=(l+r)/2;
        if(a[mid]==key)
        {
            ans=mid;
            l=mid+1;
        }
        else if(a[mid]>key)
            r=mid-1;
        else
            l=mid+1;
    }
    return (ans+1==n?-1:ans+1);
}
signed main()
{
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    cin.sync_with_stdio(false);
    ll t;
    t=1;
//    cin>>t;
    while(t--)
    {
        ll n,k;cin>>k>>n;
        ll a[n+1];
        for(ll i=1;i<=n;i++)cin>>a[i];
        k-=a[n];
        ll ans=INF;
        for(ll i=1;i<=n;i++)
        {
            if(i==1)
            {
                ans=min(ans,min(a[n]-a[1],k+a[i]+a[n]-a[i+1]));
//                cout<<"i= "<<i<<" first= "<<a[n]-a[1]<<" second= "<<k+a[i]+a[n]-a[i+1]<<endl;
            }
            else if(i==n)
            {
                ans=min(ans,min(a[n]-a[1],k+a[i-1]));
//                cout<<"i= "<<i<<" first= "<<a[n]-a[1]<<" second= "<<k+a[i-1]<<endl;
            }
            else
            {
                ans=min(ans,min(a[n]-a[i]+k+a[i-1],a[i]+k+a[n]-a[i+1]));
//                cout<<"i= "<<i<<" first= "<<a[n]-a[i]+k+a[i-1]<<" second= "<<a[i]+k+a[n]-a[i+1]<<endl;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include<vector>
#include<algorithm>
#include <queue>
#include <string>
#include <set>
#include <bitset>

using namespace std;
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define i64 int64_t
#define tos(x) to_string(x)


int main() {
	string a, b, c;
	cin >> a >> b >> c;
	if (a[a.size() - 1] == b[0] &&b[b.size() - 1] == c[0]) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

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

#define rep(i,n) for(ll i = 0; i < (n); ++i)
#define rep1(i, n) for(ll i = 1; i < (n); ++i)
#define rep4(i, start, end, step) for (ll i = (start); i < (end); i += (step))

#define BIG_PRIME 1000000007
#define BP_remainder(x) ((x) % BIG_PRIME)

#define INF 0x3fffFFFF
#define INF_NEG (INF * -1)
#define INF_LONG (INF << 32)
#define INF_LONG_NEG (INF_LONG * -1L)

typedef long long ll;
typedef char str255[256];
// char *用、strlen の ll 版
ll StrLen(char *s) { for(ll ptr = 0L;; ++ptr) if(!s[ptr]) return ptr; } 
// char * の後ろから n 文字削除, 削除後の文字数を返す
ll StrDel(char *s, int n) { ll l = StrLen(s); s[l - n + 1L] = '\0'; return l - n; }
// 正の整数の桁数
ll NumDigits(ll l){ char s[30]; sprintf(s, "%lld", l); return StrLen(s); }

int isFirst = 1;
template <class T> 
void print(T t) { if (isFirst) cout << t, isFirst = 0; else cout << " " << t; }

void chmin(ll& a, ll b) { if (a > b) a = b; }
void chmax(ll& a, ll b) { if (a < b) a = b; }

signed main()
{
    string S; cin >> S;

    string ans = "Good";
    char prev = S[0];
    rep1(i, 4){
        if (S[i] == prev) ans = "Bad";
        prev = S[i];
    }

    cout << ans << endl;

    return 0;
}


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

int main(){

	int n, id, h, w, id_best;
	double ideal, best, bmi, eps;

	ideal = 22.0;
	eps = pow(0.1, 5);
	
	while(cin >> n){
		if(n == 0) break;
		
		id_best = 1000000;
		best = 1000.0;
	
		for(int i=0; i<n; i++){
			cin >> id >> h >> w;
			bmi = w / pow(0.01 * h, 2);
			if(best > abs(ideal - bmi) || (best - abs(ideal - bmi) < eps && id_best > id)){
				best = abs(ideal - bmi);
				id_best = id;
			}
		}
	
		cout << id_best << endl;
	}

	return 0;

}

Measured memory_bytes: 1160
import java.io.*;
class Main {
	public static void main(String[] args)throws IOException {
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		int x = Integer.parseInt(str);
		  int equal = (int) Math.pow(x, 3);
		  System.out.println(equal);
		
	}

}

Measured memory_bytes: 24248
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
using namespace std;

#define INF (1ll<<60)


long long M = 1000000007;


int main(int argc, char const *argv[]) {
    long long n,p;cin>>n>>p;
    long long res = 1;
    bool b = false;
    for(int i=0;i<n;++i){
        res<<=1;
        int tmp;cin>>tmp;
        if(tmp%2==1)b=true;
    }
    if(b){
        cout<<(res>>1)<<endl;
    }
    else{
        cout<<res*(p==0)<<endl;
    }
    return 0;
}

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

int ggt(int a, int b)
{
    if (b==0)
        return a;
    else
        return ggt(b, a%b);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int x;
    cin >> x;

    int rep = 0;
    //int rest = 0;
    int deg = 360 * (x/ggt(x,360));
    //cout << deg << endl;
    do {
        rep += deg / x;
        deg = deg % x;
    } while(deg != 0);
    
    cout << rep << endl;

    return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<map>

using namespace std;
typedef long long LL;

int main(){
    int N;
    LL sum=0;
    long S[200000];
    LL ans=0;
    map<LL, int> cnt;
    cin>>N;
    for(int i=0;i<N;i++)cin>>S[i];

    for(int i=0;i<N;i++){
        sum += S[i];
        if(sum == 0)ans++;
        ans += cnt[sum];
        cnt[sum]++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 14336
#include "bits/stdc++.h"
#define _ ios_base::sync_with_stdio(0);cin.tie(0);

using namespace std;

int main() { _
    int x, a, b;
    cin >> x;
    cin >> a;
    cin >> b;
    x -= a;
    cout << (x % b) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>

using namespace std;

int main()
{
    long long k;
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>k;
    long a,b,c;
    a=k/50+50;     //要特别处理的数的大小
    b=k%50;       //要特别处理的数的个数
    c=a-b-1;      //正常相等的个数
    cout<<50<<endl;
    for(int i=0;i<50;i++)
    {
        if(i<b)
        {
            if(i==0)
            cout<<a;
            else
            cout<<" "<<a;
        }
        else
        {
            if(i==0)
            cout<<c;
            else 
            cout<<" "<<c;
        }
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner stdIn=new Scanner(System.in);
        while(true){
            int x=stdIn.nextInt();
            int y=stdIn.nextInt();
            if(x==0&&y==0){
                break;
            }
            if(x>y){
                int tmp=x;
                x=y;
                y=tmp;
            }
            System.out.println(x+" "+y);
        }
    }
}


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

int N, Y;
const int yuk = 10000;
const int hig = 5000;
const int nog = 1000;
int main(){
  cin >> N >> Y;
  bool flag =false;
  int yCounter = -1;
  int hCounter = -1;
  int nCounter = -1;
  for(int i=0; i<N+1; ++i){
    for(int j=0; j<N+1; ++j){
      if ((Y -(i*yuk + j*hig))/nog == N -i -j && N-i-j >=0){
        flag = true;
        yCounter =i;
        hCounter =j;
        nCounter =N -i -j;
      }
      if (flag == true) break;
    }
  }
  cout << yCounter << " " << hCounter << " " << nCounter << " ";
  return 0;
}

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

int gcd(int a, int b) {
    if (a%b==0) return b;
    else return gcd(b, a%b);
}

int main() {
    int K;
    cin >> K;
    int res = 0;
    for (int i=1; i<=K; i++) {
        for (int j=1; j<=K; j++) {
            for (int k=1; k<=K; k++) {
                res += gcd(gcd(i,j),k);
            }
        }
    }
    cout << res;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
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 (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

const double pi = 3.141592653589793;

double dist(double x1,double x2,double y1,double y2){
    double tmp = abs(x1 - x2)*abs(x1 - x2) + abs(y1 - y2)*abs(y1 - y2);
    tmp = sqrt(tmp);
    return tmp;
}
int main() {
    double A,B,H,M;cin >> A >> B >> H >> M;

    double hunth = 90 - M*6;
    double hun = 60 * H + M;
    double zith = 90 - hun*0.5;

    double hx = B*cos(hunth * (pi/180));
    double hy = B*sin(hunth * (pi/180));

    double zx = A*cos(zith * (pi/180));
    double zy = A*sin(zith * (pi/180));

    double ans = dist(hx,zx,hy,zy);
    cout << std::fixed << std::setprecision(15) << ans << endl;
}

Measured memory_bytes: 4084
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>

using namespace std;

const int N = 1e6 + 7;
const int INF = N * 10;

int dp[N][2];

int proc(vector<int> s) {
	int ans = 0;
	for (int i = 0; i  < (int)s.size(); i++) {
		if (s[i] >= 10) {
			s[i + 1] += s[i] / 10;
		}
		s[i] %= 10;
		ans += s[i];
	}
	return ans;
}

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

	string s;
	cin >> s;
	reverse(s.begin(), s.end());
	vector<int> a;
	for (auto t : s) {
		a.push_back(t - '0');
	}
	int n = (int)a.size();
	for (int i = 0; i < N; i++) {
		dp[i][0] = INF;
		dp[i][1] = INF;
	}
	dp[0][0] = 0;
	for (int i = 0; i < n; i++) {
		for (int c = 0; c < 2; c++) {
			int v = a[i] + c;
			if (v == 10) {
				dp[i + 1][1] = min(dp[i + 1][1], dp[i][c]);
				continue;
			}
			int add = 10 - v;
			dp[i + 1][0] = min(dp[i + 1][0], dp[i][c] + c + a[i]);
			dp[i + 1][1] = min(dp[i + 1][1], dp[i][c] + add);
		}
		// cerr << dp[i + 1][0] << ' ' << dp[i + 1][1] << endl;
	}
	int ans = INF;
	for (int i = 0; i < 2; i++) {
		ans = min(ans, dp[n][i] + i);
	}
	cout << ans << endl;
}


Measured memory_bytes: 13972
#include <stdio.h>
int main(){
	int a[100],n,x;
	
	scanf("%d",&n);
	for(x=0;x<n;x++){
			scanf("%d",&a[x]);
	}
	for(x=n-1;x>0;x--){
		printf("%d ",a[x]);
	}
	printf("%d\n",a[0]);
	return 0;
}

Measured memory_bytes: 596
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

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

int main(){
	int A,B,C;
	cin >> A >> B >> C;
	set<int> a;
	a.insert(A);
	a.insert(B);
	a.insert(C);
	if(a.size()==2)cout << "Yes" <<endl;
	else cout << "No" <<endl;
}



Measured memory_bytes: 256