akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdlib>
#include <algorithm>
using namespace std;

int main(){
  int n;
  string c;
  cin>>n;
  cin>>c;
  int siro,aka;
  int kaisuu;
  siro=0;
  aka=0;
  for(int i=0; i<n; i++)
    if(c[i]=='R')
      aka++;
  kaisuu=min(siro,aka)+abs(siro-aka);
      
  for(int i=0; i<n; i++){
    if(c[i]=='W')
      siro++;
    else
      aka--;

    kaisuu=min(kaisuu,min(siro,aka)+abs(siro-aka));
  }
  cout<<kaisuu;
  
  return 0;
}


Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<int,int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define getbit(n,i) (((n)&(1LL<<(i)))!=0)
#define setbit0(n,i) ((n)&(~(1LL<<(i))))
#define setbit1(n,i) ((n)|(1LL<<(i)))
#define togglebit(n,i) ((n)^(1LL<<(i)))
#define lastone(n) ((n)&(-(n)))
#define read freopen("debug\\in.txt","r",stdin)
#define write freopen("debug\\out.txt","w",stdout)
#define fi first
#define se second
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d%d",&a,&b)
#define PI (acos(-1))
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD (1000000007)
#define asz 500005
#define pb push_back
#define ppf pop_front
#define ppb pop_back
#define pf push_front
ll a[500005];
ll modularExponentiation(ll x,ll n,ll M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return modularExponentiation((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*modularExponentiation((x*x)%M,(n-1)/2,M))%M;

}
int main() {
    fastread;
    ll t, n, i, j, k, l, m;
    cin >> n >> k;
   /// ll sum=0;
    ll cnt=0;
    ///ll cnt=0;
    for(i=k;i>=2;i--){
        cnt=0;
        for(j=1;j*i<=k;j++){
            cnt=(a[i*j]+cnt)%MOD;
        }
        ll num=k/i;
        ll kola=modularExponentiation(num,n,MOD);
        ll res=(kola-cnt+MOD)%MOD;
        a[i]=res;
    }
    ll sum=0;
    ll kola=0;
    for(i=2;i<=k;i++){
        sum=(sum+(a[i]*i)%MOD)%MOD;
        kola=(a[i]+kola)%MOD;
    }
    cnt=(modularExponentiation(k,n,MOD)-kola+MOD)%MOD;
    ///cnt=(-cnt+modularExponentiation(k,n,MOD)+MOD)%MOD;
    sum=(sum+cnt)%MOD;
    cout<<sum;
}


Measured memory_bytes: 4392
#include<stdio.h>

int main()
{
  int S,h,m,s;

  scanf("%d",&S);
  h = S / 3600;
  m = (S % 3600) / 60;
  s = (S % 3600) % 60;
  printf("%d:%d:%d\n",h,m,s);

  return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=3e5+10;
struct point{int l,r;}a[N];
int n,m,tot,ans,c[N];
vector<int>vec[N];
int sum(int x){int ret=0;while(x)ret+=c[x],x-=x&-x;return ret;}
void add(int x,int y){while(x<=n)c[x]+=y,x+=x&-x;}
int main()
{
	scanf("%d%d",&m,&n);
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&a[i].l,&a[i].r);
		if(a[i].l)vec[a[i].r-a[i].l+1].push_back(i);
	}
	tot=m;
	for(int i=1;i<=n;i++)
	{
		ans=0;
		for(int j=1;j<=n/i;j++)ans+=sum(i*j);
		printf("%d\n",tot+ans);
		for(auto j:vec[i])add(a[j].l,1),add(a[j].r+1,-1),tot--;
	}
}

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

using namespace std;

#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long

static const ll MAX = 1000000;
static const ll INFTY = 1e12;
static const ll MOD = 1000000007;

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };

struct edge {
    ll to, cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;


const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

// 深さ優先探索
vector<bool> seen;
vector<int> colors;

int H, W, N;
int sx, sy, gx, gy; 
vector<vector<char>> field;
vector<vector<int>> dist;
//vector<pair<int, int>> gx, gy;
deque<pair<int, int>> que;

typedef vector<vector<int> > Matrix;

const ll INF = 1e18;
#define PI 3.14159265358979323846264338327950L
#define deg_to_rad(deg) (((long double)(deg)/360.0)*2*M_PI)
int main() {

    int A, B, H, M;
    cin >> A >> B >> H >> M;

    long double rad = ((long double)H*60.0 + ((long double)M)) / 2.0- (long double)M * 6.0;
    rad = PI * 2 * (rad/360.0);

    int hun = H*60+M;

    long double tansin = (long double)(360*hun/(720.0));
    long double tyosin = (long double)(M*6);

    long double kakudo;
    // if(abs(tansin-tyosin)>180){
    //     kakudo = 360-abs(tansin-tyosin);
    // }else{
    //     kakudo = abs(tansin-tyosin);
    // }
    kakudo = tansin-tyosin;


    kakudo = deg_to_rad(kakudo);

        // cout << rad << " "<< kakudo << endl;

    long double a;

    /* 余弦定理 */
    a = (long double)A * A + B * B - 2 * A * B * (long double)cosl( kakudo );
    /* 平方根 */
    a = sqrtl( a );

    printf("%20.20Lf\n", a);

    // cout << a;
}

/*
みんな、くるくるぱーにな〜れ
　∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/



Measured memory_bytes: 4104
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <stack>
using namespace std;
typedef long long int lli;
int main(void)
{
    vector<lli> a;
    lli tmp, N;
    cin >> N;
    for (lli i = 0; i < N; i++)
    {
        cin >> tmp;
        a.push_back(tmp);
        if (tmp == 0)
        {
            cout << 0 << endl;
            return 0;
        }
    }
    lli ans1 = 1;
    lli ans2 = 1;
    lli th = (lli)(powl(10, 18));
    sort(a.begin(), a.end());
    for (int i = 0; i < N; i++)
    {
        if (a[i] <= th / ans1)
        {
            ans1 *= (a[i]);
        }
        else
        {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << (lli)(ans1) << endl;
    return 0;
}

Measured memory_bytes: 4328
#include <stdio.h>

int main (){
    int a = 0;
    int b = 0;
    char op;

    scanf("%d %c %d",&a,&op,&b);

    if (op == '+'){
        printf("%d\n", a + b);
    } 
    else if (op == '-') {
        printf("%d\n",a - b);
    }


    return 0;
}

Measured memory_bytes: 128
n = int(input())
v = input().split()
if len(set(v)) == 1:
    print(int(n/2))
    exit()
even = v[0::2]
odd = v[1::2]
deven = {i:0 for i in set(even)}
dodd = {i:0 for i in set(odd)}
for i in even:
    deven[i] += 1
for i in odd:
    dodd[i] += 1
deven = sorted(deven.items(), key = lambda x: x[1], reverse = True)
dodd = sorted(dodd.items(), key = lambda x: x[1], reverse = True)
res = 0
if deven[0][0] != dodd[0][0]:
    if deven[0][1] != int(n/2):
        res += int(n/2) - deven[0][1]
    if dodd[0][1] != int(n/2):
        res += int(n/2) - dodd[0][1]
else:
    if deven[0][1] == dodd[0][1]:
        res += n - deven[0][1] - max(deven[1][1], dodd[1][1])
    else:
        if deven[0][1] > dodd[0][1]:
            res += n - deven[0][1] - dodd[1][1]
        else:
            res += n - dodd[0][1] - deven[1][1] 
print(res)

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	vector<int>a(n); for(auto&i:a)cin>>i;
	vector<int>pls;
	int64_t mns=0; int ans=0;
	for(int i=0;i<n;++i){
		int b; cin>>b;
		int cal=a.at(i)-b;
		if(cal<0)mns+=cal,++ans;
		else pls.emplace_back(cal);
	}
	sort(pls.begin(),pls.end(),greater<int>());
	for(int i=0;i<pls.size()&&mns<0;++i){
		int rem=pls.at(i);
		mns+=rem;
		++ans;
	}
	cout<<(mns<0?-1:ans)<<"\n"s;
}

Measured memory_bytes: 1276
N = int(input())
weights = list(map(int, input().split()))
gross = sum(weights)
cumulative = [sum(weights[:i]) for i in range(1, len(weights)+1)] 


abs_differences = []
for T in range(N):
    left = cumulative[T]
    right = gross - left
    abs_diff = abs(left - right)
    abs_differences.append(abs_diff)
    
print(min(abs_differences))


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

int main(){
	int n;
	cin >> n;
	int a[n];
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	cout << a[n-1];
	for(int i=1;i<n;i++){
		cout << " " << a[n-i-1];
	}
	cout << endl;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int read(){
	int x=0,f=1;char c=getchar();
	while(c<'0'||c>'9') c=='-'?f=-1,c=getchar():c=getchar();
	while(c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	return x*f;
}
int head[30001],cnt,w[30001],pd[30001];
struct node {
	int to,next;
}a[30001];
void add(int x,int y){
	a[++cnt].to=y;
	a[cnt].next=head[x];
	head[x]=cnt;
}
void dfs(int x,int fa){
    for(int i=head[x];i;i=a[i].next){
		int v=a[i].to;
		if(v==fa||w[v]>=w[x])
			continue;
		dfs(v,x);
		if(!pd[v]){
			pd[x]=1;
			break;
		}
	}
}
int main(){
	int n=read(),x,y;
	for(int i=1;i<=n;i++)
		w[i]=read();
	for(int i=1;i<n;i++)
		x=read(),y=read(),add(x,y),add(y,x);
	for(int i=1;i<=n;i++){
		memset(pd,0,sizeof(pd));
		dfs(i,0);
		if(pd[i])
			printf("%d ",i);
	}
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <math.h>//累乗計算用
#include <cstring>//配列初期化
using namespace std;
 
bool field[ 10 ][ 10000 ];//せんべいの初期状態
bool binary[ 10 ];//2進数カウンタ
long flag;//解答の候補
int r ,c ,ans;//r,c:入力用  ans:答え
 
long FlagMake( void );//解答の候補の列挙
void Count( int area );//2進数カウンタの計算
 
int main( void ){
    cin >> r >> c;
    while(r != 0 && c != 0){//r=0,c=0でプログラム終了
        for(long i = 0 ; i < r ; i++ ){
            for(long j = 0 ; j < c ; j++ ){
                cin >> field[ i ][ j ];
            }
        }//ここまで入力
 
        ans = 0;//解答の初期化
        memset(binary , 0 , sizeof( binary ) );//配列の初期化
 
        for(long i = 0 ; i < pow( 2 , r ) ; i++ ){//pow関数:pow(基数,指数) この場合、2のr乗という意味
            if(i != 0){Count( 0 );}//カウンタを1進める
            FlagMake();//カウンタごとの解答の候補を検索
            if( ans < flag ) ans = flag;//解答の候補が現状の解答より多ければ、解答更新
        }
 
        cout << ans << endl;//解答出力
 
        cin >> r >> c;//再入力
    }
}
 
long FlagMake(){
    int low ,high;
     
    flag = 0;
     
    for(long i = 0 ; i < c ; i++ ){
         
        low = 0; high = 0;//low:裏側の枚数,high:表側の枚数
         
        for(int j = 0 ; j < r ; j++ ){
            if( binary[ j ] == 1 ){//行が裏返されているとき
                if( field[ j ][ i ] == 0){high++; }
                else{low++; }
            }
            else{//行が裏返っていないとき
                if( field[ j ][ i ] == 0 ){low++; }
                else{high++; }
            }
        }
        if( low > high ){flag += low; }//列を裏返すかどうかの判定
        else{flag += high; }
    }
     
    return flag;//解答の候補を返す
}
 
void Count( int area ){
    if( binary[ area ] == 0 ){binary[ area ] = 1;}//繰り上げなしの時
    else{//繰り上げありの時
        binary[ area ] = 0;
        Count( area + 1 );
    }
}



Measured memory_bytes: 3340
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
#define MOD 1000000007
ll powll(ll a,ll b){ll r=1;rep(i,b){r*=a;}return r;}
#define swap(a,b) do{ll w=(a);(a)=(b);(b)=w;}while(0)
#define swapd(a,b) do{double w=(a);(a)=(b);(b)=w}while(0)
#define in(a) scanf("%lld", &(a))
#define in2(a,b) scanf("%lld %lld",&(a),&(b))
#define in3(a,b,c) scanf("%lld %lld %lld",&(a),&(b),&(c))
#define ind(a) scanf("%lf", &(a))
#define ins(a) scanf("%s", (a))
#define put(a) printf("%lld\n", (a))
#define putd(a) printf("%.15f\n", (a))
//      puts(a) printf("%s\n", a) 文字はこっち
//your code here!
int main(void){
    ll N, f=0;
    in(N);
    ll n = N;
    while(N){
        f += N%10;
        N /= 10;
    }
    puts(n%f ? "No":"Yes");
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
using ll=long long int;

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

    cout << a * b / 2 << endl;

    return 0;
}


Measured memory_bytes: 256
<?php
$stdin=trim(fgets(STDIN));
$nums=explode(" ",$stdin);

$count_5=0;
$count_7=0;
foreach ($nums as $num) {
    if($num==5){
        $count_5 +=1;
    }elseif ($num==7) {
        $count_7 +=1;
    }
}

if($count_5==2 && $count_7==1){
    echo "YES".PHP_EOL;
}else{
    echo "NO".PHP_EOL;
}


Measured memory_bytes: 2936
#include <iostream>
#include <vector>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int r, c;
  cin >> r >> c;

  vector<vector<int>> matrix(r+1, vector<int>(c+1));

  for(int i=0; i<r; i++) {
    for(int j=0; j<c; j++) {
      cin >> matrix.at(i).at(j);
    }
  }

  for(int i=0; i<r; i++) {
    for(int j=0; j<c; j++) {
      matrix.at(i).at(c) += matrix.at(i).at(j);
    }
  }

  for(int i=0; i<c+1; i++) {
    for(int j=0; j<r; j++) {
      matrix.at(r).at(i) += matrix.at(j).at(i);
    }
  }

  for(int i=0; i<r+1; i++) {
    for(int j=0; j<c+1; j++) {
      cout << matrix.at(i).at(j);
      if(j != c) cout << " ";
      else cout << "\n";
    }
  }
  return 0;
}



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

typedef long long LL;

int main()
{
    LL n, x, t;
    cin >> n >> x >> t;
    LL time=0;
    while(n>0){
        n = n-x;
        time += t;
    }
    cout << time << endl;
    return 0;
}

Measured memory_bytes: 3600
#include <stdio.h>

int main(void) {
  int A, B, C, D, E, F;
  int A100, B100;
  int a, b, c, d;
  double ratio;
  double max_ratio = -1, current_ratio;
  int max_sugar, max_water;

  scanf("%d %d %d %d %d %d", &A, &B, &C, &D, &E, &F);
  A100 = A * 100;
  B100 = B * 100;
  ratio = (double)E / (100.0 + E);

  for (a = 0; A100*a <= F; a++) {
    for (b = 0; A100*a + B100*b <= F; b++) {
      if (a == 0 && b == 0) continue;
      for (c = 0; A100*a + B100*b + C*c <= F; c++) {
        for (d = 0; A100*a + B100*b + C*c + D*d <= F; d++) {
          if (ratio >= (current_ratio = ((double)(C*c + D*d) / (A100*a + B100*b + C*c + D*d))) &&
            max_ratio < current_ratio) {
            max_sugar = C*c + D*d;
            max_water = A100*a + B100*b;
            max_ratio = (double)max_sugar / (max_water + max_sugar);
          }
        }
      }
    }
  }
  printf("%d %d\n", max_sugar + max_water, max_sugar);

  return 0;
}


Measured memory_bytes: 128
import java.util.*;
public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    String[] s = sc.next().split("");
    int ramen  = 700;
    for(int i = 0;i<s.length;i++){
      if(s[i].equals("o"))ramen += 100;   
    }
    System.out.print(ramen);
  } 
}

Measured memory_bytes: 21716
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int a = Integer.parseInt(str[0]);
    int b = Integer.parseInt(str[1]);
    int c = Integer.parseInt(str[2]);
    
    System.out.println(a-b>=c?0:c-(a-b));
  }
}

Measured memory_bytes: 21204
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
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; }
using pi = pair<int,int>;
int n;
vector<int> dx = {1, 0, -1, 0};
vector<int> dy = {0, 1, 0, -1};
vector<pi> mov(int x, int y) {
  vector<pi> res;
  rep(j,4) {
    int nx = x + dx[j];
    int ny = y + dy[j];
    if(0 < nx && nx <= n && 0 < ny && ny <= n) {
      res.push_back({nx, ny});
    }
  }
  return res;
}
int main()
{
  cin >> n;
  vector<int> p(n*n);
  rep(i,n*n) {
    cin >> p[i];
  }

  vector<vector<int>> c(n+1, vector<int>(n+1));
  rep1(i,n) rep1(j,n) {
    c[i][j] = min({i-1, n-i, j-1, n-j});
  }

  auto show = [&]()-> void{
		rep1(i,n) {
		  rep1(j,n) cout << c[i][j] << " ";
		  cout << "\n";
		}  
	      };
  
  vector<vector<bool>> f(n+1, vector<bool>(n+1, true));


  int res = 0;
  rep(i,n*n) {
    int x = (p[i] + n - 1)/n;
    int y = (p[i] % n == 0 ? n : p[i] % n);
    res += c[x][y];
    f[x][y] = false;
    queue<pi> q;
    q.push({x, y});
    while( !q.empty() ) {
      pi pp = q.front(); q.pop();
      int xx = pp.first, yy = pp.second;
      vector<pi> buf = mov(xx, yy);
      rep(j,buf.size()) {
	int nx = buf[j].first;
	int ny = buf[j].second;	
	if(chmin(c[nx][ny], c[xx][yy] + f[xx][yy])) {
	  q.push({nx, ny});
	}
      }
    }
  }
  cout << res << "\n";
  return 0;
}


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

struct dat {
  int d;
  vector<int> c;
  vector<vector<int>> s;
};

int calc(const dat &a, const vector<int> &last, int day, int t) {
  int v = 0;
  v += a.s.at(day - 1).at(t);
  for (int i = 0; i < 26; i++) {
    if (i == t) continue;
    v -= a.c.at(i) * (day - last.at(i));
  }
  return v;
}

int main() {
  int d;
  cin >> d;
  vector<int> c(26);
  vector<vector<int>> s(d, vector<int>(26));
  for (int i = 0; i < 26; i++) {
    cin >> c.at(i);
  }
  for (int i = 0; i < d; i++) {
    for (int j = 0; j < 26; j++) {
      cin >> s.at(i).at(j);
    }
  }
  dat a = {d, c, s};
  
  int w = 26;
  vector<vector<int>> last(w, vector<int>(26)), ans(w);
  vector<int> score(w);
  for (int i = 0; i < d; i++) {
    vector<tuple<int, int, int>> idx;
    for (int j = 0; j < w; j++) {
      vector<int> best(w, -1e9), best_t(w);
      for (int t = 0; t < 26; t++) {
        int v = calc(a, last.at(j), i + 1, t);
        if (v > best.at(w - 1)) {
          best.at(w - 1) = v;
          best_t.at(w - 1) = t;
        }
        for (int k = w - 1; k > 0; k--) {
          if (best.at(k - 1) < best.at(k)) {
            swap(best.at(k - 1), best.at(k));
            swap(best_t.at(k - 1), best_t.at(k));
          }
        }
      }
      for (int k = 0; k < w; k++) {
        idx.emplace_back(score.at(j) + best.at(k), j, best_t.at(k));
      }
    }
    sort(idx.rbegin(), idx.rend());
    vector<vector<int>> newlast(w, vector<int>(26)), newans(w);
    for (int j = 0; j < w; j++) {
      int k = get<1>(idx.at(j)), t = get<2>(idx.at(j));
      score.at(j) = get<0>(idx.at(j));
      newans.at(j) = ans.at(k);
      newlast.at(j) = last.at(k);
      newans.at(j).push_back(t);
      newlast.at(j).at(t) = i + 1;
    }
    ans = newans;
    last = newlast;
  }
  for (int i = 0; i < d; i++) {
    cout << ans.at(0).at(i) + 1 << endl;
  }
}


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

int dp[105][10];
int mod = 1000000007;

int main() {
    int H, W, K; cin >> H >> W >> K;
    dp[0][0] = 1;
    for (int i = 0; i < H; i++){
        for (int j = 0; j < 1<<(W-1); j++){
            bool ok = true;
            for (int k = 0; k < (W-2); k++){
                if(j>>k&1 == 1 && j>>(k+1)&1 == 1){
                    ok = false;
                }
            }
            if(!ok)continue;
            for (int k = 0; k < W; k++){
                int t = k;
                if(j>>(k-1)&1 == 1)t = k-1;
                if(j>>(k)&1 == 1)t = k+1;
                dp[i+1][t] += dp[i][k];
                dp[i+1][t] %= mod;
            }

        }
    }

    cout << dp[H][K-1] << endl;

    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<int> a(3);
  cin>>a.at(0)>>a.at(1)>>a.at(2);
  sort(a.begin(),a.end());
  if(a.at(0)+a.at(1)==a.at(2)){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm>
typedef long long int ll;
using namespace std;
ll n,k;
ll h[1000005];
ll a[1000005];
 

ll abso(ll n)
{
	if (n<0)
	return (-1*n);
	else
	return n;
}

ll go(ll p)
{
if (p<2)
return 0;
else if (a[p]!=-1)
return a[p];
else
{
	ll x=pow(10,11);
	for (ll i=1;i<=k;i++)
	{
		if (p-i<1)
		break;
		x=min(x,(go(p-i)+abs(h[p]-h[p-i])));
	}
	a[p]=x;
	return x;
	}	
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   
    cin>>n>>k;
    
    for (ll i=1;i<=n;i++)
    cin>>h[i];
    memset(a,-1,sizeof(a));
    cout<<go(n);
    

}


Measured memory_bytes: 15232
//#include <bits/stdc++.h>
#include<iostream>
#include<stdio.h>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;


int main(void) {

	while (1) {
		int n;

		cin >> n;
		if (n == 0) {
			break;
		}
		vector<string>l(n);
		vector<int>time(n), money(n);
		vector<double>eff(n);
		vector < pair<double, int> > dp(n);
		int p, a, b, c, d, e, f, s, m;
		string tmp;

		FOR(i, 0, n - 1) {
			cin >> l[i] >> p >> a >> b >> c >> d >> e >> f >> s >> m;
			time[i] = a + b + c + d + e + (m - 1)*(d + e);
			money[i] = m * s*f - p;
			eff[i] = (double)money[i] / (double)time[i];
			dp[i] = make_pair(eff[i], i);
			//cout << eff[i] << endl;
		}
		sort(dp.begin(), dp.end());
		
		int count = 0;
		do {
			count = 0;
			FOR(i, 0, n - 2) {
				if (dp[i].first == dp[i + 1].first) {
					if (l[dp[i].second] < l[dp[i + 1].second]) {
						count++;
						tmp = l[dp[i].second];
						l[dp[i].second] = l[dp[i + 1].second];
						l[dp[i + 1].second] = tmp;
					}
				}
			}
		} while (count != 0);
		
		RFOR(i, n-1, 0) {
			cout << l[dp[i].second] << endl;
		}
		cout << "#" << endl;
	}

	return 0;
}


Measured memory_bytes: 3160
import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    S = list(iss())
    print("".join(["1" if s == "9" else "9" for s in S]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import java.util.Scanner;
//import java.io.*;

class Main {
    public static void main(String[] args){ 
    	Scanner scan = new Scanner(System.in);
    	   	                                                 
    	String stR,str; 
        char[] atoz;
        int ascii; 
        char alpha = 'a';

                
        int [] AtoZ = new int[26];

        while(scan.hasNext()){
            stR = scan.nextLine();
            str = stR.toLowerCase();    //?°??????????
            atoz = str.toCharArray();   //char??????

                for(int ch = 0; ch < atoz.length; ch++){   //???????????¢?????????????????????
                ascii = atoz[ch] - 'a';
                if(ascii >=0 && ascii <26){
                	AtoZ[ascii]++;
                }
                }            
        }

        for(int j = 0; j < 26; j++){
        System.out.println(alpha+" : "+ AtoZ[j]);
        alpha++;
        }
     }
}

Measured memory_bytes: 25992
// In The Name Of God

#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll long long

using namespace std;

string a;

int main()
{
    IOS;
    cin >> a;
    if(a[a.size() - 1] == 's')
        a += "es";
    else
        a += 's';
    cout << a << endl;
}


Measured memory_bytes: 3604
/**
 *    author : HikaruEgashira
 *    created: 08.01.2020
**/
use proconio::input;

// @エラトステネスの篩.rs
fn factors(max: usize) -> Vec<Vec<usize>> {
    let mut factors = vec![vec![]; max];
    (2..factors.len()).for_each(|i| {
        if factors[i].is_empty() {
            (i..factors.len()).step_by(i).for_each(|j| {
                factors[j].push(i);
            });
        }
    });
    factors
}

#[proconio::fastout]
fn main() {
    input! {
        n: usize,
        a: [usize; n],
    }

    let a: Vec<usize> = a;

    const MAX_A: usize = 1_000_001;
    let factors = factors(MAX_A);

    // [6, 9] -> [[], [], [6], [6, 9], ..]
    let mut prime_pos = vec![vec![]; MAX_A];
    a.iter().for_each(|&ai| {
        factors[ai].iter().for_each(|&p| {
            prime_pos[p].push(ai);
        })
    });

    // `if a.iter()prime_pos[fi].len()`が2以上なら公約数があるってことになる
    let pairwise = a
        .iter()
        .all(|&ai| factors[ai].iter().all(|&fi| prime_pos[fi].len() == 1));
    // 因数分解表にa全てが含まれる素数がない
    let setwise = !prime_pos.contains(&a);

    let res = if pairwise {
        "pairwise coprime"
    } else if setwise {
        "setwise coprime"
    } else {
        "not coprime"
    };

    println!("{}", res);
}


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

vector<int> divisor(int x) {
	vector<int> res;

	for(int i = 1; i * i <= x; ++i) {
		if(x % i == 0) {
			res.push_back(i);
			if(i * i != x) res.push_back(x / i);
		}
	}

	return res;
}

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

