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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

int adj[101][101];
int d[101][101];

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	int n, m;
	cin >> n >> m;
	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			if(i == j) adj[i][j] = 0;
			else adj[i][j] = INF;
		}
	}
	vector<int> e1;
	vector<int> e2;
	for(int i=0; i<m; i++){
		int a, b, c;
		cin >> a >> b >> c;
		a--;
		b--;
		adj[a][b] = adj[b][a] = c;
		e1.push_back(a);
		e2.push_back(b);
	}

	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			d[i][j] = adj[i][j];
		}
	}

	for(int k=0; k<n; k++){
		for(int i=0; i<n; i++){
			for(int j=0; j<n; j++){
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}


	int ans = 0;
	for(int i=0; i<m; i++){
		int es = e1[i];
		int ee = e2[i];
		for(int j=0; j<n; j++){
			if(d[j][es] + adj[es][ee]  == d[j][ee]){
				ans++;
				j = n;
				break;
			}
		}
	}

	cout << m - ans << endl;

	
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main()
  {int N, s{}, p{-9}; cin >> N;
  int A[N], B[N], C[N - 1]; for (int &a: A) cin >> a, --a; for (int &b: B) cin >> b; for (int &c: C) cin >> c;
  for (int a: A) s += B[a] + (a - p == 1 ? C[p] : 0), p = a;
  cout << s;}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

int main(){
    int N;  cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++)
        cin >> A[i];
    
    bool ok = true;
    for(int a : A){
        if(a%2==0){
            if(!(a%3==0 || a%5 == 0)){
                ok = false;   
            }
        }
    }

    if(ok){
        cout << "APPROVED" << endl;
    }else{
        cout << "DENIED" << endl;
    }
}

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

using namespace std;

#define rep(i,m,n) for(int i=m;i<n;i++)


int main(){
 long n,w;
  cin >>n >> w;
  vector<vector<long>> v(4);
  long w1,b;
   cin >> w1 >> b;
   v[0].push_back(b);
  rep(i,1,n){
   long a;
    cin >> a >> b;
    v[a-w1].push_back(b);
  }
  
   rep(i,0,4) {
     v[i].push_back(1000000000);
     sort(v[i].begin(),v[i].end(),greater<long>());
     v[i][0]=0;
     rep(j,1,v[i].size()) v[i][j]+=v[i][j-1];
   }
  
   long res=0;
   rep(i,0,v[0].size()){
     rep(j,0,v[1].size()){
     rep(k,0,v[2].size()){
      rep(l,0,v[3].size()){
            long weight=w1*i+(w1+1)*j+(w1+2)*k+(w1+3)*l;
        if(weight>w) break;
        long value=v[0][i]+v[1][j]+v[2][k]+v[3][l];
        res=max(res,value);
      }
     }
    }
   }
  cout << res << endl;
  
 
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;

typedef struct _dice {
    int surface[6];
    int init_surface[6];

    void input(){
        for(int i=0;i<6;i++) {
            cin >> init_surface[i];
        }
        init();
    }

    void init(){
        for(int i=0;i<6;i++) {
            surface[i] = init_surface[i];
        }
    }

    void roll_N(){
        int tmp = surface[5];
        surface[5] = surface[4];
        surface[4] = surface[0];
        surface[0] = surface[1];
        surface[1] = tmp;
    }

    void roll_E(){
        int tmp = surface[5];
        surface[5] = surface[2];
        surface[2] = surface[0];
        surface[0] = surface[3];
        surface[3] = tmp;
    }

    void roll_S(){
        int tmp = surface[5];
        surface[5] = surface[1];
        surface[1] = surface[0];
        surface[0] = surface[4];
        surface[4] = tmp;
    }

    void roll_W(){
        int tmp = surface[5];
        surface[5] = surface[3];
        surface[3] = surface[0];
        surface[0] = surface[2];
        surface[2] = tmp;
    }

    void turn_right(){
        int tmp = surface[1];
        surface[1] = surface[3];
        surface[3] = surface[4];
        surface[4] = surface[2];
        surface[2] = tmp;
    }

} Dice;

bool dice_compare(Dice d1, Dice d2);

int main(){
    int n;
    cin >> n;
    Dice dice[101];
    for(int i=0;i<n;i++){
        dice[i].input();
    }
    bool ans = true;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(dice_compare(dice[i],dice[j]) == true){
                ans = false;
                break;
            }
        }
    }
    if(ans){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

bool dice_compare(Dice d1, Dice d2){
    int num = -1;
    bool result = true;
    for(int i=0;i<6;i++){
        if(d1.init_surface[0] == d2.init_surface[i]){
            d1.init();
            d2.init();
            num = i;
            if(num == 5){
                d2.roll_N();
                d2.roll_N();
            } else if(num == 1){
                d2.roll_N();
            } else if(num == 4){
                d2.roll_S();
            } else if(num == 2){
                d2.roll_W();
            } else if(num == 3){
                d2.roll_E();
            }

            for(int i=0;i<3;i++){
                if(d1.surface[1] == d2.surface[1]){
                    break;
                } else {
                    d2.turn_right();
                }
            }

            for(int i=0;i<6;i++){
                if(d1.surface[i] != d2.surface[i]){
                    result = false;
                    break;
                }
            }
            if(result) return result;
            else result = true;
        }
    }
    return false;
}


Measured memory_bytes: 3108
S = input()
K = int(input())

alp = [chr(i) for i in range(97, 97+26)]

ans = ''
for s in S:
    loc = alp.index(s)
    if s == 'a' or loc + K < 26:
        ans += s
    else:
        K -= 26 - loc
        ans += 'a'

if K > 0:
    K %= 26
    ans = ans[:-1] + alp[(alp.index(ans[-1])+K)%26]
print(ans)

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  cout << fixed << setprecision(10);
  int n;
  cin >> n;
  map<string,int> mp;
  rep(i,n){
    string s;
    cin >> s;
    mp[s]++;
  }
  cout << "AC x " << mp["AC"] << endl;
  cout << "WA x " << mp["WA"] << endl;
  cout << "TLE x " << mp["TLE"] << endl;
  cout << "RE x " << mp["RE"] << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    ll n,p;
    cin>>n>>p;
    if(n==1){
        cout<<p<<endl;
        return 0;
    }
    if(p==1){
        cout<<1<<endl;
        return 0;
    }
    int ans=0;
    for(int i=1; i<=sqrt(p); ++i){
        if((p%(ll)pow(i,n)==0)&&(p/pow(i,n-1)>=i))ans=i;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

int main(){
    int h,w,d;
    cin>>h>>w>>d;
    int x;
    vector<pair<int,int>>a(h*w+5,make_pair(0,0));
    rep(i,h)rep(j,w){
        cin>>x;
        a[x]=make_pair(i+1,j+1);//バケットソート
    }
    int q,l,r;
    cin>>q;
    vector<int>add(h*w+5,0);
    for(int i=d+1;i<=h*w;++i)add[i]=add[i-d]+abs(a[i-d].first-a[i].first)+abs(a[i-d].second-a[i].second);//累積和
    //1が書かれたマスからなのでd+1から
    rep(i,q){
        cin>>l>>r;
        cout<<add[r]-add[l]<<endl;
    }
    return 0;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
const unsigned int mod = 1000000007; 

int main(){

    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    
    int h, w;
    long long int ans;
    char inp;
    cin >> h >> w;
    vector<vector<char> > grid(h , vector<char> (w));
    vector<vector<long long int> > dp(h , vector<long long int> (w, 0));

    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin >> inp; 
            grid[i][j] = inp;
        }
    }
    
    for(int i=0;i<w;i++)
        if(grid[0][i] == '#')
            break;
        else
            dp[0][i] = 1;
    
    for(int i=0;i<h;i++)
        if(grid[i][0] == '#')
            break;
        else
            dp[i][0] = 1;

    for(int i=1;i<h;i++)
        for(int j=1;j<w;j++)
            if(grid[i][j] == '.')
                dp[i][j] = (dp[i-1][j]%mod + dp[i][j-1]%mod)%mod;

    cout << dp[h-1][w-1] << "\n";
    return 0;
}

Measured memory_bytes: 9088
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def input():
    return sys.stdin.readline().strip()

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

class union_find():
    def __init__(self, n):
        self.nodes = n
        self.node_groups = [ i for i in range(n)]
        self.group_sizes = [ 1 for _ in range(n)]
        self.group_ranks = [ 0 for _ in range(n)]

    def root(self, i):
        if self.node_groups[i] == i:
            return i
        else:
            self.node_groups[i] = self.root(self.node_groups[i])
            return self.node_groups[i]

    def same(self, a, b):
        return self.root(a) == self.root(b)

    def size(self, i):
        return self.group_sizes[self.root(i)]

    def unite(self, a, b):
        a = self.root(a)
        b = self.root(b)

        if a == b:
            return

        if self.group_ranks[a] < self.group_ranks[b]:
            self.group_sizes[b] += self.size(a)
            self.node_groups[a] = b
        else:
            self.group_sizes[a] += self.size(b)
            self.node_groups[b] = a
            if self.group_ranks[a] == self.group_ranks[b]:
                self.group_ranks[a] += 1


def main():
    INF = 999999999999999999999999
    MOD = 10**9+7

    n,m = get_nums_l()

    uf = union_find(n)

    for i in range(m):
        a,b = get_nums_l()
        a-=1
        b-=1
        uf.unite(a,b)
    
    groups = len(set([ uf.root(i) for i in range(n) ]))

    print(groups-1)

main()

Measured memory_bytes: 101952
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

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

    int p[N];
    REP(i, N){
        cin >> p[i];
    }

    int ans = 0;
    FOR(i, 1, N-2){
        int X[3] = {p[i-1], p[i], p[i+1]};
        sort(X, X+3);

        if(p[i] == X[1]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3580
n = int(input())
a = [int(input()) for _ in range(n)]

ans, tmp, flag = 0, 0, (a[0] > 0)
for i in range(n - 1, 0, -1):
    if a[i] - a[i - 1] > 1:
        flag = True
    elif tmp != a[i]:
        ans += a[i]
    tmp = max(a[i] - 1, 0)
else:
    print(-1 if flag else ans)


Measured memory_bytes: 83572
// C - Skip
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define _GLIBCXX_DEBUG
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define pb push_back
#define eb emplace_back
#define mp make_pair
#pragma GCC optimize("Ofast")
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vvli = vector<vlli>;
using vs = vector<string>;
using vvs = vector<vs>;
using vb = vector<bool>;
using vvb = vector<vb>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}
// aよりもbが大きいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T &b)
{
  if (a > b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}

lli x;
bool cmp(int a, int b)
{
  return abs(a - x) < abs(b - x);
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a, b, c, h, n, w, ans = 0, count = 0;
  string s, t;
  vector<pair<string, pair<lli, lli>>> pr;
  cin >> n >> x;
  vlli d(n), e(n, 0);
  rep(i, 0, n)
  {
    cin >> d[i];
  }
  d.pb(x);
  SORT(d);
  // sort(d.begin(), d.end(), cmp);
  rep(i, 0, d.size() - 1)
  {
    ans = d[i + 1] - d[i];
    e[i] = ans;
  }
  lli g = e[0];
  rep(i, 1, n)
  {
    g = gcd(g, e[i]);
  }
  // count = MIN(e);
  cout << g << endl;
  // cout << e << endl;
}

Measured memory_bytes: 5436
#[doc = " https://github.com/hatoo/competitive-rust-snippets"]
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;
mod util {
    use std::fmt::Debug;
    use std::io::{stdin, stdout, BufWriter, StdoutLock};
    use std::str::FromStr;
    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }
    #[allow(dead_code)]
    pub fn chars() -> Vec<char> {
        line().chars().collect()
    }
    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
    #[allow(dead_code)]
    pub fn with_bufwriter<F: FnOnce(BufWriter<StdoutLock>) -> ()>(f: F) {
        let out = stdout();
        let writer = BufWriter::new(out.lock());
        f(writer)
    }
}
#[allow(unused_macros)]
macro_rules ! get { ( [ $ t : ty ] ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . split_whitespace ( ) . map ( | t | t . parse ::<$ t > ( ) . unwrap ( ) ) . collect ::< Vec < _ >> ( ) } } ; ( [ $ t : ty ] ; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( [ $ t ] ) ) . collect ::< Vec < _ >> ( ) } ; ( $ t : ty ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . trim ( ) . parse ::<$ t > ( ) . unwrap ( ) } } ; ( $ ( $ t : ty ) ,* ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; let mut iter = line . split_whitespace ( ) ; ( $ ( iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) , ) * ) } } ; ( $ t : ty ; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ ( $ t : ty ) ,*; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ ( $ t ) ,* ) ) . collect ::< Vec < _ >> ( ) } ; }
#[allow(unused_macros)]
macro_rules ! debug { ( $ ( $ a : expr ) ,* ) => { eprintln ! ( concat ! ( $ ( stringify ! ( $ a ) , " = {:?}, " ) ,* ) , $ ( $ a ) ,* ) ; } }
const BIG_STACK_SIZE: bool = true;
#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}
fn solve() {
    let n = get!(u64);
    let a = get!(u64);
    let b = get!(u64);
    let c = get!(u64);
    let d = get!(u64);
    let e = get!(u64);

    let mut ans = 0;
    let mut n = n;
    let xs = vec![a, b, c, d, e];

    let m = xs.into_iter().min().unwrap();

    println!("{}", (n + m - 1) / m + 4);
}


