akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <array>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <utility>
#include <vector>
#define FOR(i,a,b) for (int i=(a),for_##i##_max=(b);i<=(for_##i##_max);++i)
#define RFOR(i,a,b) for (int i=(a),rfor_##i##_min=(b);i>=(rfor_##i##_min);--i)
#define REP(i,n) for (int i=0,rep_##i##_len=(n);i<(rep_##i##_len);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)
constexpr int INF = 100100100;

template<typename T>
void chmin(T &x, T y) {
  x = std::min(x, y);
}

template<typename T>
void chmax(T &x, T y) {
  x = std::max(x, y);
}

namespace { // segment-tree
template<typename T, typename FnT>
class SegmentTree {
  public:
    explicit SegmentTree(FnT const &app, T const &un, size_t size):
      SegmentTree(app, un, std::vector<T>(size, un)) {
    }
    explicit SegmentTree(FnT const &app, T const &un, std::vector<T> const &v):
      append(app), unit(un), N(1 << log2(v.size())), dat(2*N-1) {
      std::copy(begin(v), end(v), begin(dat)+N-1);
      for (size_t k = N - 1; k > 0; --k) {
        dat[k-1] = append(dat[2*k-1], dat[2*k]);
      }
    }
    void update(size_t k, T x) {
      k += N - 1;
      dat[k] = x;
      while (k > 0) {
        k = (k - 1) / 2;
        dat[k] = append(dat[2*k+1], dat[2*k+2]);
      }
    }
    T at(size_t k) const {
      return dat[k+N-1];
    }
    T query(size_t a, size_t b, size_t k, size_t l, size_t r) const {
      if (r <= a || b <= l) { return unit; }
      if (a <= l && r <= b) { return dat[k]; }
      const auto mid = (l + r) / 2;
      const auto vl = query(a, b, 2*k+1, l, mid);
      const auto vr = query(a, b, 2*k+2, mid, r);
      return append(vl, vr);
    }
    T query(size_t a, size_t b) const {
      return query(a, std::min(b, N), 0, 0, N);
    }
    T query() const {
      return query(0, N, 0, 0, N);
    }
  private:
    FnT const append;
    T const unit;
    size_t const N;
    std::vector<T> dat;

    static size_t log2(size_t n) {
      size_t p = 1;
      while ((1 << p) < n) { ++p; }
      return p;
    }
};

template<typename T, typename FnT>
SegmentTree<T, typename std::decay<FnT>::type>
make_segment_tree(FnT const &app, T const &un, size_t size) {
  return SegmentTree<T, typename std::decay<FnT>::type>(app, un, size);
}

template<typename T, typename FnT>
SegmentTree<T, typename std::decay<FnT>::type>
make_segment_tree(FnT const &app, T const &un, std::vector<T> const &v) {
  return SegmentTree<T, typename std::decay<FnT>::type>(app, un, v);
}

} // namespace

int gcd(int a, int b) {
  return b == 0 ? a : gcd(b, a%b);
}

using namespace std;

int main() {
  // cout << fixed << setprecision(10);
  int N; cin >> N;
  auto tree = make_segment_tree(gcd, 0, N);
  REP(i, N) {
    int A;
    cin >> A;
    tree.update(i, A);
  }
  int ans = -1;
  REP(i, N) {
    int g = gcd(tree.query(0, i), tree.query(i+1, N));
    chmax(ans, g);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    int ans=0;
    for(int i=0;i<4;i++)
    {
        if(s[i]=='+')
        ans++;
        else
        ans--;
    }
    cout<<ans<<endl;
    return 0;
}

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

int main() {
  int a, b, c, n, s=0, sum=0;
  cin >> a >> b >> c;
  
  for (int i=1; i<=a; i++){
    n=i;
    s=0;
    
    while (n>0){
      s=s+(n%10);
      n=n/10;
    }
    if (s>=b and s<=c)
      sum=sum+i;
  }
  
  cout << sum;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
//#define at(x,i) get<i>(x);//
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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(){
    ll n;cin >> n;
    vl count(101,0);
    vl p;
    rep(i,n){
        ll x=i+1;
        if(x==1)continue;
        bool check=true;
        for(auto y:p){
            if(x%y==0)check=false;
        }
        if(check)p.pb(x);
    }
    rep(i,n){
        ll x=i+1;
        ll tmp=0;
        while(x!=1){
            while(x%p[tmp]==0){
                x/=p[tmp];
                count[p[tmp]]++;
            }
            tmp++;
        }
    }
    ll c2=0,c4=0,c14=0,c24=0,c74=0;
    rep(i,101){
        if(count[i]>=2)c2++;
        if(count[i]>=4)c4++;
        if(count[i]>=14)c14++;
        if(count[i]>=24)c24++;
        if(count[i]>=74)c74++;
    }
    ll ans=0;
    ans+=c74;
    ans+=c24*(c2-1);
    ans+=c14*(c4-1);
    ans+=c4*(c4-1)/2*(c2-2);
    cout <<ans <<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    
    int x = s.nextInt();
    int y = s.nextInt();
    int z = s.nextInt();
    int k = s.nextInt();
    
    long[] as = new long[x];
    for (int i = 0; i < x; i++) {
      as[i] = s.nextLong();
    }
    Arrays.sort(as);
    
    long[] bs = new long[y];
    for (int i = 0; i < y; i++) {
      bs[i] = s.nextLong();
    }
    Arrays.sort(bs);
    
    long[] cs = new long[z];
    for (int i = 0; i < z; i++) {
      cs[i] = s.nextLong();
    }
    Arrays.sort(cs);
    
    PriorityQueue<Cake> q = new PriorityQueue<Cake>();
    HashSet<Cake> enqueued = new HashSet<Cake>();
    Cake maxCake = new Cake(x-1, y-1, z-1, as[x-1] + bs[y-1] + cs[z-1]);
    q.add(maxCake);
    enqueued.add(maxCake);
    
    for (int i = 0; i < k; i++) {
      Cake cake = q.poll();
      System.out.println(cake.totalScore);
      
      if (cake.aIndex-1 >= 0) {
        Cake nextCake = new Cake(cake.aIndex-1, cake.bIndex, cake.cIndex, as[cake.aIndex-1] + bs[cake.bIndex] + cs[cake.cIndex]);
        if (!enqueued.contains(nextCake)) {
          q.add(nextCake);
          enqueued.add(nextCake);
        }
      }
      if (cake.bIndex-1 >= 0) {
        Cake nextCake = new Cake(cake.aIndex, cake.bIndex-1, cake.cIndex, as[cake.aIndex] + bs[cake.bIndex-1] + cs[cake.cIndex]);
        if (!enqueued.contains(nextCake)) {
          q.add(nextCake);
          enqueued.add(nextCake);
        }
      }
      if (cake.cIndex-1 >= 0) {
        Cake nextCake = new Cake(cake.aIndex, cake.bIndex, cake.cIndex-1, as[cake.aIndex] + bs[cake.bIndex] + cs[cake.cIndex-1]);
        if (!enqueued.contains(nextCake)) {
          q.add(nextCake);
          enqueued.add(nextCake);
        }
      }
    }
  }
}

class Cake implements Comparable<Cake> {
  int aIndex;
  int bIndex;
  int cIndex;
  long totalScore;
  
  Cake(int aIndex, int bIndex, int cIndex, long totalScore) {
    this.aIndex = aIndex;
    this.bIndex = bIndex;
    this.cIndex = cIndex;
    this.totalScore = totalScore;
  }
  
  public boolean equals(Object object) {
    if (!(object instanceof Cake)) {
      return false;
    }
    Cake cake = (Cake)object;
    return this.aIndex == cake.aIndex && this.bIndex == cake.bIndex && this.cIndex == cake.cIndex;
  }
  
  public int hashCode() {
    int hashCode = aIndex;
    hashCode *= 1009;
    hashCode += bIndex;
    hashCode *= 1009;
    hashCode += cIndex;
    return hashCode;
  }
  
  public int compareTo(Cake cake) {
    if (cake.totalScore > this.totalScore) {
      return 1;
    }
    if (cake.totalScore < this.totalScore) {
      return -1;
    }
    return 0;
  }
}


Measured memory_bytes: 30236
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;cin>>n;
	long long int ct=0,a[n];a[0]=0;
	for(int i=1;i<=n;i++)
		{
			cin>>a[i];
			if(a[i]<a[i-1]){ct+=(a[i-1]-a[i]);a[i]=a[i-1];}
		}
	cout<<ct<<endl;

}

