akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

  public static void main(String[] args) {
    FastScanner sc = new FastScanner();

    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    int D = sc.nextInt();

    String ans = "Yes";
    while (true) {
      if ((C -= B) <= 0) {
        break;
      }
      if ((A -= D) <= 0) {
        ans = "No";
        break;
      }
    }
    System.out.println(ans);

  }
}

class FastScanner {
  private final InputStream in = System.in;
  private final byte[] buffer = new byte[1024];
  private int ptr = 0;
  private int buflen = 0;

  private boolean hasNextByte() {
    if (ptr < buflen) {
      return true;
    } else {
      ptr = 0;
      try {
        buflen = in.read(buffer);
      } catch (IOException e) {
        e.printStackTrace();
      }
      if (buflen <= 0) {
        return false;
      }
    }
    return true;
  }

  private int readByte() {
    if (hasNextByte()) {
      return buffer[ptr++];
    } else {
      return -1;
    }
  }

  private static boolean isPrintableChar(int c) {
    return 33 <= c && c <= 126;
  }

  private void skipUnprintable() {
    while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
      ptr++;
    }
  }

  public boolean hasNext() {
    skipUnprintable();
    return hasNextByte();
  }

  public String next() {
    if (!hasNext()) {
      throw new NoSuchElementException();
    }
    StringBuilder sb = new StringBuilder();
    int b = readByte();
    while (isPrintableChar(b)) {
      sb.appendCodePoint(b);
      b = readByte();
    }
    return sb.toString();
  }

  public int nextInt() {
    if (!hasNext()) {
      throw new NoSuchElementException();
    }
    int n = 0;
    boolean minus = false;
    int b = readByte();
    if (b == '-') {
      minus = true;
      b = readByte();
    }
    if (b < '0' || '9' < b) {
      throw new NumberFormatException();
    }
    while (true) {
      if ('0' <= b && b <= '9') {
        n *= 10;
        n += b - '0';
      } else if (b == -1 || !isPrintableChar(b)) {
        return minus ? -n : n;
      } else {
        throw new NumberFormatException();
      }
      b = readByte();
    }
  }

  public long nextLong() {
    if (!hasNext()) {
      throw new NoSuchElementException();
    }
    long n = 0;
    boolean minus = false;
    int b = readByte();
    if (b == '-') {
      minus = true;
      b = readByte();
    }
    if (b < '0' || '9' < b) {
      throw new NumberFormatException();
    }
    while (true) {
      if ('0' <= b && b <= '9') {
        n *= 10;
        n += b - '0';
      } else if (b == -1 || !isPrintableChar(b)) {
        return minus ? -n : n;
      } else {
        throw new NumberFormatException();
      }
      b = readByte();
    }
  }
}

Measured memory_bytes: 25296
// https://atcoder.jp/contests/aising2020/tasks/aising2020_b

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline ll len(V<T> arr) {
  return arr.size();
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}

const ll INF = 1e18;

void solve();

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

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

  ll res = 0;

  rep1(i, N) {
    ll a;
    cin >> a;
    if (a % 2 == 1 && i % 2 == 1) res++;
  }

  cout << res << "\n";
}


Measured memory_bytes: 3604
/*
 		Resilience is the greatest of all virtues.
 		Code by rajiv
 */
 #include <iostream>
 #include <cstring>
 #include <vector>
 #include <map>
 #include <set>
 #include <stack>
 #include <queue>
 #include <deque>
 #include <sstream>
 #include <iomanip>
 #include <cassert>
 #include <sys/time.h>
 #include <algorithm>
 #include <bitset>
 #include <cmath>
 #include <functional>
 #include <cmath>
 #include <climits>

 using namespace std ;

 #define xx first
 #define yy second
 #define ll long long
 #define ld long double
 #define el (char)0x0A
 #define sp " "
 #define pb push_back
 #define mp make_pair
 #define all(x) (x).begin(),(x).end()
 #define clr(x) memset((x),0,sizeof(x))
 #define uint unsigned int
 #define abs(x) ((x<=0)?(-x):(x))
 #define CASET  int t;cin>>t;while(t--)
 #define FORN(i,x,y) for(int i=x;i<y;i++)
 #define MAXN 100005
 #define INF 10000000010
 #define MOD 1000000007
 #define last_set_bit(x) log2((x)&(-x))
 #define add(x,y) (x)=((x)+(y))%MOD
 #define PI 3.141592653589793

 typedef pair<int,int> PII ; typedef vector<int> VI ; typedef vector<vector<int> > VVI ; typedef vector<bool> VB ; typedef vector<string> VS ;
 typedef map<int,int> MII ; typedef map<int,VI > MIV ; typedef set<int> SI ; typedef set<PII > SPII ; typedef vector<PII > VPII ; typedef vector<VPII > VVPII ;
 const int N = 100050 ;