Measured memory_bytes: 8572
N, M = map(int, input().split())

start = set()
goal = set()
for i in range(M):
    a, b = map(int, input().split())
    if a == 1:
        start.add(b)
    if b == N:
        goal.add(a)
    
if len(start & goal) != 0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 19024
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;

int main()
{
    string S,T;
    cin>>S>>T;
    int count = 0;
    for(int i = 0;i<3;i++)
    {
        if(S[i] == T[i])
        {
            count++;
        }
    }

    cout<<count<<endl;
}

Measured memory_bytes: 256
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define mem(a,v) memset((a), (v), sizeof (a))
#define enl printf("\n")
#define case(t) printf("Case #%d: ", (t))
#define ni(n) scanf("%d", &(n))
#define nl(n) scanf("%lld", &(n))
#define nai(a, n) for (int _i = 0; _i < (n); _i++) ni(a[_i])
#define nal(a, n) for (int _i = 0; _i < (n); _i++) nl(a[_i])
#define pri(n) printf("%d\n", (n))
#define prl(n) printf("%lld\n", (n))
#define pii pair<int, int>
#define pil pair<int, long long>
#define pll pair<long long, long long>
#define vii vector<pii>
#define vil vector<pil>
#define vll vector<pll>
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef cc_hash_table<int,int,hash<int>> ht;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
const double pi = acos(-1);
const int MOD = 998244353;
const int INF = 1e9 + 7;
const int MAXN = 1e6 + 5;
const double eps = 1e-9;
char x[MAXN];
ll dp[MAXN];
int arr[MAXN];

