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

// 🔴

// O(ElogE)

// pq<pair> はfirstが大きい順に出てくるのですか？
// s:= 開始ノード  v:= 頂点数  adjlist:= 隣接リスト (first:= コスト   second:= 行先)
vector<int> dijk(int s, int v, vector<vector<pair<int, int> > > adjlist){
    
    priority_queue <pair<int, int> > wait;
    vector<int> result(v, INF);

    //スタート地点を追加
    result[s] = 0;
    wait.push(make_pair(0, s));

    //ダイクストラ本体
    while(!wait.empty()){    //waitが空になるまで

        int nowpoint = wait.top().second;
        int nowcost = -wait.top().first;
        wait.pop();

        if(result[nowpoint] < nowcost) continue;


        //今いる頂点と隣接しているすべての頂点をなめる
        for(int i = 0; i < adjlist[nowpoint].size(); i++){

            int nextpoint = adjlist[nowpoint][i].second;
            int nextcost = nowcost + adjlist[nowpoint][i].first;
            //現時点より安く到達できそうであれば、結果を更新して優先度付きキューに格納
            if(result[nextpoint] > nextcost){
                result[nextpoint] = nextcost;
                wait.push(make_pair(-nextcost, nextpoint));
            }
        }
    }
    
    return result;         //結果列を返す
}

int main(){

    int V, E, S; cin >> V >> E >> S;     // V:= 頂点の数    E:= 辺の数    S:= スタートノード
    vector<vector<pair<int, int> > > adjlist(V);      //first := コスト　second := 行先

    //入力
    for(int i = 0; i < E; i++){
        int a, b, c; cin >> a >> b >> c;           // a ,b 間に コスト c の辺がある
        adjlist[a].push_back(make_pair(c, b));
        //adjlist[b].push_back(make_pair(c, a));      
    }

    vector<int> result(V);
    result = dijk(S, V, adjlist);
    //cout << result[G] << endl;

    for(int i = 0; i < V; i++){
        if(result[i] == INF) cout << "INF" << endl;
        else cout << result[i] << endl;
    }
    return 0;
}


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

using namespace std;
using P = pair<int, pair<int, int>>;

int main() {
    while(1) {
        int n, m, a;
        cin >> n >> m >> a;
        if (n == 0) break;

        vector<P> v;
        for (int i = 0; i < m; ++i) {
            int h, p, q;
            cin >> h >> p >> q;
            v.push_back(P(h, make_pair(p, q)));
        }

        sort(v.begin(), v.end(), greater<P>());

        int curr = a;

        for (P vi : v) {
            int p = vi.second.first;
            int q = vi.second.second;
            if (curr == p) curr = q;
            else if(curr == q) curr = p;
        }

        cout << curr << endl;
    }
}

Measured memory_bytes: 3084
// https://atcoder.jp/contests/agc029/tasks/agc029_b

#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

