akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.util.stream.LongStream;

public class Main implements Runnable {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        // Run with 32MB stack
        Thread thread = new Thread(null, new Main(), "", 32 * 1024 * 1024);
        thread.start();
    }

    @Override
    public void run() {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        String s = scanner.nextLine();
        int n = 0;
        for (int i = 0; i < s.length() / 2; i++) {
            if (s.charAt(i) != s.charAt(s.length() - 1 - i)) {
                n++;
            }
        }
        System.out.println(n);
    }

}


Measured memory_bytes: 24148
import math
A,B = list(map(int,input().split()))
 
A_min=12*A+math.ceil(0.5*A)
A_max=12*(A+1)+math.floor(0.5*(A+1))
B_min=10*B
B_max=10*(B+1)
 
if A_max <= B_min:
    print(-1)
elif B_max <= A_min:
    print(-1)
else:
    print(max(A_min,B_min))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(ll i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cout << "[" << #var << "] " << var << endl
const ll mod = 1000000007;


int main(){
    ll n, m;
    cin >> n >> m;
    
    vector<ll> x(n);
    vector<ll> y(n);
    vector<ll> z(n);

    rep(i, n) {
        cin >> x[i];
        cin >> y[i];
        cin >> z[i];
    }
    ll ans = 0;

    rep(i, 1LL<<3) {
        vector<bool> flg(3);
        vector<ll> score(n);
        rep(j, 3) {
            flg[j] = ((i>>j & 1)==1);
        }
        rep(j, n) {
            ll now = 0;
            if (flg[0]) now += x[j];
            else now -= x[j];
            if (flg[1]) now += y[j];
            else now -= y[j];
            if (flg[2]) now += z[j];
            else now -= z[j];
            score[j] = now;
        }
        ll sum = 0;
        sort(score.begin(), score.end());
        reverse(score.begin(), score.end());
        rep(j, m) {
            sum += score[j];
        }
        ans = max(ans, sum);
    }
    
    
    
    cout << ans << endl;
    return 0;
}


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

int main() {
  deque<int> dq;
  int q;
  cin >> q;
  for(int i = 0; i < q; i++){
    int query;
    cin >> query;
    if(query == 0){
      // d が 0 の場合、先頭に追加、1 の場合、末尾に追加
      int d, x;
      cin >> d >> x;
      if(d == 0){
        dq.push_front(x);
      }else{
        dq.push_back(x);
      }
    }else if(query == 1){
      int p;
      cin >> p;
      cout << dq[p] << endl;
    }else{
      int d;
      cin >> d;
      if(d == 0){
        dq.pop_front();
      }else{
        dq.pop_back();
      }
    }
  }
  return 0;
}


Measured memory_bytes: 4648
import sys
fin = sys.stdin.readline
from collections import defaultdict
from heapq import heappop, heappush


class Vertex(object):
    def __init__(self, name, distance):
        self.name = name
        self.distance = distance


    def __lt__(self, other_vertex):
        return self.distance < other_vertex.distance
    

    def __le__(self, other_vertex):
        return self.distance <= other_vertex.distance
    

    def __gt__(self, other_vertex):
        return self.distance > other_vertex.distance
    

    def __ge__(self, other_vertex):
        return self.distance >= other_vertex.distance


def initialize(adj, s):
    MAX_NUM = float('inf')
    parent = {s: None}
    d = {vertex: MAX_NUM for vertex in adj.keys()}
    d[s] = 0
    return d, parent


# Dijkstra can work using a minheap which does not have decrease_key.
# and also we do not have to implement Vertex class.
# Instead, we can use (distance, vertex).
# in this case, the time it takes is O(ElgE).
# E is at most O(V^2), thus O(ElgE) = O(ElgV).
def dijkstra_simple(adj, w, s):
    d, parent = initialize(adj, s)
    priority_queue = []
    heappush(priority_queue, (d[s], s))
    while priority_queue:
        distance, source = heappop(priority_queue) 
        for neighbor in adj[source]:
            new_distance = distance + w[(source, neighbor)]
            if new_distance < d[neighbor]:
                d[neighbor] = new_distance
                parent[neighbor] = source
                heappush(priority_queue, (new_distance, neighbor))
    return d


n, m, s, t = [int(elem) for elem in fin().split(' ')]
adj = defaultdict(list)
yen_weights = dict()
snuuk_weights = dict()
for _ in range(m):
    u, v, a, b = [int(elem) for elem in fin().split(' ')]
    for v1, v2 in [(u, v), (v, u)]:
        adj[v1].append(v2)
        yen_weights[(v1, v2)] = a
        snuuk_weights[(v1, v2)] = b

d_yen = dijkstra_simple(adj, yen_weights, s)
d_snuuk = dijkstra_simple(adj, snuuk_weights, t)
min_cost = float('inf')
min_cost_after_each_year_reversed = []
for vertex in range(n, 0, -1):
    min_cost = min(min_cost, d_yen[vertex] + d_snuuk[vertex])
    min_cost_after_each_year_reversed.append(min_cost)

initial_money = 10**15
print(*(initial_money - cost for cost in reversed(min_cost_after_each_year_reversed)), sep='\n')


Measured memory_bytes: 124432
// JOI - Prelim  0582
// 問題1
use std::str::FromStr;
use std::fmt::Debug;

fn read_line<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug
{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()
}

fn pow2(value: u32) -> f64
{
    (value * value) as f64
}

fn sub(anss: &mut [u32]) -> bool
{
    let mut datas : Vec<u32> = read_line();
    datas.sort();
    if datas[0] + datas[1] <= datas[2] {
        return false;
    }
    anss[0] += 1;
    let len = (pow2(datas[0]) + pow2(datas[1])).sqrt();
    let oth = datas[2] as f64;
    if len < oth {
        anss[3] += 1;
    }
    else if len > oth {
        anss[2] += 1;
    }
    else {
        anss[1] += 1;
    }
    return true;
}

fn main()
{
    let mut anss = [0u32; 4];
    loop {
        if !sub(&mut anss) {
            break;
        }
    }
    println!("{} {} {} {}", anss[0], anss[1], anss[2], anss[3]);
}


Measured memory_bytes: 5036
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	ll n,d;
	cin>>n>>d;
	ll ans=0;
	for(ll i=1;i<=n;i++) {
		ll x,y;
		cin>>x>>y;
		if(x*x+y*y<=d*d) ans++;
	} 
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
const int maxn = 2e5+10;
long long n;
int main(){
    cin>>n;
    long long ans = (n/11)*2;
    if(n% 11 == 0)   ans = ans;
    else if(n%11 <= 6 && n%11!=0)   ans = ans+1;
    else if(n%11!=0)   ans = ans+2;
    cout << ans<<endl;
}


Measured memory_bytes: 256
import collections
import sys
def read_a_integer():
    return int(sys.stdin.readline())

def read_a_list(dtype):
    return list(map(dtype, sys.stdin.readline().split()))


def main():
    N = read_a_integer()
    D = read_a_list(int)
    if D[0] != 0:
        print(0)
        return
    counter = collections.Counter(D)
    if counter[0] != 1:
        print(0)
        return
    max_D = max(D)
    ans = 1
    for i in range(2, max_D + 1):
        if i not in counter:
            print(0)
            return
        ans = (ans * (counter[i-1] ** counter[i])) % 998244353
    print(ans)
    # brute_force(N, D)

        


if __name__ == "__main__":
    main()


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

using ll = long long;
//typedef long long ll;

#define INF (1LL << 31 - 1)
#define INFLL ((1LL << 62) - 1)
#define MOD int(1e9+7)
#define repi(i,j,n) for(int i = (j); i < (n); ++i)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) for (int i = n; i >= 0; --i)
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()

int vx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, vy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};