Measured memory_bytes: 5148
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(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

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

def rangeI(it, l, r):
    for i, e in enumerate(it):
        if l <= i < r:
            yield e
        elif l >= r:
            break

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

n = int(input())


ord_a = ord("a")
def C(i):
    return chr(ord_a + i)

def conv(x):
    ans = []
    while x > 0:
        x -= 1
        y = (x)%26
        c = C(y)
        ans.append(c)
        x = x//26
    return "".join(reversed(ans))

print(conv(n))


Measured memory_bytes: 67468
#include<iostream>
#include<string>
#include<cstdlib>
#include<stack>
using namespace std;
 
int main(void) {
    string str;
    int number[1000],count = 0;
    stack<int> num;
    while(cin >> str) {
        if (str[0] == '+') {
            int a = num.top(); num.pop();
            int b = num.top(); num.pop();
            num.push(a + b);
        } else if (str[0] == '-') {
            int b = num.top(); num.pop();
            int a = num.top(); num.pop();
            num.push(a - b);
        } else if (str[0] == '*') {
            int a = num.top(); num.pop();
            int b = num.top(); num.pop();
            num.push(a * b);
        } else if (str[0] == ' ') {
        }else{
            num.push(atoi(str.c_str()));
        }
    }
    cout << num.top() << endl;
    return 0;
}

Measured memory_bytes: 1196
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
typedef long long int ll;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T>
bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false;}
template<typename T>
bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false;}
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string s;
    cin >> s;
    s += "#";
    int ans = 0;
    int len = 0;
    char prev = s[0];
    REP(i, 0, s.size()) {
        if (prev != s[i]) {
            ans++;
            len = 0;
        }
        len++;
        prev = s[i];
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

typedef pair<int, int> pii;
typedef vector<pii> vp;

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

    int n;
    cin >> n;
    vp xy[n];
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        for (int j = 0; j < a; j++) {
            int x, y;
            cin >> x >> y;
            xy[i].push_back({--x, y});
        }
    }

    int ans = -1;
    for (int i = 0; i < 1 << n; i++) {
        int bc = 0;
        bool f = true;
        for (int j = 0; j < n; j++) {
            if (i >> j & 1) {
                bc++;

                for (int k = 0; k < xy[j].size(); k++) {
                    if ((i >> xy[j][k].first & 1) != xy[j][k].second) {
                        f = false;
                    }
                }
            }
        }

        if (f) {
            ans = max(ans, bc);
        }
    }

    cout << ans << endl;

    return 0;
}


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