ll pw(ll a, ll b) {
	ll r = 1;
	while (b) {
		if (b & 1)
			r = (r * a) % MOD, b--;
		else
			a = (a * a) % MOD, b /= 2;
	}
	return r;
}

int main() {
	int n; ni(n);
	scanf("%s", x);
	if (n <= 2) {
		int val = 0;
		for (int i = n-1; ~i; i--)
			val += (x[i]-'0') * (1 << (n-i-1));
		return !pri(2*n*(val+1));
	}
	for (int i = 0; i < n; i++)
		arr[i] = x[i]-'0';
	for (int i = 1; i <= n; i++) {
		if (!(n % i == 0 && (n/i) % 2 == 1))
			continue;
		ll v1 = 0, p = 1;
		for (int j = i-1; j >= 0; j--) {
			v1 = (v1 + p*arr[j] % MOD) % MOD;
			p = (2*p) % MOD;
		}
		for (int j = i; j < n; j += i) {
			int fl = 1;
			for (int k = 0; k < i; k++) {
				int r = (j/i) % 2 == 0 ? arr[k] : (1 ^ arr[k]);
				if (r > arr[j+k]) {
					fl = 0;
					break;
				} else if (r < arr[j+k]) {
					fl = 2;
					break;
				}
			}
			if (fl == 0)
				v1 = (v1 - 1 + MOD) % MOD;
			if (fl != 1)
				break;
		}
		dp[i] = (dp[i] + v1 + 1 + MOD) % MOD;
		for (int j = 3*i; j <= n; j += 2*i)
			dp[j] = (dp[j] - dp[i] + MOD) % MOD;
		//cerr << i << " " << v1 << " " << dp[i] << "\n";
	}
	ll ans = 0;
	for (ll i = 1; i <= n; i++) {
		if (n % i == 0 && (n/i) % 2 == 1)
			ans = (ans + i*dp[i] % MOD) % MOD;
	}
	ans = (ans * 2) % MOD;
	prl(ans);
	return 0;
}