inline bool check(int ux, int uy, int x, int y) {
  return (0 <= x and x < ux and 0 <= y and y < uy);
}

inline void init() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int n, m, E;

int main() {
  cin >> n >> m;
  E = (1900 * m + 100 * (n - m)) * (1 << m);

  cout << E << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define NL            "\n"
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
int main()
{
    _SAD()
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    SRT(a,n);
    cout<<a[n-1]-a[0]<<NL;
    return 0;
}



Measured memory_bytes: 256
n,m = map(int,input().split())
count = 0
t = 0

base = [list(map(int,input().split())) for i in range(m)]

base.sort(key=lambda x:x[1])

for temp in base:
  if t <= temp[0]:
    count = count + 1
    t = temp[1]

print(count)

Measured memory_bytes: 29084
import java.util.Scanner;

class Main
{
    public static void main(String args[])
    {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        for(int i=0;i<10000000;i++)
        {
            c = c-b;
            a = a-d;
            if(c<=0)
            {
                System.out.print("Yes");
                break;
            }
            else if(a<=0)
            {
                System.out.print("No");
                break;
            }
        }


    }
}

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

int main() {
    int k;
    string s;
    cin >> k >> s;
    if (s.size() > k) {
        cout << s.substr(0, k) << "..." << endl;
    } else {
        cout << s << endl;
    }
    return 0;
}

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

int main() {
    int m;
    cin >> m;
    map<string, int> num;
    for (int i = 0; i < m; i++) {
        string s;
        cin >> s;
        num[s]++;
    }
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        num[s]--;
    }

    int ans = 0;
    for (auto p: num) {
        ans = max(ans, p.second);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
typedef long long ll;

int mod = 1000000007;

int main()
{
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  ll ans = 0;
  rep(i, 60)
  {
    ll x = 0;
    rep(j, n) if (a[j] >> i & 1) x++;
    ll now = x * (n - x) % mod;    // x * (n-x) => # of combo of 1 and 0
    rep(j, i) now = now * 2 % mod; // if I use pow() this would overflow cuz i <= 60
    ans = (ans + now) % mod;
  }
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 2560
#include <iostream>
using std::string;
using std::cin;
using std::cout;
using std::endl;

int main(void){
  std::string str;
  int n;
  int sp;
  std::string split1;
  std::string split2;
  while(cin >> str){
    if(str == "-"){
      break;
    }
    cin >> n;
    for(int i = 0;i < n;i++){
      cin >> sp;
      split1 = str.substr(sp);
      split2 = str.substr(0,sp);
      str = split1+split2;
    }
    cout << str << endl;
  }
}

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

int n, t[12][12];
bool used[12];
string ts[12];
vector<string> s;

string dp[11][1 << 11];

int eqLen(string a, string b){
  int an = a.length();
  int bn = b.length();

  for(int i = 0; i < an; i++){
    if(i + bn < an) continue;

    bool flg = true;

    for(int j = 0; j < bn; j++){
      if(i + j == an) break;
      if(a[i + j] != b[j]){
        flg = false;
        break;
      }
    }

    if(flg) return an - i;
  }
  return 0;
}

string solve(int id, int bit){
  if(bit == (1 << n) - 1){
    return s[id];
  }
  if(dp[id][bit] != ""){
    return dp[id][bit];
  }

  string res = "";

  for(int i = 0; i < n; i++){
    if(bit & (1 << i)) continue;
    string tmp = solve(i, bit | (1 << i));
    tmp = s[id].substr(0, s[id].size() - t[id][i]) + tmp;

    if(res == "" || res.length() > tmp.length() ||
       res.length() == tmp.length() && res > tmp){
      res = tmp;
    }
  }

  return dp[id][bit] = res;
}

int main(){
  while(cin >> n, n){
    memset(t, 0, sizeof(t));
    memset(used, 0, sizeof(used));
    s.clear();

    for(int i = 0; i < 11; i++){
      for(int j = 0; j < (1 << 11); j++){
        dp[i][j] = "";
      }
    }

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

    for(int i = 0; i < n; i++){
      if(used[i]) continue;

      for(int j = 0; j < n; j++){
        if(used[j]) continue;
        if(i == j) continue;
        if(ts[i].find(ts[j]) == string::npos) continue;
        used[j] = true;
      }
    }

    for(int i = 0; i < n; i++){
      if(used[i]) continue;
      s.push_back(ts[i]);
    }

    n = s.size();

    for(int i = 0; i < n; i++){
      for(int j = 0; j < n; j++){
        if(i == j) continue;
        t[i][j] = eqLen(s[i], s[j]);
      }
    }

    s.push_back("");
    cout << solve(n, 0) << endl;
  }
}

Measured memory_bytes: 1788
import collections
n=int(input())
w=[]
for i in range(n):
    w.append(str(input()))

w_count=collections.Counter(w)
if max(w_count.values())>=2:
    print("No")
    exit()

for i in range(n-1):
    if w[i][-1]!=w[i+1][0]:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 3316
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <algorithm>
#include <utility>
#include <cstring>
#include <cmath>
using namespace std;


int main() {
    int n;
    cin>>n;
    double x;
    string s;
    double ans=0;
    while(n--){
        cin>>x>>s;
        if(s=="BTC")ans+=380000.0*x;
        else ans+=x;
    }
    printf("%.9f\n",ans);
    return 0;
}


Measured memory_bytes: 256
import math
N = int(input())

# dp
# dp[i] = dp[i-1](C+=1したやつ）+ (i-1)の約数の数。

def make_prime_list_2(num):
    if num < 2:
        return []

    # 0のものは素数じゃないとする
    prime_list = [i for i in range(num + 1)]
    prime_list[1] = 0 # 1は素数ではない
    num_sqrt = math.sqrt(num)

    for prime in prime_list:
        if prime == 0:
            continue
        if prime > num_sqrt:
            break

        for non_prime in range(2 * prime, num, prime):
            prime_list[non_prime] = 0

    return [prime for prime in prime_list if prime != 0]
  
primes = make_prime_list_2(1000)

def num_primes(n):
  wk = n
  res = 1
  for p in primes:
    if p*p > wk:
      break
    cnt = 0
    while wk % p == 0:
      wk = wk // p
      cnt += 1
    res = res * (cnt+1)
  if wk >= 2:
    res *= 2
  return res

dp = [0] * (N+1)
dp[1] = 0
dp[2] = 1

for i in range(2,N):
  dp[i+1] = dp[i] + num_primes(i)
  
print(dp[N])


Measured memory_bytes: 76176
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            if (ReadLine().Contains('9'))
                WriteLine("Yes");
            else
                WriteLine("No");
        }

        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 25604
#include<iostream>

using namespace std;

int main(){
    int a[4];
    for(int i = 0; i < 4; i++)
    {
        a[i]=0;
    }
    
    for (int i=0;i<6;i++){
        int x=0;
        cin >> x;
        a[x-1] += 1;
    }
    for(int i = 0; i < 4; i++)
    {
        if(a[i]>2){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	int n,m,c;
	cin>>n>>m>>c;
	int arr[m], ans =0;
	for(int i=0; i<m; i++)cin>>arr[i];
	for (int i = 0; i < n; i++){
		int check = 0;
		for(int j=0; j<m; j++){
			int x; cin>>x;
			check+=(arr[j]*x);
		}
		if(check+c>0)ans++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3640
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<cstring>
using namespace std;

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

  long long int cnt = min(a+b+1, c) + b;
  cout << cnt << endl;

  return 0;
}



//EOF


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;
ll MOD = 1000000007;

// a^p
// 2^3 = 2 * 2^2
// 2^2 = 2 * (2^1)
// 2^1 = 2
ll modpow(ll a, ll p, ll mod) {
  if (p == 0) return 1;

  if (p % 2 == 0) {
    ll half = modpow(a, p / 2, mod) % mod;
    return half * half % mod;
  } else {
    return a * modpow(a, p - 1, mod) % mod;
  }
}

// nCa を求める
ll modCombination(ll n, ll a, ll mod) {
  if (n - a < a) {
    return modCombination(n, n - a, mod);
  }

  ll denominator = 1;  // 分母
  ll numerator = 1;    // 分子

  for (ll i = 0; i < a; i++) {
    denominator *= a - i;
    numerator *= n - i;
    denominator %= mod;
    numerator %= mod;
  }

  return numerator * modpow(denominator, mod - 2, mod) % mod;
}

class UnionFind {
 private:
  vector<ll> parents;

 public:
  UnionFind(ll n) : parents(n, -1) {}

  bool issame(ll x, ll y) { return root(x) == root(y); }

  bool merge(ll x, ll y) {
    if (issame(x, y)) return false;

    ll rx = root(x);
    ll ry = root(y);
    if (parents[rx] > parents[ry]) swap(rx, ry);
    // サイズ情報を更新
    parents[rx] += parents[ry];
    // yの親を更新
    parents[ry] = rx;

    return true;
  }

  ll size(ll x) { return -parents[root(x)]; }

 private:
  ll root(ll x) {
    if (parents[x] < 0) return x;
    // 根の親の値に木の(-)サイズの情報を入れる
    return parents[x] = root(parents[x]);
  }
};

int main() {
  ll N;
  string S;
  cin >> N >> S;

  ll ans = 0;
  for (ll i = 0; i < N;) {
    ll j = i;
    while (j < N && S[i] == S[j]) {
      j++;
    }
    ans++;
    i = j;
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
import copy

n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))

bef = -1
ans = 0
for i in A:
    ans += B[i-1]
    if(bef + 1 == i):
        ans += C[i-2]
    bef = i
print(ans)
    


Measured memory_bytes: 3444
import java.util.Scanner;
public class Main {
    public static void main (String[] args) {
	Scanner scan = new Scanner(System.in);
	String w = scan.nextLine();
	int count = 0;
	while (scan.hasNext()) {
	    String T = scan.nextLine();
	    if (T.equals("END_OF_TEXT")) {
		break;
	    }
	    String[] Ts = T.split(" ");
	    for (int i = 0; i < Ts.length; i++) {
		if (Ts[i].equalsIgnoreCase(w)) {
		    count++;
		}
	    }
	}
	System.out.println(count);
    }
}

Measured memory_bytes: 26196
#include<bits/stdc++.h>
using namespace std;
int n,m,a[51],b[51],c[51],d[51],i,j,k,l,x,y;
main(){
  cin>>n>>m;
  for(;n-i++;cin>>a[i]>>b[i]);
  for(;m-j++;cin>>c[j]>>d[j]);
  for(;n-k++;cout<<y<<endl)
    for(l=0,x=1e9;m-l++;)
      x>abs(a[k]-c[l])+abs(b[k]-d[l])&&(x=abs(a[k]-c[l])+abs(b[k]-d[l]),y=l);
}


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

int main(){
    int N, T;
    long long ans = 0;
    cin >> N >> T;
    int a[N +10];
    int t[N + 10];
    for(int i=0; i< N; ++i) {
        cin >> t[i];
    }
    for(int i=0; i< N+1; ++i) {
        a[i] = 0;
    }
    
    int head = 0;
    a[head] = 1;
    for(int i=1; i<=N; ++i){
        if(t[i-1] < t[i] && t[i] < t[i-1] + T){
            a[head]+=1;
        }else{
            head += a[head];
            a[head] = 1;
        }
    }
    for(int i=0; i<N; ++i){
        if(a[i] != 0) ans += t[i + a[i] -1] + T - t[i];
    }
    cout << ans << endl;
    

    return 0;
}


Measured memory_bytes: 1792
a, b, k = map(int, input().split(" "))
cnt = 1
for _ in range(k):
	if cnt == 1:
		if a % 2 == 1:
			a -= 1
		a = a / 2
		b += a
		cnt = cnt * (-1)
	else:
		if b % 2 == 1:
			b -= 1
		b = b / 2
		a += b
		cnt = cnt * (-1)
print(int(a), int(b))

Measured memory_bytes: 3060
import math
n = int(input())
if n % 2 == 1:
  print(0)
  exit()
if n == 0:
  print(0)
  exit()
t = n//2
i = 1
ans = 0
M = math.log10(n)/math.log10(5)
while i < M:
  ans += t//(5**i)
  i += 1

print(ans)

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

using namespace std;

int ps[100005];

int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	
	for (int i = 0; i < m; i++) {
		int l, r;
		scanf("%d%d", &l, &r);
		ps[l]++;
		ps[r + 1]--;
	}
	
	int res = 0;
	
	for (int i = 1; i <= n; i++) {
		ps[i] += ps[i - 1];
		if (ps[i] == m) res++;
	}
	
	printf("%d\n", res);
}


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

using namespace std;

int main() {
    int n, m, x, y;
    cin >> n >> m >> x >> y;

    vector<int>A(n);
    vector<int>B(m);

    for(int i = 0; i < n; i++) {
        cin >> A[i];
    }
    for(int i = 0; i < m; i++) {
        cin >> B[i];
    }
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());

    if(A[n-1] < B[0] && x < A[n-1] && B[0] < y){
        cout << "No War" << endl;
    }
    else{
        cout << "War" << endl;
    }

    return 0;
}

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

using namespace std;

int main() {
    int a, b, k;
    cin >> a >> b >> k;
    if(b-a+1<=2*k) {
        for(int i=a; i<=b; i++) 
            cout << i << endl;
    } else {
        for(int i=0; i<k; i++)
            cout << a+i << endl;
        for(int i=k-1; i>=0; i--)
            cout << b-i << endl;
    }

}

Measured memory_bytes: 256
//In the name of Allah
#include <bits/stdc++.h>
using namespace std;
#define MAX 100011
#define mod 1000000007
#define inf 1000000000000000000
#define ll long long
#define endl '\n'
int n;
int dp[MAX],a[MAX];
bool memo(int k){
	if(dp[k] != -1)return dp[k];
	bool ans = 0;
	for(int i =0 ;i < n; i++){
		if(k - a[i] >= 0)ans |= (1 - memo(k-a[i]));
		else break;
	}
	dp[k] = ans;
	return ans;
}
int main() {
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int k;	
	cin>>n>>k;
	for(int i =0 ; i < n ;i++)cin>>a[i];
	
	memset(dp,-1,sizeof dp);
	if(memo(k))cout<<"First";
	else cout<<"Second";
	return 0; 
} 

Measured memory_bytes: 5376
x1, y1, x2, y2 = map(int, input().split())

vec = [x2 - x1, y2-y1]

rotated_1 = [-1*vec[1], vec[0]]
rotated_2 = [-1*rotated_1[1], rotated_1[0]]

a = [x2 + rotated_1[0], y2 + rotated_1[1]]
b = [a[0] + rotated_2[0], a[1] + rotated_2[1]]
print(a[0], a[1], b[0], b[1])

Measured memory_bytes: 3064
import scala.io.StdIn

object Main {
  def main(args: Array[String]){
    val N = StdIn.readInt()
    val inputs = (0 to N-1).map(_ => StdIn.readInt)
    println(inputs.foldLeft(0){(acc, i) => { acc +
      (if((2 to Math.sqrt(i).toInt).forall(i % _ != 0)) 1 else 0)
    }})
  }
}

Measured memory_bytes: 120876
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,s,c=0;
    vector<int> v;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> s;
        v.push_back(s);
    }
    for(int i=0;i<n;i++){
        for(int j=n-1;j>i;j--){
            if(v[j]<v[j-1]){
                s=v[j];
                v[j]=v[j-1];
                v[j-1]=s;
                c++;
            }
        }
    }
    for(int i=0;i<n;i++){
        cout << v[i] << ((i==n-1)?"":" ") ;
    }
    cout<<endl<<c<<endl;
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long a,b,c,d;
    cin>>a>>b>>c>>d;
    long long ans;
    ans=max(a*c, a*d);
    ans=max(ans, b*c);
    ans=max(ans, b*d);
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 3596
# 入力
S=input()

# 先頭の文字が 'A'
if S[0]!='A':
  print('WA')
  exit()

# 先頭から3文字目と末尾から2文字目の間に
# 'C' が含まれる
if 'C' not in S[2:-1]:
  print('WA')
  exit()

# 上記2文字以外はすべて小文字である
s=list(S)
s.remove('A')
s.remove('C')

for x in s:
  if x not in 'abcdefghijklmnopqrstuvwxyz':
    print('WA')
    exit()

# チェックに一度もかからなかった場合
print('AC')

Measured memory_bytes: 9080
#include <bits/stdc++.h>
using namespace std;
#define FAST_IO                     \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0);
typedef long long ll;
/**
 * Uncomment the #define below if problem contains multiple test cases
 */
// #define MULTIPLE_TESTS 1

void solve() {
  ll n;
  cin >> n;

  string ans;
  ll cur = 26;
  int len = 0;
  ll t = n;
  while (n > 0) {
    n -= cur;
    cur *= 26;
    ++len;
  }
  ll pow = 26;
  n = t;
  for (int i = 0; i < len; ++i) {
    ll cur = n % 26;
    if (cur == 0) {
      ans += 'z';
      n /= 26;
      --n;
    } else {
      ans += ('a' + cur - 1);
      n /= 26;
    }
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
}

int main() {
  FAST_IO;
  int t = 1;
#ifdef MULTIPLE_TESTS
  cin >> t;
#endif

  while (t--) {
    solve();
  }

  return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
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 (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;

    ll ans = 1;

    map<char, int> X;
    REP(i,N){
        char c = S[i];
        X[c]++;
    }

    for(auto&& x : X){
        int cnt = x.second+1;
        ans *= cnt;
        ans %= MOD;
    }


    ans--;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>

#define BR "\n"
#define REP(i,n) for(int i=0;i<n;i++)

using namespace std;
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int x;
	cin >> x;
	cout << x * x << BR;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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 (b<a) { a=b; return 1; } return 0; }

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);

    int N,K; cin >> N >> K;
    VI H(N);
    REP(i,N) cin >> H[i];
    sort(H.begin(),H.end(),greater<int>());
    LL ans = 0;
    for(int i = K; i < N; i++){
        ans += H[i];
    }
    cout << ans << endl;


}


Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

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

const static ll MOD = 1000000007;

class BinaryIndexedTree {
private:
  int* bit;
  int n;
public:
  BinaryIndexedTree(int _size){
    bit = new int[_size];
    n = _size;
    fill(bit,bit+_size,0);
  }
  int sum(int i){
    int s = 0;
    while(i > 0){
      s += bit[i];
      i -= i & -i;
    }
    return s;
  }
  
  void add(int i, int x){
    while(i <= n){
      bit[i] += x;
      i += i & -i;
    }
  }
};

int main(){
  int N,R;
  ll dp[100001];
  ll target[100001];

  while(~scanf("%d %d",&N,&R)){
    if(N == 0) break;

    memset(dp,0,sizeof(dp));
    dp[0] = 1;

    for(int i=1;i<=N;i++){
      target[i] = i;
      // 4
      // v v v v
      //  1 2 3
      dp[i] = dp[i-1] * i % MOD;
    }
    for(int r = 0; r< R;r++){
      int from_idx;
      int to_idx;
      scanf("%d %d",&from_idx,&to_idx);
      swap(target[from_idx],target[to_idx]);
    }

    ll res = 0;
    BinaryIndexedTree BIT(100001);
    for(int i=N,j=0;i>=1;i--,j++){
      res += ((dp[j] % MOD) * (BIT.sum(target[i] - 1) % MOD) % MOD);
      res %= MOD;
      BIT.add(target[i],1);
    }
    printf("%lld\n",res);
  }
}

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

using namespace std;
using ll = long long;
using v1 = vector<int>;
using vl = vector<long long>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;

int main(){
	string s;
	cin >> s;
	int q;
	cin >> q;
	list<char> L_front(0);
	list<char> L_back(0);
	bool rev = false;
	rep(i, q){
		int x, f;
		cin >> x;
		if(x== 1){
			if(rev) rev = false;
			else rev = true;
		}
		if(x == 2){
			char c;
			cin >> f >> c;
			if(!rev){
				if(f == 1) L_front.push_front(c);
				if(f == 2) L_back.push_back(c);
			}else{
				if(f == 1) L_back.push_back(c);
				if(f == 2) L_front.push_front(c);
			}
		}
	}
	if(rev){
		auto itr1 = L_front.end();
		auto itr2 = L_back.end();
		reverse(s.begin(), s.end());
		while(1){
			itr2--;
			cout << *itr2;
			if(itr2 == L_back.begin()) break;
		}
		cout << s;
		while(1){
			itr1--;
			cout << *itr1;
			if(itr1 == L_front.begin()) break;
		}
		cout << endl;
	}else{
		auto itr1 = L_front.begin();
		auto itr2 = L_back.begin();
		while(itr1 != L_front.end()){
			cout << *itr1;
			itr1++;
		}
		cout << s;
		while(itr2 != L_back.end()){
			cout << *itr2;
			itr2++;
		}
		cout << endl;
	}
}


Measured memory_bytes: 9896
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;

#define REP(i, a) for (int i = 0; i < (a); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a)-1; i >= (b); --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond, yes, no) \
    { cout << ((cond) ? (yes) : (no)) << endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(), (list).rend())
#define ASSERT(cond, mes) assert(cond&& mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template <typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())
    is >> v[i];
    return is;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a) n = a;
    if (n > b) n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

std::vector<int> enum_div(int n) {
    std::vector<int> ret;
    for (int i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i != 1 && i * i != n) { ret.push_back(n / i); }
        }
    }
    return ret;
}