int main(){
    int a, b  ; cin >> a >> b ;
    if (b%a == 0){
        cout << a+b << el ;
    }
    else{
        cout << b-a << el ;
    }
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:usize = read();
    let mut dest = vec![(0i64, 0i64); n+1];
    let mut t = vec![0i64; n+1];
    let mut ans ="Yes";
    for i in 1..=n {
        t[i] = read::<i64>() - t[i-1];
        dest[i].0 = read::<i64>() - dest[i-1].0;
        dest[i].1 = read::<i64>() - dest[i-1].1;
        let c = t[i] - dest[i].0.abs() - dest[i].1.abs();
        if c >= 0 && c % 2 == 0 {
        } else {
            ans = "No";
            break;
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 4288
#include<iostream>
using namespace std;
long long n,k,w[100001],ma=0;

int fp(long long p){
  long long  sum=0,v=0;
  for(int i=0;i<k;i++){
    sum=0;
    while(sum+w[v]<=p){
      sum+=w[v];
      v++;
      if(v==n)return v;
    }
  }
  return v;
}

int main(){
  cin>>n>>k;
  for(int i=0;i<n;i++)cin>>w[i];
  long long l=0,r=1000000000,m;
  while(r-l>1){
    m=(l+r)/2;
    int v=fp(m);
    if(n<=v)r=m;
    else l=m;
  }
  cout<<r<<endl;
  return 0;
}

Measured memory_bytes: 3868
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<iterator>
#include<complex>
#include<stack>
#include "stdio.h"
using namespace std;

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

using ll = long long;
using Pii = pair<int, int>;

const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const long long mod_const = 1e9+7;

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

using MIte = multimap<ll, ll, greater<ll> >::iterator;

map<ll, int> prime_factor(ll n) {
	map< ll, int > ret;
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

// 最大公約数
ll GreatestCommonDivisor(ll a, ll b) {
	if (a < b) {
		ll tmp = a;
		a = b;
		b = tmp;
	}

	ll r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

	return b;
}

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

	// long long?
	ll A, B;
	cin >> A >> B;

	ll gcd = GreatestCommonDivisor(A, B);

	map<ll,int> m = prime_factor(gcd);

	cout << m.size() + 1 << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main() {
	int D;
	cin >> D;
	if (D == 25)puts("Christmas");
	else if (D == 24)puts("Christmas Eve");
	else if (D == 23)puts("Christmas Eve Eve");
	else puts("Christmas Eve Eve Eve");
	return 0;
}

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

using namespace std;

const int NMAX = 100000 + 5;

int N, M;
int a[NMAX];
bool vis[NMAX];
bool mark[NMAX];
vector <int> graph[NMAX];

vector <pair <int, int> > v;

void dfs(int node) {
    vis[node] = true;
    v.push_back(make_pair(a[node], node));
    for (auto it: graph[node])
        if (!vis[it])
            dfs(it);
}

int main()
{
    //freopen("data.in", "r", stdin);
    ios_base :: sync_with_stdio(false);

    cin >> N >> M;
    int necear = 2 * (N - 1 - M);

    for (int i = 1; i <= N; ++ i)
        cin >> a[i];

    for (int i = 1; i <= M; ++ i) {
        int a, b;
        cin >> a >> b;
        ++ a, ++ b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    long long int cost = 0;
    for (int i = 1; i <= N && necear; ++ i)
        if (!vis[i]) {
            v.clear();
            dfs(i);
            sort(v.begin(), v.end());
            cost += v[0].first;
            -- necear;
            mark[v[0].second] = true;
        }

    v.clear();
    for (int i = 1; i <= N; ++ i)
        if (!mark[i])
            v.push_back(make_pair(a[i], i));

    sort(v.begin(), v.end());
    for (int i = 0; i < v.size() && necear; ++ i)
        cost += v[i].first, necear --;

    if (necear)
        cout << "Impossible\n";
    else
        cout << cost << '\n';
    return 0;
}


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

int main() {
  string s;
  cin>>s;
  int check=1;
  for(int i=0;i<s.size();++i) {
    if((i+1)&1) {
        if(s[i]=='L' ) check=0;
    }
    else {
        if(s[i]=='R') check=0;
    }
  }
  if(check) cout<<"Yes";
  else cout<<"No";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N, M, X;
    cin >> N >> M >> X;
    vector<int> A(M);
    int cost_l = 0, cost_r = 0;
    for (int i = 0; i < M; i++){
        cin >> A.at(i);
        if (A.at(i) < X) cost_l++;
        if (A.at(i) > X) cost_r++;
    }
    cout << min(cost_l, cost_r) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define loope(i,a,b) for(ll i=a;i<=b;i++)
#define test() ull t;cin>>t;while(t--)
#define puu pair<ull,ull>
#define f first
#define s second
#define pb push_back
#define mkp make_pair
#define ins insert
#define Vint vector<int>
#define Vull vector<ull>
#define nl cout<<endl
#define sp cout<<" "
#define MOD 1000000007
#define all(x) x.begin(),x.end()
vector<int> cache(100005);
int fact(int k)
{
	if(k<2)
		return 1;
	if(cache[k]!=0)
		return cache[k];
	return cache[k] = k*fact(k-1) % MOD;
}
int main() 
{
	 // #ifndef ONLINE_JUDGE
  //       freopen("input.txt", "r", stdin);
  //       freopen("output.txt", "w", stdout);
  //   #endif
  //   fastio();
    int m,n;
    cin>>n>>m;
    int ansl,ansr;
    ansl = -1;
    ansr = n+1;
    loop(i,0,m)
    {
    	int l,r;
    	cin>>l>>r;
    	ansl = max(l,ansl);
    	ansr = min(r,ansr);
    }
    //cout<<ansl<<" "<<ansr<<endl;
    if(ansr>=ansl)
    	cout<<ansr-ansl+1;
    else
    	cout<<0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

const int N = 1e5+10, mod = 998244353;
int n,m,pw[N],s[3][N],mx[3];

struct Graph{
	vector<int>e[N];
	inline void Add(int x,int y){
		if (x>y) swap(x,y);
		e[x].pb(y);
	}
	int sg[N],vis[N];
	inline void Get(){
		Dow(i,n,1){
			for (auto j:e[i]) vis[sg[j]]++;
			while (vis[sg[i]]) ++sg[i];
			for (auto j:e[i]) vis[sg[j]]--;
		}
	}
}G[3];

inline void upd(int &x,int y){
	x+=y;
	if (x>=mod) x-=mod;
}

int main(){
	n=read();
	For(i,0,2){
		m=read();
		For(j,1,m) G[i].Add(read(),read());
		G[i].Get();
	}
	pw[0]=1,pw[1]=1000000000000000000ll%mod;
	For(i,2,n) pw[i]=1ll*pw[i-1]*pw[1]%mod;
	For(i,0,2) For(j,1,n) upd(s[i][G[i].sg[j]],pw[j]),mx[i]=max(mx[i],G[i].sg[j]);
	int ans=0;
	For(i,0,mx[0]) For(j,0,mx[1]) ans=(ans+1ll*s[0][i]*s[1][j]%mod*s[2][i^j])%mod;
	printf("%d\n",ans);
}

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

using namespace std;

#define fastio ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define t_times int t; cin >> t; while(t--)
#define _parr(a, n) for(int __i = 0; __i < (int )n; __i++) cout << a[__i] << ' '; cout << '\n'
#define fr(i, p, n) for(int i = (int )p; i < (int )n; i++)
#define frn(i, p, n) for(int i = (int )p; i <= (int )n; i++)
#define rev(i, n, p) for(int i = (int )n; i >= (int )p; i--)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).begin(), (c).end()
#define sci(n) scanf("%d", &n)
#define scl(n) scanf("%lld", &n)
#define prin(n) printf("%d\n", n)
#define prln(n) printf("%lld\n", n)
#define mp make_pair
#define F first
#define S second
#define pb push_back

typedef long long int LL;
typedef unsigned long long ULL;
typedef unsigned int uint;
typedef pair< int, int> ii;
typedef vector< int> vi;

const int mod = 1e9 + 7;
const LL INF = 9e18 + 2e17;
const int inf = 2e9;
const int N = 2e5 + 22;
const double eps = 1e-10;

int n, m;

void _solve() {
	cin >> n >> m;
	vector< bool> vis(n + 1, 0);
	vector< int> cnt(n + 1, 0);
	int a = 0, b = 0;
	fr(i, 0, m) {
		int x; string y;
		cin >> x >> y;
		if(vis[x]) continue;
		if(y == "AC") vis[x] = 1, a++;
		else cnt[x]++;
	}
	frn(i, 1, n) if(vis[i]) b += cnt[i];
	cout << a << ' ' << b;
}

int main() {
    fastio;
    //t_times
    _solve();
    return 0;
}

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

int main()
{
	unsigned long long dp[102][21];
	int n;
	while(cin >> n){
		if(!n)
			break;
		int d[100];
		for(int i=0;i<n;i++){
			cin >> d[i];
		}
		memset(dp,0,sizeof(dp));
		dp[1][d[0]] = 1;
		for(int i=1;i<=100;i++){
			for(int j=0;j<=20;j++){
				if(dp[i][j]!=0){
					if(0<=j+d[i] && j+d[i]<=20){
						dp[i+1][j+d[i]] += dp[i][j];
					}
					if(0<=j-d[i] && j-d[i]<=20){
						dp[i+1][j-d[i]] += dp[i][j];
					}
				}
			}
		}
		cout << dp[n-1][d[n-1]] << endl;
	}
	return 0;
}

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

int main() {
  int a, b, k;
  std::cin >> k >> a >> b;
  for (int i = a; i <= b; i++) {
    if ( i % k == 0) {
      std::cout << "OK" << std::endl;
      return 0;
    }
  }
  std::cout << "NG" << std::endl;
  return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
using namespace std;
using Int = long long;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<55)+1e9; // ~ 3.6 * 1e16
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
using T = tuple<Int,Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
ostream& operator<<(ostream& o,T t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){Int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){Int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}

class RollingHash{
public:
  typedef long long ll;
  ll B;  //B: ハッシュ基数
  Int n;
  string s;
  vector<ll> hash;
  vector<ll> k;

  RollingHash():n(-1){};
  RollingHash(string s,ll B = 1777771,ll mod = 1e9 + 7):
    B(B),n(s.size()),s(s),hash(n+1),k(n+1)
  {
    for(Int i=0;i<n;i++) hash[i+1] = (hash[i] * B % mod + s[i]) % mod;
    k[0] = 1;
    for(Int i=1;i<=n;i++) k[i] = (k[i-1] * B) % mod;
  }

  ll get(Int l,Int r){ //[l, r)
    assert(0<=l && r<=n && l<=r);
    return (mod + hash[r] - hash[l] * k[r-l] % mod) % mod;
  }
  
  //hash[a]とB.hash[b]からみて何文字一致してるか。
  Int count(Int a, RollingHash &B, Int b){
    Int L = 0, R = min( n - a, B.n - b ) + 1;
    while( L + 1 < R ){
      Int M = ( L + R ) / 2;
      get( a, a + M ) != B.get( b, b + M ) ? R = M : L = M;
    }
    return L;
  }
};
typedef unsigned long long ull;
vector<vector<Int> > Div(510000);
Int n;
string str;
RollingHash R;
Int ok(Int l,Int r){
  Int len = r - l;
  for(Int d:Div[len]){
    ull a = R.get(l+d, r);
    ull b = R.get(l, r - d) ;
    if(a == b) return 0;
  }
  return 1;
}



signed main(){
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);
  const int N = 500010;
  
  for(Int i=1;i<N;i++)
    for(int j=i+i;j<N;j+=i) Div[j].push_back(i);


  cin>>str;
  n = str.size();
  R = RollingHash(str);
  
  if(string(n, str[0]) == str) {
    cout<<n<<endl;
    cout<<1<<endl;
    return 0;
  }
  
  if(ok(0, n)){
    cout<<1<<endl;
    cout<<1<<endl;
    return 0;
  }

  Int cnt = 0;
  for(Int i=0;i<n;i++){
    if(ok(0,i) && ok(i,n)) cnt++;
  }

  cout<<2<<endl;
  cout<<cnt<<endl;
  
  
  return 0;
}


Measured memory_bytes: 96564
#include <bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long
#define vi vector <int>
#define pii pair <int, int>
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define rep(i,n) for (int i = 0; i < (int) (n); ++ i)
#define foreach(it,c) for (__typeof(c.begin()) it = c.begin(); it != c.end(); ++ it)
 
inline int read() {
	int x = 0, f = 1, c = getchar();
	for (;!isdigit(c);c = getchar()) if (c == '-') f ^= 1;
	for (; isdigit(c);c = getchar()) x = x * 10 + c - '0';
	return f ? x : -x;
}

#define N 500005
char s[N * 10], t[N];
int n, nn, m;
vi g[N];
int z[N * 10];
int dp[N];
int vis[N];

int DP(int x) {
	if (vis[x] == -1) return -1;
	if (vis[x] == 1) return dp[x];
	vis[x] = -1;
	dp[x] = 0;
	rep(i, g[x].size()) {
		int to = g[x][i];
		int xx = DP(to);
		if (xx == -1) return -1;
		dp[x] = max(dp[x], xx + 1);
	}
	vis[x] = 1;
	return dp[x];
}

int main() {
	scanf("%s%s", s, t);
	n = nn = strlen(s);
	m = strlen(t);
	while (n <= m * 2) {
		rep(i, nn) s[n + i] = s[i];
		n += nn; 
	}
	rep(i, n) s[n + i] = s[i];
	n += n;
	for (int i = n - 1; ~i; -- i) s[i + m] = s[i];
	rep(i, m) s[i] = t[i];
	n += m;
	for (int i = 1, L = 0, R = 0; i < n; ++ i) {
		if (R >= i) z[i] = min(R - i + 1, z[i - L]);
		while (i + z[i] < n && s[z[i]] == s[i + z[i]]) ++ z[i];
		if (i + z[i] - 1 > R) L = i, R = i + z[i] - 1;
	}
	for (int i = m; i < n; ++ i) {
		if (z[i] >= m) g[(i - m) % nn].pb(i % nn);
	}
	memset(dp, -1, sizeof(dp));
	int ans = 0;
	rep(i, nn) {
		int xx = DP(i);
		if (xx == -1) {
			ans = -1;
			break;
		}
		ans = max(ans, xx);
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 82176
from collections import deque
import copy
def bfs():
    h,w = map(int, input().split())
    maze = [list(input()) for i in range(h)]
    S, G = [], []
    for y in range(h):
        for x in range(w):
            if maze[y][x]=='.':
                S.append([y,x])
                G.append([y,x])
                maze[y][x]=float("inf")
            else:
                maze[y][x]=-1
    l = []
    ans = 0
    for i in range(len(S)):
        maze1 = copy.deepcopy(maze)
        maze1[S[i][0]][S[i][1]]=0
        que=deque([[S[i][0],S[i][1]]])
        while que:
          y,x=que.popleft()
          for k,m in [(1,0),(0,1),(-1,0),(0,-1)]:
            nexty,nextx=y+k,x+m
            if nexty < 0 or nexty >= h or nextx < 0 or nextx >= w:
                continue
            dist=maze1[nexty][nextx]
            if dist!=-1:
              if dist>maze1[y][x]+1:
                maze1[nexty][nextx]=maze1[y][x]+1
                que.append([nexty,nextx])
            ans = max(ans, maze1[nexty][nextx])
    print(ans)
bfs()


Measured memory_bytes: 3572
function Main(input) {
  var input = input.replace(/\n/g, '').split(/\s+/g).join();
  var five, seven;
  if ((/5/).test(input) && (/7/).test(input)) {
    five = input.match(/5/g).length;
    seven = input.match(/7/g).length;
  }

  if ( five == 2 && seven == 1) {
    console.log("YES");
  } else {
    console.log("NO");
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29356
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
using namespace std;

int main()
{
    int N;
    scanf("%d", &N);
    vector<int> A(N), B(N);
    REP(i, N){
        scanf("%d", &A[i]);
        B[i] = A[i] % 2;
    }
    long long ans = 0;
    REP(i, N){
        if(A[i] >= 3){
            if(B[i] == 1){
                ans += (A[i] - 1) / 2;
                A[i] = 1;
            }else{
                ans += (A[i] - 2) / 2;
                A[i] = 2;
            }
        }
    }
    for(int i = 0; i < N - 1; i++){
        if(A[i] == 1){
            if(A[i+1] > 0){
                ans++;
                A[i]--;
                A[i+1]--;
            }
        }else if(A[i] == 2){
            ans++;
            A[i] = 0;
        }
    }
    if(A[N-1] == 2) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
using namespace std;
template <typename T = int>
T in() {
    T temp; cin >> temp; return temp;
}

template <typename VType = int>
list<VType> const LR(VType start, VType end) {
    list<VType> ret; for (VType i = start; i < end; i++) ret.push_back(i); return move(ret);
}

int main() {
    int N(in());
    auto S(in<string>());
    int K(in());
    char c = S[K - 1];
   
    for (char& x : S) {
        if (x != c) x = '*';
    }
    cout << S << endl;
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
typedef long double ld;
using ll=long long;
using namespace std;
const int mod=1e9+7;
const ll inf = 1LL << 60;
const ld pi = (acos(-1));
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; }





int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  
  int a,b,c,d;
  cin  >> a >> b >> c >> d;
  cout << min({a+c,a+d,b+c,b+d}) << endl;
}

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

using namespace std;

signed main() {
    long long a, b, t;
    cin >> a >> b >> t;
    long long ans = 0;
    for (int i = 1; i <= t; i++)
        if (i % a == 0)
            ans += b;
    cout << ans;
    return 0;
}


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

using namespace std;
string s1, s2, s3;
int main() {
    getline(cin, s1);
    getline(cin, s2);
    getline(cin, s3);
    cout << s1[0] << s2[1] << s3[2];
    
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
 
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	int n; cin >> n; 
	int a[n], b[n], c[n], dp1[n], dp2[n], dp3[n];
	
	for(int i = 0; i < n; i++) {
		cin >> a[i] >> b[i] >> c[i];
	}

	dp1[0] = a[0]; dp2[0] = b[0]; dp3[0] = c[0];

	for(int i = 1; i < n; i++) {
		dp1[i] = max(dp2[i-1] + a[i], dp3[i-1] + a[i]);
		dp2[i] = max(dp1[i-1] + b[i], dp3[i-1] + b[i]);
		dp3[i] = max(dp1[i-1] + c[i], dp2[i-1] + c[i]);
	}
	int ans = max(max(dp1[n-1], dp2[n-1]), dp3[n-1]); 
	cout << ans << endl;
}


Measured memory_bytes: 2560
#include <iostream>
#include <set>
#include <vector>

using namespace std;

int main()
{
    string s;
    int sum = 0;
    cin>>s;
    for (int i=0;i<s.size();i++) sum+=s[i]-'0';
    if (sum%9==0) cout<<"Yes\n";
    else cout<<"No\n";
}


Measured memory_bytes: 3700
#include <stdio.h>
#include <math.h>

int main(void)
{
	int a, b, x;
    double A, B, X, t, s, r, q;
	scanf("%d %d %d", &a, &b, &x);
    A=(double)a;
    B=(double)b;
    X=(double)x;
	if(2*x<=a*a*b){
        q=sqrtl(B*B*B*B*A*A+4*X*X);
        r=A*B*B;
        t=asin(r/q);
        s=180.0*t/3.1415926535897932384;
        printf("%.10f\n",s);
    }
    else{
        t=atanl(2*B/A-2.0*X/(A*A*A));
        s=180.0*t/3.1415926535897932384;
        printf("%.10f\n",s);
    } 

    return 0;
}

Measured memory_bytes: 128
import sys
from heapq import heappop, heappush


def main():
    input = sys.stdin.readline
    INF = 10**9 + 1
    Q = int(input())
    left = []
    right = []
    min_val = 0
    for _ in range(Q):
        q = list(map(int, input().split()))
        if q[0] == 1:
            a, b = q[1], q[2]

            # Update median
            heappush(left, -a)
            heappush(right, a)

            left_max = -heappop(left)
            right_min = heappop(right)

            median_left = min(left_max, right_min)
            median_right = max(left_max, right_min)

            heappush(left, -median_left)
            heappush(right, median_right)

            # Update minimum value of f(x)
            min_val += median_right - median_left
            min_val += b

        else:
            median = -heappop(left)
            print('{} {}'.format(median, min_val))

            heappush(left, -median)


if __name__ == '__main__':
    main()


Measured memory_bytes: 19080
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  if (A==B&&B==C) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
#define INF 200000000000
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()

bool compare(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}
// 入力



int main() {
    ll a,b;
    ll ans;
    cin >>a>>b;
    if(a<b){
        rep(i,b){
            cout << a;
        }
    }else{
        rep(i,a){
            cout << b;
        }
    }
    
    cout << endl;


    return 0;
    

}

Measured memory_bytes: 3556
using Atcoder;
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            switch (S)
            {
                case "Sunny":
                    Console.Write("Cloudy");
                    break;
                case "Cloudy":
                    Console.Write("Rainy");
                    break;
                case "Rainy":
                    Console.Write("Sunny");
                    break;
            }
        }
        //static void Main(string[] args)
        //{
        //    var temp = new Atcoder.ABC130.D();
        //    temp.Run();
        //}

    }
}

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

int main(){
    int N;
    cin >> N;
    if(N%2==0){
        cout << 0.5 << endl;
    }
    else{
        cout << double(double(N/2+1)/double(N)) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		int N = in.nextInt();
		int M = in.nextInt();
		int cardNums[] = new int[2 * M + 1];

		for ( int i = 1; i <= M; i++ ) {
			cardNums[i] = in.nextInt();
			cardNums[i + M] = in.nextInt();
		}

		int limR = N;
		int limL = 1;
		
		for ( int i = 1; i <= M; i++ ) {
			if ( limL < cardNums[i] ) {
				limL = cardNums[i];
			}
		}
		for ( int i = M + 1; i <= 2*M; i++ ) {
			if ( limR > cardNums[i] ) {
				limR = cardNums[i];
			}
		}
		
		if ( limL > limR ) {
			System.out.println(0);
		} else {
			System.out.println(limR - limL + 1);
		}
		
		in.close();
	}
}

Measured memory_bytes: 87496
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define mp make_pair
using namespace std;

ll dist[int(1e5)+2];
void dfs(vector<ar<ll,2>> *v, int parent,int vertex, ll c)
{
	dist[vertex] = c;
	for(auto it:v[vertex])
		if(it[0]!=parent)
			dfs(v,vertex,it[0],dist[vertex]+it[1]);
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	memset(dist,0x3f, sizeof(dist));
	int n;
	cin>>n;
	vector<ar<ll,2> > v[n];
	for(int i = 0,j,k,c; i<n-1; i++)
	{
		cin>>j>>k>>c, --j, --k;
		v[j].push_back({k,c});
		v[k].push_back({j,c});
	}
	int q,k;
	cin>>q>>k, --k;
	dist[k] = 0;
	dfs(v,-1,k,0);
	while(q--)
	{
		int x,y;
		cin>>x>>y, --x, --y;
		cout<<dist[x]+dist[y]<<"\n";
	}
	return 0;
}

Measured memory_bytes: 15872
# -*- coding: utf-8 -*-
"""
Created on Tue Sep 10 01:44:47 2019

"""

point = 0
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

for i in range(0,N):
    point = point + B[i]
    if(i >= 1):
        if(A[i]-A[i-1] == 1):
            point = point + C[A[i-1]-1]

print(point)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
// Hey! 僕の提出を見てくれてありがとう.
// ロボ子さん可愛いぞ！！！！！君もV沼にはまろう↓
// https://www.youtube.com/channel/UCDqI2jOz0weumE8s7paEk6g
using namespace std;
/*
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
namespace mp = boost::multiprecision;// 任意長整数型
using bint = mp::cpp_int;// 仮数部長が32の浮動小数点数型
using real32 = mp::number<mp::cpp_dec_float<32>>;// 仮数部長が1024の浮動小数点数型
using real1024 = mp::number<mp::cpp_dec_float<1024>>;// ついでに有理数型
using rat = boost::rational<bint>;
*/
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
//sortを降順にする時は greater<型>()
vector<string> bubble(vector<string> a){
  bool flag=1;
  while(flag){
    flag = 0;
    for (int i = a.size()-1; i >= 1; i--) {
      if(a[i][1] < a[i-1][1]){
        swap(a[i],a[i-1]);
        flag = 1;
      }
    }
  }
  return a;
}

vector<string> selection(vector<string> a){
  for (int i = 0; i < a.size(); i++) {
    ll mini = i;
    for (int j = i; j < a.size(); j++) {
      if(a[j][1] < a[mini][1]){
        mini = j;
      }
    }
    swap(a[i],a[mini]);
  }
  return a;
}

bool check(vector<string> in , vector<string> out){
  for (int i = 0; i < in.size(); i++) {
    for (int l = i+1; l < in.size(); l++) {
      for (int a = 0; a < out.size(); a++) {
        for (int b = a+1; b < out.size(); b++) {
          if(in[i][1] == in[l][1] && in[i] == out[b] && in[l] == out[a])return false;
        }
      }
    }
  }
  return true;
}
int main(){ //srand((unsigned)time(NULL));
  ll n;
  cin >> n;
  vector<string>a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<string>x;
  x = bubble(a);
  for (int i = 0; i < n; i++) {
    cout << x[i] << (i == n-1 ? "":" ");
  }cout << endl;
  cout << (check(a,x)?"Stable" : "Not stable") << endl;
  x = selection(a);
  for (int i = 0; i < n; i++) {
    cout << x[i] << (i == n-1 ? "":" ");
  }cout << endl;
  cout << (check(a,x)?"Stable" : "Not stable") << endl;
}



Measured memory_bytes: 3172
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
#include<time.h>
#include<cassert>

using namespace std;
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H& b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H& b) const { return x == b.x && y == b.y; }
	bool operator!=(const H& b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T& a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T& a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
ll bitcount(ll x) {
	int sum = 0;
	for (int i = 0; i < 20; i++)
		if ((1ll << i) & x) sum++;
	return sum;
}
ll fact_[200000];
ll comb(ll x, ll y, ll mod = Mod) {
	if (!fact_[0]) {
		fact_[0] = 1;
		for (int i = 1; i < 200000; i++) {
			fact_[i] = fact_[i - 1] * i % mod;
		}
	}
	if (x < y) return 0;
	return mod_pow(fact_[x], mod, mod) *
		mod_pow(fact_[x - y], mod - 2, mod) % mod *
		mod_pow(fact_[y], mod - 2, mod) % mod;
}//xCy
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n;
int a[300000];
signed main() {
	cin >> n;
	n++;
	for (int i = 1; i < n; i++) {
		cin >> a[i];
		a[i] += a[i - 1];
	}
	int x = 2, y = 4;
	//1~x-1,x~i-1,i~y-1,y~n-1
	int ans = Inf;
	for (int i = 3; i < n - 1; i++) {
		if (y == i) y++;
		while (x < i - 1 && abs((a[i - 1] - a[x - 1]) - a[x - 1]) > abs((a[i - 1] - a[x]) - a[x])) {
			x++;
		}
		while (y < n - 1 && abs((a[n - 1] - a[y - 1]) - (a[y - 1] - a[i - 1])) > abs((a[n - 1] - a[y]) - (a[y] - a[i - 1]))) {
			y++;
		}
		ans = min(ans, max(a[x - 1], max(a[i - 1] - a[x - 1], max(a[y - 1] - a[i - 1], a[n - 1] - a[y - 1]))) - min(a[x - 1], min(a[i - 1] - a[x - 1], min(a[y - 1] - a[i - 1], a[n - 1] - a[y - 1]))));
	}
	cout << ans << endl;
}

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

const int MAXN = 100000;
int a[MAXN + 1], b[MAXN + 1];

int sign(ll x) {
    if(x > 0)
        return 1;
    else if(x < 0)
        return -1;
    return 0;
}

int main() {
    //ios_base::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n;
    cin >> n;
    for(int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }
    ll ans = 1e18;
    for(int sgn = -1; sgn <= 1; sgn += 2) {
        ll curSum = 0;
        int s = sgn;
        ll res = 0;
        for (int i = 0; i < n; i++) {
            b[i] = a[i];
            curSum += a[i];
            if(sign(curSum) != s) {
                res += abs(curSum) + 1;
                if(curSum > 0) {
                    b[i] -= curSum + 1;
                }
                else if(curSum < 0)
                    b[i] -= curSum - 1;
                else {
                    if(s == 1)
                        b[i]++;
                    else
                        b[i]--;
                }
                curSum -= a[i];
                curSum += b[i];
            }
            assert(sign(curSum) == s);
            s *= -1;
        }
        ans = min(ans, res);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
map<long long, long long> tmp;
constexpr long long MOD = 1000000007;
long long modpow(long long x,long long n,long long mod){
    long long res = 1;
    while(n > 0) {
        if(n & 1) (res *= x) %= mod;
        (x *= x) %= mod;
        n>>=1;
    }
    return res;
}
void factorization(long long n, map<long long, long long>& mp) {
    for(long long i=2;i*i<=n;i++){
        while(n%i==0){
            mp[i]++;
            n /= i;
        }
     }
     if(!(n == 1)) mp[n]++;
}
void findleast(map<ll, ll>& x){
    for (auto i:x){
        tmp[i.first] = max(tmp[i.first], i.second);
    }
}
long long modinv(long long x, long long mod){
    return modpow(x, mod - 2, mod); }

int main() {
    ll n;
    cin >> n;
    ll a[n];
    map<ll, map<ll, ll>> least;
    least.clear();
    tmp.clear();
    for (ll i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (ll i = 0; i < n; i++) {
      if(least.count(a[i]))continue;
        factorization(a[i], least[a[i]]);
        findleast(least[a[i]]);
    }
    ll temp = 1;
    for (auto i : tmp) {
        temp *= modpow(i.first, i.second, MOD);
        temp%=MOD;
    }
    ll ans = 0;
    for (ll i = 0; i < n; i++) {
        ans += temp * modinv(a[i], MOD);
        ans %= MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<30)-1
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
#define vii vector<int>
#define vll vector<long long>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
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; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n, a[2][110], ans;
int lsum[110], rsum[110];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> n;
    rep(i, 0, 2) {
        rep(j, 0, n) cin >> a[i][j];
    }
    lsum[n] = rsum[n] = 0;
    rep(i, 0, n) lsum[i+1] = lsum[i] + a[0][i];
    rep(i, 0, n) rsum[i+1] = rsum[i] + a[1][n-i-1];
    int p = 0;
    rep(i, 0, n) {
        ans = max(ans, lsum[i+1] + rsum[n-i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PI 4*atan(1.0)
typedef long long ll;
typedef long double ld;
using namespace std;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};

int main(){
	char s[100001];
	cin>>s;
	for(int i=1;i<strlen(s);i++){
		if(s[i]==s[i-1]){
			printf("%d %d\n",i-1+1,i+1);
			return 0;
		}
	}
	for(int i=2;i<strlen(s);i++){
		if(s[i]==s[i-2]){
			printf("%d %d\n",i-2+1,i+1);
			return 0;
		}
	}
	printf("-1 -1\n");
	return 0;
}

Measured memory_bytes: 384
import kotlin.math.*
import java.util.*

const val MOD = 1_000_000_007L

fun readI() = readLine()!!.toInt()
fun readL() = readLine()!!.toLong()
fun readD() = readLine()!!.toDouble()
fun readIs() = readLine()!!.split(' ').map(String::toInt)
fun readLs() = readLine()!!.split(' ').map(String::toLong)
fun readDs() = readLine()!!.split(' ').map(String::toDouble)

fun main(args: Array<String>) {
  val n = readI()
  val ans = IntArray(n)
  var x = 1
  while (x * x <= n) {
    val x2 = x * x
    var y = 1
    while (x2 + y * y <= n) {
      val y2 = y * y
      var z = 1
      while (x2 + y2 + z * z <= n) {
        val z2 = z * z
        val w = x2 + y2 + z2 + x * y + y * z + z * x
        if (w <= n) {
          ans[w - 1]++
        }
        z++
      }
      y++
    }
    x++
  }
  ans.forEach(::println)
}


Measured memory_bytes: 37488
/* ＵＴＦ－８ */
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	int H, A;
	std::cin >> H >> A;

	int result = (H + A - 1) / A;
	std::cout << result << "\n";
}


Measured memory_bytes: 256
n = int(input())
S = input()
cnt=0
for i in range(10):
    x=S.find(str(i),0,n-2)
    if x!=-1:
        for j in range(10):
            y=S.find(str(j),x+1,n-1)
            if y!=-1:
                for k in range(10):
                    z=S.find(str(k),y+1,n)
                    if z!=-1:
                        cnt+=1
print(cnt)

Measured memory_bytes: 3188
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long LL;
const int inf = 1 << 30;
const LL INF = 1LL << 60;
const int MaxN = 600;

int n;
char s[MaxN + 5][MaxN + 5];

void Init() {
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= n; j++)
			scanf(" %c", &s[i][j]);
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= n; j++) {
			s[i + n][j + n] = s[i][j];
			s[i][j + n] = s[i][j];
			s[i + n][j] = s[i][j];
		}
	}
}

bool check(int x, int y) {
	for(int i = 0; i < n; i++) 
		for(int j = 0; j <= i; j++) 
			if(s[x + i][y + j] != s[x + j][y + i])
				return false;
	return true;
}

int main(){
	scanf("%d", &n);
	Init();
	int ans = 0;
	for(int i = 1; i <= n; i++)
		if(check(1, i)) ans += n;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 512
require 'prime'
MOD=10**9+7;  cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.chomp.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def ar2(s1,s2,de=nil) Array.new(s1){Array.new(s2,de)} end
def ar3(s1,s2,s3,de=nil) Array.new(s1){Array.new(s2){Array.new(s3,de)}} end

def desc(ar) ar.sort!{|x,y| y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end
def ceil(a,b) (a.to_f/b).ceil end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end
def rui(ar) s=[0]; ar.size.times{|i| s<<s[-1]+ar[i]}; s end
def rev_rui(ar) s=[0]; ar.size.times.reverse_each{|i| s<<s[-1]+ar[i]}; s end

def puts_yesno(b) puts(b ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def pu(h) begin; require './../nemi_lib/debug.rb'; puts_val(h); rescue LoadError; end; end
########### ( ˘ω˘ )ｽﾔｧ… ###########
require 'openssl'
def C(a,b)
  if b==0||a==b
    1
  else
    b=a-b if a/2<b
    x=(a-b+1..a).inject(1){|res,i|res*i%MOD}
    y=(1..b).inject(1){|res,i|res*i%MOD}
    yn=OpenSSL::BN.new(y).mod_inverse(MOD)
    x*yn
  end
end

def pow(base,b)
  ans=1
  while b>0 do
    d = b/10
    m = b%10
    ans*=(base**m)
    ans%=MOD
    base = (base**10)%MOD
    b=d
  end
  ans
end

n,a,b=gsmi
all=pow(2,n)-1
puts (-C(n,a)-C(n,b)+all)%MOD

Measured memory_bytes: 4724