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

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

   int a[n][2];
   for(int i = 0; i < n; i++) cin >> a[i][0];
   for(int i = 0; i < n; i++) cin >> a[i][1];
   

   int f[n], b[n];
   int tmp = 0;
   for(int i = 0; i < n; i++){
       tmp += a[i][0];
       f[i] = tmp;
   }

   tmp = 0;

   for(int i = n-1; i > -1; i--){
       tmp += a[i][1];
       b[i] = tmp;
   }

   int ans = 0;

   //for(int i = 0; i < n; i++) cout << f[i] << endl;
   //for(int i = 0; i < n; i++) cout << b[i] << endl;

   int max_v = 0;
   for(int i = 0; i < n; i++){
       if(f[n-1] + a[n-1][1] < b[i] + f[i]){
           ans = f[i] + b[i];
           max_v = max(ans, max_v);
       }
   }

   cout << max(max_v, f[n-1] + a[n-1][1]) << endl;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

// ABC127 A - Ferris Wheel
// 2020.07.04

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int A, B; cin >> A >> B;
  int ans = B;
  if(A <= 12 && A >= 6){
    ans = B/2;
  }else if(A <= 5){
    ans = 0;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

constexpr LL INF = 1LL << 60;

int returnMinDistance(vector<pair<int,LL>> &d, vector<bool> &inq) {
    int index = -1;
    REP(i,0,d.size()) {
        if (!inq[i]) continue;
        if (index == -1) {
            index = i;
        } else {
            if (d[index] > d[i]) index = i;
        }
    }
    return index;
}

void Dijkstra(int s, VVLL &g, vector<pair<int,LL>> &d, LL &l) {
    REP(i,0,d.size()) d[i] = MP(d.size(),INF);
    d[s] = MP(0,0);
    vector<bool> inq(d.size(), true);
    for (int i = 0; i < d.size(); ++i) {
        int index = returnMinDistance(d,inq);
        inq[index] = false;
        REP(j,0,d.size()) {
            if (g[index][j] == INF) continue;
            pair<int,LL> tmp;
            tmp.first = d[index].first;
            tmp.second = d[index].second + g[index][j];
            if (tmp.second > l) {
                tmp.first++;
                tmp.second = g[index][j];
            }
            d[j] = min(d[j], tmp);
        }
    }
}

void solve() {
    LL n,m,l;
    cin >> n >> m >> l;
    int a,b,c;
    VVLL es(n,VLL(n,INF));
    REP(i,0,m) {
        cin >> a >> b >> c;
        --a; --b;
        if (c > l) continue;

        es[a][b] = min(es[a][b], (LL)c);
        es[b][a] = min(es[b][a], (LL)c);
    }

    vector<vector<pair<int,LL>>> d(n,vector<pair<int,LL>>(n));
    REP(i,0,n) Dijkstra(i,es,d[i],l);

    int q,s,t;
    cin >> q;
    REP(i,0,q) {
        cin >> s >> t;
        --s; --t;
        if (d[s][t].first == n) cout << -1 << endl;
        else cout << d[s][t].first << endl;        
    }
    
}

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

Measured memory_bytes: 2688
def b172(slist, tlist):

    ans = 0

    for s, t in zip(slist, tlist):
        if s != t:
            ans += 1

    return ans

def main():
    slist = list(str(input()))
    tlist = list(str(input()))
    print(b172(slist, tlist))

if __name__ == '__main__':
    main()

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

int main() {
	while(1){
		int n;
		cin >> n;
		if(n == 0)break;
		
		int g[10000];
		for(int i = 0; i < n; i++)
			cin >> g[i];
		
		int t = 0;
		bool ok = false;
		for(int i = 0 ; i < n; i++){
			if(g[i] >= 1)
				t++;
			if(g[i] >= 2 && !ok)
				ok = true;
		}
	
		if(ok)
			cout << (t + 1)<< endl; 
		else 
			cout << "NA" << endl;
	}
	return 0;
}

Measured memory_bytes: 1200
#include<iostream>
using namespace std;
int main(){
  string S,ans;
  int w,i;
  cin >> S >> w;
  for(i = 0; i < S.size(); i++){
    if((i%w) == 0){
      ans += S[i];
    }
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define C complex<ll>
#define pCi pair<C, int>
#define F first
#define S second
#define X real()
#define Y imag()
#define pb push_back

const int N = 101010;

using namespace std;

int n, k, a[101];
bitset<N> dp;

int main(){

	cin >> n >> k;
	for(int i=0; i<n; i++) cin >> a[i];
	sort(a, a+n);

	for(int i=a[0]; i<=k; i++){
		for(int j=0; j<n && a[j]<=i; j++) dp[i] = dp[i]|(~dp[i-a[j]]);
	}

	if(dp[k]) cout << "First\n";
	else cout << "Second\n";

	return 0;
}


Measured memory_bytes: 256
import sys
n=int(input())
X=[int(i) for i in input().split()]
mod=10**9+7
n_max=n
F,FI=[0]*(n_max+1),[0]*(n_max+1)
F[0],FI[0]=1,1
for i in range(n_max):
  F[i+1]=(F[i]*(i+1))%mod
  FI[i+1]=pow(F[i+1],mod-2,mod)


ans=0
DP=[0]*n
DP[0]=1
DP[1]=1
ans=(ans+DP[1]*(X[1]-X[0])*F[n-1]*FI[0])%mod
for i in range(2,n):
  DP[i]=(F[i-1]+DP[i-1]*i)%mod
  ans=(ans+DP[i]*(X[i]-X[i-1])*F[n-1]*FI[i])%mod
print(ans)


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

answer = []
if len(set(A)) == 1: #全て同じ
  if A[0] >= 0:
    for i in range(2, N):
      answer.append((A[1], A[i]))
      A[1] -= A[i]
    answer.append((A[0], A[1]))
    answer_A = A[0] - A[1]
  else:
    for i in range(1, N):
      answer.append((A[0], A[i]))
      A[0] -= A[i]
    answer_A = A[0]
else:
  max_A = max(A)
  min_A = min(A)
  for i in range(N):
    if A[i] == max_A:
      max_i = i
    if A[i] == min_A:
      min_i = i
  for i in range(N):
    if i != max_i and i != min_i:
      if A[i] >= 0:
        answer.append((A[min_i], A[i]))
        A[min_i] -= A[i]
      else:
        answer.append((A[max_i], A[i]))
        A[max_i] -= A[i]
  answer.append((A[max_i], A[min_i]))
  answer_A = A[max_i] - A[min_i]

print(answer_A)
for a in answer:
  print(*a)

Measured memory_bytes: 61964
import java.util.*
import kotlin.comparisons.compareBy

fun main(args: Array<String>){
    val (H, W) = readLine()!!.split(" ").map { it.toInt() }
    val S = Array(H){ readLine()!! }

    val d = Array(H){ IntArray(W){ Int.MAX_VALUE / 10 } }
    val queue = PriorityQueue<Triple<Int, Int, Int>>(H * W,compareBy { it.third })
    if(S[0][0] == '.'){
        d[0][0] = 0
    }else{
        d[0][0] = 1
    }
    queue.add(Triple(0, 0, d[0][0]))
    while (queue.isNotEmpty()){
        val e = queue.poll()
        //下
        if(e.first != H - 1){
            val newD = e.third + if(S[e.first][e.second] == '.' && S[e.first + 1][e.second] == '#') 1 else 0
            if(d[e.first + 1][e.second] > newD){
                d[e.first + 1][e.second] = newD
                queue.add(Triple(e.first + 1, e.second, newD))
            }
        }
        //右
        if(e.second != W - 1){
            val newD = e.third + if(S[e.first][e.second] == '.' && S[e.first][e.second + 1] == '#') 1 else 0
            if(d[e.first][e.second + 1] > newD){
                d[e.first][e.second + 1] = newD
                queue.add(Triple(e.first, e.second + 1, newD))
            }
        }
    }
    println(d[H - 1][W - 1])
}

Measured memory_bytes: 38272
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = Integer.parseInt(sc.next());
		int count = 0;
		for(int i=1; i<=k; i+=2) {
		    for(int j=2; j<=k; j+=2) {
		        count++;
		    }
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 21972
a=input()
b=0
c=0
d=0
e=0

for i in range(len(a)):
    if a[i]=='K':
        b +=1
    elif a[i]=='U':
        c +=1
    elif a[i]=='P':
        d +=1
    elif a[i]=='C':
        e +=1
    else:
        pass
print(min(b,c,d,e))
    
        


Measured memory_bytes: 5560
#include <numeric>
#include <vector>
#include <map>
#include <iostream>
using namespace std;

class UnionFind {
    vector<int> rank, root;
public:
    UnionFind(int n) {
        rank.resize(n, 0);
        root.resize(n);
        iota(root.begin(), root.end(), 0);
    }
    int find(int i) {
        if (root[i] == i) return i;
        else return root[i] = find(root[i]);
    }
    void join(int i, int j) {
        i = find(i); j = find(j);
        if (i == j) return;
        if (rank[i] > rank[j]) {
            root[j] = i;
        } else {
            root[i] = j;
            if (rank[i] == rank[j]) rank[j]++;
        }
    }
};

int main() {
    int n, k, l; cin >> n >> k >> l;
    UnionFind uf1(n+1), uf2(n+1);
    while (k--) {
        int a, b; cin >> a >> b;
        uf1.join(a, b);
    }
    while (l--) {
        int a, b; cin >> a >> b;
        uf2.join(a, b);
    }
    map<pair<int, int>, int> cnt;
    for (int i = 1; i <= n; i++) cnt[{uf1.find(i), uf2.find(i)}]++;
    for (int i = 1; i <= n; i++)
        cout << cnt[{uf1.find(i), uf2.find(i)}] << (i == n ? '\n' : ' ');
}


Measured memory_bytes: 15104
n = int(input())
a = [int(x) for x in input().split()]

dic = {}
count = 0

for i in range(n):
    if i + a[i] in dic.keys():
        dic[i + a[i]] += 1
    else:
        dic[i + a[i]] = 1

for i in range(n):
    if i - a[i] in dic.keys():
        count += dic[i - a[i]]
print(count)

Measured memory_bytes: 40428
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i=0;i<n;i++)a[i]=sc.nextInt();
        Arrays.sort(a);
        boolean[] dp = new boolean[a[n-1]];
        for (int i=0;i<n;i++)dp[a[i]-1]=true;
        HashSet<Integer> hash = new HashSet<>();
        for (int i=0;i<n;i++){
            if (hash.contains(a[i]))dp[a[i]-1]=false;
            else hash.add(a[i]);
            int c = 2;
            if (a[i]*2<=dp.length)dp[a[i]*2-1]=false;
            while (a[i]*(c+1)<=dp.length){
                dp[a[i]*(c+1)-1]=false;
                c++;
            }
        }
        int ans = 0;
        for (boolean b : dp) if (b) ans++;
        System.out.println(ans);
    }
}


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

long long n, m;

int main()
{
    scanf( "%lld%lld", &n, &m );

    if( n == 1 && m == 1 ) {
        printf( "1\n" ); return 0;
    }
    if( n == 1 || m == 1 ) {
        printf( "%d\n", max( n, m ) -2 ); return 0;
    }

    printf( "%lld\n", ( m - 2 ) * ( n - 2 ) );    

    return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: chars
    }
    println!("{}", if n[0] == n[2] {"Yes"} else {"No"});
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s, t;
    cin >> s >> t;
    int m = s.length();
    int n = t.length();
    vector<vector<int>> dp(m + 1, vector<int>(n + 1,0));
    for (int i = 1; i <= m; i++)
    {
        for (int j = 1; j <= n; j++)
        {
            int s1 = dp[i - 1][j];
            int s2 = dp[i][j - 1];
            if (s[i - 1] == t[j - 1])
            {
                int ans = (dp[i - 1][j - 1] + s[i - 1]);
                int res = max(max(s1, s2), ans);
                if (res = ans)
                    dp[i][j] = dp[i - 1][j - 1] + 1;
                else if (s1 == res)
                    dp[i][j] = dp[i - 1][j];
                else
                {
                    dp[i][j] = dp[i][j - 1];
                }
            }
            else
            {
                int res = max(s1, s2);
                if (s1 == res)
                    dp[i][j] = dp[i - 1][j];
                else
                {
                    dp[i][j] = dp[i][j - 1];
                }
            }
        }
    }
    int l = dp[s.length()][t.length()];
    int i = s.length(), j = t.length();
    string str;
    while (l >= 1 && i >= 1 && j >= 1)
    {
        if (s[i - 1] == t[j - 1])
        {
            str = s[i - 1] + str;
            i--;
            j--;
            l--;
        }

        else if (dp[i][j] == dp[i - 1][j])
        {
            i--;
        }
        else if (dp[i][j] == dp[i][j - 1])
        {
            j--;
        }
    }
    cout << str;
   // cout << dp[m][n] << endl;
}


