akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define meow(args...) fprintf(stderr, args)
typedef unsigned u32;
typedef long long s64;
typedef unsigned long long u64;
template<class T1, class T2> inline bool cmin(T1 &a, const T2 &b) {return b<a?(a=b, true):false;}
template<class T1, class T2> inline bool cmax(T1 &a, const T2 &b) {return a<b?(a=b, true):false;}
template<class Type> Type read() {
	Type a;
	bool b;
	unsigned char c;
	while(c=getchar()-48, (c>9)&(c!=253));
	for(a=(b=c==253)?0:c; (c=getchar()-48)<=9; a=a*10+c);
	return b?-a:a;
}
int (*rd)()=read<int>;
const u32 P=1e9+7;
u32 &inc(u32 &a, u32 b) {return (a+=b)<P?a:(a-=P);}
u32 &dec(u32 &a, u32 b) {return (a-=b)&0x80000000?(a+=P):a;}
u32 sum(u32 a, u32 b) {return inc(a, b);}
u32 dif(u32 a, u32 b) {return dec(a, b);}
u64 power(u64 a, int b) {
	u64 ans=1;
	for(; b; a=a*a%P, b/=2) if(b&1) ans=ans*a%P;
	return ans;
}

const int N=5005;
int n, size[N];
u32 tot[N], f[N][N];
std::vector<int> e[N];
void dfs(int u, int pa) {
	auto F=f[u];
	F[1]=1;
	size[u]=1;
	for(int v: e[u]) if(v!=pa) {
		dfs(v, u);
		auto G=f[v];
		for(int i=size[u]; i>=0; --i) {
			for(int j=1; j<=size[v]; ++j) F[i+j]=(F[i+j]+(u64)F[i]*G[j])%P;
			F[i]=(u64)F[i]*G[0]%P;
		}
		size[u]+=size[v];
	}
	for(int i=2; i<=size[u]; i+=2) F[0]=(F[0]+(u64)(P-F[i])*tot[i])%P;
}
int main() {
	n=rd();
	tot[2]=1;
	for(int i=4; i<=n; i+=2) tot[i]=tot[i-2]*(i-1llu)%P;
	for(int i=1; i<n; ++i) {
		int u=rd(), v=rd();
		e[u].push_back(v);
		e[v].push_back(u);
	}
	dfs(1, 0);
	printf("%u\n", dif(0, f[1][0]));
	return 0;
}


Measured memory_bytes: 97280
import Control.Applicative
import Control.Monad
import Text.Printf


type Process = (String, Int)

