akhauriyash/Code-Regression huggingface dataset:
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main(){
    let mut sa : Vec<char> = read::<String>().chars().collect();
    let mut sb : Vec<char> = read::<String>().chars().collect();
    let mut sc : Vec<char> = read::<String>().chars().collect();
    sa.reverse();
    sb.reverse();
    sc.reverse();
    let mut p = 'a';
    let mut ans = ' ';
    loop {
        if  p == 'E'{ break; }
        match p {
            'a' => {p = sa.pop().unwrap_or('E');
                    ans = 'A';
                },
            'b' => {p = sb.pop().unwrap_or('E');
                ans = 'B';
            },
            'c' => {p = sc.pop().unwrap_or('E');
                ans = 'C';
            },
            _ =>  unimplemented!() ,
        }
    }
    println!("{}",ans );
}

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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const int mod = 1e9+7;
const ll INF = 1e18;
const int inf = 1e9;

void solve()
{
  int n,m; cin>>n>>m;
  vector<ll> a(n, 0);
  vector<ll> b(n, 0);
  rep(i,n) cin>>a[i]>>b[i];
  vector<ll> c(m, 0);
  vector<ll> d(m, 0);
  rep(i,m) cin>>c[i]>>d[i];
  for (int i=0; i<n; i++) {
    ll min=inf;
    int p=1;
    for (int j=0; j<m; j++) {
      ll dis = abs(a[i]-c[j])+abs(b[i]-d[j]);
      if (min>dis) {
        min=dis;
        p=j+1;
      }
    }
    cout << p << endl;
  }
}

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


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
constexpr ll INF = 1ll << 55;

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

// multi-dimensional vector (require c++14)
template <typename T, typename U>
static inline vector<U> make_nd_vector(T &&n, U &&val) noexcept {
  static_assert(is_integral<T>::value,
                "[make_nd_vector] 1st argument must be an integer type");
  return vector<U>(forward<T>(n), forward<U>(val));
}
template <typename T, typename... Args>
static inline decltype(auto) make_nd_vector(T &&n, Args &&... args) noexcept {
  static_assert(is_integral<T>::value,
                "[make_nd_vector] 1st argument must be an integer type");
  return vector<decltype(make_nd_vector(forward<Args>(args)...))>(
      forward<T>(n), make_nd_vector(forward<Args>(args)...));
}
//
// Print from Iterator
template <typename ite>
void print_ite(ite start, ite end, char sp = ' ', char en = '\n') {
  for (auto i = start; i != end; i++)
    cout << *i << sp;
  cout << en;
}
//
inline void Yes(bool condition) { cout << (condition ? "Yes\n" : "No\n"); }

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  map<int, int> m;
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    int key = i - a[i];
    ans += m[key];
    m[i + a[i]]++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 20592
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

int main(){
  string S; cin >> S;
  int ans = 0;

  int L = 0, R = S.length() - 1;
  while (R - L > 0){
    if (S[L] == S[R]){
      L++; R--;
      continue;
    }

    if (S[L] == 'x' || S[R] == 'x'){
      ans++;
      if (S[L] == 'x') L++;
      else R--;
      continue;
    }
    cout << -1 << endl;
    return 0;
  }
  cout << ans << endl;
  return 0;
}


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

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

typedef long long ll;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//これを使うときにはCOMinit();を忘れずに

