akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 100005
#define endl "\n"
#define mod 1000000007
#define PI 3.141592653589793
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
ll n,k; ll ar[105],dp[105][N];
ll findans(ll i,ll cur_k){
	if(cur_k<0) return 0;
	if(cur_k==0) return 1;
	if(i==n+1) return 0;

	if(dp[i][cur_k]!=-1){
		return dp[i][cur_k];
	}
	ll a,b;
	a=(findans(i+1,cur_k)-findans(i+1,cur_k-min(cur_k,ar[i])-1)+mod)%mod;
	b=findans(i,cur_k-1)%mod;
	return dp[i][cur_k]=(a+b)%mod;
}
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,l;
	cin>>n>>k;
	for(i=1;i<=n;i++){
		cin>>ar[i];
	}
	memset(dp,-1,sizeof(dp));
	ll an=findans(1,k);
	cout<<an;
	return 0;
}

Measured memory_bytes: 91924
#include <stdio.h>
int main(void){
	int i,a,n,max,min;
	long int sum;
	scanf("%d",&n);
	scanf("%d ",&a);
	max=a;
	min=a;
	sum=a;
	for(i=1;i<n;i++){
		int b;
		scanf("%d ",&b);
		if(max<b)max=b;
		if(min>b)min=b;
		sum=sum+b;
	}
	printf("%d %d %ld\n",min,max,sum);
}

Measured memory_bytes: 1860
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> A(N),B(N),C(N - 1);
  for (int i = 0; i < N; i++) cin >> A[i];
  for (int i = 0; i < N; i++) cin >> B[i];
  for (int i = 0; i < N - 1; i++) cin >> C[i];
  int ans = 0;
  for (int i = 0; i < N; i++){
    ans += B[A[i] - 1];
    if (i > 0){
      if (A[i - 1] + 1 == A[i]) ans += C[A[i - 1] - 1];
    }
  }
  cout << ans;
}

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

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

int main() {

  ll A,B,K;
  cin >> A >> B >> K;

  ll rem=0;
  if (A < K) { 
    rem = K - A;
    A = 0;
  }
  else {
    A = A - K;
  }
  B = B - rem;
  if (B < 0){
    B = 0;
  }
  
  cout << A << ' ' << B << endl;

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> void pr_vec(vector<T> &v, char ep=' '){int n=v.size();REP(ni,n){cout<<v[ni];if(ni!=n-1)cout<<ep;}cout<<endl;};
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    ll N,M,K;
    cin >> N >> M >> K;
    vector<ll> A(N), B(M);
    REP(i,N) cin >> A[i];
    REP(i,M) cin >> B[i];
    Rep(i,1,N) A[i] += A[i-1];
    Rep(i,1,M) B[i] += B[i-1];

    ll ans = 0;
    REP(i, N){
        if(A[i]>K){
            chmax(ans, (ll)i);
            break;
        }
        int j = upper_bound(ALL(B), K-A[i])-B.begin();
        chmax(ans,(ll)i+j+1);
    }
    REP(i, M){
        if(B[i]>K){
            chmax(ans, (ll)i);
            break;
        }
        int j = upper_bound(ALL(A), K-B[i])-A.begin();
        chmax(ans,(ll)i+j+1);
    }
    pr(ans);
}

Measured memory_bytes: 6356
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
const int N = 1e5+5;
int a[N];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	int cnt=0;
	int temp=0;
	for(int i=1;i<n;i++)
	{
		if(a[i]==i)
		{
			temp=a[i];
			a[i]=a[i+1];
			a[i+1]=temp;
			i++;
			cnt++;
		}
	}
	if(a[n]==n)
	cnt++;
	cout<<cnt<<endl; 
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;++i)

string s;
vector<int> eval(3);
map<char,function<int(int,int)>> op;

int solve(int &i){
  if(isdigit(s[i])){
    return s[i++] - '0';
    
  }else if('P' <= s[i] and s[i] <= 'R'){
    return eval[s[i++] - 'P'];
    
  }else if(s[i] == '-'){
    i++; // '-'
    return  2 - solve(i);

  }else if(s[i] == '('){
    i++; // '('
    int l = solve(i);
    
    // '+' or '*'
    char m = s[i];
    assert(op.count(m));
    i++;

    int r = solve(i);
    i++; // ')'
    
    return op[m](l,r);
  }
  assert(false);
}

int rec(int depth){
  if(depth == 3){
    int index = 0;
    return solve(index) == 2;
  }
  int res = 0;
  rep(i,3){
    eval[depth] = i;
    res += rec(depth+1);
  }
  return res;
}

int main(void){
  op['+'] = [](int x,int y){
    if(x == 2 or y == 2) return 2;
    else if(x == 1 or y == 1) return 1;
    else return 0;
  };
  op['*'] = [](int x,int y){
    if(x == 0 or y == 0) return 0;
    else if(x == 1 or y == 1) return 1;
    else return 2;
  };
  
  while(cin >> s, s != "."){
    int res = rec(0);
    cout << res << endl;
  }
}


Measured memory_bytes: 3156
#include<iostream>
#include<algorithm>
using namespace std;
double a[55];
int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	sort(a + 1, a + n + 1,less<int>());
	for (int i = 1; i < n; i++) {
		a[i + 1] = (a[i] + a[i + 1]) / 2;
	}
	cout << a[n];
	return 0;
}

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

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

	char N[3];
	cin >> N;
	if (N[0]=='7' || N[1]=='7' || N[2]=='7')
	{
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
}