roundRobin :: Int -> Int -> [Process] -> [Process] -> [Process] -> [Process]
roundRobin q t [] []  ys = reverse ys
roundRobin q t [] xs' ys = roundRobin q t (reverse xs') [] ys
roundRobin q t ((name, time) : xs) xs' ys
  | time <= q = roundRobin q (t + time) xs xs' ((name, t + time) : ys)
  | otherwise = roundRobin q (t + q) xs ((name, time - q) : xs') ys

main :: IO ()
main = do
  [n, q] <- map read . words <$> getLine
  xs <- map (toTuple . words) <$> replicateM n getLine
  let ys = roundRobin q 0 xs [] []
  mapM_ (\(name, time) -> printf "%s %d\n" name time) ys
    where toTuple [n, t] = (n, read t)



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

// Shrotening
#define fst first
#define snd second
#define pb push_back

// Loop
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define RFOR(i,a,b) for(long i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

typedef std::pair<int,int> PII;

int A, B;
std::string S;
int main() {
    std::cin >> A >> B;
    std::cin >> S;

    int cnt = 0;
    REP(i, A+B+1) {
        if(S[i] >= '0' && S[i] <= '9') continue;
        else if(S[i] == '-') {
            cnt++;
        }else{
            std::cout << "No" << std::endl;
            return 0;
        }
    }

    if(cnt == 1 && S[A] == '-') {
        std::cout << "Yes" << std::endl;
    }
    else {
        std::cout << "No" << std::endl;
    }
}

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

using namespace std;

#define MAX 110
#define INF 1e9
typedef pair<int,int> pii;
typedef pair<pii,int> State;

struct Edge{
  int to,cost;
  Edge(int to,int cost) : to(to),cost(cost) {}
};

int V,E;
vector<Edge> G[MAX];

int dijkstra(){
  priority_queue<State,vector<State>,greater<State> > Q;
  Q.push(State(pii(0,0),0));
  int dp[MAX][2];
  fill(dp[0],dp[0]+MAX*2,INF);
  dp[0][0] = 0;

  while(!Q.empty()){
    State p = Q.top(); Q.pop();
    int v = p.first.second,s = p.second;

    if(dp[v][s] < p.first.first) continue;

    for(int i = 0 ; i < (int)G[v].size() ; i++){
      if(dp[v][s] + G[v][i].cost < dp[G[v][i].to][s]){
        dp[G[v][i].to][s] = dp[v][s] + G[v][i].cost;
        Q.push(State(pii(dp[G[v][i].to][s],G[v][i].to),s));
      }
      if(s) continue;
      int d = G[v][i].to;
      for(int j = 0 ; j < (int)G[d].size() ; j++){
        if(dp[v][0] < dp[G[d][j].to][1]){
          dp[G[d][j].to][1] = dp[v][0];
          Q.push(State(pii(dp[G[d][j].to][1],G[d][j].to),1));
        }
      }
    }
  }
  return min(dp[V-1][0],dp[V-1][1]);
}

int main(){
  int a,b,c;
  while(cin >> V >> E, V){
    for(int i = 0 ; i < V ; i++){
      G[i].clear();
    }
    for(int i = 0 ; i < E ; i++){
      cin >> a >> b >> c;
      a--, b--;
      G[a].push_back(Edge(b,c));
      G[b].push_back(Edge(a,c));
    }
    cout << dijkstra() << endl;
  }
  return 0;
}

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

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

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

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

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

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

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

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

fn main(){

    input!{
        k: usize,
    }

    let mut seven = 7;
    let mut cnt = 0;
    while cnt<=k {
        cnt += 1;
        seven %= k;
        if k%2==0 {
            println!("-1");
            return;
        }
        if seven==0{
            println!("{}", cnt);
            return;
        }
        seven = 7 + (seven*10)%k;
        //println!("{}", seven);
    }

    println!("-1");

}

Measured memory_bytes: 2104
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

class Main implements Runnable {
	public static void main(String[] args) {
		new Thread(null, new Main(), "", Runtime.getRuntime().maxMemory()).start();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		int n = sc.nextInt();
		String s = sc.next();
		for (int i = 0; i < mem.length; ++i) {
			for (int j = 0; j < mem[i].length; ++j) {
				mem[i][j] = "";
			}
		}
		System.out.println(f(0, s.length(), s));
	}

	String[][] mem = new String[101][101];

	// [s,t)
	String f(int s, int t, String S) {
		if (t - s == 1) {
			return "()";
		} else if (t - s < 1) {
			return "";
		}
		if (!mem[s][t].equals("")) {
			return mem[s][t];
		}
		String ans = "";
		for (int m = s + 1; m < t; ++m) {
			// [s,m),[m,t)に分割
			ans = next(ans, f(s, m, S) + f(m, t, S));
		}
		if (S.charAt(s) == '(' && S.charAt(t - 1) == ')') {
			ans = next(ans, "(" + f(s + 1, t - 1, S) + ")");
		} else {
			if (S.charAt(s) == '(')
				ans = next(ans, "(" + f(s + 1, t, S) + ")");
			if (S.charAt(t - 1) == ')') {
				ans = next(ans, "(" + f(s, t - 1, S) + ")");
			}
		}
		return mem[s][t] = ans;
	}

	String next(String cur, String ns) {
		if (cur.equals("") || cur.length() > ns.length() || (cur.length() == ns.length() && cur.compareTo(ns) > 0)) {
			return ns;
		} else {
			return cur;
		}
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}

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

int main() {
  int n;
  cin >> n;
  string s;
  vector<LL> initial(5);
  for (int i = 0; i < n; i ++) {
    cin >> s;
    if (s.at(0) == 'M') initial.at(0) ++;
    else if (s.at(0) == 'A') initial.at(1) ++;
    else if (s.at(0) == 'R') initial.at(2) ++;
    else if (s.at(0) == 'C') initial.at(3) ++;
    else if (s.at(0) == 'H') initial.at(4) ++;
  }

  LL ans = 0;
  int P[10] = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2};
  int Q[10] = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3};
  int R[10] = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4};
  for (int i = 0; i < 10; i ++) {
    ans += initial.at(P[i]) * initial.at(Q[i]) * initial.at(R[i]);
  }

  cout << ans << endl;
}


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

long long fn(long long mh,long long nm){
	if(nm < 2)
	{
		return 0;
	}
	long long sa = mh - nm;
	long long rt=sa;
	if(nm == 2)
	{
		return rt;
	}
	return rt *nm*(nm-1)/2 + nm*(nm-1)*(nm-2)/6;
}

int main() {
	int n;
	cin >> n;
	int m=0,a=0,r=0,c=0,h=0;
	for(int i=0;i<n;i++)
	{
		string s;
		cin >> s;
		char s1 = s.at(0);
		if(s1 == 'M')
		{
			m++;
		}
		else if(s1 == 'A')
		{
			a++;
		}
		else if(s1 == 'R')
		{
			r++;
		}
		else if(s1 == 'C')
		{
			c++;
		}
		else if(s1 == 'H')
		{
			h++;
		}
	}
	long long ans=0;
	long long mh = m + a + r + c + h;
	long long cm = mh*(mh-1)*(mh-2)/6;
	ans = cm - fn(mh,m) - fn(mh,a) - fn(mh,r) - fn(mh,c) - fn(mh,h);
	if(m*a*r==0&&m*a*c==0&&m*a*h==0&&m*r*c==0&&m*r*h==0&&m*c*h==0&&a*r*c==0&&a*r*h==0&&a*c*h==0&&c*h*r==0)
	{
		ans = 0;
	}
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
// atcoder/diverta2019-2/C/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

vector<pair<lli, lli>> path;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  while (cin >> n) {
    path.clear();
    vector<lli> a(n);
    cin >> a;
    sort(a.begin(), a.end());

    if (n == 1) {
      cout << a[0] << endl;
      continue;
    }
    if (n == 2) {
      cout << a[1] - a[0] << endl;
      cout << a[1] << ' ' << a[0] << endl;
      continue;
    }

    vector<lli> pos, neg;
    each (i, a) {
      if (0 <= i) pos.push_back(i);
      else neg.push_back(i);
    }

    if (neg.empty()) {
      path.push_back({pos.front(), pos.back()});
      neg.push_back(pos.front() - pos.back());
      pos.pop_back();
      pos.erase(pos.begin());
    } else if (pos.empty()) {
      path.push_back({neg.back(), neg.front()});
      pos.push_back(neg.back() - neg.front());
      neg.pop_back();
      neg.erase(neg.begin());
    }

    while (1 < pos.size()) {
      lli x = pos.back();
      lli y = neg.back();
      pos.pop_back();
      neg.pop_back();
      path.push_back({y, x});
      neg.push_back(y - x);
    }

    while (neg.size()) {
      lli x = pos.back();
      lli y = neg.back();
      pos.pop_back();
      neg.pop_back();
      path.push_back({x, y});
      pos.push_back(x - y);
    }

    cout << pos.front() << endl;
    each (i, path) cout << i.first << ' ' << i.second << endl;
    // cout << endl;
  }

  return 0;
}