	int n;
	cin >> n;

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

	int g = a[0];
	for(int i = 1; i < n; ++i) {
		g = __gcd(g, a[i]);
	}

	vector<int> d = divisor(g);
	sort(d.begin(), d.end());
	for(int i = 0; i < static_cast<int>(d.size()); ++i) {
		cout << d[i] << endl;
	}

	return EXIT_SUCCESS;
}

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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)


int nCr(int n , int r ) {
	int p = 1, k = 1;

	if (n - r < r ) {
		r = n - r;
	}
	if (r != 0) {
		while (r != 0) {
			p *= n ;
			k *= r ;
			int m = __gcd(p, k);
			p /= m;
			k /= m;
			n--;
			r--;
		}
	}
	else {
		p = 1;
	}
	return p ;
}

void aryan_p() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	return;
}


int32_t main() {
	


	int n ;
	cin >> n;
	string s ;
	cin >> s;

	if (n & 1) {
		cout << "No";
	}
	else {
		for (int i = 0 ; i < (n / 2) ; i++) {
			if (s[i] != s[i + n / 2]) {
				cout << "No";
				return 0 ;
			}
		}
		cout << "Yes";
	}


	return 0;
}

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  in(int, n, k);
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  sort(all(h));
  int ans = h[n - 1] - h[0];
  rep(i, n) if (i + k - 1 < n) { ans = min(ans, h[i + k - 1] - h[i]); }
  out(ans);
}


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