// long gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
// long lcm(long a, long b) { return a * b / gcd(a, b); }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, ans = 0;
    cin >> n;
    vector<int> v(n);
    // 値に対して個数を持つ。ペアとして使用する際に個数を数える。
    multiset<int> m;

    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        m.insert(a);
    }

    // 大きい値から順に処理する
    while (!m.empty()) {
        auto it = --m.end();
        int x = *(it);
        m.erase(it);
        // xより大きい２のべき乗を作成
        // while (p <= x)
        //     p *= 2;
        uint32_t p = (1u << (32 - __builtin_clz(x)));

        int y = p - x; // ペアとなるyは1通り
        auto itr = m.find(y);
        if (itr != m.end()) {
            m.erase(itr);
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 10496
use proconio::input;

fn main() {
    input! {
        n: usize,
        v: [usize; n]
    }

    let mmm = 1_000_000_007;

    let ans = {
        let mut ans = 0;
        let mut now = 0;
        for i in (1..=n-1).rev() {
            now += v[i];
            now %= mmm;
            ans += v[i-1] * now;
            ans %= mmm;
        }
        ans
    };

    println!("{}", ans)
}


Measured memory_bytes: 5540
#include<iostream>
#include<iomanip>
#include<string>
#include<set>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<functional>
using namespace std;
#define LL long long
#define MOD 100000
#define inf 1999999999


int main() {
	int a[10];
	char s;
	set<char> v = { 'a','i','u','e','o' };
	cin >> s;
	if(v.count(s))cout << "vowel" << endl;
	else cout << "consonant" << endl;
	return 0;
}


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

using namespace std;

typedef long long ll;
const int maxx = 1e6 + 5;

int main(){
	int n, m, i, j, flag;
	int a[6];
	for(i = 0; i < 5; i++) scanf("%d", &a[i]);
	scanf("%d", &m);
	flag = 1;
	for(i = 0; i < 4; i++){
		for(j = i + 1; j < 5; j++)
			if(a[j] - a[i] > m) flag = 0;
	}
	if(flag) cout << "Yay!" << endl;
	else cout << ":(" << endl;
	return 0;
}

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

using namespace std;

int main() {
    
    int n;
    cin >> n;
    
    vector<int> x(n, 0);
    
    for (int i = 0; i < n; ++i)
    {
        cin >> x[i];
    }
    vector<int> x2;
    x2 = x;
    sort(x2.begin(), x2.end());
    
    int mid = (n / 2) - 1;
    
    for (int i = 0; i < n; ++i)
    {
        if (x[i] > x2[mid])
        {
            cout << x2[mid] << endl;
        }
        else
        {
            cout << x2[mid + 1] << endl;
        }
    }
    
    
    return 0;
}

Measured memory_bytes: 3712
import heapq
N,M = map(int, input().split())
A = list(map(lambda x: -int(x), input().split()))
heapq.heapify(A)
ans = 0
for i in range(M):
    most_expensive = -heapq.heappop(A)
    most_expensive //= 2
    heapq.heappush(A, -most_expensive)
print(-sum(A))

Measured memory_bytes: 14180
#include <stdio.h>

int main()
{
  int n, x;
  int m[100];
  int sum = 0;
  int min_m = 1e5;
  int min_m_num;

  scanf("%d %d", &n, &x);
  //printf("%d %d\n", n, x);

  for (int i = 0; i < n; i++){
    scanf("%d", &m[i]);
    //printf("%d\n", m[i]);
    sum += m[i];
    if (m[i] < min_m){
      min_m = m[i];
    }
  }
  //printf("sizeof(int) = %zu byte\n", sizeof(m[0]));

  min_m_num = (int) (x - sum) / min_m;

  printf("%d\n", n + min_m_num);

  return 0;
}



Measured memory_bytes: 128
// I want to AC


#include <vector>
#include<stdio.h>
#include<string.h>
#include <cstring>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <set>
#include<cstring>
#include<queue>
#include<assert.h>
#define ll long long
#define MODD 1000000007
#define  pii  pair<int,int>
#include<stdio.h>
#include<string.h>
#include<bits/stdc++.h>
//#define  ll long long
using namespace std;
const int maxn = 1e6+7;
#define FOR(i, x, y) for (ll i = (x), _##i = (y); i < _##i; ++i)

ll mod = 1e9+7;
//const int maxn = 100010;
//ll f[maxn];
//ll inv[maxn]; // 阶乘的逆元
//void CalFact()
//{
//    f[0] = 1;
//    for (int i = 1; i < maxn; i++) f[i] = (f[i - 1] * i) % p;
//    inv[maxn - 1] = Pow(f[maxn - 1], p - 2, p);
//    for (int i = maxn - 2; ~i; i--) inv[i] = inv[i + 1] * (i + 1) % p;
//}
//ll C(int n, int m) { return f[n] * inv[m] % p * inv[n - m] % p; }
int a,b,c,q;
map<string , int > mp;
int main() {
cin >>q;int f=0 ;int flag =0 ;
for(int i=0;i<q;i++){
    cin >>a;
    if(a%2==0){
        if(a%3==0||a%5==0)f =1 ;
        else flag =1  ;
    }
    else f= 1;
}
if(f==1 &&flag  == 0)cout<<"APPROVED"<<endl;
else cout<<"DENIED"<<endl;
	return 0;

}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <sstream>
#include <climits>
#include <cfloat>
#include <complex>


typedef long long ll;
const double Eps = 1e-6;

using namespace std;

int main()
{
	int d;
	scanf("%d", &d);
	while (d--)
	{
		int n;
		scanf("%d", &n);
		bool maze[126][126];
		memset(maze, 0, sizeof(maze));
		for (int i = 0; i < n+4; ++i)
			maze[0][i] = maze[i][0] = maze[n+3][i] = maze[i][n+3] = true;

		int x = 2;
		int y = n+1;
		int dx[] = { 0, 1, 0, -1 };
		int dy[] = { -1, 0, 1, 0 };
		int dir = 0;
		while (true)
		{
			int c = 0;
			for (int i = 0; i < 4; ++i)
				if (maze[y+dy[i]][x+dx[i]])
					++c;
			if (c > 1)
				break;

			maze[y][x] = true;
			int tx = x + 2*dx[dir];
			int ty = y + 2*dy[dir];
			if (maze[ty][tx])
				dir = (dir+1) % 4;

			x += dx[dir];
			y += dy[dir];
		}
		for (int i = 2; i < n+2; ++i)
		{
			for (int j = 2; j < n+2; ++j)
				putchar(maze[i][j] ? '#' : ' ');
			putchar('\n');
		}
		if (d)
			putchar('\n');
	}

	return 0;
}

Measured memory_bytes: 0
import sys
import math
N=int(input())
ans=0
if N==1:
    print(0)
    sys.exit()

As=list(map(int, input().split()))
max_h=As[0]
for i in range(1,N):
    if As[i]<max_h:
        ans+=max_h-As[i]
    elif As[i]>max_h:
        max_h=As[i]
print(ans)


Measured memory_bytes: 32948
#include<iostream>
#include<string>
#include<cstdio>
#include <cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define int long long

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int n, k;
int a[550]; int sum;
vector<int> divi; 

int C(int di) {
    if(di == 1) return 0;
    int b[550];
    rep(i, n) {
        b[i] = a[i] % di;
    }
    sort(b, b + n);
    int sumb[550];
    sumb[0] = 0;
    rep(i, n) {
        sumb[i + 1] = sumb[i] + b[i];
    }
    rep(i, n + 1) {
        if(sumb[i] == (n  - i) * di - (sumb[n] - sumb[i])) {
            return sumb[i];
        }
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    cin >> n >> k;
    sum = 0;
    rep(i, n) {
        cin >> a[i];
        sum += a[i];
    }
    for(int i = 1; i * i <= sum; i++) {
        if(sum % i == 0) {
            divi.pb(i);
            if(i * i != sum) divi.pb(sum / i);
        }
    }
    sort(all(divi));
    int ans = 1;
    for(auto di : divi) {
        if(C(di) <= k) ans = max(ans, di);
    }
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import heapq
 
N , M = map(int,input().split())
 
# edges , costs
nodes = [[] for _ in range(3 * N)]
 
confilm = [False] * (3 * N)  # 確定フラグ
 
costs = [-1] * (3 * N)  # 最短経路
 
# 辺の入力
for _ in range(M) :
    fromNode , toNode = map(int,input().split())
    fromNode -= 1
    toNode -= 1
    fromNode *= 3
    toNode *= 3
 
    nodes[fromNode].append((toNode + 1,1))
    nodes[fromNode + 1].append((toNode + 2,1))
    nodes[fromNode + 2].append((toNode,1))
 
 
# スタート ゴール
startNode , endNode = map(int,input().split())
startNode -= 1
endNode -= 1

startNode *= 3
endNode *= 3
 
costs[startNode] = 0
 
q = [(0,startNode)]
 
# 探索
while q : # 空になるまで
    nowCost , nowNode = heapq.heappop(q)
 
    if confilm[nowNode] :
        continue
 
    confilm[nowNode] = True
 
    # 長さを更新
    for nextNode , cost in nodes[nowNode] :
        # if not confilm[nextNode] :  # 確定ノード以外
        nextCost = nowCost + cost
        if costs[nextNode] == -1 or nextCost < costs[nextNode] :
            costs[nextNode] = nextCost  # コストを更新
            heapq.heappush(q,(nextCost,nextNode))
 
if costs[endNode] < 0 :
    print(-1)
else :
    print(costs[endNode] // 3)

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


int main(){
  int N, M;
  cin >> N >> M;
  int max_L = 0;
  int min_R = N;
  for(int ii=0; ii<M; ii++){
    int l, r;
    cin >> l >> r;
    max_L = max(max_L, l);
    min_R = min(min_R, r);
  }
  cout << max(0, min_R-max_L+1) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define yoi cout<<"yo"<<endl;
#define debug(x) cerr << #x << " is " << x << endl;
#define all(x) x.begin(),x.end()
const lli inf=1e18;
const int mod=1e9+7;
int main(){
IOS;
lli a,b,i,j;
cin>>a>>b;
lli x=(lli)sqrt(a);
set<lli> v;
for(i=1;i<=1000005;i++){
    if(a%i==0&&b%i==0){
        if(v.find(i)==v.end())
        v.insert(i);
    }
    if(a%i==0){
        lli div=a/i;
        if(b%div==0&&v.find(div)==v.end())
            v.insert(div);
    }
}
vector<lli> res;
lli gcd;
for(auto it:v){
        gcd=it;
    for(j=0;j<res.size();j++){
        if(__gcd(gcd,res[j])!=1)
            break;
    }
    if(j==res.size())
        res.pb(it);
}
cout<<res.size()<<endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,k;
cin>>n>>k;
int arr[n];
for(int i=0;i<n;++i)
cin>>arr[i];
bool dp[k+1];
memset(dp,0,sizeof(dp));
for(int i=1;i<k+1;++i)
{
for(int j=0;j<n;++j)
{
bool t=0;
if(i>=arr[j])
{
t=!dp[i-arr[j]];
}
dp[i]=dp[i]|t;
}
//cout<<i<<" "<<dp[i]<<endl;
}
if(dp[k])
cout<<"First"<<endl;
else
cout<<"Second"<<endl;
}


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

int main() {
  int N, K;
  long double F, max = 0;
  cin>>N>>K;
  
  vector<int> p(N);
  vector<long double> g(N);
  vector<long double> m(N + 1, 0);
  vector<long double> sum(N, 0);
  
  rep(i, N) cin>>p[i];
  
  rep(i, N){
    g[i] = (1 + p[i])/2.0;
  }
  
  long double tmp = 0; 
  for(int i = 0; i<K;i++){
    tmp+=g[i];
  }
  sum[0] = tmp;
  
  for(int i = 1; i<N-K+1;i++){
    sum[i] = tmp + g[K+i-1] - g[i-1];
    tmp = sum[i];
  }
  
  rep(i, N){
    if(max<sum[i]) swap(max, sum[i]);
  }
  
  cout<<setprecision(12)<<max<<endl;
  
  return 0;
}

Measured memory_bytes: 10368
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

int main(){
  int H, W; cin >> H >> W;
  int N; cin >> N;
  int a = max(H,W);
  rep(i,200){
    if(i*a>=N){
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <cmath>
#include <list>
#include <chrono>
#include <thread>

using namespace std;

//template<typename T>
//using Matrix2D = std::vector<vector<T>>;

//#define cerr


#ifndef M_PI
    const double M_PI = acos(-1.0);
#endif // M_PI

#define y1 roman_kaban
#define rank oryshych_konb
#define ull unsigned long long
#define ll long long
//const int mod = int(1e9) + 7;
//const long long infLL = 1e18;
//const int MX2 = 10100500; //  e7
//const int MX = 400500; //       e5

int nxt = 1;
list<int> r1,r2;
bool go(long long n){
    if(n == 0) return true;
    if(n % 2){
        if(go(n / 2)){
            r1.push_front(nxt);
            r2.push_front(nxt);
            nxt++;
            return true;
        }
    }
    if(go(n - 1)){
            r1.push_front(nxt);
            r2.push_back(nxt);
            nxt++;
            return true;

    }
    return false;
}

int main()
{
    //freopen("/Users/ozzy/Documents/in.txt","r", stdin);
    //cout << c(4, 2) << endl;
    ios_base::sync_with_stdio(false);
    long long n;
    cin >> n;// n++;
    nxt = 1;
    go(n);

    cout << (nxt - 1) * 2 << endl;
    while(r1.begin() != r1.end()){
        cout << r1.front() << ' ';
        r1.pop_front();
    }
    swap(r1, r2);
    while(r1.begin() != r1.end()){
        cout << r1.front() << ' ';
        r1.pop_front();
    }
    cout << endl;
    return 0;
}


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

using namespace std;

#define ll long long

const int N = 102, maxV = 100005;
ll dp[maxV];
int w[N], v[N];

int main() {
	int n, W;
	scanf("%d %d", &n, &W);
	int sumV = 0;
	for (int i = 0; i < n; i++) {
		scanf("%d %d", &w[i], &v[i]);
		sumV += v[i];
	}
	for (int j = 0; j <= sumV; j++) {
		dp[j] = 2e18;
	}
	dp[0] = 0;
	for (int i = 0; i < n; i++) {
		for (int j = sumV; j >= 0; j--) {
			if (j + v[i] <= sumV) {
				dp[j+v[i]] = min(dp[j+v[i]], dp[j] + w[i]);
			}
		}
	}
	for (int i = sumV; i >= 0; i--) {
		if (dp[i] <= W) {
			printf("%d", i);
			break;
		}
	}
	return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<long long> vl;
typedef pair<long long, long long> pl;
typedef vector<vector<long long>> matrix;

#define F 						first
#define S 						second
#define PB 						push_back
#define MP 						make_pair
#define all(c) 					c.begin(), c.end()
#define f(i,a,b) 				for(ll i=a; i<b; i++)
#define rep(i,n) 				f(i,0,n)
#define tr(c,i) 				for(typeof(c).begin() i = c.begin(); i != c.end(); i++)
#define present(c,x) 			(c.find(x) != c.end())	//for set and map
#define cpresent(c,x) 			(find(all(c),x) != c.end())	//for vectors
#define w(t)					ll t; cin>>t; while(t--)
#define epsilon 				1e-9
#define MOD						(ll)1e9

void doublade() {
	ios::sync_with_stdio(false); cin.tie(0); cout.precision(10);
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
}

int main() {
	doublade();
	// w(t) {
		ll d, t, s;
		cin >> d >> t >> s;
		double time = (float)d/s;
		if(time<=((float)t)) cout<<"Yes\n";
		else cout<<"No\n";
	// }
	return 0;
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef vector<vin> vvin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) int((a).size())
const int MOD=1e9+7;

int main(){
  ll n,m,ans=0;cin>>n>>m;
  vll c(m);
  vvll dp(m+1,vll(n+1,MOD));
  rep(i,0,m){
    cin>>c[i];
  }
  dp[0][0]=0;
  rep(i,0,m){
    rep(j,0,n+1){
      if(j<c[i]){dp[i+1][j]=dp[i][j];}
      else if(j==c[i]){dp[i+1][j]=min(dp[i][j],1LL);}
      else{dp[i+1][j]=min(dp[i][j],dp[i+1][j-c[i]]+1);}
    }
  }
  
  cout<<dp[m][n]<<endl;
}



Measured memory_bytes: 11584
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<climits>
#include<cstdlib>
#include<map>
#include<math.h>
#include<utility>
#include<vector>
using namespace std ;
typedef long long ll;

// N K
// A_1, ..., A_N

int vector_finder(std::vector<int> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int f(int n)
{
    if(n%2==0)
         return n/2 ;
    else
        return 3*n+1 ;
}

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

    vector<int> a ;

    for(int i=0 ; ; i++)
    {
        int a_n;
        if(i==0)
            a_n = s ;
        else
        {
            a_n = f(a[i-1]) ;
        }

        if(vector_finder(a, a_n))
        {
            cout << i+1 << endl ;
            break ;
        }else{
            a.push_back(a_n) ;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + (ll)b) % mod
#define MUL(a, b) a = (a * (ll)b) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rer(i, a, b) for(int i = a - 1; i >= b; i--)
#define all(a) (a).begin(), (a).end()
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef pair<pi, pi> ppi;
typedef vector<ll> vec;

const int MAX_N = 500010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;

void Debug() {cout << '\n'; }

template<class FIRST, class... REST> 
void Debug(FIRST arg, REST... rest) { cout << arg << " "; Debug(rest...); }

template<class T>
ostream& operator<< (ostream& out, const vector<T>& v) {
	out << "[";
	if(!v.empty()) {
		rep(i, 0, (int)v.size() - 1) out << v[i] << ", ";
		out << v.back();
	}
	out << "]";
  return out;
}

template<class S, class T>
ostream& operator<< (ostream& out, const pair<S, T>& v) {
	out << "(" << v.first << ", " << v.second << ")";
	return out;
}

///g++ -g3 -std=c++0x -DLOCAL -Wall -ftrapv -D_GLIBCXX_DEBUG -Wl,-stack,268435456 -o
///g++ -O2 -std=c++0x -DLOCAL -Wall -Wl,-stack,268435456 -o

///////////////////////////////////////////////////////////////////////

int N, S, Q;
int A[MAX_N];
ll B[MAX_N], C[MAX_N];
bool ans[MAX_N];

void solve() {
	cin >> N >> S;
	rep(i, 0, N) cin >> A[i];
	B[N] = 1;
	for(int i = N - 1; i >= 0; i--) {
		if(A[i] / 2 < B[i + 1]) B[i] = A[i] + B[i + 1];
		else B[i] = B[i + 1];
	}
	C[0] = S;
	for(int i = 1; i <= N; i++) {
		if(C[i - 1] - A[i - 1] >= 0) C[i] = min(C[i - 1], C[i - 1] - A[i - 1]);
		else C[i] = min(C[i - 1], A[i - 1] - C[i - 1]);
	}
	//debug(vec(B, B + N + 1));
	//debug(vec(C, C + N + 1));
	for(int i = 0; i < N; i++) {
		if(B[i + 1] <= C[i]) ans[i] = true;
		else ans[i] = false;
	}
	cin >> Q;
	while(Q--) {
		int a;
		cin >> a; a--;
		if(ans[a]) cout << "YES\n";
		else cout << "NO\n";
	}
}

int main() {
	ios::sync_with_stdio(false);
    cin.tie(0);	
    cout << fixed;
	cout.precision(20);
#ifdef LOCAL
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}




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

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

int main() {
  int n;
  cin >> n;
  vector<int> t(n);
  for (int &x : t) {
    cin >> x;
  }
  int m;
  cin >> m;
  vector<int> p(m);
  vector<int> x(m);
  for (int i = 0; i < m; i++) {
    cin >> p.at(i) >> x.at(i);
  }
  int sum = 0;
  for (int x : t) {
    sum += x;
  }

  for (int i = 0; i < m; i++) {
    cout << sum - t.at(p.at(i) - 1) + x.at(i) << endl;
  }
}


Measured memory_bytes: 3612
#include <stdio.h>

int main(void){
  int w, h, x, y, r;
  
  scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);
  
  if(0<=x-r && x+r<=w && 0<=y-r && y+r<=h){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  
  return 0;
}


Measured memory_bytes: 2148
#include <stdio.h>

int main(void) {
	int i, j;
	int hit = 0;
	int blow = 0;
	int a[4], b[4];
	while((scanf("%d %d %d %d\n", &a[0], &a[1], &a[2], &a[3]) == 4) && (scanf("%d %d %d %d\n", &b[0], &b[1], &b[2], &b[3]) == 4)) {
		hit = 0; blow = 0;
		for(i=0;i<4;i++)
			if(a[i] == b[i]) hit++;
	
		for(i=0;i<4;i++)
			for(j=0;j<4;j++)
				if(i!=j && a[i]==b[j]) { blow++; break; }
				
		printf("%d %d\n", hit, blow);
	}	
	return 0;
}

Measured memory_bytes: 600
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;

typedef long long ll;

const int MAXN = 2 * 1e5;
ll p[MAXN+5];


int main()
{
    int n = 0;
    cin >> n;
    for(int i = 0; i < n; ++i){
        cin >> p[i];
    }
    ll ans = 0;
    int small = n+1;
    for(int i = 0; i < n; ++i){
        if(small > p[i]){
            ++ans;
            small = p[i];
        }
    }
    cout << ans << endl;

    return 0;
}


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

int main() {
  int a ;
  int fh = 0;
  int f = 0;
  cin >> a;

fh = a/500;
a = a-fh*500;
f = a/5;

  cout << fh*1000+f*5 << 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 rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
const long long INF = 1LL << 60;
const int MOD = 1e9 + 7;

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

#ifndef ATCODER_DSU_HPP
#define ATCODER_DSU_HPP 1

#include <algorithm>
#include <cassert>
#include <vector>

namespace atcoder {

// Implement (union by size) + (path compression)
// Reference:
// Zvi Galil and Giuseppe F. Italiano,
// Data structures and algorithms for disjoint set union problems
struct dsu {
  public:
    dsu() : _n(0) {}
    dsu(int n) : _n(n), parent_or_size(n, -1) {}

    int merge(int a, int b) {
        assert(0 <= a && a < _n);
        assert(0 <= b && b < _n);
        int x = leader(a), y = leader(b);
        if (x == y) return x;
        if (-parent_or_size[x] < -parent_or_size[y]) std::swap(x, y);
        parent_or_size[x] += parent_or_size[y];
        parent_or_size[y] = x;
        return x;
    }

    bool same(int a, int b) {
        assert(0 <= a && a < _n);
        assert(0 <= b && b < _n);
        return leader(a) == leader(b);
    }

    int leader(int a) {
        assert(0 <= a && a < _n);
        if (parent_or_size[a] < 0) return a;
        return parent_or_size[a] = leader(parent_or_size[a]);
    }

    int size(int a) {
        assert(0 <= a && a < _n);
        return -parent_or_size[leader(a)];
    }

    std::vector<std::vector<int>> groups() {
        std::vector<int> leader_buf(_n), group_size(_n);
        for (int i = 0; i < _n; i++) {
            leader_buf[i] = leader(i);
            group_size[leader_buf[i]]++;
        }
        std::vector<std::vector<int>> result(_n);
        for (int i = 0; i < _n; i++) {
            result[i].reserve(group_size[i]);
        }
        for (int i = 0; i < _n; i++) {
            result[leader_buf[i]].push_back(i);
        }
        result.erase(
            std::remove_if(result.begin(), result.end(),
                           [&](const std::vector<int>& v) { return v.empty(); }),
            result.end());
        return result;
    }

  private:
    int _n;
    // root node: -1 * component size
    // otherwise: parent
    std::vector<int> parent_or_size;
};

}  // namespace atcoder

#endif  // ATCODER_DSU_HPP

using namespace atcoder;

int main() {
	int N,Q;
	cin >> N >> Q;

	dsu d(N);

	rep(i,Q){
		int t,u,v;
		cin >> t >> u >> v;
		if(t == 0){
			d.merge(u,v);
		}else{
			if(d.same(u,v)){
				cout << 1 << endl;
			}else{
				cout << 0 << endl;
			}
		}
	}
    return 0;

}

Measured memory_bytes: 3852
#include <bits/stdc++.h>
#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)g
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

llong cnt;
int l;
int A[100000000];
int n;
vector<int> G;


void insertingSort(int A[],int n,int g){
  FOR(i,g,n){
    int v = A[i];
    int j = i - g;
    while(j >= 0 && A[j] > v){
      A[j + g] = A[j];
      j -= g;
      cnt++;
    }
    A[j +g] = v;
  }
}


void shellSort(int A[], int n){
  for(int h = 1; ; ){
    if(h > n) break;
    G.push_back(h);
    h = 3 * h + 1;
  }
  FORR(i,G.size()-1,0){
    insertingSort(A,n,G[i]);
  }
}

int main(){
  int n;
  cin >> n;
  REP(i,n)cin >> A[i];
  cnt =0;

  shellSort(A,n);
  cout << G.size() <<endl;
  FORR(i,G.size()-1,0){
    cout <<G[i];
    if(i)cout<<" ";
  }
  cout <<endl;
  cout << cnt<<endl;
  REP(i,n)cout <<A[i]<<endl;
  return  0;
}



Measured memory_bytes: 7072
MOD = 998244353


def main():
    global MOD
    N,S = map(int, input().split())
    A = list(map(int, input().split()))
    dp0 = [[0 for i in range(S+1)] for j in range(N)]
    dp1 = [[0 for i in range(S+1)] for j in range(N)]
    dp2 = [[0 for i in range(S+1)] for j in range(N)]


    dp0[0][0] = 1
    dp1[0][0] = 1
    dp2[0][0] = 1
    if A[0] <= S:
        dp1[0][A[0]] = 1
        dp2[0][A[0]] = 1
    for i in range(1,N):
        for j in range(S+1):
            if j + A[i] <= S:
                dp1[i][j+A[i]] = (dp1[i][j+A[i]] + dp0[i-1][j] + dp1[i-1][j])%MOD
                dp2[i][j+A[i]] = (dp2[i][j+A[i]] + dp0[i-1][j] + dp1[i-1][j])%MOD
            dp0[i][j] = (dp0[i][j] + dp0[i-1][j])%MOD
            dp1[i][j] = (dp1[i][j] + dp1[i-1][j] + dp0[i-1][j])%MOD
            dp2[i][j] = (dp2[i][j] + dp2[i-1][j] + dp1[i-1][j] + dp0[i-1][j])%MOD

    print(dp2[N-1][S]%MOD)

main()

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

int isprime(int n);
int isSmallTwinPrime(int n);
int GetMaxTwinPrimeNumber(int argRange);

int main()
{
	int const size = 10000;
	int data[size];	
	
	int i=0;
	while(1) //for(int i=0; data[i]!=0; i++)
	{
		cin >> data[i];
		if(data[i]<=0) break;
		i++;
	}
	
	int outputNum;
	
	for(int i=0; data[i]!=0; i++)
	{
		outputNum = GetMaxTwinPrimeNumber(data[i]);
		if(outputNum!=0)
		{
			cout << outputNum-2 << " " << outputNum << endl;
		}
	}
	
	return 0;
}

int isprime(int n) 
{
	for(int i = 2; i * i <= n; i++) 
	{
		if(n % i == 0) 
		{
			return 0;
		}
	}
	return 1;
}

int isSmallTwinPrime(int n)
{
	for(int i = 2; i * i <= n; i++) 
	{
		if((n-2) % i == 0) 
		{
			return 0;
		}
	}
	return 1;
}

int GetMaxTwinPrimeNumber(int argRange)
{
	int maxTwinPrimeNum = 0;
	
	for(int i=0; ; i++)
	{
		int Num = argRange - i;
		
		if(isprime(Num)==1 && isSmallTwinPrime(Num)==1)
		{
			maxTwinPrimeNum = Num;
			return maxTwinPrimeNum;
		}
		
		if(Num==0)
		{
			return 0;
		}
	}
}

Measured memory_bytes: 2984
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=n-1; i>=m; i--)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x%MOD,n/2);
  return x*POW(x,n-1)%MOD;
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}


int main()
{
  ll a,b,c;
  cin >> a >> b >> c;
  printf("%lld",(a-b+1)*(a-c+1));
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sys/time.h>
#include <cmath>
#include <tuple>
#include <queue>

using namespace std;

int bit[static_cast<int>(2*(1e5)+1)], n;

int sum(int i) {
    int s = 0;
    while (i > 0) {
        s += bit[i];
        i -= i & -i;
    }
    return s;
}

void add(int i, int x) {
    while (i <= n) {
        bit[i] += x;
        i += i & -i;
    }
}

void solve(string S){
    vector<int> bin(26, 0);
    for (auto&& c : S) {
        bin[c - 'a']++;
    }
    bool flag = false;
    char cent;
    for (int i = 0; i < 26; i++) {
        if (bin[i]%2 != 0) {
            if (flag == false) {
                flag = true;
                cent = 'a' + i;
            } else {
                std::cout << -1 << std::endl;
                return;
            }
        }
        bin[i] /= 2;
    }
    string cir;
    for (auto&& c : S) {
        if (bin[c - 'a'] > 0) {
            cir.push_back(c);
            bin[c - 'a']--;
        }
    }
    vector< vector< int > > vv(26, vector<int>());
    int l = 0;
    for(int i = 0; i < cir.size(); i++) {
        vv[cir[i] - 'a'].push_back(l);
        l++;
    }
    if(flag) {
        vv[cent - 'a'].push_back(l);
        l++;
    }
    for (int i = 0; i < cir.size(); i++) {
        vv[cir[cir.size()-i-1] - 'a'].push_back(l);
        l++;
    }
    vector<int> itr(26, 0);
    vector<int> a(S.size());
    for (int i = 0; i < S.size(); i++) {
        a[i] = vv[S[i] - 'a'][itr[S[i] - 'a']]+1;
        itr[S[i] - 'a']++;
    }
    long long ans = 0;
    n = S.size();
    for (int i = 0; i < static_cast<int>(2*(1e5)+1); i++) {
        bit[i] = 0;
    }
    for (int i = 0; i < S.size(); i++) {
        ans += i - sum(a[i]);
        add(a[i], 1);
    }
    std::cout << ans << std::endl;
}

int main(){	
    struct timeval start,end;
    long long span;
    gettimeofday(&start,NULL);

    string S;
    cin >> S;
    solve(S);

    gettimeofday(&end,NULL);
    span = (end.tv_sec -start.tv_sec)*1000000LL + (end.tv_usec - start.tv_usec);
    std::cerr << "--Total Time: " << span/1000 << "ms" << endl;
    return 0;
}


Measured memory_bytes: 3956
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;

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

  long long a;
  long long cnt1[61] = {0};
  for(i=0;i<n;i++)
  {
    cin >> a;
    for(int j=0;j<=60;j++)
    {
      if( (a & (1LL << j)))cnt1[j]++;
    }
  }

  long long ans = 0;

  for(i=0;i<=60;i++)
  {
    long long fac = (cnt1[i] * (n-cnt1[i]))%mod;
    fac = (fac * ((1LL<<i)%mod))%mod;
    ans = (ans + fac)%mod;
  //  cout << cnt1[i] <<" "<<i<<endl;
  }
  cout << ans<<endl;
}


Measured memory_bytes: 256
n, l = list(map(int, input().split()))

apples = []

min_apple = 99999999
min_i = -1
for i, apple in enumerate(range(l, l+n)):
    apples.append(apple)
    if min_apple > abs(apple):
        min_apple = abs(apple)
        min_i = i

res = sum(apples) - apples[min_i]
print(res)

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);

  for(int i=0; i<A.size(); i++)
    cin >> A.at(i);

  int count=0;
  bool flag;
  while(1) {
    flag=true;
    for(int i=0; i<A.size(); i++)
      if(A.at(i)%2==0) A.at(i)/=2;
      else flag=false;
    if(!flag) break;
    count++;
  }
  cout << count << endl;
}


Measured memory_bytes: 256
resolve :: Int -> Int -> Int -> Int
resolve x 0 _ = x
resolve x k d
  | x <= abs (x - d) = if even k then x else x - d
  | x > abs (x - d) = case x `div` d of
                         q
                           | q == 0 -> if abs (x - d) < x && odd k
                                          then abs (x - d)
                                          else x
                           | q >= k -> resolve (x - d * k) 0 d
                           | q < k  -> resolve (x - d * q) (k - q) d

main :: IO ()
main = do
    [x, k, d] <- getLine >>= return . map read . words
    let ans = resolve (abs x) k d
    print $ abs ans


Measured memory_bytes: 3928
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <deque>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, up) for (ll i = 0; i < up; ++i)
#define repp(i, up) for (ll i = 0; i <= up; ++i)
#define rrep(i, lo, up) for (ll i = lo; i < up; ++i)
#define rrepp(i, lo, up) for (ll i = lo; i <= up; ++i)

#define rdi(i) ll i; scanf("%lld", &i)
#define rds(s) string s; cin >> s
#define rdc(c) char c; cin >> c

#define INF 10000000000

int main()
{
    rds(s);
    rdi(q);
    deque<char> front, back;
    bool inv = false;
    rep(i, q) {
        rdi(t);
        if (t == 1) {
            inv = !inv;
        } else {
            rdi(f);
            rdc(c);
            if (f == 1) {
                if (inv) {
                    back.push_back(c);
                } else {
                    front.push_front(c);
                }
            } else {
                if (inv) {
                    front.push_front(c);
                } else {
                    back.push_back(c);
                }
            }
        }
    }
    if (inv) {
        for (auto it = back.rbegin(); it != back.rend(); ++it) {
            printf("%c", *it);
        }
        for (auto it = s.rbegin(); it != s.rend(); ++it) {
            printf("%c", *it);
        }
        for (auto it = front.rbegin(); it != front.rend(); ++it) {
            printf("%c", *it);
        }
        printf("\n");
    } else {
        for (auto it = front.begin(); it != front.end(); ++it) {
            printf("%c", *it);
        }
        for (auto it = s.begin(); it != s.end(); ++it) {
            printf("%c", *it);
        }
        for (auto it = back.begin(); it != back.end(); ++it) {
            printf("%c", *it);
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
#include <cctype>

using namespace std;

#define Int int64_t

void printVec(std::vector<int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}

int vector_finder(std::vector<string> vec, string number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}

#include <sstream> 
std::vector<std::string> StringSplit(const std::string& str, char sep)
{
	std::vector<std::string> v;
	std::stringstream ss(str);
	std::string buffer;
	while (std::getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}



int main() {
	int n; cin >> n;
	int maxx = 0;
	int dis=1;
	int cnt;
	for (int i = 1; i <= n; i++) {
		cnt = 0;
		int j = i;
		while (j) {
			j =j/2;
			cnt++;
			//cout << j;
		}
		if (cnt > maxx) dis = i; maxx = cnt;
	}
	cout << dis;

	cout << endl;
	return 0;
}

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

#define sf                  scanf
#define pf                  printf
#define srev                reverse(s.begin(),s.end())
#define sortstr             sort(s.begin(), s.end());
#define getline(s)              getline(cin, (s));
#define gcd(a, b)           __gcd(a, b)
#define lcm(a, b)           ((a)*((b)/gcd(a,b)))
#define PI                  acos(-1)
#define Precision(a) cout << fixed << setprecision(a)
#define FasterIO     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);


template <typename T> T Sqr(T x) { T n = x * x ; return n ;}
template <typename T> T Pow(T B,T P){ if(P==0) return 1; if(P&1) return B*Pow(B,P-1);  else return Sqr(Pow(B,P/2));}
template <typename T> T Abs(T a) {if(a<0)return -a;else return a;}
template <typename T> T Gcd(T a,T b){if(a<0)return Gcd(-a,b);if(b<0)return Gcd(a,-b);return (b==0)?a:Gcd(b,a%b);}
template <typename T> T Lcm(T a,T b) {if(a<0)return Lcm(-a,b);if(b<0)return Lcm(a,-b);return a*(b/Gcd(a,b));}
//scanf("%[^\n]", str);
//sort(s,s+n,greater<int>());

int main()
{
    FasterIO
    double l;
    cin >> l;
    printf("%.12lf\n",l*l*l/27);
    return 0;
}


Measured memory_bytes: 256
s = list(input())
while True:
    del s[len(s)-1]
    if len(s)%2==0:
        index=0
        while index < len(s)//2:
            if s[index] == s[len(s)//2+index]:
                index+=1
            else:
                break
        if index == len(s)//2:
            print(len(s))
            break

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n, k;
  cin >> n >> k;
  double ans = 0;

  for(int i = 1; i <= n; ++i) {
    int now = i;
    double add = 1.0/n;
    while(now < k) {
      add *= 0.5;
      now *= 2;
    }
    ans += add;
  }
  printf("%0.15f\n", ans);
}

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

int main()
{
    int N, D, X;
    cin >> N >> D >> X;

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

    int ans = X;
    for (int i = 0; i < N; i++)
    {
        for (int j = 1; j <= D; j += A[i])
        {
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace abc131_d
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = GetInt();
            var ABL = new List<List<int>>();
            var ABD = new SortedDictionary<int, List<int>>();

            for (int i = 0; i < N; i++)
            {
                var AB = GetIntList();
                ABL.Add(AB);
                if (!ABD.ContainsKey(AB[1])) ABD.Add(AB[1], new List<int>());
                ABD[AB[1]].Add(i);
            }

            long r = 0;
            foreach (var k in ABD.Keys)
            {
                var v = ABD[k];
                foreach (var i in v)
                {
                    var AB = ABL[i];
                    r += AB[0];
                    if (r > AB[1])
                    {
                        Console.WriteLine("No");
                        return;
                    }

                }
            }
            Console.WriteLine("Yes");
        }

        public static string GetStr() => Console.ReadLine();
        public static int GetInt() => int.Parse(Console.ReadLine());
        public static long GetLong() => long.Parse(Console.ReadLine());
        public static double GetDouble() => double.Parse(Console.ReadLine());
        public static decimal GetDecimal() => decimal.Parse(Console.ReadLine());

        public static List<string> GetStrList() => Console.ReadLine().Split(' ').ToList();
        public static List<int> GetIntList() => Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
        public static List<long> GetLongList() => Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList();
        public static List<double> GetDoubleList() => Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToList();
        public static List<decimal> GetDecimalList() => Console.ReadLine().Split(' ').Select(x => decimal.Parse(x)).ToList();

    }
}


Measured memory_bytes: 65364
#include <iostream>
#include <string>
using namespace std;
int main(){
  string T;
  cin>>T;
  //length()をsize()に変えた。
  int size = T.size();
  int flag[size];
  int count=0;
  int ans=0;
  
  for(int i=0;i<size;i++){
    if(T[i]=='A'||T[i]=='T'||T[i]=='G'||T[i]=='C'){
      flag[i]=1;
      count+=1;
    }else{
      flag[i]=0;
      ans = max(ans, count);
      count=0;
    }
  }
  //最終チェック
  ans = max(ans, count);
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func main() {
	var s string
	fmt.Scan(&s)

	ans := 999999999999999
	for i := 0; i <= len(s)-3; i++ {
		x := int(s[i]-'0')*100 + int(s[i+1]-'0')*10 + int(s[i+2]-'0')
		y := abs(x - 753)
		if y < ans {
			ans = y
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512