template <typename T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

struct ToUpper {
    char operator()(char c) {
        return toupper(c);
    }
};

struct ToLower {
    char operator()(char c) {
        return tolower(c);
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

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

    int ans = A[0];
    REP(i, N - 1) {
        ans = GCD(ans, A[i + 1]);
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;



int main(int argc, char* argv[])
{
    int cnt[26]={0};
    char str[1205]={0};
    int i;
    while( fgets(str, 1200, stdin) != NULL) {
        int len=strlen(str);
        if(str[len-1]=='\n') str[--len]='\0';

        for(i=0; i<len; i++) {
            if(str[i]>='a' && str[i]<='z') cnt[str[i]-'a']++;
            if(str[i]>='A' && str[i]<='Z') cnt[str[i]-'A']++;
        }
    }
    for(i=0; i<26; i++) {
        char str0[2]={0};
        str0[0]='a'+i;
        printf("%s : %d\n", str0, cnt[i]);
    }

    return 0;
}



Measured memory_bytes: 2712
#include <bits/stdc++.h>
#define Inf 0x3f3f3f3f
#define rg register
using namespace std;
typedef long long ll;
inline ll min(ll x, ll y) { return x < y ? x : y; }
inline ll max(ll x, ll y) { return x > y ? x : y; }
const int Maxn = 1e5 + 5,Mod=1e9+7;
inline int read()
{
	rg int res = 0, sign = 1;
	rg char ch = getchar();
	while (!isdigit(ch))
	{
		if (ch == '-')
			sign = -1;
		ch = getchar();
	}
	do
	{
		res = (res << 3) + (res << 1) + (ch ^ 48);
		ch = getchar();
	} while (isdigit(ch));
	return res * sign;
}
int n,cnt,k;
int fir[Maxn],son[Maxn];
ll ans=1;
struct{
	int to,last;
}e[2*Maxn];
inline void con(int u,int v)
{
	e[++cnt].to=v;
	e[cnt].last=fir[u];
	fir[u]=cnt;
}
ll qp(ll x,int y)
{
	ll res=1;
	while(y)
	{
		if(y&1)
			res=res*x%Mod;
		x=x*x%Mod;
		y>>=1;
	}
	return res;
}
void DFS(int x,int from)
{
	int s=0;
	for(int next=fir[x],nx;next;next=e[next].last)
	{
		nx=e[next].to;
		if(nx==from)
			continue;
		ans=ans*(k-(from?2:1)-(s++))%Mod;
		DFS(nx,x);
	}
}
int main()
{
	rg int a,b;
	cin>>n>>k;
	for(int i=1;i<n;i++)
	{
		scanf("%d%d",&a,&b);
		con(a,b);
		con(b,a);
	}
	DFS(1,0);
	cout<<ans*k%Mod<<endl;
	return 0;
}


Measured memory_bytes: 6912
#include<stdio.h>
#include<iostream>
#include<vector>
#include <fstream>
#include<math.h>
#include <numeric>
#include<algorithm>

using namespace std;

int main(){
    int n;
    int tmp ;
    int saidai = 0;
    int ans = 0;
  cin >> n;
    for(int i = 0;i < n ;i++){
        cin >> tmp;
        if (tmp >= saidai){
            saidai = tmp;
            ans += 1 ;
        }
    }
    cout << ans << endl;
    
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main(){
	
	int n;
	int t[100000],x[100000],y[100000],a=0,b=0,c=0;
	cin>>n;
	for(int i=0;i<n;i++)cin>>t[i]>>x[i]>>y[i];
	for(int i=0;i<n;i++){
		int ke=abs(t[i]-a)-abs(x[i]-b)-abs(y[i]-c);
		if(ke>0){
			if(ke%2!=0){
				cout<<"No"<<endl;
				return 0;
			}
		}
		else{
			if(ke!=0){
				cout<<"No"<<endl;
				return 0;
			}
		}
		a=t[i];
		b=x[i];
		c=y[i];
	}
	cout<<"Yes"<<endl;
	
	return 0;
}

Measured memory_bytes: 1408
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <set>
#include <map>
using namespace std;
#define rg register
#define LL long long
#define __space putchar(' ')
#define __endl putchar('\n')
template <typename qwq> inline void read(qwq &x)
{
	x = 0;
	rg int f = 1;
	rg char c = getchar();
	while (c < '0' || c > '9')
	{
		if (c == '-') f = -1;
		c = getchar();
	}
	while (c >= '0' && c <= '9')
	{
		x = (x << 1) + (x << 3) + (c ^ 48);
		c = getchar();
	}
	x *= f;
}
template <typename qaq> inline void print(qaq x)
{
	if (x < 0)
	{
		putchar('-');
		x = -x;
	}
	if (x > 9) print(x / 10);
	putchar(x % 10 + '0');
}
#define int LL 
const int p = 998244353;
const int maxn = 500005;
inline LL Pow(LL x, LL y)
{
	rg LL ret = 1;
	while (y)
	{
		if (y & 1) ret = ret * x % p;
		x = x * x % p;
		y >>= 1;
	}
	return ret;
}
LL fac[maxn];
inline LL C(int n, int m)
{
	return fac[n] * Pow(fac[m], p - 2) % p * Pow(fac[n - m], p - 2) % p;
}
LL n, a, b, k, ans;
signed main()
{
	read(n), read(a), read(b), read(k);
	fac[0] = 1;
	for (rg int i = 1; i <= n; ++i) fac[i] = fac[i - 1] * i % p; 
	for (rg int i = 0; i <= n && i <= k / a; ++i)
	{
		rg LL sum_a = a * i;
		rg LL sum_b = k - sum_a;
		if (sum_b % b) continue;
		sum_b /= b;
		if (sum_b > n) continue;
		ans = (ans + C(n, i) * C(n, sum_b)) % p;
	}
	print(ans);
	return 0;
}

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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

using namespace std;
using ll = long long;
using pii = pair<int, int>;

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'000'000'001;
constexpr ll LLINF = 4'000'000'000'000'000'001;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int h, w;
    cin >> h >> w;
    vector<string> a(h);
    for(int i = 0; i < h; ++i){
        cin >> a[i];
    }
    vector<vector<int>> dp(h, vector<int>(w));
    dp[0][0] = 1;
    for(int i = 0; i < h; ++i){
        for(int j = 0; j < w; ++j){
            ll pat = dp[i][j];
            if(i != 0 && a[i-1][j] == '.') pat += dp[i-1][j];
            if(j != 0 && a[i][j-1] == '.') pat += dp[i][j-1];
            dp[i][j] = pat % MOD;
        }
    }
    cout << dp[h-1][w-1] << "\n";
    return 0;
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
	#define debug(...) printf(__VA_ARGS__)
#else
	#define debug(...) (void)0
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

const int N = 105;
int arr[N];

int main() {
	int n, x;
	scanf("%d%d", &n, &x);
	for(int i=0; i<n; i++)
		scanf("%d", arr+i);
	sort(arr, arr+n);
	int ans=0;
	for(int i=0; i<n-1; i++) {
		if(x < arr[i])
			break;
		x -= arr[i];
		ans++;
	}
	if(ans == n-1 and x == arr[n-1])
		ans++;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

typedef long long ll;

#define rep(i, a,n) for (ll i = a; i < (ll)n; ++i)
#define repd(i, n) for (ll i = (n)-1; i >= 0; --i)
#define INF 10e12
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;

int main(void)
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    string ans="Good";
    rep(i,1,4)if(s[i-1]==s[i]) ans="Bad";
    cout<<ans<<endl;
}


Measured memory_bytes: 3564
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <algorithm>
#include <cmath>
#include <climits>
#define REP(i, n) for(int i=0; i<(n); i++)
#define FOR(i, a, n) for(int i=(a); i<(n); i++)
using namespace std;

int main(){
    int a,b,c;cin>>a>>b>>c;string ans=b-a==c-b?"YES":"NO";cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
# import sys
# import math
# import decimal
# import queue
# import bisect
# import heapq # priolity-queue
# import time
# import itertools
# import collections # queue
# from operator import itemgetter
# from fractions import Fraction

mod = int(1e9+7)
INF = 1<<29
lINF = 1<<35

def main():
    l = int(input())
    ans = (l/3)**3
    print(ans)
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 2940
function main(input) {
  var numStr = input.toString(10)
  var num = 0;
  for(var i = 0; i < numStr.length; i = i + 1) {
    num += Number(numStr.slice(i, i + 1))
  }
  if(input % num == 0) {
    console.log("Yes")
  } else {
    console.log("No")
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

N = int(input())
if N ==1:
  print(0)
  exit()
N_list = factorization(N)
cnt_1 = 0
for i in range(len(N_list)):
  x = 1
  y = N_list[i][1]
  cnt = 0
  while True:
    y -= x
    x += 1
    if y >= 0:
      cnt += 1
    else:
      break
  cnt_1 += cnt 
print(cnt_1)

Measured memory_bytes: 9504
# abc170_b.py
# https://atcoder.jp/contests/abc170/tasks/abc170_b

# B - Crane and Turtle /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 200点

# 問題文
# 庭に何匹かの動物がいます。これらはそれぞれ、2本の足を持つ鶴か 4本の足を持つ亀のいずれかです。
# 高橋くんは、「庭の動物の総数は X匹で、それらの足の総数は Y本である」と発言しています。
# この発言が正しいような鶴と亀の数の組合せが存在するか判定してください。

# 制約
#     1≤X≤100
#     1≤Y≤100
#     入力中のすべての値は整数である。

# 入力
# 入力は以下の形式で標準入力から与えられる。
# X Y

# 出力
# 発言が正しいような鶴と亀の数の組合せが存在すれば Yes、なければ No と出力せよ。

# 入力例 1
# 3 8

# 出力例 1
# Yes

# 「庭にいる動物の総数は 3匹で、それらの動物の足の総数は 8 本である」という発言は、
# 鶴が 2 羽、亀が 1匹いる場合に正しいため、発言が正しいような鶴と亀の数の組合せは存在します。

# 入力例 2
# 2 100

# 出力例 2
# No

# この発言が正しいような鶴と亀の数の組合せは存在しません。

# 入力例 3
# 1 2

# 出力例 3
# Yes

# 鶴と亀のうち一方のみが存在する場合も考慮します。


global FLAG_LOG
FLAG_LOG = False


def log(value):
    # FLAG_LOG = True
    FLAG_LOG = False
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    # S = lines[0]
    # N = int(lines[0])
    X, Y = list(map(int, lines[0].split()))
    # values = list(map(int, lines[1].split()))
    # values = list(map(int, lines[2].split()))
    # values = list()
    # for i in range(N):
    #     values.append(int(lines[i]))
    # valueses = list()
    # for i in range(N):
    #     valueses.append(list(map(int, lines[i+1].split())))

    result = 'Yes'
    if Y >= X*2 and Y <= X*4 and Y % 2 == 0:
        result = 'Yes'
    else:
        result = 'No'

    return [result]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['3 8']
        lines_export = ['Yes']
    if pattern == 2:
        lines_input = ['2 100']
        lines_export = ['No']
    if pattern == 3:
        lines_input = ['1 2']
        lines_export = ['Yes']
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(1)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()


Measured memory_bytes: 9200
#include <iostream>
#include <vector>
#include <limits>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

using namespace std;
using namespace boost;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

int main() {
    uint N;
    cin >> N;
    vector<uint> counts(N, 0);
    for (auto &&i: irange(0U, N)){
        uint a, count{0};
        cin >> a;
        while (a%2!=1){
            a/=2;
            count++;
        }
        counts.at(i) = count;
    }
    cout << *min_element(counts.begin(), counts.end());
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(a, n) rep(hoge, n) printf("%d%c", a[hoge], hoge == n - 1? '\n' : ' ');
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define ln(a) cout << (a) << endl
#define INF 1000000000

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

struct segtree {
    int n;
    int* dat;

    segtree(int _n) {
        n = 1;
        while(n < _n) n *= 2;
        dat = new int[n * 2 - 1];
        fill(dat, dat + n * 2 - 1, INT_MAX);
    }

    void update(int i, int x) {
        i += n - 1;
        dat[i] = x;
        while(i > 0) {
            i = (i - 1) / 2;
            dat[i] = min(dat[i * 2 + 1], dat[i * 2 + 2]);
        }
    }

    int find(int s, int t, int i, int l, int r) {
        if(t <= l || r <= s) return INT_MAX;
        if(s <= l && r <= t) return dat[i];
        int lv = find(s, t, i * 2 + 1, l, (l + r) / 2);
        int rv = find(s, t, i * 2 + 2, (l + r) / 2, r);
        return min(lv, rv);
    }
};

signed main() {
    string s, t;
    cin >> s >> t;
    ln(t + s);
}


Measured memory_bytes: 256