int main() {
  int N,ans=1;
  cin>>N;
  vector<int> vec(N);
  for(int i=0;i<N;i++)
  { cin>>vec.at(i);
  //cout<<vec.at(i);
  }
  sort(vec.begin(),vec.end());
  for(int i=0;i<N-1;i++){
   if(vec.at(i) != vec.at(i+1))
     ans++;
    
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3540
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a;
  string s;
  cin>>a>>s;
  if(s.size()<=a)
    cout<<s;
  else{
    for(int i=0;i<a;i++)
      cout<<s[i];
    cout<<"..."<<endl;
  }
}

Measured memory_bytes: 3592
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
const int N=8e3+5;
const int M=2e2+5;
const int mod=998244353;
int n,m,f[N<<3],g1[N<<3],g2[N<<3],fac[N],inv[N],dp[N][M];
inline int mul(int x,int y) {return 1ll*x*y%mod;}
template <typename _Tp> inline void IN(_Tp&x) {
    char ch;bool flag=0;x=0;
    while(ch=getchar(),!isdigit(ch)) if(ch=='-') flag=1;
    while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
    if(flag) x=-x;
}
namespace Poly {
    int filp[N<<3];
    inline int modpow(int x,int y,int res=1) {
        for(;y;y>>=1,x=mul(x,x)) if(y&1) res=mul(res,x);
        return res;
    }
    inline void NTT(int*f,int limit,short inv) {
        for(int i=0;i<limit;++i) if(i<filp[i]) swap(f[i],f[filp[i]]);
        for(int p=2;p<=limit;p<<=1) {
            int len=p>>1,tmp=modpow(3,(mod-1)/p);
            for(int k=0;k<limit;k+=p) {
                int buf=1;
                for(int l=k;l<k+len;++l,buf=mul(buf,tmp)) {
                    int t=mul(f[l+len],buf);
                    f[l+len]=(f[l]-t+mod)%mod,f[l]=(f[l]+t)%mod;
                }
            }
        }
        if(inv==1) return;
        int sl=modpow(limit,mod-2);reverse(f+1,f+limit);
        for(int i=0;i<limit;++i) f[i]=1ll*f[i]*sl%mod;
    }
}using namespace Poly;
int limit=1,cnt=0;
inline int C(int n,int m) {return mul(fac[n],mul(inv[m],inv[n-m]));}
inline void solve(int j) {
    memset(g1,0,sizeof(g1));
    memset(g2,0,sizeof(g2));
    for(int i=1;i<=n;++i) g1[i]=inv[i+2];
    for(int i=0;i<=n;++i) g2[i]=mul(dp[i][j-1],inv[i]);
    for(int i=0;i<=n;++i) dp[i][j]=(dp[i][j]+mul(dp[i][j-1],(1+i+C(i,2))%mod))%mod;
    NTT(g1,limit,1),NTT(g2,limit,1);
    for(int i=0;i<limit;++i) f[i]=mul(g1[i],g2[i]);
    NTT(f,limit,-1);
    for(int i=1;i<=n;++i) dp[i][j]=(dp[i][j]+mul(f[i],fac[i+2]))%mod;
}
int main() {
    IN(n),IN(m),fac[0]=inv[0]=1;
    for(int i=1;i<=n+2;++i) fac[i]=mul(fac[i-1],i);
    for(int i=1;i<=n+2;++i) inv[i]=modpow(fac[i],mod-2);
    while(limit<((n+1)<<1)) limit<<=1,++cnt;
    for(int i=0;i<limit;++i) filp[i]=(filp[i>>1]>>1)|((i&1)<<(cnt-1));
    dp[0][0]=1;
    for(int j=1;j<=m;++j) solve(j);
    int ans=0;
    for(int i=0;i<=n;++i) ans=(ans+mul(C(n,i),dp[i][m]))%mod;
    printf("%d\n",(ans+mod)%mod);
    return 0;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

template <class T>
inline void read(T &x) {
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar()) f ^= c == '-';
    for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
    x = f ? -x : x;
}

template <class T>
inline void write(T x) {
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    T y = 1;
	int len = 1;
    for (; y <= x / 10; y *= 10) ++len;
    for (; len; --len, x %= y, y /= 10) putchar(x / y + 48);
}

int a, p;

int main() {
	read(a), read(p);
	write((a * 3 + p) / 2);
	putchar('\n');
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		String s1 = sc.nextLine();
		String s2 = sc.nextLine();
		String s3;
		int n = s1.length();
		int ans = 0;
		while(n !=0) {
			s3  = switchs(s1,n);
//			System.out.println(s3);
			if(s3.equals(s2)) {
				ans = 1;
				break;
			}
			n--;
		}
		if(ans==1) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
	private static String switchs(String s1, int n) {
		return s1.substring(n)+s1.substring(0, n);
	}	
}	

Measured memory_bytes: 21844
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: usize,
        v: [usize; n]
    }
    let mut c = 1;
    let mut ans = 0;
    for &a in &v {
        if a == c {
            c += 1;
        } else {
            ans += 1;
        }
    }
    if ans == n {
        println!("-1");
    } else {
        println!("{}", ans);
    }
}


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

using namespace std;

int main()
{
	int n;
	cin >> n;
	int a[n], b[n], c[n], dp[n][3];
	for(int i=0;i<n;i++)
		cin >> a[i] >> b[i] >> c[i];
	dp[0][0] = a[0];
	dp[0][1] = b[0];
	dp[0][2] = c[0];
	for(int i=1;i<n;i++)
	{
		dp[i][0] = max(dp[i-1][1] , dp[i-1][2]) + a[i];
		dp[i][1] = max(dp[i-1][2], dp[i-1][0]) + b[i];
		dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c[i];
	}
	cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2])) << "\n";
	return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e6+9;
const int mod =1e9+7;
int pm(int a,int n=mod-2){
	if(n==0)return 1;
	if(n==1)return a;
	int x=pm(a,n/2);
	x=(x*x)%mod;
	if(n%2)x=(x*a)%mod;
	return x;
}
int32_t main(){
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(0),cin.tie(0);
	int n;
	cin >> n;
	int a[n],f[N]={0},s[N]={0},lcm=1,ans=0;
	for(int i=0;i<n;i++)
		cin >> a[i];
	for(int i=2;i<N;i++){
		if(s[i])continue;
		for(int j=i;j<N;j+=i)
			s[j]=i;
	}
	s[1]=1;
	for(int i=0;i<n;i++){
		int x=a[i];
		while(x>1){
			int k=0,fa=s[x];
			while(x%fa==0){
				x/=fa;
				k++;
			}
			f[fa]=max(f[fa],k);
		}
	}
	for(int i=0;i<N;i++)
		lcm=(lcm*pm(i,f[i]))%mod;
	for(int i=0;i<n;i++){
		ans=(ans+(lcm*pm(a[i]))%mod)%mod;
	}
	cout << ans;
}


