akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define ll long long
#define P pair<int,int>

int main(){
    string s,t;
    int count=0;
    cin>>s>>t;
    for(int i=0;i<s.length();i++){
        if(s[i]!=t[i]) count++;
    }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 3916
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    var ans = mutableListOf<Int>()
    ans.add((n / 1.08).toInt())
    ans.add(ans[0] + 1)
    ans.add(ans[1] + 1)
    for (i in 0 until 3) {
        if ((ans[i] * 1.08).toInt() == n) {
            println(ans[i])
            System.exit(0)
        }
    }
    println(":(")
}


Measured memory_bytes: 33476
import sys
import collections


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    s = str(input().rstrip('\n'))
    s = collections.deque(s)
    q = int(input().rstrip('\n'))
    r = False
    for _ in range(q):
        tfc = list(map(str, str(input().rstrip('\n')).split()))
        if tfc[0] == "1":
            r = not r
        else:
            if not r:
                if tfc[1] == "1":
                    s.appendleft(tfc[2])
                else:
                    s.append(tfc[2])
            else:
                if tfc[1] == "1":
                    s.append(tfc[2])
                else:
                    s.appendleft(tfc[2])
    print("".join(list(s)) if not r else "".join(reversed(s)))


if __name__ == '__main__':
    solve()


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

int get_gcd(int a, int b) {
  while(1) {
    if (a < b) swap(a, b);
    a %= b;
    if (a==0) break;
  }
  return b;
}