int main(void){
  int n = 1000;
  string s;
  while(n--){
    cin>>s;
    bool ans = true;
    for(int i = 0 ; i < s.size() - 1 ; i ++){
      if((s[i]-'A')/3 == (s[i+1]-'A')/3 && abs(s[i]-s[i+1])==1){
	continue;
	cout<<(s[i]-'A')/3<<" "<<(s[i+1]-'A')/3<<endl;
      }
      if(abs(s[i]-s[i+1])==3)continue;
      //cout<<i<<" "<<s[i]<< " "<<s[i+1]<<endl;
      ans=false;
      break;
    }
    if(ans)cout<<s<<endl;
  }
}

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

#define ll long long
#define ull unsigned ll

#define vi vector <int>
#define ii pair <int, int>
#define vii vector <ii>
#define vll vector <ll>
#define vull vector <ull>
#define INFL 9e18
#define INF 2e9
#define EPS 1e-9
#define pb push_back
#define emp emplace_back
#define PI acos(-1.0)
#define endl "\n"
#define mp make_pair
#define mod 1000003
#define DEBUG 0




int main ()

{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n;
    cin >> n;
    
    vi num(n);
    double sum = 0;
    for (int i=0; i<n; i++)
    {
        cin >> num[i];
        sum += num[i];
    }

    sum /= n;
    
    double answer = (fabs(sum-(int)sum) < 0.5) ? ((int) sum) : ((int) sum + 1);
    int difference = 0;
    for (int i=0; i<n; i++)
    {
        difference += (answer-num[i])*(answer-num[i]);
    }
    
    cout << difference << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
 
 
    double a, b, x, y;
    cin >> a >> b >> x >> y;
    double c = (a*b)/2;
    double d = a/2, e = b/2;
    if( x == d && y == e )
        cout << fixed << setprecision(10) << c << " "  << 1 << endl;
    else
        cout << fixed << setprecision(10) << c << " " << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    from sys import stdin
    input = stdin.readline

    n, m, s, t = map(int, input().split())
    uvab = [list(map(int, input().split())) for _ in [0]*m]
    g = [[] for _ in [0]*n]
    [g[u-1].append([v-1, a, b]) for u, v, a, b in uvab]
    [g[v-1].append([u-1, a, b]) for u, v, a, b in uvab]

    import heapq

    inf = 10**15

    yen = [inf for _ in [0]*n]
    h = [(0, s-1)]
    heapq.heapify(h)
    while h:
        d, i = heapq.heappop(h)
        if yen[i] == inf:
            yen[i] = d
            for x, y, z in g[i]:
                heapq.heappush(h, (d+y, x))

    snk = [inf for _ in [0]*n]
    h = [(0, t-1)]
    heapq.heapify(h)
    while h:
        d, i = heapq.heappop(h)
        if snk[i] == inf:
            snk[i] = d
            for x, y, z in g[i]:
                heapq.heappush(h, (d+z, x))

    cost = [yen[i]+snk[i] for i in range(n)]
    m = cost[-1]
    for i in range(n-1, -1, -1):
        m = min(m, cost[i])
        cost[i] = m

    for i in cost:
        print(10**15-i)


main()

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

typedef long long ll;

#define pb push_back
#define mp make_pair
#define f first
#define s second
#define all(a) a.begin(), a.end()

const int maxn = 100010;
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;
int n, m, a[maxn];
string s, ss;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n, x, t;
    cin >> n >> x >> t;
    cout << ((n+x-1)/x)*t;
}

Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <set>
#include <algorithm>