int main(void){
    COMinit();
    ll N, K; cin >> N >> K;
    ll ans = 0;
    vector<ll> A(N); rep(i, N) cin >> A[i];
    sort(A.begin(), A.end());
    for(int i = K-1; i < N; i++){
        ll inc = ((COM(i, K-1) * A[i] % MOD) + MOD) % MOD;
        ans = (ans + inc) % MOD;
    }
    for(int i = 0; i < N; i++){
        ll inc = ((COM(N-1 - i, K-1) * A[i] % MOD) + MOD) % MOD;
        ans = (ans - inc + MOD) % MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 15920
#include <bits/stdc++.h>
 
using namespace std;
 
#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
 
typedef long long ll;

ll fact[13];
int sizes[1<<12];

int main() {
 
  fact[0] = 1;
  REP(i, 1, 13) fact[i] = fact[i-1] * i;

  for(int N, M; cin >> N >> M && (N|M);) {
    vector<string> vs;
    map<string, int> mp;
    rep(i, N) {
      string s; cin >> s;
      mp[s] ++;
      vs.push_back(s);
    }

    rep(i, 1<<N) sizes[i] = 0;
    rep(S, 1<<N) {
      rep(i, N) {
        if(S >> i & 1) continue;
        sizes[S | (1<<i)] += vs[i].size();
      }
    }

    string T;
    rep(i, M) {
      char s[5001]; cin >> s, T += s;
    }

    int TSize = T.size();
    
    ll sum = 0;
    rep(st, TSize - sizes[(1<<N)-1] + 1) {
      ll dp[1<<N]; memset(dp, 0, sizeof dp);
      dp[0] = 1;
      rep(S, 1<<N) {
        if(!dp[S]) continue;
        rep(i, N) {
          if(S >> i & 1) continue;
          if(!T.compare(st + sizes[S], sizes[S|(1<<i)] - sizes[S], vs[i])) {
            dp[S|(1<<i)] = 1;
          }
        }
      }
      sum += dp[(1<<N)-1];
    }

    cout << sum << endl;
  }
 
  return 0;
}

Measured memory_bytes: 3244
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,t;
    cin>>n>>t;
    int ans=100000;
    for (int i = 0; i < n; ++i) {
        int a,b;
        cin>>a>>b;
        if(t>=b){
            ans=min(ans,a);
        }
    }
    if(ans==100000)cout<<"TLE"<<endl;
    else cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
/*****************************************************************\
    |     IN THE NAME OF ALLAH, MOST GRACIOUS AND MOST MERCIFUL       |
    |                                                                 |
    |     Author     : Mahabub Rahman                                 |
    |     Email      : mahabubrahman618@gmail.com                     |
    |     University : Comilla University, Bangladesh		          |
    |                  Department of Computer Science & Engineering   |
    \*****************************************************************/


    /*...................................Data_Types............................................*/
    #include<bits/stdc++.h>

    using namespace std;
    #define FastIO ios::sync_with_stdio(false); cin.tie(0);cout.tie(0)
    #define       ll                  long long int
    #define       ull                  unsigned long long int
    #define       veci                 vector<int>
    #define       vecc                 vector<char>
    #define       vecs                 vector<string>
    #define       vecl                 vector<long long int>
    #define       vecp                 vector<  pair<int,int> >
    #define       mapstrint            map< string , int >
    #define       mapstrstr            map< string , string >
    #define       mapint               map< int, int >
    #define       pb                   push_back
    #define       pob                  pop_back
    #define       mp                   make_pair
    ////============ CONSTANT ===============////
    #define mx9   1000000007
    #define mx7   10000007
    #define mx6   1000006
    #define mx5   200005
    #define inf   1<<30                                           //infinity value
    #define eps   1e-9

    #define mod   1000000007
    ////=====================================////

    long double PI = acosl(-1);
    bool compare_int(int a, int b) //This function is use for descending order.
    {
        return (a>b);
    }
    bool compare_string (string a, string b)
    {
        return a.size() < b.size();
    }
    bool compare_pair(const pair<int,int> &a,
                  const pair<int,int> &b)
    {
        if(a.second==b.second) return a.first>b.first;
        else return (a.second > b.second);
    }
    /*ll fact(ll n)
    {
        if(n==0 || n==1) return 1;
        else return n*fact(n-1);
    }*/

    ////======================================////
    /*bool check(int n)
    {
        for(int i=2; i<=sqrt(n); i++)
        {
            if(n%i==0)
            {
                return false;
            }
        }
        return true;
    }*/
    int32_t main()
    {
        FastIO;

        int n, m;
        cin >> n >> m;
        cout << ((n*(n-1))/2) + ((m*(m-1))/2) << endl;

    }


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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int,int>;

constexpr int INF = 1001001001;
int N, M, S, T;
std::vector<int> G[100100];
int di[100100][3];
std::priority_queue<P, std::vector<P>, std::greater<P>> pq;

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

    std::cin >> N >> M;

    for(int i=0;i<M;++i){
        int u, v;
        std::cin >> u >> v;

        G[u].emplace_back(v);
    }

    std::cin >> S >> T;

    std::fill(&di[0][0], &di[0][0] + 100100 * 3, INF);
    di[S][0] = 0;
    pq.emplace(0, S, 0);

    until(pq.empty()){
        int d, v, m;
        std::tie(d, v, m) = pq.top();
        pq.pop();

        if(d > di[v][m]){
            continue;
        }

        for(auto &w : G[v]){
            if(d + 1 < di[w][(m+1)%3]){
                di[w][(m+1)%3] = d + (m == 2);
                pq.emplace(di[w][(m+1)%3], w, (m+1)%3);
            }
        }
    }

    if(di[T][0] == INF){
        std::cout << "-1" << std::endl;
    }else{
        int mn = di[T][0];
        std::cout << mn << std::endl;
    }
}


Measured memory_bytes: 7156
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18) + 1;
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
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 h,w,k;
vector<string> s;
int dfs(int l,vector<int> tate){
    if(l==h){
        //debug(tate);
        tate.push_back(h);
    vector<int> count(tate.size(),0);
    int res=0;
    for(int i=0;i<w;i++){
        int f=0;
        vector<int> count1(tate.size(),0);
        for(int j=0;j<h;j++){
            if(tate[f]==j)f++;
            if(s[j][i]=='1'){
                count1[f]++;
            }
        }
        //debug(count1);
        //cout<<res<<"\n";
        for(int j=0;j<tate.size();j++){
            if(count1[j]>k)return INF;
            count[j]+=count1[j];
            if(count[j]>k){
                res++;
                for(int g=0;g<tate.size();g++){
                    count[g]=count1[g];
                }
                break;
            }
        }
    }
    return res+tate.size()-1;
    
    }
    else{
        int res=INF;
        chmin(res,dfs(l+1,tate));
        tate.push_back(l);
        chmin(res,dfs(l+1,tate));
        return res;
    }
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>h>>w>>k;
    rep(i,h){
        string temp;
        cin>>temp;
        s.push_back(temp);
    }
    vector<int> tate;
    cout<<dfs(1,tate)<<"\n";
}


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

int main()
{
    int t=1;
    //cin>>t;


    while( t-- )
    {
        ll x;
        cin>>x;

        ll p=100;
        int ans=0;
        while(p<x)
        {
            p=p+(p/100);
            ans++;
        }

        cout<<ans;

    }
    return 0;
}