Measured memory_bytes: 7168
#include <cstdio>
#include <iostream>

using namespace std;

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

	unsigned long long int pwr = 1;
	for (int i = 1; i <= n; i++)
	{
		pwr *= i;
		pwr = pwr % 1000000007;
	}

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

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;using ull=unsigned ll;
using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;
using P=pair<int,int>;using PL=pair<ll,ll>;
const int INF=1<<30,MOD=1000000007;const ll LINF=1ll<<60;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _overload3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPARR(i,v) for(int i=0;i<v.size();++i)
#define all(v) (v).begin(),(v).end()
#define uniq(v) sort(all(v));v.erase(unique(all(v)),v.end())
#define bit(n) (1ll<<(n))
template<class T>bool chmax(T&a,const T&b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T&a,const T&b){if(a>b){a=b;return 1;}return 0;}
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"":"im")<<"possible"<<endl
#define Poss(n) cout<<((n)?"P":"Imp")<<"ossible"<<endl
template<typename T>ostream&operator<<(ostream&o,const vector<T>&v){for(T i:v)o<<i<<' ';return o;}
template<typename T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<typename T>ostream&operator<<(ostream&o,const set<T>&v){for(T i:v)o<<i<<' ';return o;}
template<typename T,typename U>ostream&operator<<(ostream&o,const pair<T,U>&v){o<<v.first<<' '<<v.second;return o;}

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    cout<<a*b/2<<endl;
    return 0;
}


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

int n;

struct Restaurant
{
    string City = "";
    int Score = -1;
    int ID = -1;
    Restaurant(string city, int score, int id)
    {
        City = city;
        Score = score;
        ID = id;
    }
};
vector<Restaurant> vec;

int main(int argc, char *argv[])
{
    cin >> n;
    for (int i = 1; i <= n; ++i)
    {
        string s;
        int p;
        cin >> s >> p;
        vec.emplace_back(Restaurant(s, p, i));
    }
    sort(vec.begin(), vec.end(), [](Restaurant x, Restaurant y)->bool{
        if (x.City < y.City)
            return true;
        if (x.City > y.City)
            return false;
        return x.Score > y.Score;
    });
    for (Restaurant item : vec)
    {
        cout << item.ID << endl;
    }
}

Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint,time,random
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

def cal(T):
    res = 0
    last = [0] * 26
    for day in range(D):
        t = T[day]; t -= 1
        last[t] = 0
        res += s[day][t]
        for i in range(26):
            if i == t: continue
            last[i] += 1
            res -= c[i] * last[i]
    return res
start_time = time.time()
n = 26
D = inp()
c = inpl()
s = [inpl() for _ in range(D)]
last = [0] * n
res = [-1] * D
for d in range(D):
    ans = -1
    mx = -INF
    for i in range(n):
        now = s[d][i]
        for j in range(n):
            if i == j: continue
            now -= s[d][j] * (last[j]+1)
        if now > mx:
            mx = now
            ans = i
    res[d] = ans+1
    for j in range(n):
        last[j] += 1
        if j == ans: last[j] = 0
score = cal(res)
# print(now_score)
while time.time() - start_time < 1.83:
    td,tq = random.randrange(0,D), random.randrange(1,n+1)
    old_q = res[td]
    res[td] = tq
    now = cal(res)
    if now > score:
        score = now
    else:
        res[td] = old_q

for x in res:
    print(x)

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

int main()
{
    int n;
    cin >> n;
    double a[102];
    double sum = 0.0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        a[i] = 1.0 / a[i];
        sum += a[i];
    }
    printf("%.15f\n", 1.0 / sum);
}

Measured memory_bytes: 256
extern crate core;

use std::io::{self, Read};

#[macro_export]
macro_rules! input {
  ($s:expr=>$($t:tt)*) => {
    let mut lines=$s.split("\n");
    $(
        line_parse!(lines,$t);
    )*
  };
}

macro_rules! line_parse {
  ($lines:expr,($($name:ident:$t:tt)*)) => {
    let mut line=$lines.next().unwrap().split_whitespace();
    $(value_def!(line,$name,$t);)*
  };

  //複数行
  ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
    values_def!($lines,$n,$name,$t);
  };
}