using namespace std;

bool is_unique(const string &s)
{
	return set<char>(s.begin(), s.end()).size() == 1;
}

int simulate(string s, char c)
{
	int ans = 0;
	while (!is_unique(s)) {
		const int n = s.size();
		string t;
		for (int i = 0; i + 1 < n; ++i) {
			if (s[i] == c || s[i + 1] == c) {
				t += c;
			}
			else {
				t += s[i];
			}
		}
		s = move(t);
		++ans;
	}
	return ans;
}

int main()
{
	string s;
	cin >> s;
	int ans = s.size();
	for (char c : s) {
		ans = min(ans, simulate(s, c));
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#%%
n = int(input())
s = list(input())
ans = 'Yes'
if n % 2 == 0:
    m = n //2
    for i in range(m):
        if s[i] == s[i+m]:
            pass
        else:
            ans = 'No'
else:
    ans = 'No'
print(ans)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#include "string"
#define endl '\n'
#define PI pair<int,int>
#define ff first
#define ss second
#define int long long 
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL)


int nC2(int n){
	if(n==1 or n==0)
		return 0;
	return n*(n-1)/2;
}

int32_t main() {

	
	int a,b;
	cin>>a>>b;
	int ans=nC2(a)+nC2(b);
	cout<<ans<<endl;	

}


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

int main() {
  int N, K;
  cin >> N >> K;
  long ans = N / K;
  ans = ans * ans * ans;
  if (K % 2 == 0) {
    long tmp = N / K;
    if (K / 2 <= N % K) tmp++;
    ans += tmp * tmp * tmp;
  }
  cout << ans << endl;
}

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

int main() {
	int x;
	cin >> x;
	if (x == 3 || x == 7 || x == 5) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
import java.util.Scanner;
 
class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int num1 = Integer.parseInt(scan.next());
    int num2 = Integer.parseInt(scan.next());
    
    if(((num1 * num2) % 2) == 0){
      System.out.println("Even");
    }else{
      System.out.println("Odd");
    }
    
    scan.close();
    return ;
  }
}