Measured memory_bytes: 6000
#include<iostream>
#include<string>
#define REP(i,n) for(int i = 0; i < n; i++)
using namespace std;

int main(){
    string s;
    cin >> s;
    int ans = 0;
    REP(i,3){
        if(s[i] == '1') ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
use itertools::Itertools;
use proconio::input;

fn main() {
    input!(n: usize, k: usize, a: [i64; n]);

    let ans = solve(n, k, a)
        .iter()
        .fold(1, |acc, &a| (acc * a).rem_euclid(1_000_000_007));

    println!("{}", ans)
}

fn solve(n: usize, k: usize, a: Vec<i64>) -> Vec<i64> {
    if n == k {
        return a;
    }

    let (pos, neg): (Vec<_>, _) = a
        .iter()
        .sorted_by(|a, b| b.abs().cmp(&a.abs()))
        .partition(|&&a| a >= 0);
    let (mut pos, mut neg) = (&pos[..], &neg[..]);

    if pos.len() == 0 && k % 2 == 1 {
        return neg.iter().copied().skip(n - k).collect_vec();
    }

    let mut rest = k;
    let mut ret = Vec::new();
    while rest > 0 {
        let push_pos = if pos.len() >= 2 && neg.len() >= 2 {
            pos[0] * pos[1] >= neg[0] * neg[1]
        } else {
            neg.len() < 2
        };

        if push_pos || rest == 1 {
            ret.push(pos[0]);
            pos = &pos[1..];
            rest -= 1;
        } else {
            ret.extend(&neg[..2]);
            neg = &neg[2..];
            rest -= 2;
        }
    }

    ret
}


Measured memory_bytes: 10328
import java.util.*;


public class Main {

    public static void main(String[] args) {
      Scanner reader=new Scanner(System.in);
      int n=reader.nextInt();
      int a[]=new int [n];
      boolean ans=true;
      for(int i=0;i<n;i++)
      {
        a[i]=reader.nextInt();
        if(a[i]%2==0){

        if(!(a[i]%5==0||a[i]%3==0))
      {
          System.out.println("DENIED");
          return;

      }
    }
  }
      System.out.println("APPROVED");




}
}

Measured memory_bytes: 23764
#include <iostream>
using namespace std;
typedef long long ll;
int main() {
  ios::sync_with_stdio(false);
  ll N, K;
  cin >> N >> K;
  ll ret = 0;
  ll MOD = 1000000007LL;
  for (ll i=K; i<=N+1; i++) {
    ret += i * N - i * (i-1) + 1;
    ret %= MOD;
  }
  cout << ret << endl;
}

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

int main() {
  int n, m, l;
  cin >> n >> m >> l;
  vector<vector<int> > A(n, vector<int>(m, 0));
  vector<vector<int> > B(m, vector<int>(l, 0));
  vector<vector<long long> > C(n, vector<long long>(l, 0));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      cin >> A.at(i).at(j);
    }
  }
  for (int i = 0; i < m; ++i) {
    for (int j = 0; j < l; ++j) {
      cin >> B.at(i).at(j);
    }
  }

  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < l; ++j) {
      for (int k = 0; k < m; ++k) {
        C.at(i).at(j) += A.at(i).at(k) * B.at(k).at(j);
      }
    }
  }

  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < l; ++j) {
      cout << C.at(i).at(j);
      if (j == l - 1) cout << endl;
      else cout << " ";
    }
  }

  return 0;
}


Measured memory_bytes: 3268
#include <bits/stdc++.h>
using namespace std;
const int maxn = 105;
int n,sum;
int a[maxn];
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(i==j)
                continue;
            sum+=a[i]*a[j];
        }
    }
    cout<<sum/2<<endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

long lcm(long c, long d){
    long od = d;
    long oc = c;
    long t;
    if(c < d) {
        t = c;
        c = d;
        d = t;
    }

    long r;
    while(true){
        r = c % d;
        if(r == 0) break;
        c = d;
        d = r;
    }

    return oc * od / d; 
    
}