macro_rules! value_def {
    ($line:expr, $name:ident, $t:tt) => {
        let $name = value!($line, $t);
    };
}

macro_rules! values_def {
    ($lines:expr, $n:expr, $name:ident, $t:tt) => {
        let $name = {
            let mut vec = Vec::new();
            for i in 0..$n {
                let mut next = $lines.next().unwrap().split_whitespace();
                vec.push(value!(next, $t));
            }
            vec
        };
    };
}

macro_rules! value {
  //配列
  ($line:expr,[$t:tt]) => {
    $line.map(|x|{
      let mut iter=::std::iter::once(x);
      value!(iter,$t)
    }).collect::<Vec<_>>()
  };
  //タプル
  ($line:expr,($($t:tt),*)) => {
    ($(value!($line,$t),)*)
  };
  //文字列
  ($line:expr,#) => {
    $line.next().unwrap()
  };
  //インデックス(-1)
  ($line:expr,@) => {
    $line.next().unwrap().parse::<usize>().unwrap()-1
  };
  //単一値
  ($line:expr,$t:ty) => {
    $line.next().unwrap().parse::<$t>().unwrap()
  };
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn solve(input: String) -> String {
    input!(input=>(n:i64));
    (1..n + 1)
        .filter(|x| x.to_string().len() % 2 == 1)
        .count()
        .to_string()
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

tests! {
    test1: "11\n" => "9\n",
    test2: "136\n" => "46\n",
    test3: "100000\n" => "90909\n",
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include<string.h>
#define ll long long 
#include<vector>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int main(){
	IOS;
	int n;
	cin>>n;
	vector<int> v(n+1);
	for(int i=1,a;i<n;i++)
	{
		cin>>a;
		v[a]++;
	}
	for(int i=1;i<=n;i++)
	cout<<v[i]<<endl;
	}

Measured memory_bytes: 3964
### classes

class Pt
  attr_accessor :x, :y

  def initialize() end
  def initialize(x, y) @x = x; @y = y end

  def ==(pt) @x == pt.x && @y == pt.y end
  def +(pt) Pt.new(@x + pt.x, @y + pt.y) end
  def -(pt) Pt.new(@x - pt.x, @y - pt.y) end
  def -@() Pt.new(-@x, -@y) end
  def *(t) Pt.new(@x * t, @y * t) end
  def /(t) Pt.new(@x / t, @y / t) end
  def dot(v) @x * v.x + @y * v.y end
  def cross(v) @x * v.y - @y * v.x end
  def d2() @x * @x + @y * @y end
  def d() Math.sqrt(d2()) end
  def normalize() self / d() end
  def to_s() "(#{@x},#{@y})" end
end

### subroutines

def extract_convex(pts)
  n = pts.length
  return pts if n == 1

  ci = sti = (0...n).min{|a, b| pts[a].y <=> pts[b].y}
  cpt = pts[ci]
  cv = Pt.new(1, 0)
  cvd = 1.0
  #p [ci, cpt.to_s, cv.to_s, cvd]
  
  cvx = [cpt]
  used = Array.new(n){false}

  loop do
    max_cos = -2.0
    max_i = nil
    
    for i in (0...n)
      next if used[i] || i == ci
      vi = pts[i] - cpt

      if cv.cross(vi) >= 0
        vid = vi.d
        cos = cv.dot(vi) / (cvd * vid)
        if max_cos < cos
          max_cos = cos
          max_i = i
        end
      end
      #p [max_cos, max_i]
    end

    break if max_i == sti

    npt = pts[max_i]
    cvx << npt
    cv = npt - cpt
    cvd = cv.d
    cpt = npt
    ci = max_i
    #p [ci, cpt.to_s, cv.to_s, cvd]
  end

  cvx
end

def outer?(pts, cvx)
  ncvx = cvx.length

  for i in (0...ncvx)
    vi = cvx[(i + 1) % ncvx] - cvx[i]
    out = true
    for pt in pts
      if vi.cross(pt - cvx[i]) >= 0
        out = false
        break
      end
    end
    return true if out
  end
  false
end

def cross_segs?(seg0, seg1)
  p0, p1 = seg0
  q0, q1 = seg1
  pv = p1 - p0
  qv = q1 - q0

  crpq = pv.cross(q0 - p0) * pv.cross(q1 - p0)
  crqp = qv.cross(p0 - q0) * qv.cross(p1 - q0)

  if crpq != 0 || crqp != 0
    return (crpq < 0 && crqp < 0)
  end

  (q0 - p0).dot(q1 - p0) < 0 ||
    (q0 - p1).dot(q1 - p1) < 0 ||
    (p0 - q0).dot(p1 - q0) < 0 ||
    (p0 - q1).dot(p1 - q1) < 0
end

### main

loop do
  n, m = gets.split.map(&:to_i)
  break if (n | m) == 0

  bs = n.times.map{Pt.new(*gets.split.map(&:to_i))}
  ws = m.times.map{Pt.new(*gets.split.map(&:to_i))}
  #p bs.map{|pt| pt.to_s}
  #p ws.map{|pt| pt.to_s}

  bcvx = extract_convex(bs)
  wcvx = extract_convex(ws)
  nbcvx = bcvx.length
  nwcvx = wcvx.length
  #p ["bcvx", bcvx.map{|pt| pt.to_s}]
  #p ["wcvx", wcvx.map{|pt| pt.to_s}]

  if nbcvx == 1 && nwcvx == 1
    puts 'YES'
  elsif nbcvx == 1
    puts outer?(bcvx, wcvx) ? 'YES' : 'NO'
  elsif nwcvx == 1
    puts outer?(wcvx, bcvx) ? 'YES' : 'NO'
  elsif nbcvx == 2 && nwcvx == 2
    puts (! cross_segs?(bcvx, wcvx)) ? 'YES' : 'NO'
  else
    puts (outer?(bcvx, wcvx) || outer?(wcvx, bcvx)) ? 'YES' : 'NO'
  end
end

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

int main()
{
    int a,b,c;
  priority_queue<int> v;
    
    cin >> a >> b >> c;
  
  v.push(a);
  v.push(b);
  v.push(c);

  v.pop();

    int sum=0;
    sum+=v.top();
    v.pop();
    sum+=v.top();
    cout <<  sum;
    
    return 0;
}






Measured memory_bytes: 256
// I make this just for fun because i'm done
// Aimi Haraguni >> Konomi Suzuki >> Yui >>  Ikimono Gakari >> Garnidelia >> Kalafina >> Eir Aoi.   .. dude? 
// problems that involves any kind of persistent data structures are the best of the best, are not them?
 
// #pragma GCC optimize ("Ofast,unroll-loops")
// #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
 
#define pb push_back
#define ff  first
#define ss second
#define tm1 first
#define tm2 second.first
#define tm3 second.second
#define sz(x) ll(x.size())
#define fill(x, v) memset(x, v, sizeof(x))
#define all(v) (v).begin(), (v).end()
#define FER(i,a,b) for(ll i=ll(a); i< ll(b); ++i)
#define IFR(i,a,b) for(ll i=ll(a); i>=ll(b); --i )
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
 
#define N 2010
// #define M 19
 
#define mod 998244353
#define mod1 1000000007
#define mod2 1000000009
#define bas 987625403
#define sqr(x) (x)*(x)  
#define INF 2000000000000000000
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef pair<ll, ll> ii;
typedef pair<ll, ii > tri;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update> set_t;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
 
#define trace(...) fff(#__VA_ARGS__, __VA_ARGS__)
 
template<typename t> void fff(const char* x, t&& val1){
    cout<<x<< " : "<<val1<<endl;
}
template<typename t1, typename... t2> void fff(const char* x, t1&& val1, t2&&... val2){
    const char* xd=strchr(x+1, ',');
    cout.write(x, xd-x)<<" : "<<val1<<" | ";
    fff(xd+1, val2...);
}
 
int main(){
	fastio;
	ll a, b, c, d; cin>>a>>b>>c>>d;
	ll times1 = (c+b-1)/b;
	ll times2 = (a+d-1)/d;
	(times1 <= times2)? cout<<"Yes\n": cout<<"No\n";
	return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <string>

using namespace std;

int main(){
    int A,B;
    string S,T,U;
    cin>>S>>T;
    cin>>A>>B;
    cin>>U;
    if(U==S){
        A--;
    }
    else if(U==T){
        B--;
    }
    cout<<A<<" "<<B;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 110
using namespace std;
int A[N];
int dp[N][N];

int Min(int &a,int b){return a = min(a,b);}
int main(){
  int n;
  cin>>n;

  for(int i=0,cnt=0;i<n;i++){
    int a,b;
    cin>>a>>b;
    if(i == 0) A[cnt++] = a;
    A[cnt++] = b;
  }

  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++)dp[i][j] = 1e9;
    dp[i][i] = 0;
  }
  
  for(int len=0;len<n;len++)
    for(int l=1;l<n;l++){
      int r = l+len;
      if(l+len>=N)continue;
      for(int m = l;m<r;m++){
        Min(dp[l][r],dp[l][m] + dp[m+1][r] + A[l-1]*A[m]*A[r]);
      }
}
  
  cout<<dp[1][n]<<endl; 
  return 0;
}

Measured memory_bytes: 3164
import math
n=int(input())
s=0
for i in range(1,n+1):
    k=math.gcd(0,i)
    for j in range(1,n+1):
        r=math.gcd(k,j)
        for z in range(1,n+1):
            f=math.gcd(r,z)
            s+=f
print(s)

Measured memory_bytes: 9192
#include <iostream>
#include <cmath>
#include <cstring>
using namespace std;
int mod=1e9+7;
void solve()
{
    int n,m;
    cin>>n>>m;
    char str[n][m+1];
    for(int i=0;i<n;i++) {cin>>str[i];}

    int dp[n][m];
    dp[0][0]=1;
    for(int i=1;i<n;i++)
    {
        dp[i][0]=(str[i][0]=='#'?0:dp[i-1][0]);
    }
    for(int i=1;i<m;i++)
    {
        dp[0][i]=(str[0][i]=='#'?0:dp[0][i-1]);
    }
    for(int i=1;i<n;i++)
    {
        for(int j=1;j<m;j++)
        {
            dp[i][j]=(str[i][j]=='#'?0:dp[i-1][j]+dp[i][j-1]);
            if(dp[i][j]>=mod) dp[i][j]-=mod;
        }
    }
    cout<<dp[n-1][m-1]<<'\n';
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // int t;
    // cin>>t;
    // while(t--)
    solve();
	return 0;
}

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

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

   if (a + b == c || a + c == b || c + b == a)
   {
      cout << "Yes" << endl;
   }
   else
   {
      cout << "No" << endl;
   }
   return 0;
}


Measured memory_bytes: 256
/*
ID: wangjun30
LANG: C++11
TASK:
*/
#include<iostream>
#include<algorithm>
#include<unordered_map>
#include<map>
#include<set>
#include<list>
#include<unordered_set>
#include<vector>
#include<bitset>
#include<queue>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<climits>
//#include<fstream>
using namespace std;
//ifstream cin(".in");
//ofstream cout(".out");
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if((a==b && b!=c) || (a==c && a!=b) || (b==c && a!=b)){
		cout<<"Yes";
	}
	else
		cout<<"No";
	return 0;
}

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