Measured memory_bytes: 3612
#include<stdio.h>
#include<string.h>
char a[110][110];
int main()
{
	int n,l,i,j;
	char t[110];
	while(~scanf("%d%d",&n,&l))
	{
		for(i=0;i<n;i++)
		    scanf("%s",a[i]);
		for(i=0;i<n-1;i++)
		for(j=0;j<n-1-i;j++)
		{
			if(strcmp(a[j],a[j+1])>0)
			{
				strcpy(t,a[j]);
				strcpy(a[j],a[j+1]);
				strcpy(a[j+1],t);
			}
		}
		for(i=0;i<n;i++)
		    printf("%s",a[i]);
		printf("\n");	    
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main() {
    int n;
    cin >> n;
    vector< vector<int>> table(2,vector<int>(n,0));
    rep(i,2)rep(j,n)cin >> table[i][j];
    int ans = 0;
    rep(i,n){//下に降りる場所を探す
        int candy = 0;
        rep(j,i+1)candy += table[0][j];//左上から降りるところまで右に拾いながら行く
        for(int j = i;j<n;j++)candy += table[1][j];
        ans = max(ans,candy);
    }
    cout << ans << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  if(s.find("AC")<=s.size()) cout<<"Yes"<<'\n';
  else cout<<"No"<<'\n';
  return 0;
}


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

int dp[11][11];

int main(){
    int n,m,tmp;
    long long ans=0;
    scanf("%d %d",&n,&m);
    for(int i=0;i<10;i++)
    for(int j=0;j<10;j++)
    scanf("%d",&dp[i][j]);

    for(int k=0;k<10;k++)
    for(int i=0;i<10;i++)
    for(int j=0;j<10;j++)
    dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);

    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cin>>tmp;
            if(tmp!=-1) ans+=dp[tmp][1];
        }
    }

    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    double a, b, C, S, x, h;
    double PI = acos(-1);
    scanf("%lf%lf%lf", &a, &b, &C);
    C *= PI/180.0;
    
    S = a*b*sin(C)*0.5;
    x = sqrt(pow(b-a*cos(C), 2.0) + pow(a*sin(C), 2.0));
    h = b*sin(C);
    
    printf("%lf\n%lf\n%lf\n", S, a+b+x, h);
    return 0;
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
#define X first
#define Y second
#define pb push_back
#define pii pair<int, int>
typedef long long ll;
using namespace std;

const int MOD = 1e9 + 7;
const ll INF = 1e18;
const int OFF = (1 << 20);

int n;
ll a, b;

int main () {

	cin >> n;
	ll sol = 0;
	for (int i = 1; i <= n; i++) {
		ll tren = n-i+1;
		tren *= i;
		sol += tren;
	}
	
	for (int i = 0; i < n-1; i++) {
		cin >> a >> b;
		if (a > b) swap(a, b);
		ll tren = n-b+1;
		tren *= a;
		sol -= tren;
	}
	
	cout << sol;

	return 0;
}

Measured memory_bytes: 3548
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N,K=map(int,input().split())
    ans=0
    for i in range(K,N+2):
        ans+=(N*2-i+1)*i//2-i*(i-1)//2+1
        ans%=MOD
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 63328
n=int(input())
p=[int(i) for i in input().split()]
n1=[i for i in range(1,n+1)]
for i in range(n):
  for k in range(n):
    n1[i],n1[k]=n1[k],n1[i]
    if n1==p:
      print('YES')
      exit()
    n1=[i for i in range(1,n+1)]
else:
  print('NO')
    
 


Measured memory_bytes: 3060
#include<iostream>
#include <list>
#include<stack>
#include<queue>
#include <vector>
#include <set>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include <functional>
#include<fstream>

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define LL long long
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl
using namespace std;

const LL MOD = 1000000007;// 10^9+7
const int INF = (1 << 30);


//変数
int N;
vector<LL> a;






//サブ関数
//入力
void input()
{
	cin >> N;
	a.resize(N);
	REP(i, N)cin >> a[i];
}


bool all_not_positive(const vector<LL>& a)
{
	auto positive_itr = find_if(a.begin(), a.end(),
		[](const LL& num) {return num > 0; 
	});
	return positive_itr == a.end();
}

void find_best_set(const vector<LL>& a, vector<int>& bestWay, LL& highScore, int start)
{
	LL s = 0;
	vector<int> way;

	for (; start < N; start += 2) {
		if (a[start] > 0) {
			s += a[start];
			way.push_back(start);
		}

		if (s > highScore) {
			highScore = s;
			bestWay = way;
		}
	}
}

//計算
void calc()
{
	LL res = 0;
	vector<int> way, use;

	//exception
	if (all_not_positive(a)) {
		res = *max_element(a.begin(), a.end());
		int id = find(a.begin(), a.end(), res) - a.begin();
		reverse(a.begin(), a.end());
		REP(i, id) {
			way.push_back(0);
			a.pop_back();
		}
		reverse(a.begin(), a.end());

		while(a.size()>1){
			way.push_back(a.size() - 1);
			a.pop_back();
		}
		goto last;
	}
		

	//normal
	REP(i, N)find_best_set(a, use, res, i);


	REP(i, use[0]) {
		way.push_back(0);
		a.pop_back();
	}
	REP(i, use.size() - 1) {
		int del = use[i + 1] - use[i];
		del /= 2;
		del--;
		REP(j, del) {
			way.push_back(2);
			a.pop_back();
			a.pop_back();
		}
		way.push_back(1);
		a.pop_back();
		a.pop_back();
	}
	while (a.size() > 1) {
		way.push_back(a.size() - 1);
		a.pop_back();
	}
	

last:;
	cout << res << endl << way.size() << endl;
	for (auto num : way) {
		cout << num + 1 << endl;
	}
}


//出力
void output()
{

}


//デバッグ
void debug()
{
	int N;
	cin>>N;
}