int main(){
    long A, B ,C, D;
    cin >> A >> B >> C >> D;

    long b = B - B/C -B/D + B/lcm(C, D);
    long a = (A-1) - (A-1)/C - (A-1)/D + (A-1)/lcm(C, D);

    cout << b - a;
 
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <set>
using namespace std;
int main(void){
    int n, m, bef = -1;
    long long ans = 0;
    string s, t;
    set<int> alp[26];
    cin >> s >> t;
    n = s.length();
    m = t.length();
    for(int i=0;i<n;i++){
        int c = s[i] - 'a';
        alp[c].insert(i);
    }
    for(int i=0;i<m;i++){
        int c = t[i] - 'a';
        auto itr = alp[c].upper_bound(bef);
        if(itr == alp[c].end()){
            itr = alp[c].begin();
            if(itr == alp[c].end()){
                cout << -1 << endl;
                return 0;
            }
            ans += n;
            bef = *(itr);
        }else{
            bef = *(itr);
        }
        //cout << ans << " " << bef << endl;
    }
    cout << ans + bef + 1 << endl;
}


Measured memory_bytes: 5120
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void){
  int N, M, A, B, ans = 0;
  cin >> N >> M;
  vector<long long> H(N, 0);
  vector<long long> maxHigh(N, 0);
  for(int i=0; i<N; i++){
    cin >> H[i];
  }
  for(int i=0; i<M; i++){
    cin >> A >> B;
    maxHigh[A - 1] = max(maxHigh[A - 1], H[B - 1]);
    maxHigh[B - 1] = max(maxHigh[B - 1], H[A - 1]);
  }
  for(int i=0; i<N; i++){
    if(H[i] > maxHigh[i]){
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 4776
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype

template <class T>
int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount

template <class T> void max_swap(T& a, const T b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T b) { a = min(a, b); }

const double EPS = 1e-10;
typedef long long ll;
typedef pair<int, int> pint;


int main()
{
	int n, m;
	while (scanf("%d%d", &n, &m), n | m)
	{
		int ope[1024];
		for (int i = 1; i <= n; ++i)
			scanf("%d", ope + i);
		int dice[1024];
		for (int i = 1; i <= m; ++i)
			scanf("%d", dice + i);

		int pos = 1;
		for (int i = 1; i <= m; ++i)
		{
			pos += dice[i];
			if (1 <= pos && pos <= n)
				pos += ope[pos];
			if (pos >= n)
			{
				printf("%d\n", i);
				break;
			}
		}
	}
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;

int main() {
	int x, a;
	cin >> x >> a;
	if (x < a)cout << 0 << endl;
	else cout << 10 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); ++i)
#define all(v) v.begin(), v.end()
#define mp make_pair
#define INF 1e9

void init()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
}

int main()
{
    init();
    int k;
    cin >> k;

    int i = 0, surp = 0;
    vector<int> data(k, 0);

    while (1){
        i++;
        surp = ((surp * 10) % k + 7)%k;
        if (surp == 0)break;
        if (data[surp] == 1){
            cout << -1 << endl;
            return 0;
        }
        data[surp] = 1;
    }
    cout << i << endl;
    return 0;
}


Measured memory_bytes: 7140
/*
    JAI JAGANNATH!
*/
//@Author : zanj0
#include <bits/stdc++.h>
#define fastio  ios_base::sync_with_stdio(false);cin.tie(NULL);

using namespace std;
typedef long long int lli;
template <typename T>
void out(vector <T> v){
    for(lli i = 0; i < v.size(); i++){
        cout << v[i] << " ";
    }
    cout << endl;
}
void solve(){
    string s;
    cin >> s;
    puts(s[2] == s[3] && s[4] == s[5] ? "Yes" : "No") ;
}
int main(){
	#ifdef zanj0
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
    fastio
    lli t = 1;
    while(t--){
        solve();
    }
    return 0;
}



Measured memory_bytes: 256
import java.util.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static final long mod=1000000007;
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};

    public  static void main(String[] args)   throws Exception, IOException{        
        Reader sc = new Reader(System.in);
        //110110011
        PrintWriter out=new PrintWriter(System.out);
        // int n=sc.nextInt();
        int n=sc.nextInt();
        int m=sc.nextInt();
        P p[]=new P[n];
        
        for (int i = 0; i < p.length; i++) {
			p[i]=new P(sc.nextInt(),sc.nextInt());
		}
        sort(p);

        
        long ans=0;
        for (int i = 0; i < p.length; i++) {
			if(p[i].T > m) {
				ans+=(long)m*p[i].id;
				break;
			}
			else {
				ans+=(long)p[i].T*p[i].id;
				m-=p[i].T;
			}
		}

        out.println(ans);
        out.flush();
    }



    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }  
}

//class P {
//    int id, d;
//    P(int  id, int d) {
//        this.id=id;
//        this.d=d;
//    }
//}