void solve () {
    int n, m;
    cin >> n >> m;
    vector<bool> ac(n);
    map<int, int> mp;
    for (int i = 0; i < m; i++) {
        int x; string s;
        cin >> x >> s;
        x--;
        if(s == "WA" && ac[x] == 0) {
            mp[x]++;
        }
        if (s == "AC") {
            ac[x] = 1;
        }
    }
    int a = 0, b = 0;
    for (int i = 0; i < n; i++) {
        if (ac[i]) {
            a++;
            b+= mp[i];
        }
    }
    cout << a << " " << b;

}

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


Measured memory_bytes: 8264
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int num[1000000];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&num[i]);
	}
	
	sort(num,num+n);
	//printf("%d %d",num[0],num[1]);
	int count=num[n/2]-num[n/2-1];
	printf("%d",count);
	
}

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

#define ll long long

ll dp[200001],n,k,h[200001],minnn;

int main()
{
//    freopen("a.in","r",stdin);
    cin>>n>>k;
    dp[1]=0;
    for(int i=1;i<=n;i++)
    {
        cin>>h[i];
    }
    for(int i=2;i<=n;i++)
    {
        minnn=1e18;
        for(int j=1;j<=k;++j)
        {
            if(i-j==0)
                break;
            minnn=min(minnn,dp[i-j]+abs(h[i]-h[i-j]));
        }
        dp[i]=minnn;
    }
    cout<<dp[n];
}