//メイン関数
int main()
{
	input();
	calc();
	output();
	debug();
	
	return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
int change(int *a,int n)
{
	int flag=1;
	for(int i=0;i<n-1;i++)
	{
		if(a[i+1]<a[i])
		{
			flag=0;
			break;
		}
	}
	return flag;
}
int main()
{
	int n;
	scanf("%d",&n);
	int a[n];
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	int v = change(a,n);
	if(v)printf("YES\n");
	else
	{
		int k=0;
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<n;j++)
			{
				if(i!=j)
				{
					swap(a[i],a[j]);
					int f = change(a,n);
					if(f)
					{
						printf("YES\n");
						k=1;
						break;
					}
					swap(a[i],a[j]);
				}
			}
		}
		if(k==0)printf("NO\n");
	}
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var S string
	var I int
	fmt.Scanf("%d\n%s\n", &I, &S)
	r := []rune(S)
	cnt := 0
	for i := 1; i < len(r)-1; i++ {
		if string(r[i-1]) != "A" {
			continue
		}
		if string(r[i]) != "B" {
			continue
		}
		if string(r[i+1]) != "C" {
			continue
		}
		cnt++
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
double pi = 3.141592653589793238;
int main(){
    int A , B ,H ,M;
    cin >> A >> B >> H >> M;
    double a ,b;
    a = pi*H /6 + M*pi /360;
    b = pi*M /30;
    double x = cos(max(a ,b) - min(a ,b));
    cout << fixed << setprecision(10);

    cout << sqrt(A*A + B*B - 2*A*B*x) <<endl;
}


Measured memory_bytes: 4248
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <utility>
#include <set>
#include <unordered_set>
#include <stack>
#include <iterator>
#include <random>
#include <fstream>
#include <chrono>
using namespace std;
#define int long long
int32_t main() {
    ios_base::sync_with_stdio(0);
    int n;
    int k;
    cin >> n >> k;
    vector<int>h(n);
    for(int i = 0; i < n;++i)
        cin >> h[i];
    sort(h.begin(),h.end());
    if(k >= n)
        cout << 0 << "\n";
    else {
        int ans = 0;
        for (int i = 0; i < n - k; i++)
            ans += h[i];
        cout << ans << "\n";
    }
    return 0;
}

Measured memory_bytes: 2168
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int main(void) {
    string s;
    cin >> s;
    const int L = s.length();
    LL ans = 1ll * L * (L + 1) / 2;
    VI cnt(26, 0);
    REP(i, s.size()) {
        cnt[s[i] - 'a']++;
        ans -= cnt[s[i] - 'a'];
    }
    cout << ans + 1 << endl;
}


Measured memory_bytes: 640
N ,K = map(int,input().split())
D = [int(n) for n in input().split()]

flag = False

for i in range(N,100000):
    N = i
    while i > 0:
        flag = True
        if i%10 in D:
            flag = False
            break
        else:
            i //=10

    if flag == True:
        print(N)
        break


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

int main(void) {
    string S, T, U;
    int A, B;
    cin >> S >> T >> A >> B >> U;
    if(U == S) {
        cout << A-1 << ' ' << B << endl;
    } else {
        cout << A << ' ' << B-1 << endl;
    }
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main()
{
  string S;
  cin >> S;
  string T = "keyence";
  int N = S.length();
  REP1(i, N)
  {
    for (int j = i; j < N; j++)
    {
      string tmp = S.substr(0, i) + S.substr(j, N - j);
      if (tmp == T)
      {
        cout << "YES" << endl;
        return 0;
      }
    }
  }
  cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int x,y,i,j,tmp;
	scanf("%d %d",&x,&y);
	if(x<y){
		tmp = x;
		x = y;
		y = tmp;
	}
	while((tmp = x%y) !=0 ){
		x = y;
		y = tmp;
	}
	printf("%d\n",y);
	return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std ;
#define An setprecision(16) 
int main(){
    int X;
    cin >> X;
    int Ans=0;
    if(X<100)Ans = 0;
    else if(2000<=X)Ans =1;
    else{
        for(int a=0;a<20;a++){
            for(int b=0;b<20;b++){
                for(int c=0;c<20;c++){
                    for(int d=0;d<20;d++){
                        for(int e=0;e<20;e++){
                            for(int f=0;f<20;f++){
                                int A = 100*a+101*b+102*c+103*d + 104*e + 105*f;
                                if(A==X)Ans =1;
                            }
                        }
                    }
                }
            }
        }
        
    }
    cout << Ans << endl;
}

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

int main(){
	char b;
	cin >> b;
	if(b == 'A') cout << 'T' << endl;
	else if(b == 'T') cout << 'A' << endl;
	else if(b == 'C') cout << 'G' << endl;
	else cout << 'C' << endl;
}

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

void solve () {
    int n;
    cin >> n;
    vector<pair<int, int>> a(n);
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        a[i] = {x, i};
    }
    sort(a.begin(), a.end());
    for (auto p : a) {
        cout << p.second + 1 << " ";
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    solve();
    return 0;
}


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

int main(void) {
    int n, a;
    cin >> n >> a;
    for (int i = 0; n >= 500; i++) {
        n = n % 500;  
    }
    if (n - a <= 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll, ll> pll;
//int dx[4] = { 1,0,0,-1 };
//int dy[4] = { 0,1,-1,0 };
#define MOD 1000000007
#define ARRAY_MAX 1005

const int INF = 1e9 + 7;


int main(){


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

	int n;
	cin >> n;
	vector<pii> v;

	for (int i = 0; i < n; i++)
	{
		int a;
		cin >> a;
		v.push_back(pii(a, 1));
	}

	for (int i = 0; i < n; i++)
	{
		int b;
		cin >> b;
		v.push_back(pii(b, -1));
	}

	sort(v.begin(), v.end());

	int cnt = 0;
	ll ans = 1LL;

	for (int i = 0; i < 2*n; i++)
	{
		if (v[i].second == 1)
		{
			//PC
			if (cnt >= 0)
			{
				cnt++;
			}
			else
			{
				ans = (ans*ll(-cnt))%MOD;
				cnt++;
			}
		}
		else
		{
			//電源
			if (cnt <= 0)
			{
				cnt--;
			}
			else
			{
				ans = (ans*ll(cnt)) % MOD;
				cnt--;
			}
		}
	}
	cout << ans << endl;

	return 0;
}


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

#define ALL(a) (a).begin(), (a).end()
#define int long long
const int INF = 100100100100100;

using namespace std;

vector<int> divisors(int n){
	vector<int> res;
	for(int i = 1; i * i <= n; ++i){
		if(n % i != 0) continue;
		res.push_back(i);
		if(n / i == i) continue;
		res.push_back(n/i);
	}

	return res;
}

int f1(string s){
	int ret = INF;
	int n = (int)s.size();
	if(n == 2) return ret;
	vector<vector<int>> dp(n + 1, vector<int> (100, INF));
	dp[0][0] = INF - 1;
	for(int i = 0; i < n; i++){
		for(int curMa = 0; curMa < 100; curMa++){
			if(dp[i][curMa] == INF) continue;
			int curMi = dp[i][curMa];
			// ひとけたきる
			
			int val1 = stoi(s.substr(i, 1));
			//cout << i << " " << curMa << " " << curMi << " " << val1 << endl;
			int nxtMi = min(curMi, val1);
			int nxtMa = max(curMa, val1);
			//cout << nxtMi << " " << nxtMa << endl;
			//cout << i << "  from " << curMi << " " << curMa << " to " << nxtMi << " " << nxtMa << endl; 

			dp[i + 1][nxtMa] = min(dp[i + 1][nxtMa], nxtMi);

			if(i != n - 1){
				int val2;
				if(i != n - 1) val2 = stoi(s.substr(i, 2));
				nxtMi = min(curMi, val2);
				nxtMa = max(curMa, val2);
				dp[i + 2][nxtMa] = min(dp[i + 1][nxtMa], nxtMi);
				//cout << i << " " << i + 2 << "  from " << curMi << " " << curMa << " to " << nxtMi << " " << nxtMa << endl; 
			}
		}
	}
	
	/*
	for(int i = 0; i <= n; i++){
		for(int j = 0; j < 15; j++){
			cout << dp[i][j] << " ";
		}
		cout << endl;
	}
	cout << endl;
	*/

	
	for(int j = 0; j < 100; j++){
		if(dp[n][j] == INF) continue;
		//cout << "hoge " << j << " " << dp[n][j] << endl;
		ret = min(ret, j - dp[n][j]);
	}
	return ret;
}


int f2(string s){

	int ret = INF;
	int n = (int)s.size();
	auto div = divisors(n);

	for(auto i : div){
		if(i == n) continue;

		bool flag = true;
		if(i > 2){
			for(int j = 0; j < i - 2; j++){
				for(int k = 1; k < n / i; k++){
					int cur = (k - 1) * i + j;
					int nxt = k * i + j;
					if(s[cur] != s[nxt]){
						flag = false;
						break;
					}
				}
				if(!flag) break;
			}
		}

		if(!flag) continue;
		int mi = INF;
		int ma = 0;
		for(int j = 0; j < n; j += i){
			int idx = j;
			int getlen = i;
			if(i > 2){
				idx = j - 2 + i;
				getlen = 2;	
			}
			int val = stoi(s.substr(idx, getlen));
			mi = min(mi, val);
			ma = max(ma, val);
		}
		ret = min(ret, ma - mi);
	}

	return ret;
}


signed main(){
	
	string s; cin >> s;
	int ans = f1(s);
	ans = min(ans, f2(s));
	cout << ans << endl;

	return 0;
}




Measured memory_bytes: 84988
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		String s = scn.next();
		int w = scn.nextInt();
      	String[] list = s.split("");
      	String ans = "";
      	for(int i=0; i<s.length(); i+=w){
          ans = ans + list[i];
        }
      	System.out.println(ans);
	}
}


Measured memory_bytes: 39352
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
#define tpl(...) make_tuple(__VA_ARGS__)
const int INF = 0x3f3f3f3f;
const double EPS = 1e-8;
const double PI = acos(-1);
typedef long long ll;
typedef pair<int,int> pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T>ostream&operator<<(ostream &o,const vector<T>&t){o<<'[';FOR(i,t){if(i!=t.begin())o<<',';o<<*i;}return o<<']';}
template<class S,class T>ostream&operator<<(ostream &o,const pair<S,T>&t){return o<<'('<<t.first<<','<<t.second<<')';}
template<int N,class Tp>void out(ostream&,const Tp&){}
template<int N,class Tp,class,class ...Ts>void out(ostream &o,const Tp&t){if(N)o<<',';o<<get<N>(t);out<N+1,Tp,Ts...>(o,t);}
template<class ...Ts>ostream&operator<<(ostream&o,const tuple<Ts...>&t){o<<'(';out<0,tuple<Ts...>,Ts...>(o,t);return o<<')';}
template<class T>void output(T *a,int n){REP(i,n){if(i)cout<<',';cout<<a[i];}cout<<endl;}
template<class T>void output(T *a,int n,int m){REP(i,n)output(a[i],m);}
template<class T>void output(T t){if(t<0)t=-t,putchar(45);static int c[20];
int k=0;while(t)c[k++]=t%10,t/=10;for(k||(c[k++]=0);k;putchar(c[--k]^48));}
template<class S,class ...T>void output(S a,T...t){output(a);putchar(' ');output(t...);}
template<class T>bool input(T &t){int n=1,c;for(t=0;!isdigit(c=getchar())&&~c&&c-45;);
if(!~c)return 0;for(c-45&&(n=0,t=c^48);isdigit(c=getchar());t=10*t+c-48);t=n?-t:t;return 1;}
template<class S,class ...T>bool input(S&a,T&...t){input(a);return input(t...);}

ll rev(ll x) {
  ll r=0;
  for (;x;x/=10) r=r*10+x%10;
  return r;
}
ll pow10(int p) {
  ll r = 1;
  REP(i,p)r*=10;
  return r;
}
bool check_prime(ll x) {
  for (ll i=2; i*i<=x; ++i) {
    if (x%i == 0) return 0;
  }
  return 1;
}
int main() {
  int n,c;
  while(cin>>n>>c) {
    if (c < 0) {
      if (n == 1) cout << 11 << endl;
      else cout << string(2*n,'9') << endl;
    } else {
      int start = 0;
      REP(i,n) start = 10*start + 9;
      for (int i=start; i>=0; --i) {
        ll x = i*pow10(n+1) + c*pow10(n) + rev(i);
        if (check_prime(x)) {
          cout << x << endl;
          break;
        }
      }
    }
  }
}

Measured memory_bytes: 1196
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <limits.h>
#include <cstring>
#include <tuple>
#include <cassert>
#include <numeric>
using namespace std;
// type alias
typedef long long LL;
typedef vector < int > VI;
typedef unordered_map < int, int > MAPII;
typedef unordered_set < int > SETI;
typedef pair< int , int > II;
typedef tuple< int, int, int > III;
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// minmax
#define SMAX(a,b) a = max(a,b)
#define SMIN(a,b) a = min(a,b)
// debug cerr
#define TRACE true
#define dump(x) if(TRACE) { cerr << #x << " = " << (x) << endl; }
#define dump2(x,y) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << endl; }
#define dump3(x,y,z) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << endl; }
#define dump4(x,y,z,a) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << ", " << #a << " = " << (a) << endl; }
#define dumpAR(ar) if(TRACE) { FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }

/*
 
 8/22/2018
 
 21:56-22:16 analysis
 22:28 1WA
 
 */

// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG x.cpp && ./a.out
const int MAX_N=5e2+1;
const int MAX_M=2e5+1;
int N,M,Q;
int L[MAX_M],R[MAX_M];
int P1[MAX_M],P2[MAX_M];
LL mx[MAX_N][MAX_N];
void solve() {
  ZERO(mx);
  REP(i,M) {
    int l=L[i],r=R[i];
    mx[0][r]+=1,mx[0][N]-=1,mx[l+1][r]-=1,mx[l+1][N]+=1;
  }
  
  /*
  REPE(i,N) {
    REPE(j,N) cout<<mx[i][j]<<" ";
    cout<<endl;
  }*/
  
  REPE(i,N) REP(j,N) mx[i][j+1]+=mx[i][j];
  REPE(j,N) REP(i,N) mx[i+1][j]+=mx[i][j];
  /*
  REPE(i,N) {
    REPE(j,N) cout<<mx[i][j]<<" ";
    cout<<endl;
  }*/
  
  REP(i,Q) {
    int l=P1[i],r=P2[i];
    cout<<mx[l][r]<<endl;
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  cin>>N>>M>>Q;
  REP(i,M) {
    cin>>L[i]>>R[i];
    L[i]--,R[i]--;
  }
  REP(i,Q) {
    cin>>P1[i]>>P2[i];
    P1[i]--,P2[i]--;
  }
  solve();
  return 0;
}


Measured memory_bytes: 5888
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<string>
#include<iterator>
#include<cmath>
using namespace std;

int main()
{
    int N, i, count = 0;
    long double D, x, y;
    cin>>N>>D;
    for(i=0;i<N;i+=1)
    {
        cin>>x>>y;
        if(pow(x*x+y*y, 0.5)<=D)
        {
            count+=1;
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 3840
#include<stdio.h>
#include<limits.h>
#define MM 1000000007
#define ll unsigned long long
int main(){
	ll all=0,i,n,k;
	scanf("%llu%llu",&n,&k);
	for(i=k;i<=n+1;++i){
		unsigned int temp=i*(n-i+1)%MM;
		all%=MM;
		all=all+temp+1;
	}
	printf("%llu",all%MM);
	return 0;
}

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

int main(){
	
	double max=-1,min=-1,n;
	
	while(scanf("%lf",&n)!=EOF){
		if(n>max||max==-1){
			max=n;
		}
		if(n<min||min==-1){
			min=n;
		}
	}
	
	cout<<max-min<<endl;
}

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

typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;

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

    int ans(0);
    rep(i,n){
        int x;  cin >> x;
        if((i+1)%2==1 && x%2==1){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <cmath>
using namespace std;
 
int main(void){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if(b < c || d < a){
        cout << "0" << endl;
        return 0;
    }
    int s, g;
    if(a <= c){
        s = c;
    }else{
        s = a;
    }
    if(b <= d){
        g = b;
    }else{
        g = d;
    }
    cout << g-s << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	string word;
    cin >> word;
  	if (word[2] == word[3] && word[4] == word[5]) {
    	cout << "Yes" << endl;
    }
  	else {
    	cout << "No" << endl;
    }
      
	return 0;
}

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

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

using namespace std;
typedef long long ll;

int dp[5005][5005];

int main(int argc, const char * argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    
    string s;
    cin >> s;
    
    for (int i = n - 1; i >= 0; --i)
    {
        for (int j = n - 1; j >= 0; --j)
        {
            if (s[i] != s[j]) dp[i][j] = 0;
            else dp[i][j] = dp[i + 1][j + 1] + 1; //範囲外なっても範囲を余分に0でとってるし問題なし。
        }
    }
    
    int ans = 0;
    
    rep(i,n)rep(j,n)
    {
        if (i >= j) continue;
        // j-1より大きい値だと重なりが起きて答えの条件を満たさない
        int current = min(dp[i][j], j-i);
        ans = max(ans, current);
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 98048
import java.util.Scanner;
class Main {
    public static void main(String[] args) {
       Scanner sc = new Scanner(System.in);
       String a=sc.next();
       String b=sc.next();
       String c=sc.next();
       String ans="";
       ans+=a.charAt(0);
       ans+=b.charAt(0);
       ans+=c.charAt(0);
       System.out.println(ans.toUpperCase());
       
 }
 }          

Measured memory_bytes: 21716
#include<iostream>
using namespace std;
int main()
{
int n;
cin >> n;
int i=0;
if(n<=1){
cout << 1;
}
else if(2<=n&&n<=3){
cout << 2;
}
else if(4<=n&&n<=7){
cout << 4;
}
else if(8<=n&&n<=15){
cout << 8;
}
else if(16<=n&&n<=31){
cout << 16;
}
else if(32<=n&&n<=63){
cout << 32;
}
else {
cout << 64;
}
return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  double a,b,c,d,e,f,x,y;
  while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f)!=EOF){
    if(a*e!=b*d&&b!=0){
      x=(double)(c*e-b*f)/(a*e-b*d);
      y=(double)(c-a*x)/b;
    }
    else{
      y=(double)(c*d-a*f)/(b*d-a*e);
      x=(double)(c-b*d)/a;
    }
    if(x==0)x=0;
    if(y==0)y=0;
    printf("%.3f %.3f\n",x,y);
  }
  return 0;
}

Measured memory_bytes: 652
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = 350000;
const int K = 19;
int n, q;
int mod =  1e9 + 7;
int s1[N], s2[N], a[N], ans[N], f[N], invf[N];
string t[N], d[N], s;
int binpow(int x, int y){
    if (y == 0) return 1;
    if (y % 2) return x * binpow(x, y - 1) % mod;
    int z = binpow(x, y / 2);
    return z * z % mod;
}
int c(int n, int k){
    if (k < 0) return 0;
    return f[n] * invf[k] % mod * invf[n - k] % mod;
}
int check (int x){
    for (int i = 1; i <= q; i++){
        if (s[x - 1] == t[i][0]){
            if (d[i] == "L"){
                if (x == 1) return -1;
                x--;
            } else{
                if (x == n) return 1;
                x++;
            }
        }
    }
    return 0;
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int k, a, b;
    cin >> k >> a >> b;
    if (b <= a + 2){
        cout << k + 1;
        return 0;
    }
    int c = 1;
    int x = a - c;
    if (x + 2 > k){
        cout << k + 1;
        return 0;
    }
    k -= x;
    k -= 2;
    c = b;
    cout << c + (b - a) * (k / 2) + k % 2;
}


Measured memory_bytes: 6400
s = input()
S = s.count("S")
E = s.count("E")
N = s.count("N")
W = s.count("W")
if S > 0 and N > 0 or S == 0 and N == 0:
    if E > 0 and W > 0 or E == 0 and W == 0:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define N 100010
#define ll long long
int f[N];
int get_fa(int x)
{
    return f[x]==x?x:f[x]=get_fa(f[x]);
}
int main()
{
    int n,m,x,y,z;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)f[i]=i;
    for(int i=1;i<=m;i++)
    {
        scanf("%d%d%d",&x,&y,&z);
        int fx=get_fa(x),fy=get_fa(y);
        if(fx!=fy)
            f[fy]=fx;
    }
    int cnt=0;
    for(int i=1;i<=n;i++)
        if(f[i]==i)cnt++;
    cout<<cnt;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
string s[2];
int n;
const int mod = 1000000007;

int main (int argc, char const* argv[])
{	
	cin >> n;
	cin >> s[0] >> s[1];
	
	int cur = 0;
	long long ans = 1;
	int last = -1;
	while(cur < n) {
		if(s[0][cur] == s[1][cur]) {
			if(last == -1) ans *= 3;
			else if (last == 0) ans *= 2;
			else ans *= 1;
			cur += 1;
			last = 0;
		} else {
			if(last == -1) ans *= 6;
			else if (last == 0) ans *= 2;
			else ans *= 3;
			cur += 2;
			last = 1;
		}
		ans %= mod;
	}
	printf("%lld\n", ans);
	return 0;
}


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

L=[[10**10,0]]
for i in range(N):
    L.append([A[i],i])
L.sort(reverse=True)
#print(L)
DP=[[0 for i in range(N+1)]for j in range(N+1)]
#j=右に押し込んだ数
for i in range(1,N+1):
    for j in range(i+1):
        if j==0:
            DP[i][j]=DP[i-1][j]+L[i][0]*abs(L[i][1]-(i-1))
            #print(DP,DP[i-1][j]+L[i][0]*abs(L[i][1]-(i-1)))
        elif j==i:
            DP[i][j]=DP[i-1][j-1]+L[i][0]*abs(L[i][1]-(N-j))
            #print(DP,DP[i-1][j-1]+L[i][0]*abs(L[i][1]-(N-j)))
        else:
            DP[i][j]=max(DP[i-1][j]+L[i][0]*abs(L[i][1]-(i-1-j)),DP[i-1][j-1]+L[i][0]*abs(L[i][1]-(N-j)))
            #print(DP,DP[i-1][j]+L[i][0]*abs(L[i][1]-(i-1-j)),DP[i-1][j-1]+L[i][0]*abs(L[i][1]-(N-j)))
print(max(DP[-1]))

Measured memory_bytes: 101696
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const long long mod = 1000000007;
const long long inf = 1e18;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin>>n;
    if(n>=64)
        cout<<64<<endl;
    else if(n>=32)
        cout<<32<<endl;
    else if(n>=16)
        cout<<16<<endl;
    else if(n>=8)
        cout<<8<<endl;
    else if(n>=4)
        cout<<4<<endl;
    else if(n>=2)
        cout<<2<<endl;
    else
        cout<<1<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 1000000007;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;

	void doIt() {
		int n = sc.nextInt();
		int d = sc.nextInt();
		int x[][] = new int[n][d];
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < d; j++) {
				x[i][j] = sc.nextInt();
			}
		}
		int cnt = 0;
		for(int l = 0; l < n; l++) {
			for(int r = l + 1; r < n; r++) {
				if(isInt(x, d, l, r))cnt++;
			}
		}
		System.out.println(cnt);
	}
	
	boolean isInt(int[][] x, int d, int x1, int x2) {
		double sum = 0;
		for(int i = 0; i < d; i++) {
			sum += (x[x1][i] - x[x2][i]) * (x[x1][i] - x[x2][i]);
		}
		sum = Math.sqrt(sum);
		return (sum == (int)sum)?true:false;
	}
	public static void main(String[] args) {
		new Main().doIt();
	}
}


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

int main() {
    int N, K;
    cin >> N >> K;
    int ans = 0;
    vector<vector<int>> graph(N);
    for(int i = 0; i < N; ++i) {
        int a; cin >> a;
        a--;
        if(i) graph[a].emplace_back(i);
        else if(a) ans++;
    }
    auto dfs = [&](auto &&dfs, int cur, int pre) -> int {
        int n = 1;
        for(auto &to : graph[cur]) {
            if(to == pre) continue;
            n = max(n, dfs(dfs, to, cur) + 1);
        }
        if(pre && n == K) ans++, n = 0;
        return n;
    };
    dfs(dfs, 0, 0);
    cout << ans << '\n';
    return 0;
}


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

using namespace std;
using i64 = std::int_fast64_t;
using u64 = std::uint_fast64_t;

const int MOD = 1000000007;

int modpow(int x, int n, int mod) {
  int res = 1;
  while (n > 0) {
    if (n & 1) res = 1LL * res * x % mod;
    x = 1LL * x * x % mod;
    n >>= 1;
  }
  return res;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  map<int, int> primes;
  for (int i = 0; i < N; i++) {
    int x = A[i];
    for (int p = 2; p * p <= x; p++) {
      int cnt = 0;
      while (x % p == 0) {
        x /= p;
        cnt++;
      }
      if (cnt > 0) primes[p] = max(primes[p], cnt);
    }
    if (x > 1) primes[x] = max(primes[x], 1);
  }

  int l = 1;
  for (auto itr : primes) {
    l = 1LL * l * modpow(itr.first, itr.second, MOD) % MOD;
  }
  i64 res = 0;
  for (int i = 0; i < N; i++) {
    res = (res + 1LL * l * modpow(A[i], MOD - 2, MOD) % MOD) % MOD;
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 768
N, L = (int(x) for x in input().split())
def func(i):
    return (N*(2*L+N-1)//2) - (L+i-1)

if -L+1 <= 1:
    print(func(1))
elif 1 <= -L+1 and -L+1 <= N:
    print(func(-L+1))
else:
    print(func(N))


Measured memory_bytes: 3060
using System;
using System.Linq;

namespace arc091_a
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] x = Console.ReadLine().Split().Select(long.Parse).ToArray();
            if (x.Min() == 2) Console.WriteLine(0);
            else Console.WriteLine(Math.Max(1,x[0] - 2) * Math.Max(1,x[1] - 2));
        }
    }
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
int main()
{
  while(true)
  {
    int N;
    int count=0;
    cin>>N;
    if(N==0)
    {
      break;
    }
    int A[1001];
    int subsum[1001]={0};
    for(int i=1;i<=1000;i++)
    {
      A[i]=i;
    }
    for(int i=1;i<=N-1;i++)
    {
      for(int k=i;k<=N;k++)
      {
        subsum[i]=subsum[i]+A[k];
        if(subsum[i]==N)
        {
          count++;
        }
      }
    }
    cout<<count<<endl;
  }
  return 0;
}



Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
int main() {
	string S;
	cin>>S;
	rep(i,3){
		if(S[i]=='1')cout<<'9';
		else cout<<'1';
	}
	cout<<endl;
}

Measured memory_bytes: 256
# import sys
# sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]


def solve():
    n = II()
    A = LI1()
    B = LI()
    C = LI()

    # print(A)
    # print(B)
    # print(C)
    pre = -4
    ans = 0
    for a in A:
        score = B[a]
        if a - pre == 1:
            score += C[pre]
        ans += score
        pre = a
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define fi first
#define sc second
typedef pair<int,int> P;
typedef long long ll;
struct BIT{
	int b[100005];
	void init(){ memset(b,0,sizeof(b)); }
	void add(int i,int x){ for(;i<100005;i+=i&-i) b[i] += x; }
	int sum(int i){
		int ret = 0; for(;i;i-=i&-i) ret += b[i]; return ret;
	}
}kaede;
int n;
vector<int>vec[100005];
int main(){
	scanf("%d",&n);
	rep(i,n){
		int x; scanf("%d",&x);
		vec[x].pb(i+1);
	}
	int cur = 0;
	ll ans = 0;
	kaede.init();
	for(int i=100000;i>=0;i--){
		rep(j,vec[i].size()){
			int pos = vec[i][j];
			int w = kaede.sum(pos-1);
			int ww = cur-w;
			ans += min(w,ww);
		}
		rep(j,vec[i].size()) kaede.add(vec[i][j],1);
		cur += vec[i].size();
	}
	cout << ans << '\n';
}



Measured memory_bytes: 8980
def insertion(A, N, g):
  cnt=0
  for i in range(g,N):
    v=A[i]
    j=i-g
    while j >= 0 and A[j]>v:
      A[j+g]=A[j]
      j-=g
      cnt+=1
    A[j+g]=v
  return cnt

def shell(A,n):
  cnt=0
  g=[797161,265720,88573,29524,9841,3280,1093,364,121,40,13,4,1]
  G=[i for i in g if i <= n]
  m=len(G)
  for i in range(m):
    cnt+=insertion(A,n,G[i])
  print(m)
  print(*G)
  print(cnt)
  print(*A,sep='\n')

n=int(input())
A=[0]*n
for i in range(n):
  A[i]=int(input())
shell(A,n)


Measured memory_bytes: 53292
#include <bits/stdc++.h>
using namespace std;
#define N 100009
#define INF 1000000009
#define MOD 1000000007
typedef long long int ll;
#define sd(x) scanf("%d",&x)
#define sd2(x,y) scanf("%lld%lld",&x,&y)
#define sd3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define pf(x) printf("%d",x);
#define pf2(x,y) printf("%d %d\n",x,y);
#define pf3(x,y,z) printf("%d %d %d\n",x,y,z);
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define tr(x) cout<<x<< endl;
#define tr2(x,y) cout<<x<<" "<<y<<" " << endl;
#define tr3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl;
#define tr4(x,y,z,a) cout<<x<<" "<<y<<" "<<z<<  " " << a << " " << endl;
ll dp[109][N],ans;
ll a[N],b[N];
int main(){
    int i,j,n,m,t,k,x,y;
    cin >> n >> m;
    for(i=1; i<=n; i++){
        sd2(a[i],b[i]);
    }
    for(i=1; i<=n; i++){
        for(j=0; j<a[i]; j++){dp[i][j]=dp[i-1][j];ans=max(ans,dp[i][j]);}
        for(j=a[i]; j<=m; j++){
            dp[i][j]=max(dp[i][j],dp[i-1][j-a[i]]+b[i]);
            dp[i][j]=max(dp[i][j],dp[i-1][j]);
            ans=max(ans,dp[i][j]);
            // tr3(i,j,dp[i][j]);
        }
    }
    tr(ans);
}

Measured memory_bytes: 80128
// Sakhiya07 - Yagnik Sakhiya
 
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
 
#define mp make_pair
#define bp __builtin_popcountll
#define MOD  1000000007
const int N = 10000;
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL));
 
void solve()
{
     ll a,b;
     cin >> a >> b;
     ll ans = a*b;
     cout<<ans;
}

int main()
{
     FAST;
     ll t = 1;
   //  cin >> t;
     while(t--)
     {
          solve();
     }
}

Measured memory_bytes: 3656
#include <stdio.h>

int main(){

	int i,x[10000];

	for(i = 1; i <= 10000; i++){
		scanf("%d",&x[i]);

		if(x[i] == 0){
			break;
		}
	}

	for(i = 1; i <= 10000; i++){
		if(x[i] != 0){
			printf("Case %d: %d\n",i,x[i]);
		}else{
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 636
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
int main()
{
    int l,r,d;
    cin>>l>>r>>d;

    int x=l/d;
    int y=r/d;
    int ans=y-x;
    if(l%d==0) ans++;
    cout<<max(0,ans);

}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
#define eps 0.000000001
using namespace std;
typedef long double ld;
typedef pair<int,int> p;
typedef pair<ld,p> P;

int n;
ld px[200],py[200],pz[200],vx[200],vy[200],vz[200],r[200],vr[200];

ld getlen(int a,int b,ld M){
  ld ax=px[a]+vx[a]*M,ay=py[a]+vy[a]*M,az=pz[a]+vz[a]*M,ar=r[a]-vr[a]*M;
  ld bx=px[b]+vx[b]*M,by=py[b]+vy[b]*M,bz=pz[b]+vz[b]*M,br=r[b]-vr[b]*M;
  ld dx=ax-bx,dy=ay-by,dz=az-bz;
  return sqrt(dx*dx+dy*dy+dz*dz)-(ar+br);
}

ld check(int a,int b){
  ld mt=min(r[a]/vr[a],r[b]/vr[b]);
  ld L=0,R=mt,M;
  int s=0;
  while(s++<50){
    M=(L+R)/2;
    ld len=getlen(a,b,M),len1=getlen(a,b,M+eps);
    if(len<len1||len<=0)R=M;
    else L=M;
  }
  if(getlen(a,b,R)>0)return 1000;
  return R;
}

int main(){
  while(cin>>n,n){
    for(int i=0;i<n;i++)
      cin>>px[i]>>py[i]>>pz[i]>>vx[i]>>vy[i]>>vz[i]>>r[i]>>vr[i];
    priority_queue<P,vector<P>,greater<P> > q;
    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++)
	q.push(P(check(i,j),p(i,j)));
      q.push(P(r[i]/vr[i],p(i,i)));
    }
    ld used[200]={};
    while(!q.empty()){
      ld t=q.top().first;
      int a=q.top().second.first,b=q.top().second.second;
      q.pop();
      if(used[a]||used[b])continue;
      used[a]=used[b]=t;
    }
    for(int i=0;i<n;i++)printf("%.10Lf\n",used[i]);
  }
  return 0;
}

Measured memory_bytes: 4640