Measured memory_bytes: 35584
#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, n) for (ll i = 0; i < (ll)n; ++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);
    int a, b;
    cin >> a >> b;
    int ans = 0;
    switch (a + b)
    {
    case (3):
    {
        ans = 3;
        break;
    }
    case (5):
    {
        ans = 1;
        break;
    }
    case (4):
    {
        ans = 2;
        break;
    }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3592
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

int main(){
	ll n;
	scanf("%lld",&n);
	puts(n<=999?"ABC":"ABD");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int const N = 100*1000 + 16;
int const M = 1000*1000*1000 + 7;

int n;
int a[N];

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

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

  int cnt = 0;
  for(int i = 1; i+1 <= n; ++i) {
    if(a[i] == i) {
      cnt++;
      swap(a[i], a[i+1]);
    }
  }

  if(a[n] == n)
    cnt++;

  cout << cnt;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define vpll vector < pair<long long,long long> >
#define fill(a,val)  memset(a,val, sizeof (a))
#define sort_unique(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(cont) cont.begin(), cont.end()
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MAX   1e9
#define MIN  -1e9
typedef map<int,int> mpi;
typedef set<int> seti;
typedef multiset<int> mseti;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i, n)    for(long long int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define repn(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define trav(a, x) for(auto& a : x)
struct Interval{ll start,end;};
bool compare(Interval i1, Interval i2) {return (i1.start < i2.start);}

int main(){
	fio;
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	ll a;
  	cin>>a;
  	cout<<a+a*a+a*a*a;
	return 0;
}

Measured memory_bytes: 3608
#include <iostream>

using namespace std;

struct Card{
	char type;
	int num;
};

void bubble(Card l[],int n){
	int i,j;
	Card tmp;
	for(i=0;i<n;i++){
		for(j=n-1;j>i;j--){
			if(l[j].num < l[j-1].num){
				tmp = l[j];
				l[j] = l[j-1];
				l[j-1] = tmp;
			}
		}
	}
}

void select(Card l[],int n){
	int i,j,min;
	Card tmp;
	for(i=0;i<n;i++){
		min = i;
		for(j=i;j<n;j++){
			if(l[j].num < l[min].num){
				min = j;
			}
		}
		tmp = l[i];
		l[i] = l[min];
		l[min] = tmp;
	}
}

int main(void){
	int n,i,flag=0;
	Card list1[36],list2[36];
	cin >> n;
	for(i=0;i<n;i++){
		cin >> list1[i].type >> list1[i].num;
		list2[i].type = list1[i].type;
		list2[i].num = list1[i].num;
	}
	bubble(list1,n);
	select(list2,n);
	for(i=0;i<n;i++){
		cout << list1[i].type << list1[i].num;
		if(i==n-1){
			cout << endl;
		}else{
			cout << " ";
		}
	}
	cout << "Stable" << endl;
	for(i=0;i<n;i++){
		cout << list2[i].type << list2[i].num;
		if(list1[i].type != list2[i].type){
			flag = 1;
		}
		if(i==n-1){
			cout << endl;
		}else{
			cout << " ";
		}
	}
	if(flag == 1){
		cout << "Not stable" << endl;
	}else{
		cout << "Stable" << endl;
	}
}


Measured memory_bytes: 3124
//四則演算 #pragma GCC target("avx")
//並列計算 #pragma GCC optimize("O3")
//条件分岐を減らす #pragma GCC optimize("unroll-loops")
//浮動小数点演算 #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int i=(a);i<(n);++i)
#define eFOR(i,a,n) for(int i=(a);i<=(n);++i)
#define rFOR(i,a,n) for(int i=(n)-1;i>=(a);--i)
#define erFOR(i,a,n) for(int i=(n);i>=(a);--i)
#define each(i, a) for(auto &i : a)
#define SORT(i) sort(i.begin(),i.end())
#define rSORT(i) sort(i.rbegin(),i.rend())
#define fSORT(i,a) sort(i.begin(),i.end(),a)
#define all(i) i.begin(),i.end()
#define out(y,x) ((y)<0||h<=(y)||(x)<0||w<=(x))
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }
inline void print() { cout << "\n"; }
template<class T, class... Ts>inline void print(const T& a, const Ts&... ts) { cout << a << " "; print(ts...); }
template<class T>inline void print(const vector<T>& v) { for (int i = 0; i < v.size(); ++i)cout << v[i] << (i == v.size() - 1 ? "\n" : " "); }
template<class T>inline void print(const vector<vector<T>>& v) { for (auto& a : v)print(a); }
inline string reversed(const string& s) { string t = s; reverse(all(t)); return t; }

void dfs(string s, int a) {

}

int main() {
    init();

    int k; string s; cin >> k >> s;
    if (s.length() <= k)print(s);
    else print(s.substr(0, k) + "...");




    return 0;
}

Measured memory_bytes: 3620
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <numeric>
#include <limits>
#include <type_traits>
#include <locale>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;
typedef pair<long long int, pll> lpll;


const long long int mod = 1000000007;
const long long int INF = 1e18;
const long double PI=3.14159265358979323; 
const long long int pl=1000000;

long long int H1,M1,H2,M2,K;


int main(){
    cout << fixed << setprecision(18);
    cin>>H1>>M1>>H2>>M2>>K;
    if(H1*60+M1<=H2*60+M2){
        cout<<60*H2+M2-60*H1-M1-K<<endl;
    }
}




Measured memory_bytes: 3632
#include<stdio.h>

int main(){
    int n;
    int i;
    int num;
    char *tmp = NULL;
    int max=0,min=0;
    char ch;

    while(~scanf("%d",&n)){
        getchar();
        int no = 0;
        num = 0;
        max = min = 0;
        while((ch = getchar())){
            if(ch == ' '||ch == '\n'){
                if(num > max){
                    max = min = num;
                }else if(num < min){
                    min = num;
                }

                if(max - min > 1){
                    no = 1;
                }
                num = 0;
                if(ch == '\n') break;
            }else{
                num=num*10+ (ch - '0');
            }
        }

        printf("%s\n",no?"No":"Yes");
    }
    return 0;
}


Measured memory_bytes: 128
import java.util.*;

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

    int n = sc.nextInt();
    boolean ans = false;

    for (int i = 0; i <= n/7; i++) {
      if ((n-7*i) % 4 == 0) {
        ans = true;
      }
    }

    if (ans == true) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}


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

#define REP(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
#define REPN(i, m, n) for(int (i)=(int)(m); (i)<(int)(n); (i)++)
#define REP_REV(i, n) for(int (i)=(int)(n)-1; (i)>=0; (i)--)
#define debug(x) cout << #x << ": " << (x) << endl;

using namespace std;

int main() {
//    ifstream in("C:\\Users\\P218024\\Documents\\Cpp Projects\\abc094\\sample.txt");
//    cin.rdbuf(in.rdbuf());

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

    int n;
//    cin >> n;
    scanf("%d", &n);
            
    int X[n] = {0};
    int X_copy[n] = {0};
    REP(i,n) {
        scanf("%d", &X[i]);
//        cin >> X[i];
        X_copy[i] = X[i];
    }

    sort(X, X+n);

    int a = X[n / 2 - 1];
    int b = X[n / 2];
    REP(i, n) {
        cout << ((X_copy[i] < b) ? b : a) << endl;
    }

}

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

const long long mod = 1e9+7;
int n,m;
std::vector<bool> b;




int main()
{
    std::cin>>n>>m;
    std::vector<bool> b(n,true);
    for(int i=0;i<m;i++){
        int tmp;
        std::cin>>tmp;
        b[tmp] = false;
    }
    std::vector<long long> dp(n+1);
    dp[0] = 1;if(b[1])dp[1] = 1;
    for(int i=2;i<=n;i++){
        if(!b[i])continue;
        dp[i] = (dp[i-1]+dp[i-2]) % mod;
    }
    std::cout<<dp[n]<<std::endl;
}

Measured memory_bytes: 1024
//Think simple yet elegant.
#include <bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll  long long
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pi pair<int,int>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define REP(i,n) for(int i=0;i<n;i++)
const ll maxn=500005;
const ll mod=1e9+7;


int main(){
	fast;
	int d,s,t;
	cin>>d>>s>>t;
	double ans=(1.0*d)/s;
	if(ans>t)
		cout<<"No";
	else
		cout<<"Yes";
}




Measured memory_bytes: 3608
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <limits.h>
using namespace std;
long long inf=100000000;
long long C[51][51];
long long ans=0;
void comb_table(int n)
{
  for(int i=0;i<=n;i++)
    {
      for(int j=0;j<=i;j++)
	{
	  if(j==0 or j==i)
	    {
	      C[i][j]=1;
	    }
	  else
	    {
	      C[i][j]=(C[i-1][j-1]+C[i-1][j]);
	    }
	}
    }
}
int main(int argc,char const* argv[])
{
  int a,b,n,comb=0,comb2=0;
  double maxave=0.0;
  double tmpave=0.0;
  cin >> n >> a >> b;
  long long v[50];
  for(int i=0;i<n;i++)
    {
      cin >> v[i];
    }
  sort(v,v+n);
  reverse(v,v+n);
  for(int i=0;i<a;i++)
    {
      tmpave+=v[i];
    }
  comb_table(n);
  maxave=tmpave/a;
  for(int i=0;i<n;i++)
    {
      if(v[i]==v[a-1])
	{
	  comb++;
	  if(i<a)
	    {
	      comb2++;
	    }
	}
    }
  if(comb2==a)
    {
      for(comb2=a;comb2<=b;comb2++)
	{
	  ans+=C[comb][comb2];
	}
    }
  else
    {
      ans=C[comb][comb2];
    }
  cout.precision(20);
  cout << maxave << endl;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main{
    private static void solver(InputReader sc, PrintWriter out) throws Exception {
           long n = 100;
           long k = sc.nextLong();
            int count=0;
            while(true){
                n += (n/100);
                count++;
                if(n >= k )
                    break;
            }
            out.println(count);

    }
    private static int gcd(int a, int b){
        if(b==0)
            return a;
        return gcd(b, a%b);
    }
    public static void main(String[] args) throws Exception {
        // long start =  System.nanoTime();
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        solver(in,out);
        out.close();


    }
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int[] readIntArray(int n){
            int arr[] = new int[n];
            for(int i=0;i<n;i++) arr[i] = nextInt();
            return arr;
        }
    }
}
class Pair{
    int x;
    int y;
    Pair(int x, int y) {
        this.x = x;
        this.y = y;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Pair pair = (Pair) o;
        return x == pair.x &&
                y == pair.y;
    }

    @Override
    public int hashCode() {
        return Objects.hash(x, y);
    }
}


Measured memory_bytes: 32792
import Control.Applicative
import Control.Monad
import Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as B
import Data.Map.Strict (Map, (!))
import qualified Data.Map.Strict as M

main :: IO ()
main = do
  n <- readLn
  solve <$> replicateM n (head <$> B.words <$> B.getLine) >>= printAns

solve :: [ByteString] -> [Int]
solve ss = [m ! ac, m ! wa, m ! tle, m ! re]
  where
    im = M.fromList [(ac, 0), (wa, 0), (tle, 0), (re, 0)]
    m = foldl f im ss
    f m s = M.insertWith (+) s 1 m
    ac = B.pack "AC"
    wa = B.pack "WA"
    tle = B.pack "TLE"
    re = B.pack "RE"
    
printAns :: [Int] -> IO ()
printAns [a, b, c, d] = do
  putStrLn $ "AC x " ++ show a
  putStrLn $ "WA x " ++ show b
  putStrLn $ "TLE x " ++ show c
  putStrLn $ "RE x " ++ show d


Measured memory_bytes: 24516
#include <stdio.h>
#define INT_MAX (1<<30)

int
merge(int *a, int l, int m, int r)
{
	int ln = m - l;
	int rn = r - m;
	int ls[ln + 1], rs[rn + 1];
	int i, j, k, c = 0;

	for (i = 0; i < ln; i++)
		ls[i] = a[l + i];
	ls[i] = INT_MAX;

	for (i = 0; i < rn; i++)
		rs[i] = a[m + i];
	rs[i] = INT_MAX;

	for (i = j = 0, k = l; k < r; k++) {
		if (ls[i] <= rs[j])
			a[k] = ls[i++];
		else
			a[k] = rs[j++];
		c++;
	}

	return c;
}

int
merge_sort(int *a, int l, int r)
{
	if (l + 1 < r) {
		int m = (l + r) / 2;

		return (merge_sort(a, l, m) +
			merge_sort(a, m, r) +
			merge(a, l, m, r));
	}

	return 0;
}

int
main(int argc, char **argv)
{
	int n;

	scanf("%d", &n);

	{
		int a[n];
		int i, s;

		for (i = 0; i < n; i++)
			scanf("%d", a + i);

		s = merge_sort(a, 0, n);

		for (i = 0; i < n; i++)
			printf("%s%d", i ? " " : "", a[i]);
		printf("\n%d\n", s);
	}

	return 0;
}


Measured memory_bytes: 5580
### main

loop do
  n, k, m = gets.split.map(&:to_i)
  break if (n | k | m) == 0
  #p [n, k, m]

  pos = m - 1
  sts = (1..n).to_a
  sts.delete_at(pos)

  while sts.length > 1
    pos = (pos + k - 1) % sts.length
    sts.delete_at(pos)
  end

  puts sts.first
end

Measured memory_bytes: 8592
#include <iostream>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)


int main() {
    string s,t; cin >> s >> t;
    int ans=0;
    rep(i, 3){
        if(s[i] == t[i]){
            ans++;
        }
    }
    cout << ans;
}

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

int main() {
	cin.tie(0)->sync_with_stdio(false);

	int h, w, K; cin >> h >> w >> K;
	vector<string> s(h);
	REP(i, h) cin >> s[i];

	vector<vector<int> > res(h, vector<int>(w, 0));
	int k = 1;
	REP(i, h) REP(j, w) {
		if (s[i][j] == '#')
			res[i][j] = k++;
	}

	REP(i, h) {
		REP(j, w - 1) {
			if (res[i][j] != 0) {
				if (res[i][j+1] == 0)
					res[i][j+1] = res[i][j];
			}
		}
		for (int j = w - 1; j > 0; j--) {
			if (res[i][j] != 0) {
				if (res[i][j-1] == 0)
					res[i][j-1] = res[i][j];
			}
		}
	}

	while (true) {
		REP(i, h) REP(j, w) {
			if (res[i][j] == 0) {
				if (i + 1 < h) {
					if (res[i + 1][j] != 0)
						res[i][j] = res[i + 1][j];
				}
			}
		}
		REP(i, h) REP(j, w) {
			if (res[i][j] == 0) {
				if (i - 1 >= 0)
					if (res[i - 1][j] != 0)
						res[i][j] = res[i - 1][j];
			}
		}
		bool ok = true;
		REP(i, h) {
			int sum = 0;
			REP(j ,w) {
				sum += res[i][j];
			}
			if (sum == 0) {
				ok = false;
				break ;
			}
		}
		if (ok) break ;
	}
	int sum = 0;
	REP(i, w) sum += res[h - 1][i];
	if (sum == 0) {
		REP(i, w) res[h - 1][i] = res[h - 2][i];
	}
	REP(i, h) {
		REP(j, w)
			cout << res[i][j] << " ";
		cout << '\n';
	}
	return 0;
}

Measured memory_bytes: 3900
#include<bits/stdc++.h>
#define rep(i,a,b) for (int i=a; i<=b; i++)
#define per(i,a,b) for (int i=a; i>=b; i--)
using namespace std;
typedef long long LL;

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 ans=0;
char s[10];

int main() {

	#ifndef ONLINE_JUDGE
	///	freopen("data.in","r",stdin);
	//	freopen("data.out","w",stdout);
	#endif

	scanf("%s",s);
	rep(i,0,3) {
		if (s[i]=='+') ans++; else ans--;
	}
	printf("%d\n",ans);
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) (x).begin(), (x).end()
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
  #define debug(x) cerr << #x " => " << x << endl
#else
  #define debug(x) 0
#endif
using lint = long long;
constexpr int    INF  = 1 << 30;
constexpr lint   INFL = 1LL << 62;
constexpr int    MOD  = (int)1e9 + 7;
constexpr double EPS  = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  int a, b;
  cin >> a >> b;
  cout << max(a - 2 * b, 0) << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

@SuppressWarnings("unused")
public class Main {

  private static void solve() {
    int t = ni();

    for (int i = 0; i < t; i ++) {
      long n = nl();
      long m = nl();
      long a = nl();
      long b = nl();

      out.println(floor_sum(n,m,a,b));
    }
  }

  public static long floor_sum(long n, long m, long a, long b){
    long ans = 0;
    if(a >= m){
        ans += (n-1) * n * (a/m) / 2;
        a %= m;
    }
    if(b >= m){
        ans += n * (b/m);
        b %= m;
    }

    long y_max = (a*n+b) / m;
    long x_max = y_max * m - b;
    if(y_max == 0) return ans;
    ans += (n - (x_max+a-1)/a) * y_max;
    ans += floor_sum(y_max, a, m, (a-x_max%a)%a);
    return ans;
}

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 53544
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

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; }

ll ans=1,N,K,a,b,mod=1e9+7,cnt;
ll ccnt[100010][2]={};
vector<ll> G[100010],G2[100010];
bool visited[100010]={};

// ll cntnodes(ll node){
//     set<ll> s;
//     for(ll x:G2[node]){
//         s.insert(x);
//         for(ll y:G2[x]){
//             if(y==node)continue;
//             s.insert(y);
//         }
//     }
//     // for(ll x:s)out(x);
//     return s.size();
// }

// ll cntnodes(ll node){
//     ll cnt=0;
//     for(ll x:G2[node]){
//         cnt++;
//         for(ll y:G2[x]){
//             if(y==node)continue;
//             cnt++;
//         }
//     }
//     return cnt;
// }

void dfs(ll node){
    visited[node]=true;
    cnt=ccnt[node][1]+ccnt[node][0];
    if(cnt<K)ans=(ans*(K-cnt))%mod;
    else ans=0;
    for(ll x :G[node]){
        if(!visited[x]){
            G2[node].push_back(x);
            G2[x].push_back(node);
            ccnt[x][0]+=1;
            ccnt[x][1]+=ccnt[node][0];
            ccnt[node][0]+=1;
            ccnt[node][1]+=ccnt[x][0];
            dfs(x);
        }
    }

}

int main(){
    cin>>N>>K;
    rep(i,N-1){
        cin>>a>>b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    dfs(0);
    out(ans);
    
}


Measured memory_bytes: 17536
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        // code goes here
        String s = br.readLine();
        long sum = 0;
        for(int i = 0; i < s.length(); i++){
            sum += s.charAt(i) - '0';
        }
        if(sum % 9 == 0){
            sb.append("Yes\n");
        }else {
            sb.append("No\n");
        }
        System.out.print(sb.toString());
    }

    private static int nextInt(BufferedReader br) throws IOException{
        return Integer.parseInt(br.readLine());
    }

    private static int[] nextIntArray(BufferedReader br, int n) throws IOException{
        StringTokenizer st = new StringTokenizer(br.readLine());
        int[] arr = new int[n];
        for(int i = 0; i < n; i++){
            arr[i] = Integer.parseInt(st.nextToken());
        }
        return arr;
    }

    static class Pair<A, B>{
        A first;
        B second;
        public Pair(A first, B second){
            this.first = first;
            this.second = second;
        }
    }
}