Measured memory_bytes: 3616
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		long k = sc.nextLong();
		if (k <= 10) {
			System.out.println(k);
			return;
		}
		long[][] dp = new long[11][12];
		for (int i = 0; i < 10; i++) {
			dp[1][i + 1] = 1;
		}
		long sum = 9;
		int in = 0;
		int jn = 0;
		out: for (int i = 2; i < 11; i++) {
			for (int j = 0; j < 10; j++) {
				dp[i][j + 1] = dp[i - 1][j] + dp[i - 1][j + 1] + dp[i - 1][j + 2];
				if (j == 0) {
					continue;
				}
				sum += dp[i][j + 1];
				if (sum >= k) {
					in = i;
					jn = j;
					break out;
				}
			}
		}
		ArrayList<Integer> list = new ArrayList<>();
		list.add(jn);
		for (int i = in - 1; i >= 1; i--) {
			if (sum - dp[i][jn + 2] < k) {
				list.add(jn + 1);
				jn = jn + 1;
			} else if (sum - dp[i][jn + 2] - dp[i][jn + 1] < k) {
				sum -= dp[i][jn + 2];
				list.add(jn);
			} else if (sum - dp[i][jn + 2] - dp[i][jn + 1] - dp[i][jn] < k) {
				sum -= dp[i][jn + 2] + dp[i][jn + 1];
				list.add(jn - 1);
				jn = jn - 1;
			} else {
				System.out.println("po");
			}
		}
		for (Integer integer : list) {
			System.out.print(integer);
		}
		System.out.println();
	}
}

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;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
		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 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();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || Integer.MAX_VALUE < nl) {
			throw new NumberFormatException();
		}
		return (int) nl;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 21204
#include "bits/stdc++.h"
using namespace std;
#define mod 1000000007
#define all(c) begin(c),end(c)
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
using ll = long long;
using vi = vector<int>; using vs = vector<string>;
int dd[] = { 0, 1, 0, -1, 0 }; //→↓←↑

void solve()
{
	int N, M, X;
	cin >> N >> M >> X;

	vi A(M);
	int S = 0;
	int T = 0;
	for (int i = 0; i < M; i++)
	{
		cin >> A[i];
		if (A[i] < X)
		{
			S++;
		}
		else
		{
			T++;
		}
	}

	cout << min(S, T) << endl;

}

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

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

using namespace std;

typedef long long ll;

int main(){
    vector<pair<ll,ll>> a;
    multiset<ll> b,r;
    int n;
    scanf("%d",&n);
    for(int i = 0; i<n; i++){
        ll xi,yi;
        scanf("%lld%lld",&xi,&yi);
        if(xi>yi)
            swap(xi,yi);
        a.push_back({xi,yi});
        b.insert(xi);
        r.insert(yi);
    }
    sort(a.begin(),a.end());
    ll r2 = a[n+n-1].first,b1 = a[0].first,r1,b2;
    auto solve = [&](){
        return (*r.rbegin()-*r.begin())*(*b.rbegin()-*b.begin());
    };
    ll ans = solve();
    for(int i = 0; i<n; i++){
        b.erase(b.find(a[i].first));
        r.insert(a[i].first);
        r.erase(r.find(a[i].second));
        b.insert(a[i].second);
        ans = min(ans,solve());
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 23020
def main():
    a, b = map(int, input().split())

    if a == 0 or b == 0:
        print("Zero")
    elif a < 0 and b < 0:
        if (b - a + 1) % 2 == 0:
            print("Positive")
        else:
            print("Negative")
    elif a < 0 and 0 < b:
        print("Zero")
    elif 0 < a and 0 < b:
        print("Positive")


if __name__ == "__main__":
    main()


Measured memory_bytes: 61860
import sys
from operator import itemgetter

inf = 1<<60

def solve():
    N, M = map(int, sys.stdin.readline().split())

    cost = [[inf]*N for i in range(N)]
    for u in range(N):
        cost[u][u] = 0

    for i in range(M):
        si, ti, di = map(int, sys.stdin.readline().split())
        cost[si][ti] = di

    res = WarshallFloyd(N, cost)

    if res is None:
        print('NEGATIVE CYCLE')
    else:
        for i in range(N):
            print(*[res[i][j] if res[i][j] < inf else 'INF' for j in range(N)])


def WarshallFloyd(N, cost):
    dist = [[inf]*N for i in range(N)]

    for i in range(N):
        for j in range(N):
            dist[i][j] = cost[i][j]

    for k in range(N):
        for i in range(N):
            for j in range(N):
                if dist[i][k] < inf and dist[k][j] < inf:
                    dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])

    if any(dist[i][i] < 0 for i in range(N)):
        return None
    else:
        return dist

if __name__ == '__main__':
    solve()

Measured memory_bytes: 8596
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

using ll = long long;
template <ll MOD = 1000000007>
struct Mint{
    ll x;

    Mint() : x(0) {}
    Mint(ll t){
        x = t % MOD;
        if(x < 0) x += MOD;
    }
    
    Mint pow(ll n){
        Mint res(1), t(x);
        while(n > 0){
            if(n & 1) res *= t;
            t *= t;
            n >>= 1;
        }
        return res;
    }