class P implements Comparable<P>{
    int id,T;
    P(int id, int T) {
        this.id=id;
        this.T=T;
    }
    public int compareTo(P p){
        return id-p.id; //des
    }
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
    	int r[] = new int[size];
    	for (int i = 0; i < size; i++) {
			r[i] = this.nextInt(); 
		}
    	return r;
    }
    public long[] nextLongArray(int size) throws IOException{
    	long r[] = new long[size];
    	for (int i = 0; i < size; i++) {
			r[i] = this.nextLong(); 
		}
    	return r;
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


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

#define int long long

int M=1e9+7;

signed main() {
	int N,K;
	cin>>N>>K;
	vector<int> candies(N+1);
	for (int i=0;i<N;i++){
		cin>>candies[i];
	}
	vector<int>dp(K+1);
	dp[0]=1;
	for (int i=1;i<=N;i++){
		vector<int> prefix_sum(K+1);
		prefix_sum[0]=dp[0];
		for (int j=1;j<=K;j++){
			prefix_sum[j]=(prefix_sum[j-1]%M+dp[j]%M)%M;
		}
		for (int j=K;j>=0;j--){
			if (j<=candies[i-1]) dp[j]=prefix_sum[j];
			else dp[j] = (M+prefix_sum[j]-prefix_sum[j-candies[i-1]-1])%M;
		}
	}
	cout<<dp[K];
    return 0; 
}


Measured memory_bytes: 4828
#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N = 200005;
ll a[N], b[N], suma[N], sumb[N];
int main() {
    ll n, m, k, ans = 0;
    cin >> n >> m >> k;
    suma[0] = sumb[0] = 0;
    for(int i = 1; i <= n; ++i) {
        scanf("%lld",&a[i]);
        suma[i] = suma[i-1] + a[i];
    }
    for(int i = 1; i <= m; ++i) {
        scanf("%lld",&b[i]);
        sumb[i] = sumb[i-1] + b[i];
    }
    
    ll Max = 0;
    for(int i = 0; i <= n; ++i) {
        if(suma[i] > k) break;
        ll t;
        if(sumb[m] > k-suma[i]) {
            t = lower_bound(sumb+1,sumb+1+m,k-suma[i]) - sumb;
            if(sumb[t] > k-suma[i]) --t;
            //printf("t = %d\n",t);
        } else t = m;
        if(t + i > Max) Max = t+i;
    }

    cout << Max << '\n';
return 0;
}

Measured memory_bytes: 9940
#include <cstdio>
#include <cmath>
using namespace std;

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

    c = a * pow(10, floor(log10(b) + 1)) + b;

    if (ceil(sqrt(c)) != floor(sqrt(c))) {
        printf("No\n");
    } else {
        printf("Yes\n");
    }
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = 1e16;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;
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 double PI = acos(-1.0);
// cout << fixed << setprecision(14);
 
 
signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

    int N, K;
    cin >> N >> K;
    int ans = 0;
    for(int i=K+1;i<=N;i++){
        ans += N/i * (i-K);
        int rem = N % i;
        ans += max((int)0, rem-K+1);
        if(K == 0) --ans;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void) {

	int x, y,tmp;

	while (1) {

		scanf("%d %d", &x, &y);

		if (x == 0 && y == 0)
			break;

		else if (x > y) {
			tmp = x;
			x = y;
			y = tmp;
		}

		printf("%d %d\n", x, y);

	}
	
	return(0);

}


Measured memory_bytes: 2020
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
bool cmp(int a, int b)
{
    return a < b;
}
int main()
{
    int n;
    int a[105];
    int sum = 0;
    cin >> n;
    for(int i = 0; i < n; ++i)
    {
        cin >> a[i];
        sum += a[i];
    }
    sort(a, a + n, cmp);
    if(sum % 10 != 0)
    {
        cout << sum << endl;
    }
    else
    {
        int sum2 = 0;
        bool flag = 0;
        for(int i = 0; i < n; ++i)
        {
            sum2 = sum - a[i];
            if(sum2 % 10 != 0)
            {
                flag = 1;
                break;
            }
        }
        if(flag) cout << sum2 << endl;
        else cout << 0 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] abc = new int[3];
		
		for (int i = 0; i < abc.length; i++) {
			abc[i] = sc.nextInt();
		}
		
		if (abc[0] == abc[1] && abc[1] == abc[2]) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 21844
import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
	int rest = N%7;
	for(int i = 0; i<25; i++) {
	    for(int j = 0; j<14; j++) {
		if(i*4+j*7 == N) {
		    System.out.println("Yes");
		    return;
		}
	    }
	}
	System.out.println("No");
    }
}

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

const int kNmax = 5010;

int n, k;
string s;
set<string> substring;

void clear() {
	while ((int)substring.size() > k) {
		auto it = substring.end();
		--it;
		substring.erase(it);
	}
}