Measured memory_bytes: 21844
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <functional>
#include <climits>
using namespace std;

// 動的セグメント木 (必要なノードだけ作る)

template <typename MonoidType>
struct SegNode {
    MonoidType value;
    SegNode *ch[2];
    SegNode() {}
    SegNode(MonoidType value_) : value(value_) {
        ch[0] = ch[1] = nullptr;
    }
};

template <typename MonoidType, typename IdxType = int>
struct DynamicSegmentTree {
    using Function = function< MonoidType(MonoidType, MonoidType) >;

    // node, identity element
    IdxType n;
    SegNode<MonoidType>* root;
    MonoidType E0;

    // update / combine function
    Function upd_f, cmb_f;

    // initialize
    DynamicSegmentTree() {
        root = new SegNode<MonoidType>;
    }
    DynamicSegmentTree(IdxType n_, MonoidType E0_,
                       Function upd_f_, Function cmb_f_) :
        E0(E0_), upd_f(upd_f_), cmb_f(cmb_f_) {
        root = new SegNode<MonoidType>(E0_);
        n = 1; while(n < n_) n *= 2;
    }

    void update(SegNode<MonoidType> *node, IdxType k, MonoidType x, IdxType l, IdxType r) {
        if(r - l == 1) {
            node->value = upd_f(node->value, x);
            return;
        }

        IdxType mid = (l + r) / 2;
        MonoidType vl = E0, vr = E0;
        if(l <= k and k < mid) {
            if(!node->ch[0]) node->ch[0] = new SegNode<MonoidType>(E0);
            update(node->ch[0], k, x, l, mid);
        }
        if(mid <= k and k < r) {
            if(!node->ch[1]) node->ch[1] = new SegNode<MonoidType>(E0);
            update(node->ch[1], k, x, mid, r);
        }
        vl = (node->ch[0] ? node->ch[0]->value : E0);
        vr = (node->ch[1] ? node->ch[1]->value : E0);
        node->value = cmb_f(vl, vr);
    }