Measured memory_bytes: 16000
#include <stdio.h>
#include <limits.h>

int BLOCK_S = 10;
int BLOCK_T = 11;
int BLOCK_X = 12;
int BLOCK_NULL = -1;

/* 足の届く範囲 */
int REACH[2][9][2] = {
	{{-1, -2}, {-1, -1}, {-1, 0}, {-1, 1}, {-1, 2}, {-2, -1}, {-2, 0}, {-2, 1}, {-3, 0}},
	{{1, -2}, {1, -1}, {1, 0}, {1, 1}, {1, 2}, {2, -1}, {2, 0}, {2, 1}, {3, 0}}
};

int w, h, s[60][30]; /* 崖のデータ */

/* 指定された座標のブロックを返す */
int getBlock(int x, int y) {
	if (x < 0 || x >= w || y < 0 || y >= h) return BLOCK_NULL;
	return s[y][x];
}

/* 幅優先探索 */
int memo[60][30][2]; /* 探索のメモ (ブロックに足が掛かるまでの最短時間) */
int UNREACHED = INT_MAX;
typedef struct { int time; int x; int y; int foot; } Log; /* 探索状態 */

/* FIFOキュー */
typedef Log Data;
Data queue[2000]; int queue_size = 2000; int queue_head; int queue_length;
void initqueue() {
	queue_length = 0;
}
void enqueue(Data d) {
	queue[(queue_head + queue_length) % queue_size] = d;
	queue_length++;
}
Data dequeue() {
	Data d = queue[queue_head];
	queue_head = (queue_head + 1) % queue_size;
	queue_length--;
	return d;
}

/* 幅優先探索をする */
int search(Log l) {
	int i;
	/* この試行が現在いるブロックまでの最短経路か確認する */
	if (l.time > memo[l.y][l.x][l.foot]) return UNREACHED;

	/* 次の動作 */
	for (i = 0; i < 9; i++) {
		int x = l.x + REACH[l.foot][i][0];
		int y = l.y + REACH[l.foot][i][1];
		int b = getBlock(x, y);
		if (b == BLOCK_X || b == BLOCK_NULL || b == BLOCK_S) {
			/* 足を置けないブロック */
			continue;
		} else if (b == BLOCK_T) {
			/* 崖登り完了 */
			return l.time;
		} else {
			/* 次のブロック */
			if (l.time + b < memo[y][x][1 - l.foot]) {
				memo[y][x][1 - l.foot] = l.time + b;
				Log m = {l.time + b, x, y, 1 - l.foot};
				enqueue(m);
			}
		}
	}

	return UNREACHED;
}

int main(void) {
	int min, i, j;

	/* データセット毎の処理 */
	while (scanf("%d%d", &w, &h) == 2 && w >= 2 && w <= 30 && h >= 5 && h <= 60) {
		/* 崖を表現する行列データを読み込む */
		for (i = 0; i < h; i++) {
			for (j = 0; j < w; j++) {
				scanf("%1s", &(s[i][j]));
				/* int 型の配列に変換する */
				if (s[i][j] >= '0' && s[i][j] <= '9') s[i][j] -= '0';
				else if (s[i][j] == 'S') s[i][j] = BLOCK_S;
				else if (s[i][j] == 'T') s[i][j] = BLOCK_T;
				else s[i][j] = BLOCK_X;

				/* メモを初期化する */
				memo[i][j][0] = UNREACHED;
				memo[i][j][1] = UNREACHED;
			}
		}

		/* 探索の始点をキューに入れる */
		for (i = 0; i < w; i++) {
			if (s[h - 1][i] == BLOCK_S) {
				Log l0 = {0, i, h - 1, 0}; /* 右足から */
				Log l1 = {0, i, h - 1, 1}; /* 左足から */
				enqueue(l0);
				enqueue(l1);
			}
		}
		/* 幅優先探索する */
		min = UNREACHED;
		while (queue_length > 0) {
			int t = search(dequeue());
			if (t < min) min = t;
		}

		/* 結果を出力する */
		if (min == UNREACHED) printf("-1\n");
		else printf("%d\n", min);

		/* デバッグ */
		/*
		for (i = 0; i < h; i++) {
			for (j = 0; j < w; j++) {
				printf("%2d ", s[i][j]);
			}
			printf("\n");
		}
		printf("\n");
		for (i = 0; i < h; i++) {
			for (j = 0; j < w; j++) {
				if (memo[i][j][0] == UNREACHED) printf("-1 ");
				else printf("%2d ", memo[i][j][0]);
			}
			printf(" | ");
			for (j = 0; j < w; j++) {
				if (memo[i][j][1] == UNREACHED) printf("-1 ");
				else printf("%2d ", memo[i][j][1]);
			}
			printf("\n");
		}
		printf("\n\n");
		*/
	}

    return 0;
}

Measured memory_bytes: 664
#include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
#include <chrono>
#include <cstdlib>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
// bool operator<(const pair<int, int> &a, const pair<int, int> &b)
// {
//     if (a.first == b.first)
//         return a.second < b.second;
//     return a.first < b.first;
// };

/*unsigned int xor128(void)
{
    static unsigned int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    unsigned int t = (x ^ (x << 11));
    x = y;
    y = z;
    z = w;
    return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
unsigned int xor128rnd(unsigned int m)
{
    return xor128() % m;
}*/