    Mint inv() const {
        ll a = x, b = MOD, u = 1, v = 0, t;
        while(b > 0){
            t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        return Mint(u);
    }

    Mint & operator += (Mint a){
        x += a.x;
        if(x >= MOD) x -= MOD;
        return *this;
    }
    Mint & operator -= (Mint a){
        x += MOD - a.x;
        if(x >= MOD) x -= MOD;
        return *this;
    }
    Mint & operator *= (Mint a){
        x = 1LL * x * a.x % MOD;
        return *this;
    }
    Mint & operator /= (Mint a){
        return (*this) *= a.inv();
    }

    Mint operator + (Mint a) const { return Mint(x) += a; }
    Mint operator - (Mint a) const { return Mint(x) -= a; }
    Mint operator * (Mint a) const { return Mint(x) *= a; }
    Mint operator / (Mint a) const { return Mint(x) /= a; }

    Mint operator - () const{ return Mint(-x); }

    bool operator == (const Mint a){ return x == a.x; }
    bool operator != (const Mint a){ return x != a.x; }
    bool operator < (const Mint a){ return x < a.x; }

    friend ostream & operator << (ostream & os, const Mint &a){
        return os << a.x;
    }

    friend istream & operator >> (istream & is, Mint &a){
        ll t;
        is >> t;
        a = Mint<MOD>(t);
        return (is);
    }
};

template <typename T>
struct Comb{
    vector<T> fac, fin;

    Comb(int sz) : fac(sz + 1), fin(sz + 1){
        fac[0] = fin[sz] = T(1);
        for(int i = 1; i <= sz; i++){
            fac[i] = fac[i - 1] * T(i);
        }
        fin[sz] /= fac[sz];
        for(int i = sz - 1; i >= 0; i--){
            fin[i] = fin[i + 1] * T(i + 1);
        }
    }

    inline T fact(int k) const { return fac[k]; }
    inline T finv(int k) const { return fin[k]; }

    T P(int n, int k) const {
        if(k < 0 || n < k) return T(0);
        return fac[n] * fin[n - k];
    }

    T C(int n, int k) const {
        if(k < 0 || n < k) return T(0);
        return fac[n] * fin[n - k] * fin[k];
    }