    MonoidType query(SegNode<MonoidType> *node, IdxType a, IdxType b, IdxType l, IdxType r) {
        if(b <= l or r <= a) return E0;
        if(a <= l and r <= b) return node->value;

        IdxType mid = (l + r) / 2;
        MonoidType vl = (node->ch[0] ? query(node->ch[0], a, b, l, mid) : E0);
        MonoidType vr = (node->ch[1] ? query(node->ch[1], a, b, mid, r) : E0);
        return cmb_f(vl, vr);
    }
    
    // update k-th element (applied value: x)
    void update(IdxType k, MonoidType x) {
        update(root, k, x, 0, n);
    }

    // range query for [a, b)
    MonoidType query(IdxType a, IdxType b) {
        return query(root, a, b, 0, n);
    }
};

void DSL_2_A() {
    int N, Q; cin >> N >> Q;
    int indexed = 0;

    DynamicSegmentTree<int> seg(N, INT_MAX,
                                [](int a, int b) { return b; },
                                [](int a, int b) { return min(a, b); });
    for(int i=0; i<Q; i++) {
        int q, x, y; cin >> q >> x >> y;
        if(q == 0) {
            x -= indexed;
            seg.update(x, y);
        }
        if(q == 1) {
            x -= indexed; y -= indexed; y++;
            cout << seg.query(x, y) << endl;
        }
    }
}

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



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

int main()
{   
    int i,a,b;
    scanf("%d%d",&a,&b);
        if(b==100){
            i=a*1000+b;
        }
        else if(b>=10){
            i=a*100+b;
        }
        else{
            i=a*10+b;
        }
        if(ceil(sqrt(i))==floor(sqrt(i)))
    printf("Yes");
    else printf("No");

    return 0;
}


Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#include<stdio.h>
#include<functional>
#include<queue>

using ll = long long;

using namespace std;

ll mod = 1000000007;

ll n_pow(ll a, ll n) {
	if (n == 0)return 1;
	ll t = n_pow(a, n / 2);
	t *= t;
	t %= mod;
	if (n % 2 == 1)t *= a;
	return t % mod;
}

const int INF = 1001001001;
//const ll INF = 1e18;

int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };

ll cal_gcd(ll a, ll b) {
	ll m = max(a, b);
	ll n = min(a, b);
	while (m%n != 0) {
		ll b = m % n;
		m = n;
		n = b;
	}
	return n;
}