/*bool operator<(const pair<int, int> &a, const pair<int, int> &b)
{
    if (a.first == b.first)
    {
        return a.second < b.second;
    }
    return a.first < b.first;
}*/

int N, K;
double arr[3000];
double dp[3000][3000];
vector<int> v1, v2;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cin >> N;
    dp[0][0] = 1.0;

    for (int i = 0; i < N; ++i)
    {
        double p;
        cin >> p;
        for (int j = 0; j <= i; ++j)
        {
            dp[i + 1][j + 1] += dp[i][j] * p;

            dp[i + 1][j] += dp[i][j] * (1 - p);
        }
    }
    double ans = 0.0;
    for (int i = N / 2 + 1; i <= N; ++i)
    {
        ans += dp[N][i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 68864
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define rep(i,a,n) for(int i=a;i<n;++i)
#define per(i,a,n) for(int i=n-1;i>=a;--i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) ((int)x.size())
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
const ll linf=1e18;
const int inf=1001001001;
const ll mod=1e9+7; // 998244353 = (119<<23)+1
// head
const int nax=1e5+7;
int n,m;
int pref[nax];
int main() {
	  ios::sync_with_stdio(false);
  	cin.tie(0);
		cin>>n>>m;
		rep(i,0,m) {
			int a,b;
			cin>>a>>b;
			pref[a]++;
			pref[b+1]--;
		}
		int ans=0;
		rep(i,1,n+1) {
			pref[i]+=pref[i-1];
//			cout<<pref[i]<<' ';
			if(pref[i]==m) ans++;
		}
		cout<<ans;
		return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int num(int i, int n, int s)
{
	int cnt = 0;
	
	if (n == 0){
		return (!s);
	}
	
	if (i == 10 || s < 0){
		return (0);
	}
	
	cnt += num(i + 1, n - 1, s - i);
	cnt += num(i + 1, n, s);
	
	return (cnt);
}

int main(void)
{
	int n, s;
	
	while (1){
		scanf("%d %d", &n, &s);
		
		if (n == 0 && s == 0){
			break;
		}
		
		printf("%d\n", num(0, n, s));
	}
	
	return (0);
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#include<unordered_set>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie();
    int n, m;
    cin>>n>>m;
    vector<int> v(n);
    unordered_set<int> setPositions;
    int flag = 1;
    for(int i = 0; i < m; i++){
        int s, c;
        cin>>s>>c;
        s -= 1;
        if(setPositions.find(s) != setPositions.end()){
            if(v[s] != c){
                cout<<"-1";
                flag = 0;
            }
        }else{
            setPositions.insert(s);
            v[s] = c;
        }
    }
    int ans = 0;
    if(setPositions.find(0) == setPositions.end()){
        if(n!=1)
        v[0] = 1;
        else
        {
            v[0] = 0;
        }
        
        setPositions.insert(0);
    }else
    {
        if(v[0] == 0 && n!=1){
            cout<<"-1";
            flag = 0;
        }
    }
    int p = 1;
    for(int i = n-1; i >= 0; i--){
        if(setPositions.find(i) != setPositions.end()){
            ans += v[i]*p;
        }
        p*=10;
    }
    if(flag)
    cout<<ans;
    return 0;
}

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

using namespace std;

#define int long long
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

typedef pair<int,int> PI;
typedef pair<int,pair<int,int>> PII;
static const int INF=1010000000000000017LL;
static const double eps=1e-12;
static const double pi=3.14159265358979323846;
static const int dx[4]={1,-1,0,0};
static const int dy[4]={0,0,1,-1};
static const int ddx[8]={1,-1,0,0,1,1,-1,-1};
static const int ddy[8]={0,0,1,-1,1,-1,1,-1};

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 N,M;
int X[100005],Y[100005],Z[100005];
vector<int> V[100005];

bool visited[100005];
int ans;

void bfs(int s){
    queue<int> que;
    que.push(s);
    visited[s]=true;
    while(que.size()){
        int p=que.front();
        que.pop();
        //cout<<p<<endl;
        for(auto u:V[p]){
            if(visited[u])continue;
            que.push(u);
            visited[u]=true;
        }
    }
}

signed main(){
    cin>>N>>M;
    for(int i=0;i<M;++i){
        cin>>X[i]>>Y[i]>>Z[i];
        X[i]--,Y[i]--;
        V[X[i]].push_back(Y[i]);
        V[Y[i]].push_back(X[i]);
    }
    priority_queue<PI> pq;
    for(int i=0;i<N;++i)pq.push(PI(V[i].size(),i));
    while(pq.size()){
        int p=pq.top().second;
        //cout<<pq.top().first<<endl;
        pq.pop();
        if(visited[p])continue;
        //cout<<p<<endl;
        bfs(p);
        ans+=1;
        //cout<<ans<<endl;
    }
    cout<<ans<<endl;
}

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

const int INF = 0x3f3f3f3f;

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

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


public class Main {

	public static void main(String[] a){

		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));

		String tmpString = null;

		try {
			if(null != (tmpString = bf.readLine())){
				long ans = qa(Integer.parseInt(tmpString));
				System.out.println(ans);
			}
		} catch (IOException e) {
		}
	}

	private static long qa(int number){
		if(number == 1)return number;
		return number * qa(number - 1);
	}
}

Measured memory_bytes: 9400
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 絶対値求めやつ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#include <vector>
#include <string>
#include<iomanip>//浮動小数点数を出力する制度の指定
//使い方　数値をnumとして　cout<<setprecision(n)<<num ;nは桁数
#define rep(i,n) for(int i = 0; i < (n);i++)
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
using namespace std;
using ll =long long;
#define INF 2000000000
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; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
/*覚えてないことメaモ
数値型から文字列に変換　to_string(number);これは簡単
文字列から数値型に変換　stoi(number)
文字列からllに変換　stoll(number)*/

//ここから書き始める
int main(){
	// A T , G , C;
	vector<char> a ={'A','T','G','C'};
	vector<char> b = {'T','A','C','G'};
	char s; 
	cin >> s;
	rep(i,4){
		if(s==a[i]) {
			cout<<b[i]<<endl;
			break;
		}
	}
		
}


Measured memory_bytes: 256
#pragma GCC optimize "03"
#include "bits/stdc++.h"
using namespace std;
 
#define ll long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
 
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;

vector<pi> ed;
 
signed main() {
	IOS;
	#ifdef LOCAL
		freopen("input.txt","r", stdin);
		freopen("output.txt","w",stdout);
	#endif
	int n, k;
	cin >> n >> k;
	if(k > (n-2)*(n-1)/2)
		return cout << -1, 0;
	for(int i = 2; i <= n; i++)
		ed.push_back({1, i});
	k = (n-1)*(n-2)/2 - k;
	for(int i = 2; i <= n && k > 0; i++){
		for(int j = i+1; j <= n && k > 0; j++){
			ed.push_back({i, j});
			k--;
		}
	}
	cout << ed.size() << endl;
	for(auto i: ed)
		cout << i.fi << " " << i.se << endl;
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false); cin.tie(0)
#define loop(i, a, b) for(lli i=a; i<b; i++)
#define loopb(i, a, b) for(lli i=a; i>=b; i--)
#define pb push_back
typedef long long int lli;
typedef pair<lli, lli> pii;
typedef vector<lli> vll;
// use to avoid collision
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
// for pair in unordered_map
struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
lli power(lli x, lli y, lli p){
    lli res = 1;
    x = x % p;
    while (y > 0) {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
map<pii, lli> mp;
vector<vll> S;
vector<bool> vis;
void dfs(lli s, lli pc){
	vis[s] = true;
	lli col = 1;
	loop(i, 0, S[s].size()){
		if(vis[S[s][i]] == true)	
			continue;
		pii temp = {min(s, S[s][i]), max(s, S[s][i])};
		if(col == pc)	col++;
		mp[temp] = col;
		dfs(S[s][i], col);
		col++;
	}
	return ;
}
lli solve(){
	lli n;
	cin>>n;
	S.clear();
	S.resize(n+1);
	vector<pii> edg(n-1);
	vis.clear();
	vis.resize(n+1, false);
	lli k = 0;
	loop(i, 1, n){
		lli a, b;
		cin>>a>>b;
		edg[i-1] = {min(a, b), max(a, b)};
		S[a].pb(b);
		S[b].pb(a);
		lli x = S[b].size();
		lli y = S[a].size();
		k = max(k, max(x, y));
	}
	dfs(1, 0);
	cout<<k<<"\n";
	loop(i, 0, n-1)
		cout<<mp[edg[i]]<<"\n";
	cout<<"\n";
	return 0;
}
int main(){
	fastio;
	lli t;
//	cin>>t;
	t = 1;
	while(t>0){
		t--;
		solve();
	}
}


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

int main(){
  int R;
  cin>>R;
  if(R>=2800){
    cout<<"AGC"<<endl;
    return 0;
  }
  if(R>=1200){
    cout<<"ARC"<<endl;
    return 0;
  }
  cout<<"ABC"<<endl;
  return 0;
}


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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define COUT(x) cout<<(x)<<"\n"

int main(){
    int n,a,b;
    cin >> n >> a >> b;
    vector<int> x(n);
    REP(i,n) cin >> x[i];
    ll ans = 0;
    for(int i=1;i<n;i++){
        ll num = x[i]-x[i-1];
        if(num*a>=b){
            ans += b;
        }
        else ans += num*a;
    }
    COUT(ans);
    return 0;
}

Measured memory_bytes: 640
s = input()

answer = "Yes"

s_list = list(s)
s_list_reverse = list(reversed(s))

n = int((len(s_list)-1)/2)
m = int((len(s_list)+3)/2)

for i in range(len(s_list)):
  if s_list[i] != s_list_reverse[i]:
    answer = "No"
    break

    
s_list_1 = s_list[0:n]
s_list_1_reverse = list(reversed(s_list_1))

for i in range(len(s_list_1)):
  if s_list_1[i] != s_list_1_reverse[i]:
    answer = "No"
    break

s_list_2 = s_list[m-1:]
s_list_2_reverse = list(reversed(s_list_2))    
    
for i in range(len(s_list_2)):
  if s_list_2[i] != s_list_2_reverse[i]:
    answer = "No"
    break
    
print(answer)
    

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

using namespace std;

int main() {
    vector<int> predas;
    vector<int> cutsos;
    int n, k;
    cin >> n >> k;

    for (int i = 0 ; i < n ; i++) {
        int c;
        cin >> c;
        predas.push_back(c);
    }
    cutsos.push_back(0);

    for (int i = 1; i < n ; i++) {
        int min = cutsos[i - 1] + abs(predas[i-1] - predas[i]);
        for (int j = i - 2; j >= i - k && j >= 0 ; j--) {
            if (cutsos[j] + abs(predas[j] - predas[i]) < min) min = cutsos[j] + abs(predas[j] - predas[i]);
        }
        cutsos.push_back(min);
    }

    cout << cutsos.back() << "\n";
}

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

int main() {

	int a, b;
	cin >> a >> b;

	int count = 0;
	for (int i = a; i <= b; i++) {
		int i0 = i/10000;
		int i1 = (i/1000)%10;
		int i3 = (i/10)%10;
		int i4 = i%10;

		if (i0 == i4 && i1 == i3) {
			count++;
		}
	}
  	cout << count << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
    string s,t;
    cin>>s>>t;
    int ans = t.size();
    for(int i=0; i<=s.size() - t.size(); i++){
        int res = 0,m = 0;
        for(int j=i; j <= i+t.size() - 1; j++){
            if(s[j] != t[m])
                res++;
            m++;
        }
        ans = min(ans, res);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3588
import java.io.*;
import java.util.*;
 
public class Main{
	public void solve(){
		String exp = next();
		int m = nextInt();
		
		int a = calc2(exp);
		int b = calc1(exp);
		if(a == m && b == m){
			out.println("U");
		}else if(a == m){
			out.println("M");
		}else if(b == m){
			out.println("L");
		}else{
			out.println("I");
		}
	}
	public int calc1(String exp){
		int ans = exp.charAt(0) - '0';
		for(int i = 1; i < exp.length() - 1; i+=2){
			if(exp.charAt(i) == '+'){
				ans += (exp.charAt(i + 1) - '0');
			}else{
				ans *= (exp.charAt(i + 1) - '0');
			}
		}
		return ans;
	}
	String ss;
	int idx;
	public int calc2(String exp){
		this.ss = exp;
		this.idx = 0;
		return e();
	}
	
	public int e(){
		int val = t();
		while(idx < ss.length() && ss.charAt(idx) == '+'){
			idx++;
			val += t();
		}
		return val;
	}
	public int t(){
		int val = f();
		while(idx < ss.length() && ss.charAt(idx) == '*'){
			idx++;
			val *= f();
		}
		return val;
	}
	
	public int f(){
		int val = ss.charAt(idx++) - '0';
		return val;
	}
	
	private static PrintWriter out;
	public static void main(String[] args){
		out = new PrintWriter(System.out);
		new Main().solve();
		out.flush();
	}
	
	
	
	public static int nextInt(){
		int num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10 + (c - '0');
		}
		return minus ? -num : num;
	}
	
	public static long nextLong(){
		long num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10l + (c - '0');
		}
		return minus ? -num : num;
	}
	public static String next(){
		int c;
		while(!isAlNum(c = read())){}
		StringBuilder build = new StringBuilder();
		build.append((char)c);
		while(isAlNum(c = read())){
			build.append((char)c);
		}
		return build.toString();
	}
	
	
	private static byte[] inputBuffer = new byte[1024];
	private static int bufferLength = 0;
	private static int bufferIndex = 0;
	private static int read(){
		if(bufferLength < 0) throw new RuntimeException();
		if(bufferIndex >= bufferLength){
			try{
				bufferLength = System.in.read(inputBuffer);
				bufferIndex = 0;
			}catch(IOException e){
				throw new RuntimeException(e);
			}
			if(bufferLength <= 0) return (bufferLength = -1);
		}
		return inputBuffer[bufferIndex++];
	}
	
	private static boolean isAlNum(int c){
		return '!' <= c && c <= '~';
	}
}

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

#define ll long long
#define sd(x) scanf("%d", &(x))
#define pii pair<int, int>
#define F first
#define S second
#define all(c) ((c).begin()), ((c).end())
#define sz(x) ((int)(x).size())
#define ld long double

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<", "<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"{";
	for(int i = 0;i < (int)v.size(); i++){
		if(i)os<<", ";
		os<<v[i];
	}
	os<<"}";
	return os;
}

#ifdef LOCAL
#define cerr cout
#else
#endif

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

int main(){
	int n, m; sd(n); sd(m);
	if(m % 2 == 1){
		printf("-1\n");
		return 0;
	}
	vector<vector<int>> adj(n);
	vector<int> req(n);
	vector<int> a(m), b(m), flip(m);
	for(int i = 0; i < m; i++){
		int u, v; sd(u); sd(v);
		u--; v--;
		a[i] = u; b[i] = v;
		adj[u].push_back(i);
		adj[v].push_back(i);
		req[u] ^= 1;
	}
	vector<int> vis(n);
	function<void(int)> dfs = [&](int s){
		vis[s] = 1;
		for(int e : adj[s]){
			int v = a[e] ^ b[e] ^ s;
			if(!vis[v]){
				dfs(v);
				if(req[v]){
					flip[e] = 1;
					req[v] ^= 1;
					req[s] ^= 1;
				}
			}
		}
	};
	dfs(0);
	vector<int> deg(n);
	for(int i = 0; i < m; i++){
		if(flip[i]) swap(a[i], b[i]);
		deg[a[i]] ^= 1;
		printf("%d %d\n", a[i] + 1, b[i] + 1);
	}
	for(int i = 0; i < n; i++) assert(!deg[i]);
}

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

int main() {
	int n,m;cin>>n>>m;
	vector<int> a(m),b(m);
	for(int i=0;i<m;i++){
		cin>>a[i]>>b[i];
	}
	vector<int> use(n+1,1);
	vector<int> p;
	p.push_back(1);
	use[1]=0;
	int ans=0;
	int exgo=0;
	while(1){
		if(p.size()==0)break;
//		for(int i=0;i<p.size();i++){
//			cout<<p[i];
//		}
//		cout<<endl;
		int u=p.back();
		int v=0;
		p.pop_back();
		for(int i=0;i<m;i++){
			if(a[i]==u){
				v=b[i];
			}
			if(b[i]==u){
				v=a[i];
			}
			if(exgo>=v)v=0;
			if(use[v]==0)v=0;
			if(v)break;
		}
		if(v){
			exgo=0;
			p.push_back(u);
			p.push_back(v);
			use[v]=0;
			if(p.size()==n){
				ans++;
				p.pop_back();
				exgo=v;
				use[v]=1;
			}
		}else{
			exgo=u;
			use[u]=1;
		}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin >> n >> k;
    string s;
    cin >> s;
    int tmp = 0;
    for(int i=0;i<n-1;i++){
        if(s[i]==s[i+1])tmp++;
    }
    cout<<min(tmp+2*k,n-1)<<endl;
}

Measured memory_bytes: 3676
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=2000000000;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main() {
    int N;
    cin >> N;
    vector<int> A(N), B(N);
    int maxa = 0, score = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i] >> B[i];
        if (maxa < A[i]) {
            maxa = A[i];
            score = B[i];
        }
    }
    cout << score + maxa << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
const int N=1e6+100;
struct poi
{
    double x,y;
};
ll qpow(ll x,ll y){
    ll sum=1;
    while(y){
        if(y&1)
            sum=sum*x%mod;
        y/=2;
        x=x*x%mod;
    }
    return sum;
}
ll fac[N];
ll C(ll m,ll n){
    return fac[n]*qpow(fac[m],mod-2)%mod*qpow(fac[n-m],mod-2)%mod;
}
int main()
{
    fac[0]=1;
    for(int i=1;i<=1e6;i++){
        fac[i]=fac[i-1]*i%mod;
    }
    int x,y;
    scanf("%d%d",&x,&y);
    ll sum=x+y;
    if(sum%3!=0){
        printf("0\n");
    }else{
        ll ans=0;
        sum/=3;
        for(int i=0;i<=sum;i++){
            if(2*sum-i==x&&sum+i==y){
                ans=(ans+C(i,sum))%mod;
            }
        }
        printf("%lld\n",ans);
    }
    return 0;
}


Measured memory_bytes: 8064
#include <iostream>
#include <cstdio>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
long long mmin(long long a,long long b)
{
	if(a<b)return a;
	return b;
}
int main()
{
	long long n;
	cin>>n;
	long long i;
	long long ans=1e12;
	if(n==1)
	{
		puts("0");
		return 0;
	 } 
	for(i=1;i<=sqrt(n)+1;i++)
	{
		if(n%i==0)
		{
			ans=mmin(ans,i+n/i-2);
		}
	}
	cout<<ans;
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int, input().split()))
B=list(map(int, input().split()))
C=list(map(int, input().split()))

ans=B[A[0]-1]
for i in range(1,N):
    j=A[i-1]-1
    k=A[i]-1
    ans+=B[k]
    if j+1==k:
      ans+=C[j]
print(ans)

Measured memory_bytes: 61888
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 1000

priority_queue<int> Q[NUM];

int main(){

	int N,num_query;
	scanf("%d %d",&N,&num_query);

	int command,A,B;

	for(int loop = 0; loop < num_query; loop++){

		scanf("%d",&command);

		switch(command){
		case 0:

			scanf("%d %d",&A,&B);
			Q[A].push(B);
			break;

		case 1:

			scanf("%d",&A);
			if(!Q[A].empty()){
				printf("%d\n",Q[A].top());
			}
			break;

		case 2:

			scanf("%d",&A);
			if(!Q[A].empty()){
				Q[A].pop();
			}
			break;
		}
	}

	return 0;
}




Measured memory_bytes: 4028
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;

typedef long long LL;
const int N = 2e5 + 50;
const int mod = 1e9 + 7;

struct Bit {
#define lb(x) (x & (- x))
  LL a[N];
  Bit() { memset(a, 0, sizeof a); }
  inline void Add(int p, LL v) {
    for (; p < N; p += lb(p)) {
      a[p] += v;
      if (a[p] >= mod) a[p] -= mod;
    }
  }
  inline LL Sum(int p) {
    LL res = 0;
    for (; p > 0; p -= lb(p)) {
      res += a[p];
      if (res >= mod) res -= mod;
    }
    return res;
  }
} dp;

int n, m;
int a[N], b[N], tab[N];
int x[N], y[N];
vector <int> po[N];
bool tops[N];

int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i ++) scanf("%d", &a[i]);
  for (int i = 1; i <= m; i ++) scanf("%d", &b[i]);
  int k = n; n = 0;
  for (int i = 1, p = 0; i <= k; i ++) {
    if (a[i] <= b[1] || a[i] >= b[m]) continue;
    while (p <= m && a[i] >= b[p + 1]) p ++;
    if (b[p] == a[i]) continue;
    n ++;
    x[n] = a[i] - b[p];
    y[n] = b[p + 1] - a[i];
  }
  for (int i = 1; i <= n; i ++) {
    tab[i + i - 1] = x[i];
    tab[i + i] = y[i];
  }
  sort(tab + 1, tab + n + n + 1);
  k = unique(tab + 1, tab + n + n + 1) - tab - 1;
  for (int i = 1, p, q; i <= n; i ++) {
    p = lower_bound(tab + 1, tab + k + 1, x[i]) - tab;
    q = lower_bound(tab + 1, tab + k + 1, y[i]) - tab;
    po[p].push_back(q);
  }
  for (int i = 1; i <= k; i ++) {
    vector <int> &v = po[i];
    sort(v.begin(), v.end());
    v.resize(unique(v.begin(), v.end()) - v.begin());
    reverse(v.begin(), v.end());
    for (auto it : v)
      dp.Add(it, dp.Sum(it - 1) + 1);
  }
  printf("%lld\n", dp.Sum(k) + 1);
  return 0;
}

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


 
int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int a,b,c;
  cin>>a>>b>>c;
  int k;
  cin>>k;
  if(c>b && b>a){
    cout<<"Yes";
    return 0;
  }
  while(b<=a && k--){
     b*=2;
  }
  while(k--){
    c*=2;
  }
  if(c>b && b>a){
    cout<<"Yes"<<endl;
    //cout<<a<<" "<<b<<" "<<c;
  }else{
    cout<<"No"<<endl;
  }
  
  

}

Measured memory_bytes: 3632
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
using namespace std;
char s[5];
int num=0;
int main(){
	cin>>s;
	for(int i=0;i<strlen(s);i++)
		if(s[i]=='+')num++;else num--;
	cout<<num;
	return 0;
}

Measured memory_bytes: 256