Measured memory_bytes: 36012
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;
LL A[26];
LL MOD=1e9+7;
int main(){
	cin>>N;
	string S;
	cin>>S;
	LL ans=1;
	REP(i,26){
		A[i]=1;
	}
	REP(i,N){
		LL a=(S[i]-'a');
		A[a]++;
	}
	REP(i,26){
		ans*=A[i];
		ans%=MOD;
	}
	ans+=MOD-1;
	ans%=MOD;
	cout<<ans<<endl;
}

Measured memory_bytes: 512
n=int(input())
s=[*input()]
q=int(input())
from collections import *
d=defaultdict(list)
for i,c in enumerate(s):
  d[c]+=[i]
from bisect import *
for _ in range(q):
  x,y,z=input().split()
  y=int(y)-1
  if x=='1':
    if s[y]==z: continue
    d[s[y]].pop(bisect(d[s[y]],y)-1)
    s[y]=z
    insort(d[z],y)
  else:
    print(sum(bisect(l,int(z)-1)-bisect_left(l,y)>0 for l in d.values()))

Measured memory_bytes: 35156
N, A, B, C, D = map(int, input().split())
S = input()

if A < C < B < D:
    if not (S.find("##", A - 1) < C - 1 and S.find("##", A - 1) != -1) and not (
            S.find("##", B - 1) < D - 1 and S.find("##", B - 1) != -1):
        print("Yes")
    else:
        print("No")