main () {
  char s[100000 + 1];
  scanf("%s", s);

  int ans_0_start = 0;
  int ans_1_start = 0;
  for (int i = 0; s[i] != '\0'; i++) {
    if (i % 2 == 0) {
      if (s[i] == '0') {
        ans_1_start++;
      }
      else {
        ans_0_start++;
      }
    }
    else {
      if (s[i] == '0') {
        ans_0_start++;
      }
      else {
        ans_1_start++;
      }
    }
  }

  printf("%d\n", min(ans_0_start, ans_1_start));

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define ve vector
#define chmin(x,y) x = min(x,y)

int main(){
    int n;
    cin >> n;
    ve<int> a(n),b(n+1);
    rep(i,n){
        cin >> a[i];
        b[a[i]] = (int)i;
    }
    ll ans = 0;
    set<int> s;
    s.insert(b[n]);
    s.insert(b[n-1]);
    ans += (ll)(n-1) * (1+*s.begin()) * (n-*next(s.begin()));
    s.insert(-1);
    s.insert(n);
    for (int i = n-2; i>0; i--) {
        int x = b[i];
        s.insert(x);
        auto it = s.find(x);
        ve<int> l(2,-1),r(2,n);
        rep(j,2){
            if(it == s.begin()) break;
            it--;
            l[j] = *it;
        }
        it = s.find(x);
        rep(j,2){
            it++;
            if(it == s.end()) break;
            r[j] = *it;
        }
        ans += (ll)i * (x-l[0]) * (r[1]-r[0]);
        ans += (ll)i * (l[0]-l[1]) * (r[0] - x);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8636
#include <algorithm>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;

using namespace std;

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

  char prev = s[0];
  int ans = 1;
  for (int i = 1; i < n; i++) {
    char c = s[i];
    if (c != prev) {
      ans++;
    }
    prev = c;
  }
  cout << ans << endl;
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;

namespace cswork {
    class Program {
        static void Main (string[] args) {
            // ontest165.Q ();
                      List<long> l = ReadList ();
            long a = l[0];
            long b = l[1];
            long c = l[2];
            long d = l[3];

            while (true) {
                c -= b;
                if (c <= 0) {
                    Write ("Yes");
                    Exit ();
                    return;
                }

                a -= d;
                if (a <= 0) {
                    Write ("No");
                    Exit ();
                    return;
                }
            }
        }

        public static void Write (string str) {
            Console.WriteLine (str);
        }

        public static void Write (int i) {
            Console.WriteLine (i);
        }

        public static void Write (double d) {
            Console.WriteLine (d);
        }

        public static string ReadStr () {
            return Console.ReadLine ();
        }

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

        public static long Read () {
            return long.Parse (Console.ReadLine ());
        }

        public static double ReadDouble () {
            return double.Parse (Console.ReadLine ());
        }

        public static void Exit () { }

        public static List<string> ReadListStr () {
            return new List<string> (ReadStr ().Split (" "));
        }

        public static List<long> ReadList () {
            return ReadListStr ().ConvertAll (x => long.Parse (x));
        }
    }
}

Measured memory_bytes: 27788
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>

void add(uint64_t** l, int* c, uint64_t v) {
	*l = realloc(*l, sizeof(**l) * (*c + 1));
	if (*l == NULL) exit(2);
	(*l)[(*c)++] = v;
}

uint64_t* yakusu(int* num, uint64_t x) {
	uint64_t* r1 = NULL, *r2 = NULL;
	uint64_t i;
	int c1 = 0, c2 = 0;
	int mofu;
	if (x > 1) add(&r2, &c2, x);
	for (i = 2; i * i <= x; i++) {
		if (x % i == 0) {
			add(&r1, &c1, i);
			if (x / i != i) add(&r2, &c2, x / i);
		}
	}
	r1 = realloc(r1, sizeof(*r1) * (c1 + c2));
	if (r1 == NULL) exit(2);
	for (mofu = 0; mofu < c2; mofu++) {
		r1[c1 + mofu] = r2[c2 - 1 - mofu];
	}
	if (num != NULL) *num = c1 + c2;
	return r1;
}

int main(void) {
	uint64_t* y1, *y2;
	int n1, n2;
	uint64_t N;
	int count = 0;
	int i1, i2;
	int i, truen1;
	if (scanf("%" SCNu64, &N) != 1) return 1;
	y1 = yakusu(&n1, N);
	y2 = yakusu(&n2, N - 1);

	truen1 = 0;
	for (i = 0; i < n1; i++) {
		uint64_t sim = N;
		while (sim % y1[i] == 0) sim /= y1[i];
		if (sim % y1[i] == 1) y1[truen1++] = y1[i];
	}
	n1 = truen1;

#if 0
	printf("%" PRIu64 " : ", N);
	for (i = 0; i < n1; i++) printf(" %" PRIu64, y1[i]);
	printf("\n%" PRIu64 " : ", N - 1);
	for (i = 0; i < n2; i++) printf(" %" PRIu64, y2[i]);
	puts("");
#endif
	for (i1 = i2 = 0; i1 < n1 && i2 < n2; ) {
		if (y1[i1] == y2[i2]) {
			count++;
			i1++;
			i2++;
		} else if (y1[i1] < y2[i2]) {
			count++;
			i1++;
		} else {
			count++;
			i2++;
		}
	}
	count += (n1 - i1) + (n2 - i2);
	printf("%d\n", count);
	free(y1);
	free(y2);
	return 0;
}

/*

N - K はmod KでNと合同

→ Nを1にするには、N を K で割ったあまりが0か1
→ KはNの約数か、N-1の約数

約数が多い数
http://oeis.org/A002182
その約数の数
http://oeis.org/A002183

1124388064800の約数が6912個なのでヨシ！

割り切っちゃいけない場合がある
→少ないから全部シミュレーションしてチェックする

*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int a, b; cin >> a >> b;
    int ans = (b >= a) ? a : a - 1;
    cout << ans << endl; 
}

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

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) {
        cin >> a[i];
    }
    for(int i = 1; i < n; ++i){
        a[i] += a[i-1];
    }
    ll ans = 1e18;
    rep(i,n-1) {
        ll r = a[n-1] - a[i];
        ll l = a[i];
        ans = min(ans, abs(r-l));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4732
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <iomanip>
#include <cmath>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    string S;
    cin >> S;
    int s=0,ans=0;
    REP(i,S.size()){
        if(S[i]=='S'){
            ++s;
        } else {
            if(s==0) ++ans;
            else --s;
        }
    }
    cout << ans+s << '\n';
    return 0;
}

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

int main()
{
    int n; cin >> n;
    int x;
    int cnt[2*100000] = { 0 };
    for (int i = 0; i < n - 1; i++)
    {
        cin >> x;
        cnt[x - 1]++;
    }
  
    
    for (int j = 0; j < n; j++)
    {
        cout << cnt[j] << endl;
    }
    return 0;
}




Measured memory_bytes: 4404
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vi a(n), b(n);
    rep(i, n) {
        cin >> a[i];
    }
    rep(j, n) {
        cin >> b[j];
    }

    vvi dp(1<<n, vi(51, INF));
    dp[0][0] = 0;
    for(int i = 1; i < (1<<n); i++) {
        int cnt = 0;
        int C = __builtin_popcount(i)-1;
        rep(j, n) {
            if(i>>j&1) {
                int num;
                if(abs(j-C)&1) {
                    num = b[j];
                } else {
                    num = a[j];
                }
                int now = i^(1<<j);
                for(int k = 0; k <= num; k++) if(dp[now][k] != INF) {
                    chmin(dp[i][num], dp[now][k] + cnt);
                }
            } else cnt++;
        }
    }
    int ans = INF;
    rep(i, 51) {
        chmin(ans, dp[(1<<n)-1][i]);
    }
    cout << (ans == INF?-1:ans) << endl;
}

Measured memory_bytes: 66820
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		sc.close();
		S = S.replace("/","");
		String ans = (Integer.valueOf(S)>20190430 ? "TBD":"Heisei");
		System.out.println(ans);
	}

}

Measured memory_bytes: 35500
#include <iostream>

std::string O;
std::string E;

int main(void){
    std::cin >> O;
    std::cin >> E;

    auto ito = O.begin(), endo = O.end();
    auto ite = E.begin(), ende = E.end();

    while( ito != endo || ite != ende ){
        if( ito != endo ){
            std::cout << *ito;
            ito++;
        }
        if( ite != ende ){
            std::cout << *ite;
            ite++;
        }
    }
    std::cout << std::endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	
	int angka;
	scanf("%d", &angka);
	
	int angka3 = angka % 10;
 
	int angka2 = (angka - angka3) / 10;
	int angka2real = angka2 % 10;
	int angka1 = angka - (angka2real * 10) - angka3;
	int angka1real = angka1 / 100;
	
	if(angka1real == 7){
		printf("Yes\n");
	}
	else if(angka2real == 7){
		printf("Yes\n");
	}
	else if(angka3 == 7){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 1640
/*
 KUNAL RAUT (ZUKONIT14)  :- "DO WHAT YOU DONT LIKE!"
 -PICT,PUNE! :)
 */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mod 1000000007
#define inv (mod+1)/3
#define mod9 1000000009
#define pi 3.1415926535
#define MAXN 1000001
#define MAX2N 1*1000 + 10
#define all(v) v.begin(), v.end()
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define forci(p,n) for(ll i=p;i<(ll)n;i++)
#define forcj(p,n) for(ll j=p;j<(ll)n;j++)
#define bolt ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define bits(a) __builtin_popcount(a)
#define test ll t;cin>>t;while(t--)
ll zero=0;
ll one=1;
ll gcd(ll a,ll b){    if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) {    return (a/gcd(a,b)*b);}
ll expo(ll x, ll y) {ll res=1;x=x%mod;while(y>0){if(y&1)res=(1ll*res*x)%mod;
    y=y>>1;x=(1ll*x*x)%mod;} return res;}
ll ncr(ll n,ll r){ ll res=1; if(r>n-r)r=n-r; for(ll i=0;i<r;i++) {  res*=n-i;  res/=i+1; } return res;}
ll max(ll a,ll b){return (a>b)?a:b;}
bool prime(ll n){ll i;for(i=2;i<=sqrt(n);i++){if(n%i==0)return false;}return true;}
bool sortbysec(const pair<ll,ll> &a,const pair<ll,ll> &b){return(a.second<=b.second);}

//https://www.youtube.com/watch?v=k4V3Mo61fJM

ll rr[]={0,1,1,1,0,-1,-1,-1,};
ll cc[]={1,1,0,-1,-1,-1,0,1};

signed main()
{
    bolt;
    ll h,n,x;cin>>h>>n;ll sum=0;
    forci(0,n)
    cin>>x,sum+=x;
    if(sum>=h)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


Measured memory_bytes: 256
a,b,c,x,y=map(int,input().split())
if a+b<=c*2:
    print(a*x+b*y)
else:
    if x<y:
        ans=c*2*x
        y-=x
        ans+=min(c*2*y,b*y)
        print(ans)
    else:
        ans=c*2*y
        x-=y
        ans+=min(c*2*x,a*x)
        print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N,sum=0;
  cin >> N;
  for(long long i=1; i<=N; i++){
    if(i%3!=0 && i%5!=0){
    	sum += i;
    }
  }
 
  cout << sum << endl;
  
}

Measured memory_bytes: 3636
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

def min(a,b)
  return a>b ? b : a
end

def max(a,b)
  return a>b ? a : b
end
h,n=get_i
ab=array(n,1)
max=0
n.times do|i|
  ab[i]=get_i
  max=max(max,ab[i][0])
end
INF=Float::INFINITY
dp=array(h+max+1,1,INF)
dp[0]=0
1.upto(h+max) do|j|
  ab.each do|a,b|
    dp[j]=min(dp[j],dp[j-a]+b) if j-a>=0
  end
end
puts dp[h..h+max].min

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


struct Barricada {
    long long S, T, X;
    bool operator<(const Barricada& rhs) const
    {
        return X > rhs.X;
    }
};

bool compare_barr(Barricada lhs, Barricada rhs){
    if (lhs.S - lhs.X < rhs.S - rhs.X) return true;
    return false;
}

Barricada barr[200000];
long long people[200000];
long long people_ans[200000];
long long ans[200000];
map <long long, long long> mapeo;

int main(){
    int n, q, pointer = 0;
    long long s, t, x, d;
    cin >> n >> q;
    for (int i = 0; i < n; ++i) {
        cin >> s >> t >> x;
        barr[i] = {s,t,x};
    }
    sort(barr, barr+n, compare_barr);
    priority_queue<Barricada> que;
    for (int j = 0; j < q; ++j) {
        cin >> people[j];
        people_ans[j] = people[j];
        mapeo[people[j]] = j;
    }
    sort(people, people+q);
    for (int k = 0; k < q; ++k) {
        while (pointer < n) {
            if (people[k] >= barr[pointer].S - barr[pointer].X) {
                que.push({barr[pointer].S, barr[pointer].T, barr[pointer].X});
                //cout << que.top().X << "a "<< k<<"\n";
                pointer++;
                continue;
            }
            break;
        }
        while (que.size()){
            if(people[k] >= que.top().T - que.top().X){
                que.pop();
                continue;
            }
            break;
        }
        if (que.size()) ans[mapeo.find(people[k])->second] = que.top().X;
        else ans[mapeo.find(people[k])->second] = -1;
    }
    for (int l = 0; l < q; ++l) {
        cout << ans[l] << "\n";
    }
    return 0;
}

Measured memory_bytes: 28912
n = int(input())
lis = []
for i in range(n):
    a, b = input().split()
    lis.append((a, int(b), i + 1))
lis.sort(key=lambda x: x[1], reverse=True)
lis.sort(key= lambda x: x[0])
print(*[lis[i][2] for i in range(n)], sep="\n")


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


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#define fo(i, n) for(int i=0; i<n; i++)
#define Fo(i, k, n) for(int i=k; i<n; i++)
#define w(x)  int x; cin>>x; while(x--)
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x,y) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<"\n"
#define watch3(x,y,z) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<"\n"
#define watch4(x,y,z,q) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<" and "<<(#q)<<" is "<<(q)<<"\n"
#define MOD 1000000007
#define INF 1000000007;
#define F first
#define S second
#define pb(x) push_back(x);


#define ll  long long
#define all(c) (c).begin(),(c).end()
#define endl "\n"

typedef vector<int> vl;
typedef vector< vl > vvl;
typedef pair< int, int> pll;
typedef map< int, int> mll;


#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif





void c_p_c()
{
#ifndef ONLINE_JUDGE
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
void parray(int a[], int n) {
	for (int i = 0; i < n; i++) {
		cout << a[i] << " ";
	}
	cout << endl;
}
int no = 1, n1;
int recu(int n, int k, int val) {


	if (n == n1) {
		return min(val * 2, val + k);
	}
	return min( recu(n + 1, k, 2 * val), recu(n + 1, k, val + k)              );


}
int digit(int n) {

	int temp = 0;
	while (n) {
		// temp += n % 10;
		n = n / 10;
		temp++;
	}



	return temp;
}

bool check(int a[], int n) {
	for (int i = 0; i < n; ++i)
	{
		/* code */
		if (a[i] % 2)
			return false;
	}
	return true;
}


int main() {
	int i,  n, k, c = 0, sum = 0;
	c_p_c();
	// cout<<"Sd"<<endl;>
	cin>>n;
	int a[n];
	fo(i,n) cin>>a[i];


	sort(a,a+n);
	reverse(a,a+n);

	for (int i = 0; i < n; ++i)
	{
		/* code */
		if(i%2==0)
			sum+=a[i];
		else 
			sum-=a[i];
	}

cout<<sum<<endl;



}

Measured memory_bytes: 3592
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);

		while (scanner.hasNextLine()) {
			String[] line = scanner.nextLine().split(" ");
			Deque<Double> deque = new ArrayDeque<Double>();
			for (int i = 0; i < line.length; i++) {
				if (Character.isDigit(line[i].charAt(0))
						|| line[i].length() > 1) {
					deque.push(Double.parseDouble(line[i]));
				} else {
					double a = deque.pop();
					double b = deque.pop();
					if (line[i].equals("+")) {
						deque.push(b + a);
					} else if (line[i].equals("-")) {
						deque.push(b - a);
					} else if (line[i].equals("*")) {
						deque.push(b * a);
					} else {
						deque.push(b / a);
					}
				}
			}
			System.out.println(deque.pop());
		}
	}
}