    T H(int n, int k) const {
        if(n < 0 || k < 0) return T(0);
        return k == 0 ? T(1) : C(n + k - 1, k);
    }
};

signed main(){
    ll x,y;
    cin >> x >> y;
    ll sum = x + y;
    if(sum % 3 == 0 && sum / 3 <= x && x <= sum / 3 * 2 && sum / 3 <= y && y <= sum / 3 * 2){
        ll mn = min(x, y);
        Comb<Mint<MOD>> C(1e6);
        cout << C.C(sum / 3, mn - sum / 3) << endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 15872
#Counter
import collections
h, w = map(int, input().split())
a = []
for i in range(h):
    a.append(input())


palinmoji = ""
for i in range(h):
    palinmoji += a[i]

palinli = collections.Counter(palinmoji)

if h % 2 == 0 and w % 2 == 0:
    for i in palinli:
        if palinli[i] % 4 != 0:
            print("No")
            exit()
    print("Yes")
elif h % 2 == 0 and w % 2 != 0:
    cnt = 0
    for i in palinli:
        if palinli[i] % 4 != 0:
            if palinli[i] % 2 != 0:
                print("No")
                exit()
            if palinli[i] % 2 == 0:
                cnt += 1
            if cnt == h // 2 + 1:
                print("No")
                exit()
    print("Yes")
elif h % 2 != 0 and w % 2 == 0:
    cnt = 0
    for i in palinli:
        if palinli[i] % 4 != 0:
            if palinli[i] % 2 != 0:
                print("No")
                exit()
            if palinli[i] % 2 == 0:
                cnt += 1
            if cnt == w // 2 + 1:
                print("No")
                exit()
    print("Yes")
elif h % 2 != 0 and w % 2 != 0:
    cnt = 0
    onecnt = 0
    for i in palinli:
        if palinli[i] % 4 != 0:
            if palinli[i] % 2 != 0:
                onecnt += 1
                if (palinli[i] - 1) % 4 != 0 and onecnt == 1:
                    cnt += 1
                    pass
                elif onecnt == 2:
                    print("No")
                    exit()
            if palinli[i] % 2 == 0:
                cnt += 1
    if cnt >= h // 2 + w // 2 + 1:
        print("No")
        exit()
    print("Yes")

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

typedef long long ll;
typedef vector<int> vi;

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

    //freopen("E:\\Codes\\Problem\\C++\\AAA.txt", "r", stdin);
    //freopen("C:\\Users\\Dell\\Desktop\\Problem\\BBB.txt", "w", stdout);
    
    int a,b;
    cin>>a>>b;

    if(a<= 8 && b<= 8){
        cout<<"Yay!";
        return 0;
    }
    cout<<":(";
    
    
     
}

Measured memory_bytes: 3580
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main()
{
	for(int p,q;cin>>p>>q;){
		//dump(p);
		//dump(q);
		if(p%q==0){
			cout<<"0"<<endl;
			continue;
		}
		p%=q;
		map<int,int> m;
		string res;
		int loop=-1;
		for(int i=0;p;i++){
			p*=10;
			int div=p/q;
			int mod=p%q;
			//printf("# %d %d %d\n",p,div,mod);
			if(m.count(mod)){
				loop=m[mod];
				if(res[loop]!='0'+div){
					res+='0'+div;
					loop++;
				}
				break;
			}
			else
				m[mod]=i;
			res+='0'+div;
			p%=q;
		}
		//dump(loop);
		cout<<res<<endl;
		if(loop!=-1)
			cout<<string(loop,' ')<<string(res.size()-loop,'^')<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define ll  long long 
#define ull unsigned long long int
#define boost ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL)
#define vi vector<int>
#define P push_back
#define F first
#define S second
#define debug(x) cout<<x<<" "
#define pi vector<pair<int,int> >
#define all(a) a.begin(),a.end()
#define int ll
using namespace std;
using namespace __gnu_pbds;
typedef tree <int, null_type,less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
ll const mod=1e9+7;
int powi(int i,int b){
    int res=1;
    while(b){
        if(b&1)res*=i,res%=mod;
        b>>=1;
        i*=i;
        i%=mod;
    }
    return res;
}
// map<int,int> m;
// ll fact(int n){
// 	//if(n==0)return 0;
// 	if(n<=1)return 1;
// 	if(m[n]!=0)return m[n];
// 	return m[n]=(n*fact(n-1))%mod;
//}
// int ncr(int n,int r){
//     int h=fact(n);
//     int v=fact(r);
//     int j=fact(n-r);
//     v*=j;
//     v%=mod;
//     v=powi(v,mod-2);
//     return (h*v)%mod;
// }
// vi ar(2000000);
// vi sz(2000000);
// int root(int a){
//     if(ar[a]==a)return a;
//     return ar[a]=root(ar[a]);
// }
// int merge(int a,int b){
//     int h=root(a),j=root(b);
//     int ans=sz[h]*sz[j];
//     sz[j]+=sz[h];
//     if(h!=j){
//         ar[h]=j;
//     }
//     return ans;
// } 
void solve(){
    int n,r;
    cin>>n>>r;
    if(n>=10){
        cout<<r<<"\n";return;
    }else{
        int ans=r+100*(10-n);
        cout<<ans;
    }
}
signed main(){
    boost;
    int t=1;
    //cin>>t;
    for(int _=1;_<=t;_++){
        //cout<<"Case #"<<_<<": ";
        solve();
        cout<<"\n";
    }
    
    return 0;
}

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

int main() {
  long int N,M,a,b,ans=0;
  using pii = pair<int64_t,int64_t>;
  pii ab;
  cin >> N >> M;
  vector<bool> vec(N+1);
  vector<long int> H(N);
  vec.assign(N+1,1);
  for(int i=0;i<N;i++) cin >> H.at(i);

  for(int i=0;i<M;i++){
    cin >> ab.first >> ab.second;
    tie(a,b)=ab;

    if(H.at(a-1) > H.at(b-1)) vec.at(b) = 0;
    else if(H.at(a-1) < H.at(b-1)) vec.at(a) = 0;
    else{
      vec.at(a) = 0;
      vec.at(b) = 0;
    }
  }

  for(int i=1;i<=N;i++){
    if(vec.at(i)) ans++;
  }

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

Measured memory_bytes: 4052
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int n, i, j, h[100002], a[100002] =  {0}, k;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    cin >> n >> k;
    for(i = 0; i < n; i++) {
    	cin >> h[i];
    }

    for(i = 1; i < n; i++) {
    	int mx = 1e9 + 1;
    	for(j = max(0, i - k); j < i; j++) {
    		mx = min(mx, a[j] + abs(h[j] - h[i]));
    	}
    	a[i] = mx;
    }
    cout << a[n - 1] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ms(i, j) memset(i, j, sizeof i)
#define LL long long
#define db double
//atcoder only 
#define rd(a) scanf("%d", &a)
#define rd2(a, b) scanf("%d%d", &a, &b)
#define pty printf("YES\n")
#define ptn printf("NO\n")
#define pt printf
using namespace std;
int n, a[100000 + 5];
void clean() {
}
void solve() {
	clean();
	int ans = 0;
	for (int i = 1; i <= n; i++) rd(a[i]);
	for (int i = 1; i <= n; i++) {
		if (i != a[i]) continue;
		if (i == n) {ans++; break;}
		swap(a[i], a[i + 1]);
		ans++;
	}	
	pt("%d\n", ans);
}
int main() {
	rd(n), solve();
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
queue<long long> q;
vector<long long> ans;
long long n,m,i,j,k,l,p,o,s;
int main()
{
    for(i=1;i<=9;i++)
    q.push(i);
    while(ans.size()<111111)
    {
        n=q.front();
        ans.push_back(n);
        q.pop();
        m=n%10;
        if(m>0) q.push(n*10+m-1);
        if(m<9) q.push(n*10+m+1);
        q.push(n*10+m);
    }
    sort(ans.begin(),ans.end());
	cin>>k;
    cout<<ans[k-1];
    return 0;
}

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

int main(void)
{
	int num,i;
	int tmp;
	int min=1000000,max=-1000000;
	long long sum = 0;
	
		cin >> num;
	
	for(i = 0; i < num; i++)
	{
		cin >> tmp;
		
		if(tmp < min)
		{
			min = tmp;
		}
		if(max < tmp)
		{
			max = tmp;
		}
		sum += tmp;
	}
	cout << min << " " << max << " " << sum << endl;
	
	return 0;
}


Measured memory_bytes: 3096
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<complex.h>
#include<utility>
using namespace std;

typedef long long int ll;

int main(){


    ll a,b,c,k,ans;
    cin >> a >> b >> c >> k;
    if(k%2 == 0){
        ans = a-b;
    }else{
        ans = b-a;
    }
    if(ans> 1000000000000000000){
        cout << "Unfair" << endl;
    }else{
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn=100005;
bool vis[maxn];
int main(int argc, char const *argv[])
{
	ios::sync_with_stdio(false);
	int n;
	while(cin>>n){
		int a;
		map<int,int>mii;
		for(int i=0;i<n;i++){
			cin>>a;
			mii[a]++;
		}
		int ans=0;
		for(auto ite:mii){
			if(ite.second&1){
				ans++;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

ll gcd(ll a, ll b) {
    if (b == 0) return a;

    return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
    return (a * b) / gcd(a, b);
}

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

    cout << lcm(a, b) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int a, b, c, i, j, k;
	k = 0;

	scanf("%d %d %d", &a, &b, &c);

	if ((1 <= a) && (1 <= b) && (1 <= c) && (a <= 10000) && (b <= 10000) && (c <= 10000) && (a <= b))
	{
		for (i = a;i <= b; i = i + 1)
		{
			j = c % i;
			if (j == 0)
			{
				k = k + 1;
			}
		}
	}
	printf("%d\n",k);
	return 0;
}

Measured memory_bytes: 596
# include <bits/stdc++.h>
using namespace std;
string a;
int main()
{
    cin>>a;
    for(register int i=0;i<a.length();i++)
        if(a[i]=='C')
            for(register int j=i+1;j<a.length();j++)
                if(a[j]=='F')
                {
                    cout<<"Yes";
                    return 0;
                }
    cout<<"No";            
    return 0;            
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
//一点更新区間取得
#include<vector>
#include<functional>
#include<limits>
template<typename T>
struct segtree{
	function<T(T,T)>calcfn,updatefn;
	int n;
	T defvalue;
	vector<T>dat;
	segtree(int n_=0,T defvalue_=numeric_limits<T>::max(),
		function<T(T,T)>calcfn_=[](T a,T b){return a.second<b.second?b:a.second>b.second?a:a.first<b.first?a:b;},
		function<T(T,T)>updatefn_=[](T a,T b){return make_pair(b.first,a.second+b.second);}
	):defvalue(defvalue_),calcfn(calcfn_),updatefn(updatefn_)
	{
		n=1;
		while(n<n_)n<<=1;
		dat.assign(2*n-1,defvalue);
	}
	void copy(const vector<T>&v)
	{
		for(int i=0;i<v.size();i++)dat[i+n-1]=v[i];
		for(int i=n-2;i>=0;i--)dat[i]=calcfn(dat[i*2+1],dat[i*2+2]);
	}
	void update(int i,T a)
	{
		i+=n-1;
		dat[i]=updatefn(dat[i],a);
		while(i>0)
		{
			i=(i-1)/2;
			dat[i]=calcfn(dat[2*i+1],dat[2*i+2]);
		}
	}
	T query(int a,int b,int i=0,int l=0,int r=-1)//[a,b)
	{
		if(r<0)r=n;
		if(r<=a||b<=l)return defvalue;
		else if(a<=l&&r<=b)return dat[i];
		else
		{
			return calcfn(
				query(a,b,i*2+1,l,(l+r)/2),
				query(a,b,i*2+2,(l+r)/2,r)
			);
		}
	}
};
main()
{
    int n,q;cin>>n>>q;
    segtree<pair<int,int> >P(n+1,make_pair(0,0));
    for(int i=1;i<=n;i++)P.update(i,make_pair(i,0));
    for(;q--;)
    {
        int a,b;cin>>a>>b;
        P.update(a,make_pair(a,b));
        pair<int,int>p=P.query(1,n+1);
        cout<<p.first<<" "<<p.second<<endl;
    }
}


Measured memory_bytes: 19196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll fastpow(ll a,ll b,ll mod){
    ll ans=1;
    while (b){
        if(b&1) ans=(ans*a)%mod;b>>=1;a=(a*a)%mod;
    }return ans;
}
ll C(ll n,ll m,ll mod){
    if(n<m) return  0;
    if(m>n-m) m=n-m;ll a=1,b=1;
    for(int i=0;i<m;i++){
        a=(a*(n-i))%mod;
        b=(b*(i+1))%mod;
    }
    return  a*fastpow(b,mod-2,mod)%mod;
}
ll lucas(ll n,ll m,ll mod){
    if(m==0) return  1;
    return lucas(n/mod,m/mod,mod)*C(n%mod,m%mod,mod)%mod;
}
int main(){
    ll n,a,b,m,mod=1e9+7;
    cin>>n>>a>>b;
    cout<<((fastpow(2,n,mod)-lucas(n,a,mod)-lucas(n,b,mod)-1)%mod+mod)%mod<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountl
#define m_p make_pair
#define inf 1000000000000000000
#define MAXN 1000001
#define eps 0.0000000001
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T>//usage rand<long long>()
T rand() {
    return uniform_int_distribution<T>()(rng);
}

// string to integer stuuu()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

//////////////

#define S second
#define F first
// #define int long long  

//////////

signed main()
{
	fastio;
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;++i)
		cin>>a[i];
	int ma=0;
	int ans=0;
	for(int i=0;i<n;++i)
		if(a[i]>=ma)
		{
			ans++;
			ma=a[i];
		}
	cout<<ans;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <ctime>

#define Rep(i, n) for (int i = 1; i <= n; i ++)
#define Rep0(i, n) for (int i = 0; i <= n; i ++)
#define RepG(i, x) for (int i = head[x]; i; i = edge[i].next)
#define v edge[i].to
#define mp(a, b) make_pair(a, b)

using namespace std;
const int N = 100010;
struct Edge{ int to, next;} edge[N * 2];
int head[N], num;
void add_edge(int a, int b) { edge[++ num] = (Edge){b, head[a]}, head[a] = num;}
int dfs(int x, int f)
{
	int ret = 0;
	RepG(i, x) if (v != f)
		ret ^= (dfs(v, x) + 1);
	return ret;
}

int main()
{
	int n;
	scanf("%d", &n);
	Rep(i, n - 1) {
		int x, y;
		scanf("%d%d", &x, &y);
		add_edge(x, y); add_edge(y, x);
	}
	
	if (dfs(1, 0)) printf("Alice\n");
	else printf("Bob\n");
	
	return 0;
}

Measured memory_bytes: 6784
// https://atcoder.jp/contests/abc112/tasks/abc112_c
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

#define FOR(i, n) for (int i = 0; i < (n); i++)
#define EACH(i, n) for (auto &i: n)

int64_t check(vector<int64_t> x, vector<int64_t> y, vector<int64_t> h, int64_t cx, int64_t cy) {
  int64_t hh =  0;
  FOR (i, h.size()) {
    if (h[i] == 0) {
      continue;
    }
    hh = h[i] + abs(x[i] - cx) + abs(y[i] - cy);
    break;
  }
  for (int i = 0; i < h.size(); i++) {
    int64_t t = max(hh - abs(x[i] - cx) - abs(y[i] - cy), (int64_t)0);
    if (t != h[i]) {
      return -1;
    }
  }
  return hh;
}

void solv(int n) {
  vector<int64_t> x(n), y(n), h(n);

  FOR(i, n) {
    cin >> x[i] >> y[i] >> h[i];
  }
  FOR(cx, 101) {
    FOR(cy, 101) {
      int64_t ans = check(x, y, h, cx, cy);
      if (ans != -1) {
        cout << cx << " " << cy << " " << ans << endl;
        return;
      }
    }
  }
}

int main() {
  int n;

  while (cin >> n) {
    solv(n);
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
////////////////////
template< typename T>
struct SparseTable{
    vector<vector<T> > st;
    vector<int> lookup;
    ll op(ll a,ll b){
        //max , min or etc...
        return gcd(a,b);
    }
 
    SparseTable(const vector<T> &v){
        int b=0;
        while((1<<b)<=v.size()) b++;
        //resize  st[k][i]:iの2^k先までの範囲の
        st.assign(b,vector<T>(1<<b));
        for(int i=0;i<v.size();i++) st[0][i]=v[i];
        for(int i=1;i<b;i++){
            for(int j=0;j+(1<<i)<=(1<<b);j++){
                st[i][j]=op(st[i-1][j],st[i-1][j+(1<<(i-1))]);
            }
        }
        lookup.resize(v.size()+1);
        for(int i=2;i<lookup.size();i++){
            lookup[i]=lookup[i>>1]+1;
        }
    }
    //[)
    T f(int l,int r){
        assert(l<=r);
        //a[l~l+2^k],a[r-2^k~r]が区間を覆うように
        int b=lookup[r-l];
        return op(st[b][l],st[b][r-(1<<b)]);
    }
};
//////////////

//gcdは冪等性が成り立つのでSparseTable適用可能
int main(){
    int n;
    cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    SparseTable<ll> sp(a);
    ll ans=0;
    rep(i,n){
        ll tmp;
        if(i==0) tmp=sp.f(1,n);
        else if(i==n-1) tmp=sp.f(0,n-1);
        else tmp=gcd(sp.f(0,i),sp.f(i+1,n));
        ans=max(ans,tmp);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 19584
import math

isPrime = [True] * 110001
primes = [];
def eratos(n):
    isPrime[0] = isPrime[1] = False
    for i in range(2,int(math.sqrt(n))):
        if isPrime[i]:
            j = 2 * i
            while j <= n:
                isPrime[j] = False
                j = j + i
    for i in range(2,110000):
        if isPrime[i]:
            primes.append(i)
eratos(110000)

while True:
    try:
        p = int(input())
        if p == 0:
            break
        ans = 0
        for i in range(0,p):
            ans += primes[i]
        print(ans)
    except:
        break


Measured memory_bytes: 6696
#include<bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define pb push_back

using namespace std;

double n,m,a[105],sum,ans;

int main()
{
    cin >> n >> m;
    for (int i=0;i<n;i++)
    {
        cin >> a[i];
        sum+=a[i];
    }
    double val=(sum/(4.0*m));
    for (int i=0;i<n;i++)
    {
        if (a[i]>=val)ans++;
    }
    if (ans>=m)cout << "Yes\n";
    else cout << "No\n";
}


Measured memory_bytes: 256
from itertools import*
from math import*
from collections import*
from heapq import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = float("inf")
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)

N = int(input())
#N = k(k-1)//2を満たすkが存在するかをまず判定
k = ceil(sqrt(2*N))
if k*(k-1) != 2*N:
    print("No")
    exit()
print("Yes")
print(k)
#crossing pairを構成する(1からNまで各２個ずつ別々に含まれるように配置)
S = [[]for _ in range(k+1)]
num = 1
for i in range(1,k):
    for j in range(i+1,k+1):
        S[i].append(num)
        S[j].append(num)
        num +=1
for i in range(1,k+1):
    print(k-1," ".join(map(str,S[i])))

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

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

ll n,a,b; 
vll h;

bool isOk(ll m){
  ll cnt=0;
  rep(i,n){
    ll x = (h[i]-m*b);
    if(x<=0) continue;
    cnt+=(x+(a-b-1))/(a-b);
  }
  if(cnt<=m) return true;
  else return false;
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  cin>>n>>a>>b;
  h.resize(n);
  rep(i,n) cin>>h[i];
  
  ll ok=1e9, ng=0;
  while(abs(ok-ng)>1){
    ll m=(ok+ng)/2;
    if(isOk(m)) ok=m;
    else ng=m;
  }
  cout<<ok<<endl;
}

Measured memory_bytes: 1024
import java.util.*;

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

        String str = sc.next();

        if(str.charAt(2) == str.charAt(3) &&
        str.charAt(4) == str.charAt(5)){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 22740
#include <stdio.h>
#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1<<17, stdin), p1 == p2) ? EOF : *p1++)
char buf[(1 << 17)], *p1 = buf, *p2 = buf;
inline int read() {
    char c = getchar(); int x = 0, f = 1;
    while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}
int ab[(1<<17)];
int main(int argc, char *argv[])
{
	int n = read(),m = read();
	for (int i = 0; i < m; ++i) {
		int a = read(),b = read();
		if (*(ab+b) < a) {*(ab+b) = a;}
	}
	int ans = 0;
	int k = 1;
	for (int i = 1; i <= n; ++i) {
		if (k <= *(ab+i)) {
			k = i;
			++ans;
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main() {
  int x, a, b;
  cin >> x >> a >> b;
  int dis1 = abs(x - a);
  int dis2 = abs(x - b);

  if (dis1 < dis2) {
    cout << "A" << endl;
  } else {
    cout << "B" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
def l(): return list(map(int, input().split()))
def m(): return map(int, input().split())

def main():
  c = [0]*3
  for i in range(3):
    c[i] = l()
  # for i in range(2):
  #   x = c[2][i+1] - c[2][i]
  #   for j in range(2):
  #     if c[j][i+1] - c[j][i] != x:
  #       print('No')
  #       exit()
  # print('Yes')

  a = [0]*3
  b = [0]*3
  b[0] = min(c[0])
  for i in range(3):
    a[i] = c[0][i] - b[0]
  for i in range(1,3):
    b[i] = c[i][0] - a[0]
  # print(a,b)
  for i in range(3):
    for j in range(3):
      if c[i][j] != a[j] + b[i]:
        print('No')
        exit()
  print('Yes')

  
if __name__ == '__main__':
  main()

Measured memory_bytes: 3064
pub fn read_parameters<T>() -> Result<Vec<T>, String>
where
    T: std::str::FromStr,
{
    let mut line = String::new();
    std::io::stdin()
        .read_line(&mut line)
        .map_err(|err| format!("{:?}", err))?;

    let xs = line.trim().split_whitespace();
    let mut result = Vec::new();

    for x in xs {
        let ans = x.parse::<T>().map_err(|_| format!("{}", "parse error"))?;
        result.push(ans);
    }
    Ok(result)
}

fn main() {
    let n = read_parameters::<usize>().unwrap();
    let n = n[0];

    let mut i = 1;
    loop {
        let mut x = i;
        if x % 3 == 0 {
            print!(" {}", i);
            i += 1;
            if i <= n {
                continue;
            } else {
                break;
            }
        }

        loop {
            if x % 10 == 3 {
                print!(" {}", i);
                break;
            }
            x /= 10;
            if x != 0 {
                continue;
            } else {
                break;
            }
        }
        i += 1;
        if i <= n {
            continue;
        } else {
            break;
        }
    }
    println!("");
}



Measured memory_bytes: 5036
#include<bits/stdc++.h>
#define INF 1<<30
#define MAX 100005
#define ll long long
#define speed ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
using namespace std;
int main()
{
    speed;
    ll N;
    cin>>N;
    ll A[N+1],B[N+1],C[N+1];
    ll AA[N+1],AB[N+1],AC[N+1];
    for(ll i=0;i<N;i++) cin>>A[i]>>B[i]>>C[i];
    AA[0]=A[0],AB[0]=B[0],AC[0]=C[0];
    for(ll i=1;i<N;i++){
        AA[i]=max(AB[i-1],AC[i-1])+A[i];
        AB[i]=max(AC[i-1],AA[i-1])+B[i];
        AC[i]=max(AA[i-1],AB[i-1])+C[i];
    }
    cout<<max(AA[N-1],max(AB[N-1],AC[N-1]));
}


Measured memory_bytes: 4992