Measured memory_bytes: 1792
#include <bits/stdc++.h>
#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 n, y; cin >> n >> y;
  int ans_i, ans_j, ans_k;
  bool own = false;
  rep(i,n){
    rep(j,n-i){
      rep(k,n-i-j){
        int cnt = i + j + k;
        if(cnt == n){
          int sum = i * 10000 + j * 5000 + k * 1000;
          if(sum == y){
            own = true;
            ans_i = i;
            ans_j = j;
            ans_k = k;
          }
        }
      }
    }
  }

  if(own) cout << ans_i << " " << ans_j << " " << ans_k << '\n';
  else cout << "-1" << " " << "-1" << " " << "-1" << '\n'; 
  return 0;
}


Measured memory_bytes: 256
L, R = map(int, input().split())
res = [0] * 2019
for i in range(L, R + 1):
    if res[i % 2019] > 0:
        break
    else:
        res[i % 2019] += 1

if res[0] == 1:
    print(0)
else:
    ans = 2019
    for i in range(2019):
        for j in range(i + 1, 2019):
            if res[i] == res[j] == 1:
                ans = min(ans, i * j % 2019)
    print(ans)

Measured memory_bytes: 69408
X = str(input())
Y = 'ACGT'
X += "*"
sm = 0
ans = 0
# dp表

for x in X:
    if x in ('A', 'C', 'G', 'T'):
        sm += 1
    else:
        ans = max(ans, sm)
        sm = 0
print(ans)


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

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

    int N;
    cin >> N;
    vector<ll> A(N);
    map<ll, ll> ma;
    rep(i, N) { cin >> A[i]; }

    sort(all(A));

    int cnt = 1;
    ll prev = 0;
    bool judge = 0;
    rep(i, N) {
        if (i != 0) {
            if (prev * 2 >= A[i])
                cnt++;
            else
                cnt = 1;
        }

        prev += A[i];
    }

    cout << cnt << endl;
}

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


int main(){
    long long N;
    cin >> N;
    if (N == 0){
        cout << 0 << endl;
        return 0;
    }
    vector<int> nums;
    int sign = 1;
    while (N){
        if (N % 2){
            nums.push_back(1);
            N -= sign;
        }else{
            nums.push_back(0);
        }
        N /= 2;
        sign = -sign;
    }
    reverse(nums.begin(), nums.end());
    for (auto v : nums) cout << v;
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);
      
      //入力
      int N = sc.nextInt();
      int count = 0;
      
      //桁数を取得する
      for(int i=1; i<=N; i++){
        int V = String.valueOf(i).length();
        
       //桁数が奇数のときカウント
        if(V%2!=0){
        	count++;
        }
      }
      //出力
      System.out.println(count);
    }
}

Measured memory_bytes: 28372
import java.util.Scanner;
import java.util.LinkedList;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
  	LinkedList<Character> stack = new LinkedList<>();
    String s = sc.next();
    String res = "";
    
    for (int i = 0; i < s.length(); i++) {
    	if (s.charAt(i) == 'B') {
          if (!stack.isEmpty()) {
          	stack.pop();
          }
        } else {
        	stack.push(s.charAt(i));
        }
    }
                       
    while (!stack.isEmpty()) {
      res = stack.pop() + res;
    }
                       
    System.out.println(res);
  }
}