Measured memory_bytes: 17220
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main{ 
	
	private static int change(int a,int n) {
		
		int b = String.valueOf(a).length();
		String str = String.valueOf(a);
		
		while(str.length()<n)str+="0";

		char[] c = str.toCharArray();
		Arrays.sort(c);

		int max = 0;int min = 0;
		
		for(int i=0;i<str.length();i++) min = min*10+(c[i]-'0');
		for(int i=str.length()-1;i>=0;i--)max = max*10+(c[i]-'0');

		return max-min;
		
	}
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			
			while(sc.hasNext()) {
				int a = sc.nextInt();
				int n = sc.nextInt();
				if(a+n==0)break;
				
				
				int c = a;
				HashMap<Integer,Integer> hm = new HashMap<>();
				hm.put(a, 0);
				for(int i=1;;i++) {
					c = change(c,n);
					if(hm.containsKey(c)) {
						System.out.println((hm.get(c))+" "+c+" "+(i-hm.get(c)));
						break;
					}
					else
						hm.put(c, i);
					
				}
				
			}
		}
	}
}



Measured memory_bytes: 27440
#include<stdio.h>

int main(){
  int n = 0;
  long long a[10000] = {};
  int i = 0;
  long cnt = 0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%lld",&a[i]);
  }
  for(i=0;i<n;i++){
    while(1){
      if(a[i] % 2 == 0){
        a[i] /= 2;
        cnt++;
      }else{
        break;
      }
    }
  }
  
  printf("%ld",cnt);
  return 0;
}

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