elif C < D:
    if S.find("##", A - 1) > D - 1 or S.find("##", A - 1) == -1:
        print("Yes")
    else:
        print("No")
else:
    if S.find("...", B - 2) < D - 1 and S.find("...", B - 2) != -1:
        if S.find("##", A - 1) > C - 1 or S.find("##", A - 1) == -1:
            print("Yes")
        else:
            print("No")
    else:
        print("No")


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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

/*{
  }*/

using vi = vector<int>;
using vvi = vector<vi>;
using P = pair<int,int>;

//constexpr int mod = 1e9+7;
//constexpr int inf = 1LL<<60;

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

  vi a(3*n);
  rep(i, 0, 3*n) cin >> a[i];

  vi L(n+1), R(n+1);
  int suml = 0, sumr = 0;
  priority_queue<int, vi, greater<int>> quel;
  priority_queue<int> quer;
  rep(i, 0, n){
    suml += a[i];
    quel.push(a[i]);
    sumr += a[3*n-1-i];
    quer.push(a[3*n-1-i]);
  }

  L[0] = suml;
  R[n] = sumr;
  rep(i, 0, n){
    suml += a[i+n];
    quel.push(a[i+n]);
    suml -= quel.top();
    quel.pop();
    L[i+1] = suml;

    sumr += a[2*n-1-i];
    quer.push(a[2*n-1-i]);
    sumr -= quer.top();
    quer.pop();
    R[n-1-i] = sumr;
  }