int main() {
	//ifstream cin("in");
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	
	cin >> s >> k;
	n = s.length();
	
	for (int i = 0; i < n; i++) {
		string crtSubstr;
		for (int j = i; j < n; j++) {
			crtSubstr += s[j];
			substring.insert(crtSubstr);
			
			clear();
		}
	}
	
	cout << *substring.rbegin();
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 405
using namespace std;
char s[N];int K,dp[N][N][N];
int main(){
	scanf("%s",s+1);scanf("%d",&K);
	int n=strlen(s+1);
	for (int i=1;i<=n;i++) dp[i][i][0]=1;
	for (int len=2;len<=n;len++){
		for (int l=1;l<=n-len+1;l++){
			int r=l+len-1;
			if (s[l]==s[r]){
				for (int k=0;k<=K;k++)
					dp[l][r][k]=max(dp[l][r][k],dp[l+1][r-1][k]+2);
				for (int k=0;k<=K;k++) dp[l][r][k]=max(dp[l+1][r][k],dp[l][r][k]),dp[l][r][k]=max(dp[l][r][k],dp[l][r-1][k]);
			}
			else {
				for (int k=0;k<=K;k++) dp[l][r][k]=max(dp[l+1][r][k],dp[l][r][k]),dp[l][r][k]=max(dp[l][r][k],dp[l][r-1][k]);
				for (int k=1;k<=K;k++) dp[l][r][k]=max(dp[l+1][r-1][k-1]+2,dp[l][r][k]);
			}
		}
	}
	int ans=0;
	for (int i=0;i<=K;i++) ans=max(ans,dp[1][n][i]);
	printf("%d\n",ans);
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(i,n)cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int n;
    cin>>n;
    vi a(n);

    //|i-j| = a[i]+a[j]
    //= j-i = a[i]+a[j] (j>i)
    //= i+a[i] = j-a[j]
    REP(i,n) {
        cin>>a[i];
    }

    map<ll,ll> mp1;
    map<ll,ll> mp2;

    REP(i,n) {
        mp1[a[i]+(i+1)]++;
        mp2[a[i]+(i+1)] += 0;
        mp2[(i+1)-a[i]]++;
        mp1[(i+1)-a[i]] += 0;
    }

    ll ans = 0;
    for(auto& e : mp1){
        ans += e.second * mp2[e.first];
        //DEBUG2(e.first, e.second);
    }

    // for(auto& e : mp2){
    //     DEBUG2(e.first, e.second);
    // }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 49356
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>


using namespace std;
string yn(bool a)
{
  if (a){return "Yes";}
  else{return "No";}
}
int gcd(int p,int q)
{
  int a=p,b=q;

  do{
  if(a>b){swap(a, b);}
  b=b%a;
  if(b==0){return a;break;}
}
while(1);
}

int main()
{
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  vector<int>a(n);
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
  }
  int gc=a[0];
  for(int i=0;i<n-1;i++)
  {
    gc=gcd(gc,a[i+1]);
  }
  cout<<gc;

  return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

void read();
template<typename First, typename... Rest> void read(First& first, Rest&... rest);
void write();
template<typename First, typename... Rest> void write(First first, Rest... rest);
template<typename T> void write_vec(vector<T>& v, char divider);

int main(){
    int N, M;
    read(N, M);
    vector<int> H(N);
    for(int i = 0; i < N; i++){
        read(H[i]);
    }
    vector<int> A(M);
    vector<int> B(M);
    for(int i = 0; i < M; i++){
        read(A[i], B[i]);
    }
    vector<vector<int>> mt(N + 1);
    for(int i = 0; i < M; i++){
        mt[A[i]].push_back(B[i]);
        mt[B[i]].push_back(A[i]);
    }
    int ans = 0;
    for(int i = 1; i <= N; i++){
        bool f = true;
        for(int j = 0; j < mt[i].size(); j++){
            if(H[i - 1] <= H[mt[i][j] - 1]) f = false;
        }
        if(f) {
            ans++;
        }
    }
    write(ans);
    return 0;
}

//配列以外の入力を受け取る
void read(){

}
template<typename First, typename... Rest>
void read(First& first, Rest&... rest){
    cin >> first;
    read(rest...);
}
//
//配列以外を出力する
void write(){

}
template<typename First, typename... Rest>
void write(First first, Rest... rest){
    cout << first << " ";
    write(rest...);
}
//
//配列を区切って出力する
template<typename T>
void write_vec(vector<T>& v, char divider){
    for(size_t i = 0; i < v.size(); i++){
        cout << v[i] << divider;
    }
}
//

Measured memory_bytes: 9592
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	ar := make([]int, n)
	sr := make([]int, n)
	sum := 0
	for i := range ar {
		fmt.Scan(&ar[i])
		if i == 0 {
			sum += abs(ar[i])
		} else {
			sum += abs(ar[i-1] - ar[i])
		}
		sr[i] = sum
	}
	ans := 0
	if n == 2 {
		ans = abs(ar[1]) * 2
	} else {
		ans = abs(ar[1]) + (sr[n-1] - sr[1]) + abs(ar[n-1])
	}
	fmt.Println(ans)
	for i := 1; i < n-1; i++ {
		v := sr[i-1] + abs(ar[i-1]-ar[i+1])
		if i == n-2 {
			v += abs(ar[n-1])
		} else {
			v += (sr[n-1] - sr[i+1]) + abs(ar[n-1])
		}
		fmt.Println(v)
	}
	if n == 2 {
		fmt.Println(abs(ar[0]) * 2)
	} else {
		fmt.Println(sr[n-2] + abs(ar[n-2]))
	}
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}


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

int main()
{
    ll x,y,i;
    cin >> x;
    i = 0;
    y = 100;
    while (y < x)
    {
        y = y + y / 100;
        i++;
    }
    cout << i;
    return 0;
}

Measured memory_bytes: 3624
#binary search
def isOK(lis, index, key):
    if lis[index] >= key:
        return True
    else:
        return False
def binary_search(lis, key):
    ng = -1
    ok = len(lis)
    while abs(ok - ng) > 1:
        mid = int((ok + ng)/2)
        if isOK(lis, mid, key):
            ok = mid
        else:
            ng = mid
    return ok

n = int(input())
S = [int(s) for s in input().split()]
q = int(input())
count = 0
for t in input().split():
    key = int(t)
    index = binary_search(S, key)
    if index != len(S) and index != -1 and S[index] == key:
        count += 1
print(count)


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

using namespace std;

int adjmat[105][105];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int N, M = 0;
	cin >> N;
	if (N%2==0){
		for (int i = 1; i <= N; ++i){
			for (int j = 1; j <= N; ++j){
				adjmat[i][j] = 1;
			}
		}
		for (int i = 1; i <= N; ++i){
			adjmat[i][N-i+1] = 0;
			adjmat[N-i+1][i] = 0;
		}
	}
	else{
		N--;
		for (int i = 1; i <= N; ++i){
			for (int j = 1; j <= N; ++j){
				 adjmat[i][j] = 1;
			}
		}
		for (int i = 1; i <= N; ++i){
			adjmat[i][N-i+1] = 0;
			adjmat[N-i+1][i] = 0;
		}
		N++;
		for (int i = 1; i < N; ++i){
			adjmat[i][N] = 1;
			adjmat[N][i] = 1;
		}
	}
	for (int i = 1; i <= N; ++i){
		for (int j = i+1; j <= N; ++j){
			M += adjmat[i][j];
		}
	}
	cout << M << '\n';
	for (int i = 1; i <= N; ++i){
		for (int j = i+1; j <= N; ++j){
			if (adjmat[i][j]) cout << i << ' ' << j << '\n';
		}
	}
	cout << flush;
	//for (int i = 0; i < 1e9; ++i){for (int j = 0; j < 1e9; ++j){}}
}