int main() {
	string s;
	cin >> s;
	if (s == "ABC")cout << "ARC" << endl;
	else {
		cout << "ABC" << endl;
	}
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
using namespace std;
int n, w[100], l[100], r[100];
int main() {
	while (cin >> n, n) {
		for (int i = 0; i < n; i++) cin >> w[i] >> l[i] >> r[i];
		int f = 1;
		for (int i = 0; i < n; i++) {
			int s = 0;
			for (int j = 0; j < n; j++) {
				if (l[j] <= l[i] && l[i] < r[j]) s += w[j];
			}
			if (s > 150) f = 0;
		}
		cout << (f ? "OK" : "NG") << endl;
	}
}

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

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var n = cin.nextInt();
            for (int i = 0; i < 10; i++)
            {
                var tmp = Math.Pow(2, i);
                if(tmp > n)
                {
                    Console.WriteLine(Math.Pow(2, i-1));
                    return;
                }
            }
            
        }
    }

    class Scanner
    {
        string[] s;
        int i;

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

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

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

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

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

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

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

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

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


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

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


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


int main(){
  string s;
  cin >> s;
  int n=s.size();
  int aid=200001;
  int zid=0;
  for(int i=0;i<n;++i){
    if(s[i]=='A'){
      aid=min(aid,i);
    }
    if(s[i]=='Z'){
      zid=max(zid,i);
    }
  }
  int ans=zid-aid+1;
  cout << ans << endl;
  return 0;
}


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

int main() {
    int N, p, mi, cnt;
    cnt = 0;
    mi = __INT_MAX__;
    cin >> N;
    REP(i, 0, N){
        cin>>p;
        if(mi > p){
            cnt++;
            mi = p;
        }
    }
    cout << cnt << endl;
};
// 1 5 4 3 2


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

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

const int INF=1e9;
const int MOD=1e9+7;

int main(){
    int x; cin >> x;
    if(x==1){
        cout << 0 << endl;
    }else{
        cout << 1 << endl;
    }
}

Measured memory_bytes: 3588
#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 reps(i,a,b) for(int i= a; i < b; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int x;
  cin >> x;
  if(x) {
    cout << 0 << endl;
  } else {
    cout << 1 << endl;
  }
  return 0;
}


Measured memory_bytes: 3628
import sys
S = list(input())
for i in range(len(S)):
    if i % 2 == 0:
        if S[i] == "R" or S[i] == "U" or S[i] == "D":
            continue
        else:
            print("No")
            sys.exit()
    else:
        if S[i] == "L" or S[i] == "U" or S[i] == "D":
            continue
        else:
            print("No")
            sys.exit()
else:
    print("Yes")

Measured memory_bytes: 3064
#include<stdio.h>
#include<iostream>
using namespace std;
int main() {
	int a, b, c, d,i = 0;
	scanf("%d %d %d", &a, &b, &c);
	for (; a <= b; a++) {
		if (c % a == 0)i++;
	}
	printf("%d\n", i);

}


Measured memory_bytes: 3216
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long n,k;
	cin>>n>>k;
	long long rez=0;
	for(long long i = k ; i <= n+1 ; i ++){
		rez+=1+(n-i+1)*i%int(1e9+7);
	}
	cout<<rez%int(1e9+7);
}

Measured memory_bytes: 3636
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
template< typename T > istream &operator>>(istream &is, vector< T > &v) { for(T &in : v) is >> in; return is; }

int z(int n){
    int a=1;
    while(a<=n){
        a*=2;
    }
    return a;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int n;
    cin>>n;
    vector<int> a(n);
    REP(i,n) cin >> a[i];
    sort(rall(a));
    map<int,int> mp;
    rep(i,n){
        mp[a[i]]++;
    }
    ll ans=0;
    rep(i,n){
        if(mp[a[i]]>0){
            mp[a[i]]--;
            int beki=z(a[i]);
            if(mp[beki-a[i]]>0){
                mp[beki-a[i]]--;
                ans++;
            }
            else{
                mp[a[i]]++;
            }
        }
    }
    cout<<ans<<endl;
    
}

Measured memory_bytes: 26880
#include<bits/stdc++.h>
using namespace std;
double dp[350][350][350];
int n, cnt[4];
double calc(int cnt1, int cnt2, int cnt3){
	if((cnt1<0||cnt2<0||cnt3<0) || cnt1+cnt2+cnt3==0) return 0;
	if(dp[cnt1][cnt2][cnt3]+1>1e-20) return dp[cnt1][cnt2][cnt3];
	double su = cnt1+cnt2+cnt3+0.0;
	dp[cnt1][cnt2][cnt3] = n/su 
	                       + calc(cnt1-1,cnt2,cnt3)*(cnt1/su) 
	                       + calc(cnt1+1,cnt2-1,cnt3)*(cnt2/su)
	                       + calc(cnt1,cnt2+1,cnt3-1)*(cnt3/su);
	return dp[cnt1][cnt2][cnt3];
}
int main(){
	cin >> n;
	for (int i = 0; i <= n; ++i) for(int j = 0; j <= n; j++) for(int k = 0; k <= n; k++) dp[i][j][k]=-1;
	for (int i = 0; i < n; ++i){
		int x; cin >> x;
		cnt[x]++;
	}
	cout << setprecision(10) << fixed << calc(cnt[1], cnt[2], cnt[3]) << endl;	
}

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

using LL = long long; using ll = LL;
using PII = pair<int, int>; using pii = PII;
using PLL = pair<LL, LL>; using pll = PLL;
using VI = vector<int>; using VL = vector<LL>;
#define FOR(i,s,t) for(int i =s; i < t;i++)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()

void solve() {
	int N = 10;
	priority_queue<int>pq;
	FOR(i, 0, N) {
		int a; cin >> a;
		pq.push(a);
	}
	FOR(i, 0, 3) {
		cout << pq.top() << endl;
		pq.pop();
	}


}

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

	solve();

	return 0;
}


Measured memory_bytes: 3136