//  rep(i, 0, n+1){
//    cout << L[i] << " ";
//  }
//  cout << endl;
//
//  rep(i, 0, n+1){
//    cout << R[i] << " ";
//  }
//  cout << endl;

  int ans = -1e15;
  rep(i, 0, n+1){
    chmax(ans, L[i]-R[i]);
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 5996
N = int(input())
A, B = [], []
for i in range(N):
    a, b = map(int, input().split())
    A.append((a,b))
    B.append((i,a+b))
B.sort(key=lambda x:x[1], reverse=True)
res = 0
for i, _ in B[::2]:
    res += A[i][0]
for i, _ in B[1::2]:
    res -= A[i][1]
print(res)

Measured memory_bytes: 94800
#include<stdio.h>

int main()
{
    float m,n,ar[200005],sum=0.0;
    scanf("%f %f",&n,&m);
    for(int i=0;i<n;i++){
        scanf("%f",&ar[i]);
        sum+=ar[i];
    }
    float a=sum/(m*4);
    int cnt=0;
    for(int i=0;i<n;i++)
    {
        if(ar[i]>=a)
            cnt++;
    }
    if(cnt>=m)
        printf("Yes\n");
    else
        printf("No\n");
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
       for(;;) {
          char[] s=sc.next().toCharArray();
          if(s[0]=='0')break;
          int[] l= {0,0};
          for(int i=1;i<s.length;i++) {
              l[s[i]-'A']++;
          }
          l[l[0]>l[1]?0:1]++;
          System.out.println(l[0]+" "+l[1]);
       }
    }
}


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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long int a,b,s=0;
    cin>>a>>b;
    s=a*b;
    cout<<s<<endl;
    
      
    
    return 0;
}


Measured memory_bytes: 3640
N = int(input())
X = list(map(int, input().split()))

sx = sorted(X)
a = sx[N // 2 - 1]
b = sx[N // 2]

if a == b:
    for i in range(N):
        print(a)
else:
    for i in range(N):
        if X[i] < b:
            print(b)
        else:
            print(a)


Measured memory_bytes: 26016
#include<cstdio>
int main(){
  int h=1,i;
  int a[4]={10,50,100,500};
  int n;
  while(scanf("%d",&n),n){
    int b[4],c[4]={};
    int sm=-n;
    for(i=0;i<4;++i){
      scanf("%d",b+i);
      sm+=a[i]*b[i];
    }
    for(i=3;i>=0;--i){
      c[i]+=sm/a[i];
      sm-=sm/a[i]*a[i];
    }
    if(h)
      h=0;
    else
      puts("");
    for(i=0;i<4;++i){
      if(b[i]>c[i])
	printf("%d %d\n",a[i],b[i]-c[i]);
    }
  }
  return 0;
}

Measured memory_bytes: 0