using namespace std;

int main(){

    int N;
    cin >> N;
    vector< pair<int, int> > AB(N);
    for(int i = 0; i < N; i++) cin >> AB[i].first >> AB[i].second;

    sort(AB.begin(), AB.end(), [](pair<int, int> x, pair<int, int> y){ return x.second < y.second; });

    int64_t time = 0;
    bool deadline = true;
    for(int i = 0; i < N; i++){
        time += AB[i].first;
        if(time > AB[i].second) deadline = false;
    }

    cout << (deadline ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct res{
	int num;
	char city[15];
	int point;
}res;

int cmp(const void *a, const void *b){
	int name = strcmp(((res*)a)->city, ((res*)b)->city);
	if(name == 0)
		return ((res*)b)->point - ((res*)a)->point;
	else return name;
}

int main(void){
	int n;
	scanf("%d", &n);
	res *array = malloc(sizeof(res) * n);
	for(int i = 0; i < n; i++){
		scanf("%s %d", array[i].city, &(array[i].point));
		array[i].num = i + 1;
	}
	qsort(array, n, sizeof(res), cmp);
	for(int i = 0; i < n; i++)
		printf("%d\n", array[i].num);
}


Measured memory_bytes: 128
a,b, c,d = map(int, input().split())
#taka = (c-1)//b + 1
#ao = (a-1) // d + 1
#if taka <= ao:
#    print("Yes")
#else:
#    print("No")

if (c+b-1)//b <= (a+d-1)//d:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9160
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
typedef vector<int> vi;

int main() {
  int n;
  cin >> n;
  vi a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int count = 0;
  for (int j = 0; j < n; j++) {
    if (a[j] == count + 1) {
      count ++;}
  }
  if (count > 0) {
    cout << n - count;}
  else{
    cout << -1;}
}

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

int main() {
	string s;
	cin >> s;
	string ans = "";
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'B') {
			if(ans.size())ans.pop_back();
		}
		else ans.push_back(s[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int MAxx = 1e5 + 5;
bool visited[MAxx];
ll len[MAxx];
ll in_degree[MAxx];
vector<ll> edges[MAxx];
void dfs(int a)
{
	visited[a] = true;
	for(ll b : edges[a])
	{
		len[b] = max(len[b], len[a]+1);
		--in_degree[b];
		if(in_degree[b]==0)
		{
			dfs(b);
		}
	}
}
int main()
{
	int n,m;
	cin>>n>>m;
	memset(visited, false, sizeof visited);
	memset(len, 0, sizeof len);
	for(int i = 0 ; i < m ; i++)
	{
		ll a,b; cin>>a>>b;
		edges[a].push_back(b);
		++in_degree[b];
	}
	for(int i = 1; i <=n ; i++ )
		if(!visited[i]&&in_degree[i]==0)
			dfs(i);
	ll ans = 0;
	for(int i = 1; i <= n;  i++)
		ans = max(ans, len[i]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 10496
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7;

signed main()
{
	IO_OP;
	
	int n;
	cin >> n;
	multiset<int> m;
	vi v;
	for(int i=0;i<(1<<n);i++) {
		int t;
		cin >> t;
		m.insert(-t);
	}
	int e = *m.begin();
	v.PB(e); m.erase(m.begin());
	for(int i=0;i<n;i++) {
		int sz = v.size();
		for(int j=0;j<sz;j++) {
			auto it = m.upper_bound(v[j]);
			if(it == m.end()) {
				cout << "No" << endl;
				return 0;
			}
			v.PB(*it);
			m.erase(it);
		}
	}
	cout << "Yes" << endl;

}





Measured memory_bytes: 13816
if __name__ == "__main__":
    N = int(input())
    n = 40
    for i in range(40, -1, -1):
        if (N >= (1 << i) - 1):
            n = i
            break
    data = []
    for i in range(n):
        data.append(i + 1)
    N -= (1 << n) - 1
    tmp = n
    for i in range(n - 1, -1, -1):
        if (N < (1 << i)):
            continue
        tmp += 1
        data = data[:i] + [tmp] + data[i:]
        N -= (1 << i)
    ans = []
    for x in range(len(data)):
        ans.append(x + 1)
    ans = ans + data
    print (len(ans))
    print (" ".join(map(str, ans)))


Measured memory_bytes: 3064
#include <iostream>

using namespace std;
const int MAX = 1001;

short max(short a,short b) {
	if (a > b) {
		return a;
	} else {
		return b;
	}
}
short solve(string str1,string str2) {
	int len1 = str1.length();
	int len2 = str2.length();
	str1 = " " + str1;
	str2 = " " + str2;
	short LCS[MAX][MAX];
	for (int i=0;i<=len1;i++) {
		LCS[i][0] = 0;
	}
	for (int i=0;i<=len2;i++) {
		LCS[0][i] = 0;
	}
	int max1 = 0;

	for (int i=1;i<=len1;i++) {
		for (int j = 1;j<=len2;j++) {
			if (str1[i] == str2[j]) {
				LCS[i][j] = LCS[i-1][j-1] + 1;
			} else {
				LCS[i][j] = max(LCS[i-1][j],LCS[i][j-1]);
			}
			max1 = max(LCS[i][j],max1);
		}
	}
	return max1;
}

int main() {
	int n;
	cin >> n;
	for (int i=0;i<n;i++) {
		string str1,str2;
		cin >> str1 >> str2;
		cout << solve(str1,str2) << endl;
	}
	return 0;

}


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

int main(){
  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;
  
  if(e-d>k || e-c>k || e-b>k || e-a>k){
    cout << ":(" << endl;
  } else if(d-c>k || d-b>k || d-a>k){
    cout << ":(" << endl;
  } else if(c-b>k || c-a>k){
    cout << ":(" << endl;
  } else if(b-a>k){
    cout << ":(" << endl;
  } else {
    cout << "Yay!" << endl;
  }
  return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
bool comp(ll a, ll b)
{
  return a>b;
}
int main()
{
  ll n,k;
  cin>>n>>k;
  if(k>=n){cout<<0;return 0;}
  
  ll ar[n];ll sum=0;
  for(int i=0;i<n;i++){cin>>ar[i];sum+=ar[i];}
  sort(ar,ar+n,comp);
  for(int i=0;i<k;i++)sum-=ar[i];
  cout<<sum;
}

Measured memory_bytes: 1792
/*..........AAKASH GOYAL............*/
/*............DAIICT................*/
 
#include <bits/stdc++.h>
using namespace std;
 
#define    int                      long long int
 
#define    f(i,j,n)                 for(int i = j; i <= n; i++)
#define    r(i,n,j)                 for(int i = n; i >= j; i--)
#define    mod                      1000000007
#define    speed                    ios_base::sync_with_stdio(false);
#define    upp                      cin.tie(NULL);
#define    pb                       push_back
#define    mp                       make_pair
#define    T                        int tt; cin >> tt; while(tt--)
#define    ff                       first
#define    ss                       second
#define    all(container)           container.begin() , container.end()
#define    sz(container)            (int)container.size()
#define    pii                      pair <int , int>
#define    ppi                      pair <int , pii>               
#define    sp(x)                    setprecision(x)
 
int32_t main()
{
    speed upp
    int n,m;
    cin>>n>>m;
    int ans=m*(m-1);
    ans/=2;
    ans+= (n*(n-1))/2;
    cout<<ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define longinf 9223372036854775807LL
#define intinf 2147483647
#define inf 998244353
#define lol long long
#define in(n,s) insert(n,s)//ノート参照
#define SYOU(x) setprecision(x)
#define abs(x,y) (max(x,y)-min(x,y))
#define mp make_pair
#define fi first
#define se second
using namespace std;
lol a,b,c,d,e=0,g,h;
int i[111110];
lol dp[100011];
lol ka(int x){
    if(dp[x]!=-1) return dp[x];
    if(x==0) return 0;
    lol nx=longinf;
    for(int n=x-1;n>=max(0LL,x-b);n--){
	nx=min(nx,abs(i[x],i[n])+ka(n));
    }
    return dp[x]=nx;
}
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >>a>>b;
  memset(dp,-1,sizeof(dp));
  dp[0]=0;
  for(int n=0;n<a;n++) cin >>i[n];
  cout <<ka(a-1)<<'\n';
  return (0);
}


Measured memory_bytes: 6144
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

int main(int argc, char **argv) {
	int a, b;
	cin >> a >> b;
	if ((a < 0 && b > 0) || a == 0 || b == 0) {
		cout << "Zero" << endl;
	}
	else if (a < 0 && (b - a) % 2 == 0) {
		cout << "Negative" << endl;
	}
	else {
		cout << "Positive" << endl;
	}
	return 0;
}


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

#define ll  long long

const int N=1e5+9;
ll mod=998244353;
ll modpow(ll a,ll n){
    ll sum=a,ret=1;
    while (n > 0){
        if (n & 1)
            ret=sum*ret%mod;
        n/=2;
        sum=sum*sum%mod;
    }
    return ret;
}
int main()
{
    int x;
    cin>>x;
    vector<int>v(x);
    map<int,int>m;
    for (int i=0;i<x;i++){
        cin>>v[i];
        m[v[i]]++;
    }
    if (m[0]!=1||v[0]!=0)
        cout<<0<<endl;
    else{
        ll ans=1;
        for (int i=1;i<x;i++){
            if (m[i]){
                ans=ans*modpow(m[i-1],m[i])%mod;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

int n;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    int ans = n / 2;
    if(n % 2 == 0) ans--;
    cout << ans << endl;
}


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

using namespace std;

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

  int n, a;
  cin >> n;
  double res = 0.0;
  while (n--) {
    cin >> a;
    res += 1./a;
  }
  cout << setprecision(10) << 1./res << endl;

  return 0;
}



Measured memory_bytes: 256
typedef long long ll;
#include<bits/stdc++.h>
using namespace std;
ll maxl(ll a, ll b){ return ((a<b)?b:a);}
ll minl(ll a, ll b){ return ((a>b)?b:a);}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n,x,t;
    cin >> n >> x >> t;
    int ans = n/x;
    if (n%x!=0)
        ans++;
    cout << (ans*t) << "\n";
}


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

vector<int> vec = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int K;

int main() {
  cin >> K;
  
  cout << vec[K - 1] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
#define N 3010
int a[N], n, w[N];
vector<int> g[N];

int dfs(int u){
	if(w[u]) return w[u];
	for(auto v: g[u]){
		if(dfs(v)<0) return w[u] = 1;
	}
	return w[u] = -1;
}

int main(){
	cin>>n;
	rep(i, n) cin>>a[i];
	rep(i, n-1){
		int u, v;
		cin>>u>>v;
		u--; v--;
		if(a[u]>a[v]) g[u].push_back(v);
		if(a[v]>a[u]) g[v].push_back(u);
	}
	rep(i, n) dfs(i);
	rep(i, n) if(w[i]>0) cout<<i+1<<" "; cout<<endl;
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<cstring>
#include<cstdio>
#define MN 1000
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int n,head[MN+5],cnt,X[MN+5],g[MN+5],flag=1,f[MN+5][5005],F[MN+5][5005],sum[MN+5];
struct edge{int to,next;}e[MN+5];
inline void ins(int f,int t){e[++cnt]=(edge){t,head[f]};head[f]=cnt;}
void dfs(int x)
{
	f[x][0]=1;
	for(int i=head[x];i;i=e[i].next)
	{
		dfs(e[i].to),sum[x]+=X[e[i].to]+g[e[i].to];
		for(int j=0;j<=X[x];++j) if(f[x][j]) 
		{
			if(j+X[e[i].to]<=X[x]) F[x][j+X[e[i].to]]=1;
			if(j+g[e[i].to]<=X[x]) F[x][j+g[e[i].to]]=1;		
		}
		for(int j=0;j<=X[x];++j) f[x][j]=F[x][j],F[x][j]=0;
	}
	for(int k=X[x];~k;--k) if(f[x][k]) return (void)(g[x]=sum[x]-k);
	flag=0;
}
int main()
{
	n=read();
	for(int i=2;i<=n;++i) ins(read(),i);
	for(int i=1;i<=n;++i) X[i]=read();
	dfs(1);puts(flag?"POSSIBLE":"IMPOSSIBLE");	
	return 0;
}

Measured memory_bytes: 38528
# -*- coding: utf-8 -*-
from pprint import pprint
N = int(input())
tn = list(map(int, input().split()))
vn = list(map(int, input().split()))

tn_sum = sum(tn)
time_tbl = [0 for _ in range(tn_sum*2+1)]  # 0.5刻みで×２

lrv = []
lrv.append([0, 0, 0])
t_sum = 0
for t, v in zip(tn, vn):
    lrv.append([t_sum, t_sum+t, v])
    t_sum += t
lrv.append([tn_sum, tn_sum, 0])


def f(l,r,x,v):
    if x <= l:
        return v + l - x
    elif l < x < r:
        return v
    else:
        return v + x - r

for t05 in range(tn_sum*2+1):
    time_tbl[t05] = min([f(l, r, t05/2, v) for l, r, v in lrv])

area = .0
for i in range(tn_sum*2):
    area += (time_tbl[i] + time_tbl[i+1])/4

print(area)


Measured memory_bytes: 44892
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9;
const int mod = 998244353;
using ll = long long;
using P = pair<ll, ll>;
double PI = acos(-1);



signed main(){
    int n;
    cin >> n;
    int mi = inf;
    int ans = 0;
    int cnt = 0;
    rep(i,n) {
        int a;
        cin >> a;
        ans += abs(a);
        if(a<0) cnt++;
        mi = min(mi,abs(a));
    }
    //cout << ans<<" "<<cnt << endl;
    if(cnt%2==1) ans -=abs(mi)*2;
    cout << ans << endl;
    


    return 0;
}



Measured memory_bytes: 3580
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <queue>
#include <stack>
#include <stdlib.h>
using namespace std;
#include <numeric>
#define rep(i,n) for (int i = 0; i <n; i++) 
#include <bits/stdc++.h>
using namespace std;

using namespace std;
int gcd(int x,int y){
    if(x<y)swap(x,y);
    if(y==0) return x;
    return gcd(x%y,y);
}
int main(){
    int n;
    
    
    string s;
    std::cin >> s;
    n=s.size();
    int k=0;
    rep(i,n){
        if(0==i%2){if(s.at(i)=='0')k++;}
        else {if(s.at(i)=='1')k++;}
    }
    std::cout << min(k,n-k) << std::endl;
    
    
    
}

Measured memory_bytes: 512
#include <iostream>
#include <math.h>
using namespace std;

int main() {
	double n, d, x[10][10]; int ans=0;
	
	cin>>n>>d;
	
	for(int row=0;row<n;row++){
		for(int col=0;col<d;col++){
			cin>>x[row][col];
		}
	}
	
	for(int i=0;i<n-1;i++){
		for(int j=i+1;j<n;j++){
			double tmp=0;
			for(int col=0;col<d;col++){
				tmp+=pow(x[i][col]-x[j][col],2);
			}
			tmp=sqrt(tmp);
			if(tmp/(int)tmp==1) ans+=1;
		}
	}
	cout<<ans;
	
	return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input!{
        n: u32,
    };

    println!("{}", 2u32.pow((1..n+1).map(|x| x.trailing_zeros()).max().unwrap()));
}


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

using namespace std;

#define F first
#define S second
#define modulo ll (1e9 + 7)

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

void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}

const int N = 50, M = 500, OO = 0x3f3f3f3f;
const ll llOO = 0x3f3f3f3f3f3f3f3f;


int main(){
    init();

    int n;  cin >> n;

    ll ans = 1;
    for(int i = 1;i <= n;i++)   ans = (ans * i) % modulo;

    cout << ans;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    N, M = map(int, input().split())
    AB = [list(map(int, input().split())) for _ in range(N)]
    CD = [list(map(int, input().split())) for _ in range(M)]
    for i in range(N):
        for j in range(M):
            if j == 0:
                result = abs(AB[i][0] - CD[j][0]) + abs(AB[i][1] - CD[j][1])
                count = j + 1
            elif result > abs(AB[i][0] - CD[j][0]) + abs(AB[i][1] - CD[j][1]):
                result = abs(AB[i][0] - CD[j][0]) + abs(AB[i][1] - CD[j][1])
                count = j + 1
        print(count)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
/*
行列計算
*/

#include <stdio.h>

int main(void){
  int A[100][100];
  int B[100], C[100];
  int n, m,i,j;

  scanf("%d %d", &n, &m);

  for(i=0; i<n; i++){
    for(j=0; j<m; j++){
      scanf("%d", &A[i][j]);
    }
  }

  for(i=0; i<m; i++)
    scanf("%d",&B[i]);

  // 計算開始
  for(i=0; i<n; i++){
    for(j=0; j<m; j++){
      C[i] += A[i][j] * B[j];
    }
  }

  // 出力開始
  for(i=0; i<n; i++)
    printf("%d\n", C[i]);

  return 0;

}



Measured memory_bytes: 2040
#include <stdio.h>

int box[100001];
int pos[100001];
int n, m;

int main(void)
{
    int i, j, x, y, count;

    scanf("%d %d", &n, &m);

    for (i = 1; i <= n; i++) {
        box[i] = 1;
        pos[i] = 0;
    }
    pos[1] = 1;

    for (i = 0; i < m; i++) {
        scanf("%d %d", &x, &y);
        if (box[x] == 1) {
            box[x] = 0;
            box[y]++;
            if (pos[y] == 0) {
                pos[y] = pos[x];
            }
            pos[x] = 0;
        } else {
            box[x]--;
            box[y]++;
            if (pos[y] == 0) {
                pos[y] = pos[x];
            }
        }
    }

    count = 0;
    for (i = 1; i <= n; i++) {
        count += pos[i];
    }

    printf("%d\n", count);

    return 0;

}


Measured memory_bytes: 896
#include<bits/stdc++.h>
#define ull unsigned long long
# define lli long long int
# define ulli unsigned long long int
#define ll long long
#define db double
#define ldb long double
#define vi vector<int>
#define vull vector<ull>
#define vll vector<ll>
#define pb push_back
#define si set<int>
#define sll set<ll>
#define ins insert
#define rep(i,n) for(int i=0;i<n;i++)
#define vpp vector<pair<int,int>>
#define mp make_pair
#define ft first
#define sc second
#define MOD 1000000007
using namespace std;
// ll prime[10000000];
// //Modular Exponentiation
//     ll fastExpo(ll x,ll n){
//         if(n==0) return 1;
//         if((n&1)==0) return fastExpo((x*x)%MOD,n/2)%MOD;
//         return ((x%MOD)*fastExpo((x*x)%MOD,(n-1)/2))%MOD;
//     }
//   //Euclidean Algorithm
//      ll gcd(ll a,ll b){
//       return (b==0)?a:gcd(b,a%b);
//     } 
//  // Extended Euclidean Algorithm
//   ll exgcd(ll a,ll b,ll &x, ll &y){
//   if(b==0){
//     x=1,y=0;
//     return a;
//   }
//    ll x1,y1;
//     ll d=exgcd(b,a%b,x1,y1);
//    x=y1;
//    y=x1-y1*(a/b);
//    return d;    
//  }    
  //sieve
//   void sieve(){
//   prime[0]=0;
//   prime[1]=0;
//   for(int i=2;i<10000000;i++){
//     prime[i]=1;
//   }
//   for(int i=2;i*i<10000000;i++){
//     if(prime[i]==1){
//       for(int j=i*i;j<10000000;j+=i){
//         prime[j]=0;
//       }
//     }
//   }
// }  
    bool compare(const pair<int,double>&p1,const pair<int,double>&p2)
    {
       if(p1.second>p2.second)
        return true;
       else if(p1.second==p2.second)
        return p1.first<p2.first;
       return false;

    }
     int main(){
      ios_base::sync_with_stdio(false);
      cin.tie(0);
      cout.tie(0);
     // cout << fixed;
      //cout.precision(2);
           
             ll n;
             cin>>n;
             string s;
             unordered_map<string,int>m;
             for(int i=0;i<n;i++)
              {
                 cin>>s;
                 m[s]++;
              }
              cout<<"AC"<<" "<<"x"<<" "<<m["AC"]<<"\n";
              cout<<"WA"<<" "<<"x"<<" "<<m["WA"]<<"\n";
              cout<<"TLE"<<" "<<"x"<<" "<<m["TLE"]<<"\n";
              cout<<"RE"<<" "<<"x"<<" "<<m["RE"]<<"\n";
             return 0;
            }

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

int main() {
  int n;
  string s;
  cin >> n;
  vector<string> v(n);
  
  for(int i = 0; i < n; i++) {
    cin >> s;
    v.at(i) = s;
  }
  
  int ans = 1;
  sort(v.begin(), v.end());
  queue<string> q;
  q.push(v.at(0));
  
  for(int i = 0; i < n; i++) {
    if(q.front() != v.at(i)) {
      q.push(v.at(i));
      q.pop();
      ans++;
    }
  } 
  cout << ans << endl;
}

Measured memory_bytes: 9492
function Main(input) {
    // 1行目がinput[0], 2行目がinput[1], …に入る
    // 上下左右が全て"."である"#"が存在するかどうかを探す
    H = Number(input.split("\n")[0].split(" ")[0]);
    W = Number(input.split("\n")[0].split(" ")[1]);
    S = new Array;
    answer="Yes";
    for(i=0;i<H;i++){
        S[i]= input.split("\n")[i+1].split("");
    }

    function isBlack(a,b){
        //s[a][b]が#であるかどうかを判定する関数
        if(a < 0 || b < 0|| a >= H || b >= W) return false;
        if(S[a][b]=="#"){
            return true;
        }else{
            return false;
        }
    }

    function isDraw(a,b){
        //#マスの上下4マスに#があるかどうかを確認する関数
        if(S[a][b]!=="#"){
            return true;
        }else{
            if(isBlack(a-1,b)|| isBlack(a+1,b)||isBlack(a,b-1)||isBlack(a,b+1)){
                return true;
            }else{
                return false;
            }
        }
    }
    
    for(i=0;i<H;i++){
        for(j=0;j<W;j++){
            if(isDraw(i,j)){
            }else{
                answer = "No";
                break;
            }

        }
        if(answer == "No") break;
    }

    console.log(answer);
    
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

const int maxn = 1e5 + 5;

vector<int>vis(maxn), que(maxn), G[maxn];

int main() {
	int n; cin >> n;
	for (int i = 1, u, v; i < n; i++) {
		cin >> u >> v;
		G[u].push_back(v); G[v].push_back(u);
	}
	int l = 1, r = 0;
	vis[l] = 1, vis[n] = 2;
	que[++r] = 1, que[++r] = n;
	while (l <= r) {
		int u = que[l++];
		for (auto v : G[u]) {
			if (!vis[v]) {
				vis[v] = vis[u];
				que[++r] = v;
			}
		}
	}
	int sumF = 0, sumS = 0;
	for (int i = 1; i <= n; i++) {
		if (vis[i] == 1)sumF++;
		else sumS++;
	}
	cout << (sumF > sumS ? "Fennec" : "Snuke") << endl;

	return 0;
}

Measured memory_bytes: 6528
#input data
n,m,x = map(int, input().split())
A=[]
C=[]
inf = 10**9
result = inf
#
for _ in range(n):
	CA = list(map(int, input().split()))
	C.append(CA[0])
	A.append(CA[1:])
for i in range(1<<n):
	rikaido = [0]*m
	cnt = 0	
	for j in range(n):
		if (i>>j)&1:
			for k in range(m):
				rikaido[k] += A[j][k]
			cnt += C[j]
		else:
			pass
	if min(rikaido)>=x:
		result = min(result, cnt)
if result== inf:
	print(-1)
else:
	print(result)

Measured memory_bytes: 9168
// ABC 151-C
// 2020.1.12 bal4u

#include <stdio.h>
#include <ctype.h>
#include <string.h>

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif

int in() {   // 非負整数の入力
	int n = 0; int c;
//	do c = gc();
//	while (isspace(c));
	c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

int WA[100005];
int AC, NG;

int main()
{
	int N, M;
	
	N = in(), M = in();
	while (M--) {
		int p = in();
		int S = gc(); gc(), gc();
		if (WA[p] < 0) continue;
		if (S == 'A') {
			++AC, NG += WA[p];
			WA[p] = -1;
		} else ++WA[p];
	}
	printf("%d %d\n", AC, NG);
	return 0;
}


Measured memory_bytes: 512
s = input()
t = input()
 
s_list = list(s)
t_list = list(t)
 
s_list.sort()
t_list.sort(reverse=True)
 
s = "".join(s_list)
t = "".join(t_list)
 
if s < t:
 	print("Yes")
else:
 	print("No")

Measured memory_bytes: 3060
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 整数の入力
		long a = sc.nextLong();
		long b = sc.nextLong();
		long x = sc.nextLong();
        
        long start = (a + x - 1) / x;
        long end = (b + x - 1) / x;
        long ans = start == end ? 0 : end - start;
        if (b % x == 0) {
          ans++;
        }
    
		// 出力
		System.out.println(ans);
	}
}

Measured memory_bytes: 21844