Measured memory_bytes: 22996
// Template
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <cmath>
#include <complex>
#include <cassert>
#define rep_override(x, y, z, name, ...) name
#define rep2(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, r) for (int i = (l); i < (r); ++i)
#define rep(...) rep_override(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003;
template <typename T> inline bool chmin(T &x, const T &y) {if (x > y) {x = y; return 1;} return 0;}
template <typename T> inline bool chmax(T &x, const T &y) {if (x < y) {x = y; return 1;} return 0;}
struct IOSET{IOSET(){cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10);}} ioset;

// Main Code
int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    
    int sum = 0;
    rep(i, n) sum += a[i];
    vector<int> ds;
    for (int i = 1; i * i <= sum; ++i) {
        if (sum % i == 0) {
            ds.push_back(i);
            ds.push_back(sum / i);
        }
    }
    
    int ans = 0;
    for (int d: ds) {
        vector<int> b = a;
        rep(i, n) b[i] %= d;
        sort(all(b));
        vector<ll> b_sum(n + 1, 0);
        rep(i, n) b_sum[i + 1] = b_sum[i] + b[i];
        vector<int> c = b;
        rep(i, n) c[i] = (c[i] + d - 1) / d * d - c[i];
        vector<ll> c_sum(n + 1, 0);
        rep(i, n) c_sum[i + 1] = c_sum[i] + c[i];
        ll mn = INF;
        rep(i, 1, n) chmin(mn, max(b_sum[i], c_sum[n] - c_sum[i]));
        if (mn <= k) chmax(ans, d);
    }
    
    cout << ans << "\n";
    return 0;
}


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

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

Measured memory_bytes: 5196
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#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 INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b,c,k;cin >> a >> b >> c >> k;
    if(k<a){
        cout << k << endl;
    }
    else if(k>=a&&k<=a+b){
        cout << a << endl;
    }
    else{
        cout << a-(k-a-b) << endl;
    }
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
 
int main(){
 int aa, ah, ba, bh;
  cin >> ah >> aa >> bh >> ba;
  int turn = 1;
  while(ah > 0 && bh > 0){
    if (turn%2 == 1) bh = bh-aa;
    else ah = ah- ba;
    turn++;
  }
  if(bh <=0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3624
H, W = map(int, input().split())
a = [list(input()) for i in range(H)]

dp = [[0]*W for i in range(H)]
mod = 10**9 + 7
dp[0][0] = 1

for i in range(H):
    for j in range(W):
        if a[i][j] == '#':
            continue
        if j > 0:
            dp[i][j] += dp[i][j-1]
        if i > 0:
            dp[i][j] += dp[i-1][j]
        dp[i][j] %= mod
print(dp[-1][-1])


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

int main() {
	int N, L;
	int ans = 0;
	cin >> N >> L;
	if (L >= 0) {
		ans = (L + L + N - 1) * N / 2-L;
	}
	else {
		if (L + N - 1 >= 0) {
			ans = (L + L + N - 1) * N / 2;
		}
		else {
			ans = (L + L + N - 1) * N / 2 - (L + N - 1);
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
from bisect import bisect_left
n=int(input())
c=sorted(list(map(int,input().split())))
mod=10**9+7
#2のx乗を前計算(mod)(0~N-1)
p=[1]*(n+1)
for i in range(n):
    p[i+1]=p[i]*2
    p[i+1]%=mod
ans=0
#それ以上のもの
for i in range(n):
    b=bisect_left(c,c[i])
    x=n-i-1
    ans+=(p[x]+x*p[x-1])*c[i]*p[i]
    ans%=mod
print(ans*p[n]%mod)

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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 C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    i64 H, W, h, w; cin >> H >> W >> h >> w;
    cout << (H - h) * (W - w) << endl;

    return 0;
}

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

using ll = long long;
using vi = vector<int>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using pii = pair<int,int>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back

ll modpow(ll m,ll n,ll p) {
  if(n==0) return 1;
  ll res=modpow(m,n/2,p);
  if(n%2==0) res=(res*res)%p;
  else res=(((res*res)%p)*m)%p;
  return res;
}

int main() {
  ll ans=-1;
  ll k; cin>>k;

  for(ll n=1;n<=k;n++) {
    if(7*(modpow(10,n,9*k)-1)%(9*k)==0) {
      ans=n;
      break;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3524
// Gaurav Aggarwal
 
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii > vii;
typedef vector<pll > vll;
#define pb push_back
#define mp make_pair 
#define mod 1000000007
#define F first
#define S second
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define For(i, a, b) for(__typeof (a) i=a; i<=b; i++)
#define inp_arr(a,n) for(__typeof (n) i=0; i<n; ++i) {cin>>a[i];}
#define debug_arr(a,n) {{for(__typeof (n) i=0; i<n; ++i) {cout<<a[i]<<" ";}cout<<"\n";}}
 
ll power(ll x, ll y) 
{ 
    ll res = 1;   
    while (y > 0) { 
        if (y & 1) 
            res = (res*x)%mod; 
        y = y>>1;
        x = (x*x)%mod;
    } 
    return res%mod; 
}

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

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

    int a,b,c;
    cin>>a>>b>>c;
    int left = a-b;
    cout<<c - min(left,c);
    return 0;
}

Measured memory_bytes: 256