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

int main() {
    int n;
    cin >> n;
    vector<ll> x (n);
    vector<ll> x_sort (n);
    for(int i=0; i<n; i++){
        ll a;
        cin >> a;
        x.at(i) = a;
        x_sort.at(i) = a;
    }
    sort(x_sort.begin(),x_sort.end());
    ll L,R;
    L = x_sort.at(n/2-1);
    R = x_sort.at(n/2);
    for(int i=0; i<n; i++){
        if(x.at(i) <= L){
            cout << R << endl;
        }
        else{
            cout << L << endl;
        }
    }
}

Measured memory_bytes: 5376
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        
        System.out.println(c + " " + a + " " + b);
    }
}


Measured memory_bytes: 21844
s = int(input())
hashSet = set([s])

m = 2
while True:
  if s % 2 == 0:
    s //= 2
  else:
    s = 3*s + 1
  if s in hashSet:
    print(m)
    break
  else:
    hashSet.add(s)
    m += 1

Measured memory_bytes: 3060
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
using namespace std;
#define INF 100000000
#define MAXN 110

typedef long long ll;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

int main(void) {
    int n, w;
    while (1) {
        cin >> n >> w;
        if (n == 0 && w == 0) break;
        int v[MAXN], ma = 0;
        for (int i = 0; i < n; i++) {
            cin >> v[i];
            ma = max(ma, v[i]);
        }
        int num = ma / w;
        int group[num+1];
        for (int i = 0; i <= num; i++) group[i] = 0;
        for (int i = 0; i < n; i++) {
            group[v[i] / w]++;
        }
        ma = 0;
        for (int i = 0; i <= num; i++) {
            ma = max(ma, group[i]);
        }
        double ans = 0.01;
        for (int i = 0; i <= num; i++) {
            ans += (1.0*group[i]) * (1.0-(1.0*i) / (1.0*num)) / (1.0*ma);
        }
        printf("%.10f\n", ans);
    }
    return 0;
}

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define lep(j,n) for(int j=0; j<(n); j++)
#define reps(i,n) for(int i=1; i<(n); i++)
#define leps(j,n) for(int j=1; j<(n); j++)
#define pii pair<int,int>
#define gsort(x,n) sort((x),(x)+(n),greater<int>())
#define all(x) (x).begin(), (x).end()
#define int long long
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
const long long mod = 1000000007;
using namespace std;

#define return(Z) re:(Z)

long long h[10000010],x[10000010],z[10000010];

signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int r,g;
    cin>>r>>g;

    int a=g-r;
    a=a*2;
    cout<<r+a<<'\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int k,a,b;
  bool j =false;
  cin >> k >> a >>b;
  for(int i=a; i<=b; i++){
    if( (i%k) == 0){
      j=true;
      break;
    }
  }
  if(j)
    cout << "OK" <<endl;
  else
    cout << "NG" <<endl;
    
}