Measured memory_bytes: 384
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <string>
#include <vector>
using namespace std;
using ll = int64_t;
#define rep(i, j, n) for (int i = j; i < (int)n; ++i)
#define rrep(i, j, n) for (int i = (int)n - 1; j <= i; --i)

constexpr ll MOD = 1000000007;
constexpr int INF = 0x3f3f3f3f;
constexpr ll INFL = 0x3f3f3f3f3f3f3f3fLL;

int main() {
  int w, h;
  cin >> w >> h;
  vector<ll> p(w), q(h);
  for (ll& x : p) cin >> x;
  for (ll& x : q) cin >> x;

  ll ans = 0;
  rep(i, 0, w) ans += p[i];
  rep(i, 0, h) ans += q[i];

  sort(p.begin(), p.end());
  sort(q.begin(), q.end());

  // すべての(i, j)にたいして、min(p[i], q[j])を足す。
  rep(i, 0, w) {
    ll num = lower_bound(q.begin(), q.end(), p[i]) - q.begin();
    ans += (h - num) * p[i];
  }
  rep(i, 0, h) {
    ll num = upper_bound(p.begin(), p.end(), q[i]) - p.begin();
    ans += (w - num) * q[i];
  }

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

Measured memory_bytes: 4836
#include<stdio.h>
#include<string.h>
char str[205];
char str1[205];
int len_str[200];
int main(){

while(1){
        scanf("%s",str);
        if(str[0]=='-')
            break;

        int len = strlen(str);
        int n;
        scanf("%d",&n);
        for(int i=0;i<n;i++){
            scanf("%d",&len_str[i]);
        }
        int i,j,k;
        for( i=0;i<n;i++){
            for( j=len_str[i],k=0;j<len;j++,k++){
                str1[k] = str[j];
            }
            for( j=0;j<len_str[i];j++){
                str1[k] = str[j];
                k++;
            }
            str1[k] = '\0';
            for(j=0;j<len;j++){
                str[j] = str1[j];
            }
        }
        printf("%s\n",str);
}



return 0;
}



Measured memory_bytes: 2048
dic = {"a":0, "b":1, "c":2}
c = [[dic[i] for i in input()] for _ in range(3)]

turn = 0
while c[turn]:
    next_turn = c[turn][0]
    c[turn] = c[turn][1:]
    turn = next_turn
else:
    rdic = {0: "A", 1:"B", 2:"C"}
    print(rdic[turn])

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

#include <boost/multiprecision/cpp_int.hpp>

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define rep_3(i, initial, n) \
  for (int(i) = (int)(initial); (i) < (int)(n); ++(i))
#define rep(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int(i) = (int)(n); (i) > 0; (i)--)
#define rep_r_3(i, initial, n) \
  for (int(i) = (int)(initial); (i) > (int)(n); (i)--)
#define rep_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define type definition
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int;  // 多倍長整数（任意精度）
typedef pair<int, int> P;

// define construct variable
const double EPS = numeric_limits<double>::epsilon();
// 10^9 + 7
const ll MOD = ll(1e9) + 7;
const ll INF = ll(1e10);
const string ALPHABET = "abcdefghijklmnopqrstuvwxyz";
const double PI = acos(-1);

// define methods
// 最大公約数
ll gcd(const ll a, const ll b) { return b ? gcd(b, a % b) : a; }
// 最小公倍数
ll lcm(const ll a, const ll b) { return a / gcd(a, b) * b; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector<pair<ll, ll>> prime_factorize(ll n) {
  vector<pair<ll, ll>> p;
  for (ll i = 2; i * i <= n; i++) {
    if ((n % i) != 0) continue;
    pair<ll, ll> a = make_pair(i, 0);
    while ((n % i) == 0) {
      n /= i;
      a.second += 1;
    }
    p.push_back(a);
  }

  if (n != 1) p.push_back(make_pair(n, 1));
  return p;
}
// 組み合わせの整合性を保つ（後ほど解析する）
ll modinv(ll a) {
  ll b = MOD, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= MOD;
  if (u < 0) {
    u += MOD;
  }
  return u;
}
// 順列
ll permutation(const ll n, const ll m) {
  ll result = 1;
  for (ll i = n; i > n - m; i--) {
    result = (result * i) % MOD;
  }
  return result;
}

// 繰り返し n 乗法
ll repeat_square(const ll n, const ll x) {
  if (x == 0) return 1;
  ll res = repeat_square(n, x / 2);
  res = res * res % MOD;
  if ((x % 2) == 1) res = res * n % MOD;
  return res;
}
// 組み合わせ nCm
ll combination(ll n, ll m) {
  ll p = permutation(n, m);
  ll div = 1;
  for (ll i = 2; i <= m; i++) {
    div = (div * i) % MOD;
  }
  return (p * modinv(div)) % MOD;
}

// アルファベットの取得
string get_alphabet(ll n) {
  n--;
  return string(1, 'a' + (n % 26));
}

int main() {
  int N, M;
  ll K;
  cin >> N >> M >> K;
  vector<ll> A(N), B(M), x, y;

  ll sumb = 0;
  rep(i, N) {
    ll a;
    cin >> a;
    A[i] = a;
  }
  rep(i, M) {
    ll b;
    cin >> b;
    B[i] = b;
    sumb += b;
  }

  x.push_back(0);
  y.push_back(0);
  rep(i, N) {
    x.push_back(A[i] + x[i]);
  }
  rep(i, M) {
    y.push_back(B[i] + y[i]);
  }

  ll ans = 0;
  ll j = M;
  rep(i, N+1) {
    if (x[i] > K) break;
    while(y[j] > (K - x[i])) {
      j--;
    }
    // cout << temp << ", " << i+1 << ", " << i+1+j << ", " << (K-total) << endl;
    ans = max(ans, i+j);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 11096
#include<stdio.h>
int main()
{
    int n;
    scanf("%d",&n);
    int i,count = 0,ar[n];
    for(i = 0;i<n;i++)
    {
        scanf("%d",&ar[i]);
    }
    for(i = 1;i<n-1;i++)
    {
        if(ar[i-1]<ar[i] && ar[i]<ar[i+1] || ar[i-1]>ar[i] && ar[i]>ar[i+1])
     {
         count++;
     }
    }
    printf("%d\n",count);







    return 0;
}


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

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

    string S;
    cin >> S;
    if (S == "Sunny") cout << "Cloudy" << endl;
    if (S == "Cloudy") cout << "Rainy" << endl;
    if (S == "Rainy") cout << "Sunny" << endl;

    return 0;
}


Measured memory_bytes: 256
using System;
 
class Program
{
  static void Main(string[] args)
  {
	var wk = Console.ReadLine().Split(' ');
    int A = int.Parse(wk[0]);
    int B = int.Parse(wk[1]);
    int T = int.Parse(wk[2]);
    int rslt = T / A * B;
    
    Console.WriteLine(rslt);
  }
}

Measured memory_bytes: 11092
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	return n
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Scan()
	s := sc.Text()

	Runes := []rune(s)
	count := 0
	max := 0
	for i, v := range Runes {
		if string(v) == "A" || string(v) == "T" || string(v) == "C" || string(v) == "G" {
			count++
			if i == len(Runes)-1 {
				if count > max {
					max = count
				}
			}
		} else {
			if count > max {
				max = count
				count = 0
			}
		}
	}
	fmt.Println(max)

}


Measured memory_bytes: 640
S = list(input())
K = int(input())

cnt = 0
for i in S:
    if i == '1':
        cnt += 1
    else:
        if cnt == 0:
            print(i)
            exit()
        elif K <= cnt:
            print(1)
            exit()
        else:
            print(i)
            exit()
else:
    print(1)


Measured memory_bytes: 3060
#include "bits/stdc++.h"
#define ed cout<<"\n";
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ll longlongint
using namespace std;
int main(){
     SPEED;
     int x,a,b;
     cin>>x>>a>>b;
     x-=a;
     x%=b;
     cout<<x;
     ed;
     return 0;
}


Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 1000000007


h, w = LI()
grid = SR(h)
que = deque()


def dfs():
    for y in range(h):
        for x in range(w):
            if grid[y][x] == '#':
                for i, j in [(0,1),(1,0),(-1,0),(0,-1)]:
                    if 0<=y+i<h and 0<=x+j<w and grid[y+i][x+j] == '#':
                        break
                else:
                    return 'No'
    return 'Yes'



print(dfs())



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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n, k;
	cin >> n >> k;
	int h[n+1];
	for (int i = 1; i <= n; i++) {
		cin >> h[i];
	}
	int dp[n+1];
	dp[1] = 0;
	dp[2] = abs(h[1] - h[2]);
	for (int i = 3; i <= n; i++) {
		dp[i] = dp[i-1] + abs(h[i-1] - h[i]);
		for (int j = 2; j <= k; j++) {
			if (i-j <= 0) break;
			dp[i] = min(dp[i], dp[i-j] + abs(h[i-j] - h[i]));
		}
	}
	cout << dp[n] << "\n";
	
	return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  vector<string>S(N);
  for (int i = 0; i < N; i++) {
    cin >> S.at(i);
    sort(S.at(i).begin(), S.at(i).end());
  }
  
  sort(S.begin(), S.end());
  
  long long counta = 1;
  long long countb = 0;
  for (int i = 0; i < N-1; i++) {
    if (S.at(i) == S.at(i+1)){
      counta++;
    }
    if (S.at(i) != S.at(i+1) || i == N-2){
      countb += counta * (counta-1) / 2;
      counta = 1;
    }
  }
  cout << countb << endl;
}
  
  
    

Measured memory_bytes: 6316
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

#define ALL(a) (a).begin(), (a).end()
#define int long long

using namespace std;

int calc(){
	string str; cin >> str;
	vector<int> b(1,2);
	for(size_t i = 0; i < str.size(); i++){
		if(str[i] == 'A')b.push_back(1);
		else if(i < str.size()-1 && str[i] == 'B' && str[i+1] == 'C'){
			b.push_back(0);
			i++;
		}
		else{
			if(b.back() != 2)b.push_back(2);
		}
	}
	int ret = 0;
	size_t w = 1;
	for(size_t i = 0; i < b.size(); i++){
		if(b[i] == 0){
			ret += i - w;
			w++;
		}
		else if(b[i] == 2){
			w = i+1;
		}
	}
	return ret;
}



signed main(){
	cout << calc() << endl;

	return 0;
}



Measured memory_bytes: 2680