Measured memory_bytes: 3636
#include<iostream>
using namespace std;
int n,m,a[4];
int main(){
	cin>>n>>m;
	a[n]++;a[m]++;
	for(int i=1;i<=3;i++){
		if(!a[i]){
			cout<<i<<endl;return 0;
		} 
	} 
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using P = pair<int,int>;
using ll = long long;
int n, m, a, b;
ll ans, pw[55];
unsigned long long bt[55];
vector<P> G[55];
bool dfs(int u, int p, int t, int i){
	for(P nx: G[u]) if(nx.first != p){
		if(nx.first == t || dfs(nx.first,u,t,i)){
			bt[i] |= 1ll << nx.second;
			return true;
		}
	}
	return false;
}
int main(){
	scanf("%d", &n);
	rep(i,n-1){
		scanf("%d%d", &a, &b);
		G[a].push_back(P{b,i});
		G[b].push_back(P{a,i});
	}
	scanf("%d", &m);
	rep(i,m){
		scanf("%d%d", &a, &b);
		dfs(a,a,b,i);
	}
	pw[0] = 1;
	rep(i,n-1) pw[i+1] = pw[i] * 2;
	rep(i,1<<m){
		unsigned long long tmp = 0;
		rep(j,m) if(i>>j&1) tmp |= bt[j];
		ans += pw[n-1-__builtin_popcountll(tmp)] * (__builtin_popcount(i)%2 ? -1 : 1);
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 384
from math import sqrt


def eratosthenes(x):
    prime = []
    for i in range(2, int(sqrt(x)) + 1):
        if x % i == 0:
            prime.append(i)
            while x % i == 0:
                x //= i
    
    return prime


N = int(input())
prime = eratosthenes(N)
ans = 0
for x in prime:
    i = 1
    while N % x**i == 0:
        ans += 1
        N //= x**i
        i += 1
    while N % x == 0:
        N //= x

if N > 1:
    ans += 1
print(ans)

Measured memory_bytes: 9160
import java.util.Scanner;

public class Main {

	private void solve() {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int C = in.nextInt();
		int[][] D = new int[C][C];
		for(int i=0;i<C;i++) {
			for(int j=0;j<C;j++) {
				D[i][j] = in.nextInt();
			}
		}
		int[][] colors = new int[3][C];
		for(int i=0;i<N;i++) {
			for(int j=0;j<N;j++) {
				int c = in.nextInt();
				colors[((i+1)+(j+1))%3][c-1] ++;
			}
		}
		long[][] costs = new long[3][C];
		for(int i=0;i<3;i++) {
			for(int j=0;j<C;j++) {
				costs[i][j] = moveCost(colors[i],D,j);
			}
		}
		long ans = Long.MAX_VALUE;
		for(int i=0;i<C;i++) {
			for(int j=0;j<C;j++) {
				if(i==j) continue;
				for(int k=0;k<C;k++) {
					if(i==k || j==k) continue;
					ans = Math.min(ans, costs[0][i]+costs[1][j]+costs[2][k]);
				}
			}
		}
		System.out.println(ans);
	}

	public static void main(String[] args) {
		new Main().solve();
	}
	
	public long moveCost(int[] colors, int[][] cost, int selectedColor) {
		long sum = 0;
		for(int i=0;i<colors.length;i++) {
			sum += colors[i]*cost[i][selectedColor];
		}
		return sum;
	}
}

Measured memory_bytes: 78768
#include<iostream>
#include<vector>
#include<stdlib.h>
#include<time.h>

int main(void){
  char s[10];
  int sum=0;
  std::cin>>s;
  for(int i=0  ;i<10; i++){
    if(s[i]=='+')sum++;
    else if(s[i]=='-')sum--;
    else if(s[i]=='\0')break;
    else ;
  }
  std::cout<<sum<<std::endl;

  return 0;
}

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

int main() {
  ll N,M;
  cin >> N;
  vector<ll> t(N);
  ll ans=0;
  for(ll i=0;i<N;i++) {
    cin >> t[i];
    ans += t[i];
  }
  cin >> M;
  vector<ll> p(M),x(M);
  for(ll i=0;i<M;i++) {
    ll temp=ans;
    ll p,x;
    cin >> p >> x;
    temp = temp-t[p-1]+x;
    cout << temp << endl;
  }
}

Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');

var g_input = '';
process.stdin.on('data', function(chunk) {
    g_input += chunk;
});

process.stdin.on('end', function() {
    Main(g_input.split(/\r?\n/));
});

function Main(input) {

    var digits = input[0].split('');

    var maxContNum = 0;
    var contNum = 1;
    for (var i = 1; i < digits.length; i++) {
        if (digits[i] == digits[i - 1]) {
            contNum++;
        }
        else {
            maxContNum = Math.max(maxContNum, contNum);
            contNum = 1;
        }
    }
    maxContNum = Math.max(maxContNum, contNum);

    if (maxContNum >= 3) {
        console.log('Yes');
    }
    else {
        console.log('No');
    }

    return 0;
}


Measured memory_bytes: 7500
#include<bits/stdc++.h>
#define rep(i,f,n) for(int i=(f); (i) < (n); i++)
#define repe(i,f,n) for(int i=(f); (i) <= (n); i++)
using namespace std;

typedef long long ll;
ll INF = 1LL << 60;

int
main() {

  int n, k; cin >> n >> k;
  vector<ll> dis_cdl(n);
  rep(i, 0, n) cin >> dis_cdl[i];

  ll ans = INF;
  for(int i =  0; i + k - 1 < n; i++){
    ll from_left = dis_cdl[i + k - 1] - dis_cdl[i] + abs(dis_cdl[i]);
    ll from_right = dis_cdl[i + k -1] - dis_cdl[i] + abs(dis_cdl[i + k - 1]);
    ans = min(ans,min(from_left, from_right));
  }

  cout << ans << endl;

  return 0;
}




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

const long long mod = 1e9+7;

// a^bを返す
long long Pow(long long a, long long b) {
	long long ret = 1;
	while (b > 0) {
		if (b & 1) {
			ret = (ret % mod) * (a % mod) % mod;
		}
		a = (a % mod) * (a % mod) % mod;
		b /= 2;
	}

	return ret % mod;
}

// nCkを返す
long long nCk(long long n, long long k) {
	long long bunbo = 1, bunshi = 1;
	for (int ki = 1; ki <= k; ki++) {
		bunbo *= ki;
		bunshi *= n - ki + 1;
		bunbo %= mod;
		bunshi %= mod;
	}

	return bunshi * Pow(bunbo, mod - 2) % mod;
}

signed main() {
	long long n, a, b;
	cin >> n >> a >> b;

	// 全体の本数
	long long ans = Pow(2, n) - 1;

	// nCaの分を引く
	ans -= nCk(n, a);
	ans %= mod;

	// nCbの分を引く
	ans -= nCk(n, b);
	ans %= mod;

	// ans を絶対値modの範囲に収める → modを足して正の値にする → あまりを求める
	ans = ((ans % mod) + mod) % mod;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long   // aaaaaaaaaaaaaaaaaa
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()
#define in(s,x) s.find(x) != s.end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define SIZE(buff) (sizeof(buff)/sizeof(buff[0]))
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<pair<int,int>> VPII;
const ll mod=1000000007;
const ll INF= 1LL<<60-1;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
template<typename T, typename U>ostream& operator << (ostream& os, pair<T, U>& pair_var)
{os << "(" << pair_var.first << ", " << pair_var.second << ")";return os;}

// head


int m,n,k,res,tmp,tmp2,tmp3,h,x,y;
VI a;
deque<PII> que;
string s;
//VI b;
vector<PII> g[2100600];
vector<int> b;
vector<VI> c;
int rui[210000];
set<int> ch;
int dp[1<<13];

signed main() {
	cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n>>m;
  c.resize(m);
  rep(i,0,m){
    cin>>x>>y;
    a.pb(x);b.pb(y);
    rep(j,0,b[i]){
      cin>>x;
      c[i].pb(x);
    }
  }
  rep(i,0,1LL<<n){
    dp[i] = -1;
  }
  dp[0] = 0;
  rep(i,0,m){
    rep(j,0,1<<n){
      if(dp[j] != -1){
        x = j;
        rep(k,0,b[i]){
          x |= 1<<(c[i][k]-1);
        }
        if(dp[x] != -1) dp[x] = min(dp[x],dp[j]+a[i]);
        else dp[x] = dp[j]+a[i];
      }
    }
  }
  std::cout << dp[(1<<n)-1] << '\n';
}


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

// int main () {
    
//     ll a,b,n;
//     cin >> a >> b >> n;

//     int max;
//     for (int i = 1; i<=n; i++) {
//         ll now = a*i/b - a*(i/b);
//         if (now > max) max = now;
//     }

//     cout << max << endl; 
// }

int main () {
    ll a,b,n;
    cin >> a >> b >> n;
    ll x = min(b-1,n);
    ll ans = a*x/b - a*(x/b);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3680
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int n;
  cin>>n;
  vector<long long int> a(n);
  for(long long int i=0; i<n; i++){
    cin>>a.at(i);
  }
  sort(a.begin(),a.end());
  while(a.size()>1){
    a.at(a.size()-1)%=a.at(0);
    if(a.at(a.size()-1)==0){
      a.pop_back();
    }
    if(a.at(a.size()-1)<a.at(0)){
      sort(a.begin(),a.end());
    }
  }

  cout<<a.at(0)<<endl;
}

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

using namespace std;

using i64 = long long;

int main(){
    i64 n;
    cin >> n;
    i64 ans = n - 1;
    for(i64 i = 1; i < n; ++i){
        if(i * i > n) break;
        if(n % i == 0) ans = min(ans, n / i + i - 2);
    }
    cout << ans << endl;
}

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

string operator*(string str, size_t n) {
  string result = "";
  rep(i, n){
  	result += str;
  }
  return result;
}


int main() {
  int h, w;
  int cnt;
  cin >> h >> w;
  vector<string> stage(h);
  rep(y, h) {
  	cin >> stage[y];
  }
  rep(y, h) {
  	rep(x, w) {
      if (stage[y][x] == '#') continue;
      cnt = 0;
      range(addx, -1, 2){
      	range(addy, -1, 2) {
          //cout << x + addx << y + addy << endl;
          if (0 <= x + addx && x + addx < w && 0 <= y + addy && y + addy < h) {
            if (stage[y + addy][x + addx] == '#') cnt += 1;
          }
        }
      }
      stage[y][x] = '0' + cnt;
    }
  }
  rep(y, h) {
  	cout << stage[y] << endl;
  }
}

Measured memory_bytes: 3624
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <string>
#include <cstring>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <vector>
#include <fstream>
#include <list>
#include <iomanip>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define ms(s) memset(s, 0, sizeof(s))
const int INF = 1e9;
inline int read(){
	int X = 0,w = 0 ;
	char ch = 0;
	while(!isdigit(ch)) {w |= ch == '-';ch = getchar();}
	while(isdigit(ch)) X = (X<<3) + (X<<1) + (ch ^ 48),ch = getchar();
	return w ? -X : X;
}

double f[305][305][305];
int main() 
{
	int n;
	cin>>n;
	int c1=0,c2=0,c3=0;
	for(int i=1;i<=n;i++)
	{
		int x;
		cin>>x;
		if(x==1)
		{
			c1++;
		}
		else if(x==2)
		{
			c2++;
		}
		else
		{
			c3++;
		}
	}
	for(int k=0;k<305;k++)
	{
		for(int j=0;j+k<305;j++)
		{
			for(int i=0;i+j+k<305;i++)
			{
				if(i==0 and j==0 and k==0)
				{
					continue;
				}
				if(i+j+k>305)
				{
					continue;
				}
				double wait=1.0*n/(i+j+k);
				double pi=1.0*i/(i+j+k);
				double pj=1.0*j/(i+j+k);
				double pk=1.0*k/(i+j+k);
				if(i)
				{
					f[i][j][k]+=pi*f[i-1][j][k];
				}
				if(j)
				{
					f[i][j][k]+=pj*f[i+1][j-1][k];
				}
				if(k)
				{
					f[i][j][k]+=pk*f[i][j+1][k-1];
				}
				f[i][j][k]+=wait;
			}
		}
	}
	printf("%.9f",f[c1][c2][c3]);
    return 0;
}

Measured memory_bytes: 221568
A, B, C, X, Y = map(int, input().split())

min_count = min(X, Y)
max_count = max(X, Y)

p1 = (C * min_count) * 2 + A * (X - min_count) + B * (Y -min_count)
p2 = A * X + B * Y
p3 = (C * max_count) * 2

print(min(p1, p2, p3))


Measured memory_bytes: 3064
S = input()
ans = 0
for i in range(len(S),0,-1):
    for j in range(len(S)-i+1):
        flag = True
        for c in S[j:j+i]:
            if c not in ["A","T","C","G"]:
                flag = False
        if flag:
            ans = max(ans,i)
print(ans)

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

using namespace std;

typedef long long ll;

const ll MOD = 1LL << 32;
const ll INF = 1e18+7;

signed main()
{
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n), b(n);
    vector<vector<ll>> v(n);
    for(ll i = 0; i < n; ++i){
        cin >> a[i] >> b[i];
        v[--a[i]].push_back(b[i]);
    }
    for(auto& x : v){
        sort(x.begin(), x.end(), greater<ll>());
    }

    ll st = 0;
    ll en = n + 1;
    auto f = [&](ll p){
        if(p == 0 || p == n + 1 || p > k)
            return 0LL;
        priority_queue<ll> que;
        for(auto& x : v){
            if(x.empty())
                continue;
            que.push(x.front());
        }
        if((int)que.size() < p)
            return 0LL;
        ll score = p * p;
        for(int i = 0; i < p; ++i){
            score += que.top();
            que.pop();
        }
        ll noko = k - p;
        for(auto& x : v){
            if(x.size() <= 1)
                continue;
            for(ll i = 1; i < (ll)x.size(); ++i)
                que.push(x[i]);
        }
        for(ll i = 0; i < noko; ++i){
            score += que.top();
            que.pop();
        }
        return score;
    };
    while(en - st > 2){
        ll diff = (en - st) / 3;
        ll st_mid = st + diff;
        ll en_mid = en - diff;
        if(f(st_mid) < f(en_mid))
            st = st_mid;
        else
            en = en_mid;
    }
    ll maxscore = 0;
    for(ll i = st; i <= en; ++i){
        maxscore = max(maxscore, f(i));
    }
    cout << maxscore << endl;
}


Measured memory_bytes: 9140
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <cmath>

using namespace std;
typedef pair<int, int> P;
typedef pair<P, int> PI;

void solve()
{
	int N, S;
	cin >> N >> S;
	vector<int> a(N);
	for (int i = 0; i < N; ++i)
	{
		cin >> a[i];
	}
	long long int sum = 0;
	int start = 0;
	int end = 0;
	int minLen = 1e9;
	while (true)
	{
		while (end < N && sum < S)
		{
			sum += a[end];
			++end;
		}
		if (sum < S)
		{
			break;
		}
		minLen = min(minLen, end - start);
		sum -= a[start];
		++start;
	}
	if (minLen > N)
	{
		minLen = 0;
	}
	cout << minLen << endl;
}

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


Measured memory_bytes: 3168
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <iomanip>

#include <fstream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void)
{

    double a, b, h, m;
    static const double pi = 3.1415926535897932384;
    
    cin >> a >> b >> h >> m;
    
    h *= 30;
    h += (m / 60) * 30;
    m *= 6;

    cout << fixed << setprecision(15) << pow(a*a + b*b - 2.0 * a * b * cos((h - m) * pi / 180), 0.5);
}

Measured memory_bytes: 4356
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5 << 28, MOD = 1e9 + 7;

int N, M, K;
vi A, B;
string S, T;

void input() { cin >> S; }
void solve() {
  deque<int> q;
  for (auto x : S) {
    if (x == '0') {
      q.push_back(0);

    } else if (x == '1') {
      q.push_back(1);
    } else {
      if (q.size()) {
        q.pop_back();
      }
    }
  }
  while (q.size()) {
    cout << q.front();
    q.pop_front();
  };
  cout << endl;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<ctime>
#include<cstdlib>
#define LL long long 

using namespace std;
const int MAXN = 1e5 + 10, INF = 1e8 + 10, mod = 1e9 + 7, mod2 = 1e9 + 6;
inline int read() {
    char c = getchar(); int x = 0, f = 1;
    while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}

main() { 
#ifdef WIN32
//	freopen("a.in", "r", stdin);
	//freopen("b.out", "w", stdout);
#endif
	int a = read(), b = read();
	if(a + b == 15)  putchar('+');
	else if (a * b == 15)putchar('*');
	else putchar('x');
	return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<stack>
#include<queue>
#include<iomanip>
#include<set>
#include<bitset>
#include <cstdio>
#include <cmath>

using namespace std;

typedef long long ll;
#define put(n) cout<<(n)<<"\n"
#define FOR(i,num,N) for(int(i)=(num);(i)<(N);++(i))
#define RFOR(i,num,N) for(int (i)=(num);(i)>(N);--(i))
#define all(v) (v).begin() , (v).end()
#define rall(v) (v).rbegin() , (v).rend()

int main(){
    int N,left,right;
    cin>>N;
    vector<int> T(N);
    FOR(i,0,N) cin>>T[i];

    left = T[0]/10;
    for(int i=1;left>=i&&i<N;++i){
        left = max(left,T[i]/10+i);
    }

    reverse(T.begin(),T.end());

    right = T[0]/10;
    for(int i=1;right>=i&&i<N;++i){
        right = max(right,T[i]/10+i);
    }

    if(left>=N-1 && right>=N-1) cout<<"yes\n";
    else cout<<"no\n";

}


Measured memory_bytes: 3868
#include <bits/stdc++.h>
using namespace std;
#define im 2147483647
#define lm 9223372036854775807
#define ll long long
#define vb vector<bool>
#define vi vector<int>
#define vl vector<long long>
#define vvi vector<vector<int>>
#define ii pair<int, int>
#define ff first
#define ss second
#define _graph map<int, vector<int>>
#define lower_str(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define upper_str(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define debug(index, num) cout << "Case #" << index << ": " << num << endl
#define nmax(an, na) an = max(an, na)
#define nmin(an, na) an = min(an, na)
#define rep(i, a, b) for (int i = a; i < b; i++)
#define rep2(i, a, b) for (int i = a; i <= b; i++)
#define repp(i, a, b) for (int i = a; i >= b; i--)
#define repp2(i, a, b) for (int i = a-1; i >= b; i--)
#define be(x) x.begin(), x.end()
#define rbe(x) x.rbegin(), x.rend()
#define pb push_back
#define IO                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)

int main () {
    IO;
    int n;
    cin >> n;
    vi v(n);
    rep(i, 0, n) cin >> v[i];
    int ans = 0, seg = 0;
    rep(i, 1, n){
        if(v[i] > v[i-1]) {
            seg = i;
        }
        ans = max(ans, i - seg);
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long ll;
 
int main(){
    string s;
    int n;
    while(cin>>n && cin>>s){
        for(int i=0; i<s.size(); i++){
            if((s[i]+n) > 90)
                s[i] = (s[i] - 26)+n;
 
            else s[i] += n;
        }
        cout<<s<<endl;
    }
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextLong();
        }
        Arrays.sort(a);

        int lastIndex = -1;
        boolean[] dp = new boolean[k + 1];
        dp[0] = true;

        for (int i = n - 1; i >= 0; i--) {
            for (int j = k; j >= 0; j--) {
                if (dp[j]) {
                    if (j + a[i] >= k) {
                        lastIndex = i;
                    } else {
                        dp[(int)(j + a[i])] = true;
                    }
                }
            }
        }
        System.out.println(lastIndex == -1 ? n : lastIndex);
    }
}


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

#define null               ""
#define endl               '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fr, to)    for (int i = fr; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

const int nsz = 1e5;
int n, m, a[nsz + 5];
num ans;
pair<int, int> op[nsz + 5];

int inline read() {
    int res = 0;
    char c = getchar();
    for (; !isdigit(c); c = getchar());
    for (; isdigit(c); res *= 10, res += c ^ 48, c = getchar());
    return res;
}

int main() {
    ios_base::sync_with_stdio(0);
    n = read();
    m = read();
    cont (i, n) {
        a[i] = read();
    }
    sort(a + 1, a + n + 1);
    cont (i, m) {
        int cnt = read(), to = read();
        op[i] = {to, cnt};
    }
    sort(op + 1, op + m + 1);
    reverse(op + 1, op + m + 1);
    int it = 1;
    cont (i, m) {
        int cur = op[i].first, cnt = op[i].second;
        for (; it <= n && cnt; ++it, --cnt) {
            if (cur <= a[it])  break;
            a[it] = cur;
        }
    }
    cont (i, n) {
        ans += a[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 1408
#include<iostream>
#include<string>

using namespace std;

int main(){
  int f[6];
  for(int i = 0;i<6;i++){
      int temp;
      cin>>temp;
      f[i] = temp;
  }
  string roll;
  cin>>roll;
  for(int i = 0;i < roll.size();i++){
      char temp = roll[i];
      int temp_1;
      switch (temp)
      {
      case 'S':
          temp_1 = f[4];
          f[4] = f[5];
          f[5] = f[1];
          f[1] = f[0];
          f[0] = temp_1;
          break;
    case 'N':
          temp_1 = f[1];
          f[1] = f[5];
          f[5] = f[4];
          f[4] = f[0];
          f[0] = temp_1;
          break;
    case 'W':
          temp_1 = f[2];
          f[2] = f[5];
          f[5] = f[3];
          f[3] = f[0];
          f[0] = temp_1;
          break;
    case 'E':
          temp_1 = f[2];
          f[2] = f[0];
          f[0] = f[3];
          f[3] = f[5];
          f[5] = temp_1;
          break;
      default:
          break;
      }
  }
  cout<<f[0]<<endl;
  return 0;
}


Measured memory_bytes: 3164
/*
    B - Palace
    https://atcoder.jp/contests/abc113/tasks/abc113_b
*/
#include <bits/stdc++.h>
using namespace std;

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

    int n;
    cin >> n;
    double t, a;
    cin >> t >> a;

    vector<int> Hi(n);
    for (int i = 0; i < n; i++) {
        cin >> Hi[i];
    }

    double _min = 100001 * 60;
    int min_idx = 0;
    for (int i = 0; i < n; i++) {
        double temp = t - (double)Hi[i] * 0.006;
        // cout << " diff : " << abs(a - temp) << endl;
        if (_min > abs(a - temp)) {
            _min = abs(a - temp);
            min_idx = i + 1;
        }
    }
    cout << min_idx << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)

N, M, Q = map(int, input().split())
arr = [list(map(int, input().split())) for _ in range(Q)]
ans = set()

def generate_arr(target):
    if len(target) == N:
        tmp = 0
        for item in arr:
            if target[item[1]-1] - target[item[0]-1] == item[2]:
                tmp += item[3]
            ans.add(tmp)
        return
    for i in range(target[-1],M+1):
        next_target = target.copy()
        next_target.append(i)
        generate_arr(next_target)
for i in range(1,M+1):
    generate_arr([i])
print(max(ans))

Measured memory_bytes: 9604
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int H, W, N;
        public long MOD = 1000000007;

        public void Run()
        {
            // HとW, XとYが逆なので注意
            {
                var line = Input.ReadIntArray();
                W = line[0];
                H = line[1];
                N = line[2];
            }

            var O = new List<int>[H];
            for (int i = 0; i < H; i++)
            {
                O[i] = new List<int>();
                // 壁を追加する
                O[i].Add(W);
            }

            for (int i = 0; i < N; i++)
            {
                var line = Input.ReadIntArray();
                int x = line[0] - 1;
                int y = line[1] - 1;
                O[y].Add(x);
            }

            for (int y = 0; y < H; y++)
            {
                O[y].Sort();
            }

            // 各行の押し付けられる位置。初期値はWとしておく
            int[] T = new int[H];
            for (int y = 0; y < H; y++)
            {
                T[y] = W;
            }

            // 次のマスに移動できるか
            int f = 0;
            for (int y = 0; y < H; y++)
            {
                foreach (var x in O[y])
                {
                    if (x > f)
                    {
                        T[y] = x;
                        break;
                    }
                }

                if (y < H - 1)
                {
                    f++;
                    var s = new HashSet<int>(O[y+1]);
                    while (s.Contains(f))
                    {
                        f++;
                    }

                    // これ以上下に行けない
                    if (f >= W) break;
                }
            }

            Console.WriteLine(T.Min());
        }
    }

    // libs ----------
    

    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 39216
package main

import "fmt"
import "math"

func main() {
	var H, W float64
	fmt.Scan(&H)
	fmt.Scan(&W)

	if H == 1 || W == 1 {
		fmt.Println(1)
	} else {
		res := H * W / 2
		fmt.Println(int(math.Ceil(res)))
	}
}


Measured memory_bytes: 512
#include<stdio.h>
int main() {
	int N, i, j, num = 0, a;
	int A[100000];
	scanf("%d", &N);
	for (i = 0; i < N; i++) {
		scanf("%d", &A[i]);
		for (j = 0; j < N; j++) {
			if (A[i] < A[j]) {
				num = A[i];
				A[i] = A[j];
				A[j] = num;
			}
		}
	}
	a = A[N - 1] - A[0];
	printf("%d", a);
	/*for (i = 0; i < N; i++) {
		printf("%d ", A[i]);
	}*/
	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

void sort(int v[], int n) {
    int i;
    int buf;
    short sorted = 0;
    
    while(!sorted) {
        sorted = 1;
        for(i=0; i<n-1; i++) {
            if(v[i]<v[i+1]) {
                buf = v[i];
                v[i] = v[i+1];
                v[i+1] = buf;
                sorted = 0;
            }
        }
    }
    
    return;
}

int main(void){
    int h[10];
    int i;
    
    for(i=0; i<10; i++) {
        scanf("%d", &h[i]);
    }
    sort(h, 10);
    
    for(i=0; i<3; i++) {
        printf("%d\n", h[i]);
    }
    
    return 0;
}

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  long long n, a, b;
  cin >> n >> a >> b;
  if ((b - a) & 1) {
    cout << min((a - 1) + (b - 1) + 1, (n - a) + (n - b) + 1) / 2 << '\n';
  } else {
    cout << (b - a) / 2 << '\n';
  }
}


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

int prime[101];
int idx = 0;

int num(int m) {
    int count = 0;
    for (int i = 0; i < idx; i++) {
        if (prime[i] >= (m - 1)) {
            count++;
        }
    }
    return count;
}

int main(int argc, const char * argv[]) {
    int N;
    
    cin >> N;
    
    idx = N + 1;
    
    for (int i = 2; i < N + 1; i++) {
        int cur = i;
        for (int j = 2; j < i + 1; j++) {
            while (cur % j == 0) {
                prime[j] += 1;
                cur /= j;
            }
        }
    }

    cout << (num(75) + num(25)
             * (num(3) - 1) + num(15)
             * (num(5) - 1) + num(5)
             * (num(5) - 1) * (num(3) - 2) / 2) << endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int , input().split()))
B = sorted(list(set(A)),reverse=True)
S = len(B)
if N <=2 or S<= 2:
    print(0)
else:
    count = 0
    for i in range(S-2):
        high = B[i]
        hc = A.count(B[i])
        for j in range(S-2-i):
            mid = B[i +j+1]
            mc = A.count(B[i +j+1])
            for k in range(S-2- i -j):
                if B[i +j+k +2]>(high - mid):
                    lc = A.count(B[i +j+k +2])
                    count += (hc*mc*lc)
    print(count)


Measured memory_bytes: 9184
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var n = cin.nextInt();

            var ans = 0;
            for (int i = 1; i <= n; i+=2)
            {
                if (Divisor(i).Count == 8) ans++;
            }
            
            Console.WriteLine(ans);
        }

        List<int> Divisor(int n)
        {
            var ret = new List<int>();
            for (int i = 1; i * i <= n; i++)
            {
                if (n % i == 0)
                {
                    ret.Add(i);
                    if (i != n / i) ret.Add(n / i);
                }
            }
            return ret;
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
#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<string> vs;
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<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int a,b;

int main(){
	cin>>a>>b;
	if((a+b)%2==1) cout<<"IMPOSSIBLE"<<endl;
	else cout<<(a+b)/2<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int MOD = 1000000007;
const int MAX = 2000100;
long long fac[MAX], finv[MAX], inv[MAX];
void init_comb() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
long long comb(int n, int r) {
  if (n < r) return 0;
  if (n < 0 || r < 0) return 0;
  return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

template<int Mod> class ModInt {
  int v;
public:
  constexpr ModInt(const long long x = 0) noexcept : v((x % Mod + Mod) % Mod) {};
  constexpr ModInt &operator+=(const ModInt rhs) noexcept {
    v += rhs.v;
    if (v >= Mod)
      v -= Mod;
    return *this;
  }
  constexpr ModInt &operator-=(const ModInt rhs) noexcept {
    if (v < rhs.v)
      v += Mod;
    v -= rhs.v;
    return *this;
  }
  constexpr ModInt &operator*=(const ModInt rhs) noexcept {
    v = int(1LL * v * rhs.v % Mod);
    return *this;
  }
  constexpr ModInt &operator/=(ModInt rhs) noexcept {
    long long exp = Mod - 2;
    while (exp) {
      if (exp & 1)
        *this *= rhs;
      rhs *= rhs;
      exp >>= 1;
    }
    return *this;
  }
  constexpr ModInt operator-() const noexcept { return ModInt(-v); }
  constexpr ModInt operator+(const ModInt rhs) const noexcept {
    return ModInt(*this) += rhs;
  }
  constexpr ModInt operator-(const ModInt rhs) const noexcept {
    return ModInt(*this) -= rhs;
  }
  constexpr ModInt operator*(const ModInt rhs) const noexcept {
    return ModInt(*this) *= rhs;
  }
  constexpr ModInt operator/(const ModInt rhs) const noexcept {
    return ModInt(*this) /= rhs;
  }
  constexpr bool operator==(const ModInt rhs) const noexcept {
    return v == rhs.v;
  }
  constexpr bool operator!=(const ModInt rhs) const noexcept {
    return v != rhs.v;
  }
  constexpr ModInt pow(long long exp) const noexcept {
    ModInt res(1), mul(v);
    while (exp) {
      if (exp & 1)
        res *= mul;
      mul *= mul;
      exp >>= 1;
    }
    return res;
  }
  friend ostream &operator<<(ostream &os, const ModInt obj) noexcept {
    return os << obj.v;
  }
  friend istream &operator>>(istream &is, ModInt &obj) noexcept {
    long long tmp;
    is >> tmp;
    obj = ModInt<Mod>(tmp);
    return is;
  }
};
using mint = ModInt<MOD>;

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  init_comb();
  int k;
  string s;
  cin >> k >> s;
  int n = s.size();
  mint ans;
  rep(i, k+1)
    ans += mint(25).pow(i)*mint(26).pow(k-i)*comb(n-1+i, i);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 51152
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner scanner = new Scanner(System.in);
	    //String input1 = scanner.next();
	    String input2 = scanner.next();

	    //int h=Integer.parseInt(input1);
	    int n=Integer.parseInt(input2);
	    int a[]=new int[n];
	    Set<String> sa=new HashSet<String>();
	    for(int i=0;i<n;i++) {
	    	if(!sa.add(scanner.next())) {
	    		System.out.println("NO");
	    		return;
	    	}
	    }
	    scanner.close();
	    int sum=sa.stream()
	    		.mapToInt(s->Integer.parseInt(s))
	    		.sum();
	    	System.out.println("YES");
	}

}


Measured memory_bytes: 75676
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

while True:
    s1 = input()
    if s1 == '.':
        break
    else:
        s2 = input()
        s1,s2 = s1.split('\"'),s2.split('\"')
        if len(s1) != len(s2):
            print('DIFFERENT')
        else:
            L = len(s1)
            cnt = 0
            for i in range(L):
                d1,d2 = s1[i],s2[i]
                if i%2 == 0:
                    if d1 != d2:
                        print('DIFFERENT')
                        break
                elif i%2 == 1:
                    if d1 != d2:
                        cnt += 1
            else:
                if cnt == 0:
                    print('IDENTICAL')
                elif cnt == 1:
                    print('CLOSE')
                else:
                    print('DIFFERENT')



Measured memory_bytes: 7144
H,W,N = map(int, input().split())

field = {}
for i in range(N):
    a,b = map(int, input().split())
    a,b = a-1,b-1
    for j in range(a-1, a+2):
        for k in range(b-1, b+2):
            if not field.get(j):
                field[j] = {}
            if not field[j].get(k):
                field[j][k] = 0
            field[j][k] += 1

ans = [0] * 10
for kh in field.keys():
    for kw in field[kh].keys():
        if 1 <= kh <= H-2 and 1 <= kw <= W-2:
            ans[field[kh][kw]] += 1

tmp = (H-2)*(W-2)
for i in range(1,10):
    tmp -= ans[i]

ans[0] = tmp
for i in range(10):
    print(ans[i])



Measured memory_bytes: 142792
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let s = get!(String).chars().collect::<Vec<_>>();
    for i in 0..s.len()-1 {
        if s[i] == s[i+1] {
            println!("Bad");
            return;
        } 
    }
    println!("Good");
}


Measured memory_bytes: 8572
/*
 * author :Sadik Hassan
 *
*/
#include "bits/stdc++.h"
using namespace std;
using   ll =          long long;
#define nl            "\n"
#define pb            push_back
#define fi            first
#define se            second
#define PI            (acos(-1.0))
#define repp(i,a,n)   for(int i=a;i<n;i++)
#define rep(i,n)      for(int i=0;i<n;i++)
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
#define w(t)          int t;cin>>t;while(t--)
#define TSFL(s)       transform(s.begin(),s.end(),s.begin(),::toupper);
#define TSFH(s)       transform(s.begin(),s.end(),s.begin(),::tolower);
#define _SAD()     	  ios::sync_with_stdio(0),cin.tie(0),cout.tie(0),cout<<fixed<<setprecision(15);
typedef vector<int> vi;
typedef vector<ll> vii;
typedef set<int> si;
typedef set<ll> sii;
/*---------------------------------------------------------------------*/

const int N = 2e5+5;
const int MOD =(int)1e9+7;
const int INF = (int)1e9+5;

int main()
{
    _SAD()
    int n;
    cin>>n;
    vi aa(1e6+100,0),a(n);
    rep(i,n)cin>>a[i];
    VSRT(a);
    int gu=0;
    rep(i,n)
    {
        bool fl=1;
        if(i+1<n&&a[i]==a[i+1])fl=0;
        if(aa[a[i]]==1)continue;
            for(int j=a[i];j<=1e6;j+=a[i])
            {
                aa[j]=1;
            }
        if(fl)gu++;
    }
    cout<<gu<<nl;
    return 0;
}


Measured memory_bytes: 7952
def search_rolling_hash(S, T):
    base = 1234
    mod = 10**9+7
    n, m = len(S), len(T)
    rolling_hash = [0]*(n-m+1)  
    rolling_hash[0] = ord(S[0])
    b_m = pow(base, m, mod)
    T_hash = ord(T[0])
    start_index = []
    for i in range(1, m):
        rolling_hash[0]*=base
        rolling_hash[0]+=ord(S[i])
        rolling_hash[0]%=mod
        T_hash = (T_hash*base+ord(T[i]))%mod
    if rolling_hash[0] == T_hash: start_index.append(0)
    for i in range(1, ls):
        rolling_hash[i] = (rolling_hash[i-1]*base-ord(S[i-1])*b_m+ord(S[i+m-1]))%mod
        if rolling_hash[i] == T_hash: start_index.append(i)
    return start_index
import sys
s = input()
t = input()
ls, lt = len(s), len(t)
S = s*(lt//ls+2)
index = search_rolling_hash(S, t)
flag = [False]*ls
for i in index:
    flag[i] = True
stack = []
inf = float('inf')
cnt = [inf]*ls
for i in range(ls):
    if flag[i] == False:
        stack.append(i)
        cnt[i] = 0
while stack:
    x = stack.pop()
    y = (x-lt)%ls
    if cnt[y] == inf:
        cnt[y] = cnt[x]+1
        stack.append(y)
ans = max(cnt)
if ans == inf:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 115204
#include <bits/stdc++.h>
using namespace std;
int n,k,x,y,ans;
int main() {
    scanf("%d %d %d %d",&n,&k,&x,&y);
    for (int i=0;i<min(n,k);i++) {
        ans+=x;
    }
    for (int i=0;i<n-k;i++) {
        ans+=y;
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;

public class Main { 
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] a = new int[N];
    int[] b = new int[N];
    int[] c = new int[N];
    int[] d = new int[N];
    int[] aa = new int[N];
    int[] cc = new int[N];
    int count =0;
    for (int i =0; i<N; i++) {
      a[i] = sc.nextInt();
      b[i] = sc.nextInt();
      aa[i] = a[i] + b[i] * 1000;
    }
    Arrays.sort(aa); //bでソートした配列、下3桁はaの情報
    for (int i =0; i<N; i++) {
      a[i] = aa[i] % 1000;
      b[i] = aa[i] / 1000;
    }
    for (int i =0; i<N; i++) {
      c[i] = sc.nextInt();
      d[i] = sc.nextInt();
      cc[i] = c[i] * 1000 + d[i];
    }
    Arrays.sort(cc);
    for (int i =0; i<N; i++) {
      c[i] = cc[i] / 1000;
      d[i] = cc[i] % 1000;
    }
    L:for (int i =0; i<N; i++) {
      for (int j =N-1; j>=0; j--) {
        if (c[i] > a[j] && d[i] > b[j]) {
          count++;
          a[j] = 201;
          b[j] = 201;
          continue L;
        }
      }
    }
    System.out.println(count);
  }
}    

Measured memory_bytes: 36452
package main

import "fmt"

func main() {
	var x, ans int
	fmt.Scan(&x)
	ans = 2 * (x / 11)
	if x%11 > 6 {
		ans += 2
	} else if x%11 != 0 {
		ans++
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512