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

int main(void){
    string s,t;
    cin >> s >> t;
    int count=0;
    for (int i = 0; i < s.size(); i++){
        if (s[i]!=t[i])
        {
            count++;
            break;
        }
        
    }
    if (count==1)
    {
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    
    
    
}

Measured memory_bytes: 3628
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

int main() {
	ios_base::sync_with_stdio( false );

	int N;
	string S;
	cin >> N >> S;

	map<int, int> t;
	for( int i = 0; i < N; ++i ) { t[S[i]] += 1; }

	long ans = 1;
	for( auto& v: t ) {
		ans = ans * (v.second+1) % 1000000007;
	}

	cout << ans-1 << endl;

	return 0;
}


Measured memory_bytes: 512
#include <iostream>
typedef long long ll;
using namespace std;

ll mod=1000000007;

int main() {
	ll N, K;
	cin >> N >> K;
	ll ans=0, now=0;
	for(ll i=0; i<=N; ++i){
	    (now += (N-i*2+mod)%mod) %= mod;
	    if(i+1>=K) (ans += now+1) %= mod;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3632
import sys
import math
def input():
    return sys.stdin.readline()[:-1]

n = int(input())
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append(cnt)

    if temp!=1:
        arr.append(1)

    if arr==[]:
        arr.append(1)
    return arr

li = factorization(n)
if n==1:
    print(0)
else:
    cnt = 0
    for x in li:
        cnt += math.floor((math.sqrt(1+8*x)-1)/2)
    print(cnt)


Measured memory_bytes: 63596
#include<iostream>
#include <algorithm>
#include <functional>

using namespace std;

int main(){

int i,k,x,ans;

cin >> k >> x;

for(i=0;i<(2*k-1);i++){
  if( i != 0) cout << " ";
  cout << x + i - (k-1);
}

cout << endl;

return 0;

}

Measured memory_bytes: 256
/* ex5_3
   moka223711 */

#include <stdio.h>
#define ROW 101
#define COL 101

int main(void){
    int row, col, i, j, br[ROW]={0}, bc[COL]={0};
    char sq[ROW][COL];
    scanf("%d %d", &row, &col);
    for(i = 0; i < row; i++){
        for(j = 0; j < col; j++){
            scanf(" %c", &sq[i][j]);
            if(sq[i][j]=='#'){
                br[i] = 1;
                bc[j] = 1;
            }
        }
    }
    for(i = 0; i < row; i++){
        if(br[i] == 0)
            continue;
        for(j = 0; j < col; j++){
            if(bc[j] == 0)
                continue;
            printf("%c", sq[i][j]);
        }
        printf("\n");
    }
    return 0;
}

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

template <int mod>
struct ModInt {
  int x;
  ModInt() : x(0) {}
  ModInt(int64_t y)
      : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator*=(const ModInt &p) {
    x = (int)(1LL * x * p.x % mod);
    return *this;
  }
  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }
  ModInt operator-() const { return ModInt(-x); }
  ModInt operator+(const ModInt &p) const {
    return ModInt(*this) += p;
  }
  ModInt operator-(const ModInt &p) const {
    return ModInt(*this) -= p;
  }
  ModInt operator*(const ModInt &p) const {
    return ModInt(*this) *= p;
  }
  ModInt operator/(const ModInt &p) const {
    return ModInt(*this) /= p;
  }
  bool operator==(const ModInt &p) const {
    return x == p.x;
  }
  bool operator!=(const ModInt &p) const {
    return x != p.x;
  }
  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }
  ModInt pow(int64_t n) const {
    ModInt ans(1), mul(x);
    while(n) {
      if(n & 1) ans *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ans;
  }
  friend ostream &operator<<(ostream &os, const ModInt &p) {
    return os << p.x;
  }
  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt<mod>(t);
    return (is);
  }
  static int get_mod() { return mod; }
};
#define MOD (long long)(1e9 + 7)

long long n, a, b;

ModInt<MOD> solve();

int main() {
  cin >> n >> a >> b;
  cout << solve() << endl;
  return 0;
}

ModInt<MOD> solve() {
  ModInt<MOD> res = 2;
  res = res.pow(n);
  res -= 1;
  ModInt<MOD> now = 1;
  for(int i = 1; i <= a; ++i) {
    now *= n - i + 1;
    now /= i;
  }
  res -= now;
  now = 1;
  for(int i = 1; i <= b; ++i) {
    now *= n - i + 1;
    now /= i;
  }
  res -= now;
  return res;
}

Measured memory_bytes: 256
x = int(input())
a = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(a[x])

Measured memory_bytes: 3060
use std::borrow::BorrowMut;
use std::fs::File;
use std::io::{stdout, BufWriter, Read, Write};
use std::thread;

fn main() {
    thread::Builder::new()
        .stack_size(32 * 1024 * 1024) // 32MB
        .spawn(run)
        .unwrap()
        .join()
        .unwrap();
}

/// ローカル環境なら _in.txt から入力を受ける
fn read_input() -> String {
    let stdin = std::io::stdin();
    let mut s = String::new();
    match option_env!("LOCAL") {
        Some(_) => File::open("src/_in.txt")
            .expect("File not found")
            .read_to_string(&mut s)
            .unwrap(),
        None => stdin.lock().read_to_string(&mut s).unwrap(),
    };
    s
}

fn solve(i: i64, csf: &[(i64, i64, i64)]) -> i64 {
    let mut t: i64 = 0;
    for &(c, s, f) in &csf[(i as usize)..] {
        if t < s {
            t = s + c
        } else {
            t = (t as f64 / f as f64).ceil() as i64 * f + c
        }
    }
    t
}

fn run() {
    let out = stdout();
    let mut out = BufWriter::new(out.lock());
    let input = read_input();
    let mut input = input.split_whitespace();

    let n: i64 = input.next().unwrap().parse().unwrap();
    let csf: Vec<(i64, i64, i64)> = (0..(n - 1))
        .map(|_| {
            let v: Vec<i64> = input
                .borrow_mut()
                .take(3 as usize)
                .map(|s| s.parse().unwrap())
                .collect();
            (v[0], v[1], v[2])
        })
        .collect();

    for i in 0..n {
        writeln!(out, "{}", solve(i, &csf)).ok();
    }
}


Measured memory_bytes: 8572
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();//AtoB
		int B = sc.nextInt();//BtoC
		int C = sc.nextInt();//CtoA
		int[] ans = { A + B, A + C, B + C };
		int min = 10000;
		for (int a : ans) {
			if (min > a) {
				min = a;
			}
		}

		System.out.println(min);
		sc.close();
	}
}


Measured memory_bytes: 21716
import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;
public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        String s = bf.readLine();
        int n = s.length();
        ArrayList<Integer> pos = new ArrayList<Integer>();
        for(int i=0; i<n-1; i++) {
          if(s.charAt(i)=='R' && s.charAt(i+1)=='L') pos.add(i);
        }
        int[] ans = new int[n];
        for(int i : pos) {
          int cur = i;
          int count = 0;
          while((cur >=0) && (s.charAt(cur) == 'R')) {
            count++;
            if(count%2 == 1) ans[i] ++;
            else ans[i+1]++;

            cur--;

          }
          cur = i+1;
          count = 0;
          while((cur < n) && (s.charAt(cur) == 'L')) {
            count++;
            if(count%2 == 1) ans[i+1] ++;
            else ans[i]++;

            cur++;

          }

        }
        StringBuilder sb = new StringBuilder();
        for(int i : ans) sb.append(i+" ");
        out.println(sb.toString());
        // int n = Integer.parseInt(bf.readLine());
        // StringTokenizer st = new StringTokenizer(bf.readLine());
        // int[] a = new int[n]; for(int i=0; i<n; i++) a[i] = Integer.parseInt(st.nextToken());
        // int n = Integer.parseInt(st.nextToken());

        out.close(); System.exit(0);
    }
}


Measured memory_bytes: 39664
#include<iostream>
#include<vector>
#include<string>
#include<utility>
#include<algorithm>

typedef long long ll;

int main(){
	int l, r, d;
	std::cin >> l >> r >> d;
	int ans = 0;
	int tmp = 0;
	for(int i=l; i<=r; i++){
		if(i%d == 0){
			tmp = i;
			ans++;
			break;
		}
	}
	if(ans == 0){
		std::cout << ans << std::endl;
	}else{
		std::cout << ans + (r - tmp) / d << std::endl;
	}
	
	return 0;
}

Measured memory_bytes: 3672
#include<stdio.h>
#define N 40
   
int n,res,A[N],B[N];

void solve(int l,int r){
   
  int p,i;
 
  p=A[res];
   
  if(l>r)return;
  if(l==r){
    if(B[l]==A[0]) printf("%d",B[l]);
    else printf("%d ",B[l]);
    res++;
    return;
  }
   
  res++;
  for(i=l;i<=r;i++){
    if(B[i]==p)break;
  }
  solve(l,i-1);
  solve(i+1,r);
     
  if(p==A[0])printf("%d",p);
  else printf("%d ",p);
}
 
int main(){
   
  int i;
 
  scanf("%d",&n);
 
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
 
  for(i=0;i<n;i++){
    scanf("%d",&B[i]);
  }
   
  solve(0,n-1);
  printf("\n");
 
  return 0;
}



Measured memory_bytes: 2092
module.exports=function(e){var r={};function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)t.d(n,o,function(r){return e[r]}.bind(null,o));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=0)}([function(e,r,t){t(1)(t(2).readFileSync("/dev/stdin","UTF-8"))},function(e,r){e.exports=function(e){for(var r=e.split("\n"),t=Number(r[0]),n=[],o=0;o<t;o++){var u=r[o+1].split(" "),i={s:u[0],p:Number(u[1]),num:o+1};n.push(i)}n.sort(function(e,r){return e.s==r.s?r.p-e.p:e.s>r.s?1:e.s<r.s?-1:void 0});for(var f=0;f<t;f++)console.log(n[f].num)}},function(e,r){e.exports=require("fs")}]);

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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  int N; cin >> N;
  int result = (N-1)/2;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>

using namespace std;
typedef long long ll;

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

int main() {

    ll A,B,H,M;
    cin >> A >> B >> H >> M;
    double m = 360/60*M;
    double h = 360/720.0*(H*60+M);
    double out = 0;
    if(abs(m-h)==180) out = A+B;
    else if(abs(m-h)==0) out = abs(A-B);
    else out = sqrt(A*A + B*B -2*A*B*cos((abs(m-h)/180*M_PI)));
    cout << fixed << setprecision(9) << out << endl;
    return 0;
}


Measured memory_bytes: 4164
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		int sum = 0;
		int count = 0;
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for(long i = 0 ; i < n ; i++) {
			count++;
			sum += pow(10 , i , n) * 7;
			sum += n;
            sum %= n;
			if(sum == 0) {
				System.out.println(count);
				return;
			}

		}
		System.out.println(-1);

	}
	public static long pow(long a,long b,int M) {
        long ret = 1;
        long tmp = a;
        while(b>0) {
            if((b&1)==1) ret = (ret * tmp) % M;  //2進数によるべき乗の高速計算
            tmp = (tmp * tmp) % M;
            b = b>>1;
        }
        return ret;
    }
}



Measured memory_bytes: 35672
#include <iostream>
using ll = long long;
using namespace std;

int main() {
    ll a,b ,x, c, d, v;
    cin >> a >> b >> x;
    c = (a+x-1)/x;
    d = b/x;
    if(d == c){
        v = 0;
        if (a != c *x) v = 1;
        if (a%x == 0) v = 1;
    } else {
        v = d-c+1;
    }
    cout << v;

    return 0;
}

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

using namespace std;

#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 = long long;
using P = std::tuple<int,int>;

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

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

    int N;
    std::cin >> N;

    const string YESNO[2] = {"No", "Yes"};
    std::cout << YESNO[N / 100 == N % 10] << std::endl;
}


Measured memory_bytes: 256
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System;

public class hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        var b = new char[n];
        for (int i = 0; i < n; i++) b[i] = '0';
        for (int i = 0; i < a[0]; i++) b[a[i + 1]] = '1';
        Array.Reverse(b);
        var m = Convert.ToInt32(new string(b), 2);
        getAns(n, m);

    }
    public static void getAns(int n, int m)
    {
        var sb = new StringBuilder();
        var imax = 1 << n;
        for (int i = 0; i < imax; i++)
            if ((i & m) == m)
            {
                var a = new List<int>();
                for (int j = 0; j < n; j++)
                    if (((i >> j) & 1) == 1) a.Add(j);
                if (a.Count() == 0) sb.Append(string.Format("{0}:\n", i));
                else
                {
                    sb.Append(string.Format("{0}: ", i));
                    sb.Append(string.Join(" ", a));
                    sb.Append("\n");
                }
            }
        Console.Write(sb);
    }
}


Measured memory_bytes: 50784
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;


int N,T,A;
int H[1200];

int main(){
    cin >>N;
    cin >>T>>A; //初期値
    int Mind=2000000;

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

    for (int i=1;i<N+1;++i){
        int d=(T*1000-H[i]*6)-A*1000;
        if(d<0) d=-d;

        if(d<Mind){
            Mind=d;
            res=i;
        }      
    }

    cout <<res<<endl;
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<string> blue(n);
    rep(i,0,n){
        cin >> blue[i];
    }
    int m;
    cin >> m;
    vector<string> red(m);
    rep(i,0,m){
        cin >> red[i];
    }
    int ans = 0;
    auto calc = [&](string s) {
        int buf = 0;
        for (string t: blue) {
            if (t == s) buf++;
        }
        for (string t: red) {
            if (t == s) buf--;
        }
        return buf;
    };

    for (string t: blue) {
        ans = max(ans, calc(t));
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
//B - Comparison:
//Assunto: 
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define loop(i, a, b) for(int i = a; i < b; i++)
#define loopBack(i, a, b) for(int i = a; i >= b; i--)
#define INF INT_MAX
#define LINF LLONG_MAX
#define DINF DBL_MAX
#define MAX 100050
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    string a, b;
    cin >> a >> b;
    if(a.size() < b.size()) cout << "LESS\n";
    else if(a.size() > b.size()) cout << "GREATER\n";
    else {
        if(a > b) cout << "GREATER\n";
        else if(a < b) cout << "LESS\n";
        else cout << "EQUAL\n"; 
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define nl '\n'
#define f(i, n) for (int i = 0; i < n; ++i)
#define INF 1e9 + 5
using namespace std;
int solve() {
    int n;
    cin >> n;
    vector<int> d;
    int k = n;
    while (k) {
        d.push_back(k % 10);
        k /= 10;
    }

    int ans = INF;
    for (int i = 0; i < (int)d.size(); i++) {
        k = 100 * d[i] + 10 * d[i] + d[i];
        int l = 100 * (d[i] + 1) + 10 * (d[i] + 1) + d[i] + 1;
        if (k >= n) {
            ans = min({ans, k});
        }
        if (l >= n) {
            ans = min({ans, l});
        }
    }
    return ans;
}

bool okay(int a) {
    string s = to_string(a);
    for (int i = 0; i < (int)s.size() - 1; ++i) {
        if (s[i + 1] != s[i]) return false;
    }
    return true;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    // for (int i = 100; i <= 999; ++i) {
    cout << (solve()) << nl;
    // }
    // solve();
}

Measured memory_bytes: 3612
// Copyright 2019 yaito3014
#include <bits/stdc++.h>
using namespace std;
using namespace literals;

int main(){
	cin.tie(nullptr); ios::sync_with_stdio(false);
	int H, W, N;
	cin >> H >> W >> N;
	int ans = ceil(float(N)/max(H, W));
	cout << ans << endl;
}


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

int N, M;

vector<int> solve() {
    vector<vector<int>> imosu(M, vector<int>(800));
    int R;
    cin >> R;
    int t, n, m, s;
    for (int i = 0; i < R; i++) {
        cin >> t >> n >> m >> s;
        t -= 540, m--;
        if (s) {
            imosu[m][t] += 1;
        } else {
            imosu[m][t] -= 1;
        }
    }

    for (int i = 0; i < imosu.size(); i++) {
        for (int j = 1; j < imosu[i].size(); j++) {
            imosu[i][j] += imosu[i][j - 1];
        }
    }

    vector<int> ret;
    int Q;
    cin >> Q;
    int ts, te;
    for (int i = 0; i < Q; i++) {
        cin >> ts >> te >> m;
        ts -= 540, te -= 540, m--;
        int tmp = 0;
        for (int j = ts; j < te; j++) {
            if (imosu[m][j] >= 1) tmp++;
        }
        ret.push_back(tmp);
    }
    return ret;
}

int main() {
    while (1) {
        cin >> N >> M;
        if (!N & !M) break;
        vector<int> ans = solve();
        for (auto& i : ans) {
            cout << i << endl;
        }
    }
}


Measured memory_bytes: 33564
#include<bits/stdc++.h>
#define MAXN 100005
#define inf 1000000000001
using namespace std;

int main (){
	
	//freopen("t.txt","r",stdin);
	int n;
	long long a[MAXN];
	cin>>n;
	for (int i=0;i<n;i++){
		cin>>a[i];
	}
	long long id=a[0];
	int d=0,mx=0;
	for (int i=1;i<n;i++){
		if (a[i]<=id){
			id=a[i];
			d++;
			mx=max(mx,d);
		}
		else{
			d=0;
			id=a[i];
		}
	}
	cout<<mx;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
typedef long long ll;
const ll longinf=1LL<<60;
using namespace std;

int n,k;

int main()
{
    cin>>n>>k;
    cout<<(n-k+1)<<endl;
    return 0;
}



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

using namespace std;
typedef long long int lli;

const int MAXN = 100010;

int n;

int a[MAXN];
int b[MAXN];

int main()
{
	scanf("%d",&n);

	for(int i = 1 ; i <= n ; i++)
		scanf("%d %d",&a[i],&b[i]);

	lli add = 0;

	for(int i = n ; i > 0 ; i--)
	{
		lli t = ( a[i] + add )%b[i];
		if( t != 0 ) add += b[i] - t;
	}

	printf("%lld\n",add);
}

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

using namespace std;

#pragma GCC optimization("O3")
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
#define INF 1000000000

#define start_routine() int begtime = clock();
#define end_routine()                                                       \
  int endtime = clock();                                                    \
  cerr << "\nTime elapsed: " << (endtime - begtime) * 1000 / CLOCKS_PER_SEC \
       << " ms\n\n";
#define ff first
#define ss second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define mll map<ll, ll>
#define sz(a) a.size()
#define all(a) a.begin(), a.end()

ll gcd(ll a, ll b) {
  if (!b) return a;
  return gcd(b, a % b);
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
#ifndef ONLINE_JUDGE
  start_routine();
  //freopen("in.txt", "r", stdin);
  // freopen("out.txt", "w", stdout);
#endif
  ll n, m, ans = 1;
  cin >> n >> m;
  ll g = gcd(n, m);
  if (g % 2 == 0) ans++;
  while (g % 2 == 0) g /= 2;
  ll max_f = sqrt(g);
  for (auto i = 3; i <= max_f; i += 2) {
    if (g % i == 0) {
      ans++;
      while (g % i == 0) g /= i;
      max_f = sqrt(g);
    }
  }
  if (g > 1) ans++;

  std::cout << ans << "\n";

#ifndef ONLINE_JUDGE
  end_routine();
#endif
  return 0;
}

Measured memory_bytes: 256
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a

# Union Find
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# 約数生成
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


inf = 10 ** 18
mod = 10 ** 9 + 7

n = ir()
if n%2 == 1:
    print(0)
else:
    ans = 0
    tmp = 2
    dp = [0 for i in range(50)]
    for i in range(1,50):
        if tmp < 10**18:
            tmp = tmp*5
            dp[i-1]=n//tmp
        else:
            break
    for i in range(49):
        ans+=(dp[i]-dp[i+1])*(i+1)
    print(ans)

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

inline double dist(vector<double> &a, vector<double> &b){
  double res = 0;
  for(int i=0;i<3;i++){
    res += (a[i]-b[i])*(a[i]-b[i]);
  }
  return res;
}

int main(){
  int n,m;
  cin >> n >> m;
  vector< vector<double> > c(n);
  for(int i=0;i<n;i++){
    double l,a,b;
    cin >> l >> a >> b;
    c[i] = {l,a,b};
  }

  double ans = 0;
  for(int bit=1;bit<(1<<n);bit++){
    if(__builtin_popcount(bit) == m){
      double sum = 0;
      for(int i=0;i<n;i++){
	if( ((bit>>i) & 1) == 0 )continue;
	for(int j=i+1;j<n;j++){
	  if( ((bit>>j) & 1) == 0 )continue;

	  sum += dist(c[i],c[j]);
	}
      }
      ans = max(ans, sum);
    }
  }
  cout << fixed << setprecision(9) << ans << endl;
}

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

int gcd(int a,int b){
  int tmp;
  while(a!=0){
  if(a<b){
    tmp=a;
    a=b;
    b=tmp;
  }
    a=a%b;
  }
  return b;
}


int main(){
  long long a,b,c,d;
  cin>>a>>b>>c>>d;
  long long ans=0;
  long long rest_ac,rest_bc,rest_ad,rest_bd;
  long long cd,rest_bcd,rest_acd;
  cd=c*d;
  cd=cd/gcd(c,d);
  rest_ac=a/c;
  rest_bc=b/c;
  rest_ad=a/d;
  rest_bd=b/d;
  rest_bcd=b/cd;
  rest_acd=a/cd;
  if(a%c==0) rest_ac--;
  if(a%d==0) rest_ad--;
  if(a%cd==0) rest_acd--;
  ans=b-a+1-(rest_bc-rest_ac)-(rest_bd-rest_ad)+(rest_bcd-rest_acd);
  
  /*  for(long long i=a;i<=b;i++){
    if(i%c!=0){
      if(i%d!=0) ans++;
    }
  }*/
  cout<<ans<<endl;
  return 0;
}


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

typedef long long int ll;
typedef pair<ll,ll> P;

int main(){
    string s;
    cin>>s;
    if(s[2]==s[3]&&s[4]==s[5]){
        cout<<"Yes";
    }else{
        cout<<"No";
    }


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ROUNDUP(divisor,dividend) (divisor + (dividend - 1)) / dividend
double n,k;
double ans=0,x,y;
int main(){
  cin >> n >> k;
  x = 1/n; y = 0.5;
  for (int i = 1; i <= n; i++) {
    int l=0;
    int temp = i;
    for (l = 0; l < k; l++) {
      if(temp >= k) break;
      temp *= 2;
    }
    ans += x * pow(y,l);
  }
  printf("%1.12lf\n",ans);
}


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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())
#define IN(x, a, b) x >= a and x < b

using namespace std;
using ll = long long;

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> constexpr T INF = numeric_limits<T>::max() / 2;
#pragma endregion

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> A(n);
  vector<vector<int>> bucket(200000);
  REP(i, n) {
    int a;
    cin >> a;
    a--;
    A[i] = a;
    bucket[a].emplace_back(i);
  }
  // REP(i, SZ(bucket)) { sort(ALL(bucket[i])); }
  int prev_left = -1;
  REP(i, SZ(bucket)) {
    int left = INF<int>;
    REP(j, SZ(bucket[i])) {
      if (bucket[i][j] > prev_left) {
        chmin(left, bucket[i][j]);
      }
    }
    if (left == INF<int>) {
      if (i == 0) {
        cout << -1 << endl;
        return 0;
      }
      cout << n - i << endl;
      return 0;
    }
    prev_left = left;
  }
  cout << 0 << endl;

  return 0;
}

Measured memory_bytes: 12032
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;
ll copy(ll n){return n;}
int main(){
	ll n,k;cin>>n>>k;
	vector<ll> sum(n + 2,0);
	for(ll i = 0; i <= n; i++) {
		sum[i + 1] = (i + 1) + sum[i]; 
		// cout << sum[i + 1] << endl;
	}
	vector<ll> sum2(n + 2,0);
	ll cnt = 0;
	for(ll i = copy(n); i >= 0 ; i--) {
		if(cnt == 0)sum2[cnt] = i;
		else sum2[cnt] = sum2[cnt - 1] + i;
		// cout << sum2[cnt] << endl;
		cnt++;
	}
	ll ans =0;
	for(ll i = k - 1; i <= n; i++) {
		// cout << "sum" << sum[i] << "sum2" << sum2[i] << endl;
		ans += sum2[i] - sum[i];
		ans++;
		ans %= mod;
		// cout << ans << endl;
	}
	cout << ans << endl;



	return 0;
}

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

int main() {
  int n, s;
  cin >> n >> s;
  int flag=1;
  for(int i=0;i<n+1;i++) {
    for(int j=0;j<n-i+1;j++) {
      if (s==1000*i+5000*j+10000*(n-i-j)) {
        cout << n-i-j << " " << j << " " << i << endl;
        flag=0;
        break;
      }
    }
    if(!flag) {
      break;
    }
  }
  if(flag) {
    cout << "-1 -1 -1" << endl;
  }
}


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

// ford-fulkerson
struct edge {
    int to, cap, rev;
};

using edges = std::vector<edge>;
using graph = std::vector<edges>;

void add_edge(graph& g, int from, int to, int cap) {
    g[from].push_back(edge{to, cap, static_cast<int>(g[to].size())});
    g[to].push_back(edge{from, 0, static_cast<int>(g[from].size()-1)});
}

int dfs(graph& g, std::vector<bool>& used, int v, int t, int f) {
    if(v == t) {
        return f;
    }
    used[v] = true;
    for(int i=0; i<g[v].size(); ++i) {
        edge& e = g[v][i];
        if(!used[e.to] && e.cap > 0) {
            int d = dfs(g, used, e.to, t, std::min(f, e.cap));
            if(d > 0) {
                e.cap -= d;
                g[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

int max_flow(graph& g, int s, int t) {
    int flow = 0;
    int INF = 1e9;
    std::vector<bool> used(g.size(), false);
    while(true) {
        std::fill(used.begin(), used.end(), false);
        int f = dfs(g, used, s, t, INF);
        if(f == 0) {
            return flow;
        }
        flow += f;
    }

}

int main() {
    int m, n;
    while(cin >> m >> n, m) {
        vector<int> b(m), r(n);
        for(int i = 0; i < m; ++i) {
            cin >> b[i];
        }
        for(int i = 0; i < n; ++i) {
            cin >> r[i];
        }
        graph g(n + m + 2);
        int const source = n + m;
        int const sink = source + 1;
        for(int i = 0; i < m; ++i) {
            add_edge(g, source, i, 1);
            for(int j = 0; j < n; ++j) {
                if(__gcd(b[i], r[j]) != 1) {
                    add_edge(g, i, j + m, 1);
                }
            }
        }
        for(int i = 0; i < n; ++i) {
            add_edge(g, i + m, sink, 1);
        }
        cout << max_flow(g, source, sink) << endl;
    }
}

Measured memory_bytes: 7372
#include <iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<math.h>
#define REP(i,n) for(int i=0;i<n;i++)

using namespace std;

int main() {
    int n,m;
    cin >> n >> m;
    
    int num = pow(2,n);
    vector<vector<int> > a(num, vector<int>(n));
    int dum;

    REP(i,num) {
        dum = i;
        REP(j, n) {
            a[i][j] = dum%2;   
            dum = dum/2;
        }
    }


    int cnt = 0;
    int k;
    vector<vector<int> > v(m, vector<int>(num));
    REP(i,m) {
        cin >> k;
        vector<int> s(k);
        REP(j, k) {
            cin >> s[j];
        }

        REP(j,num) {
            REP(l, k) cnt += a[j][s[l]-1];
            v[i][j] = cnt % 2;
            cnt = 0;
        }

    }

    vector<int> p(m);
    REP(i,m) cin >> p[i];

    int res = 0;
    cnt = 0;

    REP(i,num) {
        REP(j,m) {
            if(v[j][i] == p[j]) cnt++;
        }
        if (cnt == m) res++;
        cnt = 0;
    }

    cout << res << endl; 
}

Measured memory_bytes: 384
import java.util.*;
    public class Main {
     
    	public static void main(String[] args) {
    			
    		Scanner scan=new Scanner(System.in);
    		
    		String upper =scan.next();
    		String lower =scan.next();

    		
    		if (upper.charAt(0)==lower.charAt(2)&&upper.charAt(2)==lower.charAt(0)&&upper.charAt(1)==lower.charAt(1)) {
    			System.out.print("YES");
    		}else {
    			System.out.print("NO");
    		}
    		
    	
  
    				
 
     
    }
    }
// end 

Measured memory_bytes: 21588
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

count=0

for i in range(n-1):
    if a[i]==a[i+1]-1:
        d=a[i]
        #print(d)
        count+= c[d-1]

#print(sum(b))
print(sum(b)+ count)

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

int main(){
	int N;
	cin >> N;
	int i;
	for(i=0;i<=(N/4);i++){
		if((N-4*i)%7==0){
			cout << "Yes\n";
			break;
		}
	}
	if(i==(N/4)+1) cout << "No\n";

	return 0;
}


Measured memory_bytes: 256
N = int(input())
List = [2]
Newlist = []

for i in range(3,10**4):
  for j in List:
    if i%j == 0:
      break
  else:
    List.append(i)

for j in List:
  if j%5 == 1:
    Newlist.append(j)

for j in range(N):
  print(Newlist[j], end=" ")

Measured memory_bytes: 3060
#include<stdio.h>

int main() {
   int n;
   int A[10000],B[10000],a,b;
   int s;
   int i,j,k=0;

   scanf("%d\n",&n);
   for (i=0; i<n; i++) {
      scanf("%d",&a);
      A[i]=a;
   }
   scanf("%d\n",&s);
   for (i=0; i<s; i++) {
      scanf("%d",&b);
      B[i]=b;
  }

   for (i=0; i<n; i++)
      for (j=0; j<s; j++)
         if (A[i]==B[j]) {
            k++;
            A[i]=-1;
            B[j]=-2;
        }
   printf("%d\n",k);

   return 0;

}

Measured memory_bytes: 644
fn run() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let n: usize = it.next().unwrap().parse().unwrap();
    let k: usize = it.next().unwrap().parse().unwrap();
    let ans = (n <= k) as usize;
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 5028
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

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

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
 
    char s[3][11];
    
    rep(i, 3){
        scanf("%s", s[i]);
        printf("%c", s[i][0]-32);
    }
    
    return 0;
}



Measured memory_bytes: 1592
N, T = map(int, input().split())
a = []
for i in range(N):
    a.append(list(map(int, input().split())))

b = []
count = 0
for i in range(N):
    if a[i][1] <= T:
        b.append(a[i][0])
        count += 1
if count == 0:
    print('TLE')

else:
    print(min(b))


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

int main(){
    int a,b;
    
    while(1){
        cin>>a>>b;
        if (a==0 && b==0) break;
        
        if (a<b){
            cout<<a<<" "<<b<<endl;
        }else{
            cout<<b<<" "<<a<<endl;
            
        }
    }
    
    return 0;
}


Measured memory_bytes: 2992
#include <iostream>
using namespace std;
int main(void){
    int N, j, max = 0, buffer = -1;
    
    cin >> N;
    
    int Jun[N], M[N], B[N-1];
    
   for(j = 0; j < N; j++){
       cin >> Jun[j];
   }
    
    for(j = 0; j < N; j++){
       cin >> M[j];
   }
   
   for(j = 0; j < N-1; j++){
       cin >> B [j]; 
   }
    
    for(int i = 0; i < N; i++){
        max += M[(Jun[i])-1];
       if((Jun[i]-1) == buffer){
            max += B[(Jun[i])-2];
        }
        buffer = Jun[i];
    }
    
    cout << max;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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 <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
ll a, b, c, d;
ll gcd(ll x, ll y) {
    if (x < y) swap(x, y);
    if (y == 0) return x;
    return gcd(x % y, y);
}
ll lcm(ll x, ll y) {
    return x / gcd(x, y) * y;
}
ll f(ll x) {
    return x - (x / c + x / d - x / lcm(c, d));
}
int main() {
    cin >> a >> b >> c >> d;
    cout << f(b) - f(a - 1) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<int, pair<int, int>> PP;
typedef pair<P, int> PPi;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

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

    int n;
    cin >> n;
    vector<int> l(n);
    for(int i = 0; i < n; ++i)  cin >> l[i];
    sort(l.begin(), l.end());
    ll ans = 0;
    for(int i = 0; i < n - 1; ++i){
        for(int j = i + 1; j < n; ++j){
            int a = l[i], b = l[j];
            int left = abs(a - b), right = a + b;
            int cnt = lower_bound(l.begin(), l.end(), right) - upper_bound(l.begin(), l.end(), left);
            if(left < a && a < right)   --cnt;
            if(left < b && b < right)   --cnt;
            ans += cnt;
        }
    }
    cout << ans / 3 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
	int a,b=0,t,j,k,n,i,s[100000+1],v,c[100000+1]={0};
	while(1)
	{
		cin>>n>>k;
		if(n==0&&k==0)
		{
			break;
		}
		for(i=0;i<n;i++)
		{
			cin>>s[i];
		}
		v=n-k+1;
		for(i=0;i<v;i++)
		{
			for(a=i;a<k+i;a++)
			{
				c[i]=c[i]+s[a];

			}
		}
		for(i=0;i<v;i++)
		{
			if(b<c[i])
			{
				b=c[i];
			}
		}
		cout<<b<<endl;
	}
	return 0;
}			

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

int main()
{
    int n;
    cin >> n;
    vector<string> w(n);
    rep(i, n) cin >> w[i];
    map<string, int> mp;
    bool ok = true;
    rep(i, n)
    {
        mp[w[i]]++;
        if (i == 0)
            continue;
        int ws = w[i - 1].size() - 1;
        // cout << ws << endl;
        if (w[i - 1][ws] != w[i][0])
            ok = false;
    }
    for (auto p : mp)
    {
        if (p.second > 1)
            ok = false;
    }
    if (ok)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;
int main() {
	int n;
	cin >> n;
	while (n != 0) {
		int a[10][10] = {}, sum_h[11] = {}, sum_v[11] = {};
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				cin >> a[i][j];
				printf("%5d",a[i][j]);
				sum_h[i] += a[i][j];
				sum_v[j] += a[i][j];
			}
			sum_v[n] += sum_h[i];
			printf("%5d\n", sum_h[i]);
		}
		for (int i = 0; i < n; i++)
			printf("%5d", sum_v[i]);
		printf("%5d\n", sum_v[n]);
		cin >> n;
	}
	return 0;
}


Measured memory_bytes: 3112
N,M,C = gets.split(" ").map(&:to_i)
b = gets.split(" ").map(&:to_i)

count = 0
N.times do
    a = gets.split(" ").map(&:to_i)
    sum = 0
    M.times do |i|
        sum += a[i] * b[i]
    end
    count += 1 if sum + C > 0
end
print count

Measured memory_bytes: 1788
#include <stdio.h>
int main(void)
{
	int n, i, j = 0;
	int a[100];
	
	scanf("%d", &n);
	for(i = 0; i < n; i++){
		scanf("%d", &a[i]);
	}
	
	for(i = 0; i < n; i++){
		if(a[i] % 2 == 0 && a[i] % 3 != 0 && a[i] %5 != 0){
			j++;
		}
	}
	
	if(j >= 1){
		printf("DENIED");
	}
	else{
		printf("APPROVED");
	}
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

typedef long long ll;

ll a, b, c;
ll u;

int main() {
	cin >> a >> b >> c;
	ll k = min(b,c);
	u += 2*k;
	b -= k;
	c -= k;
	k = min(a,c);
	u += k;
	a -= k;
	c -= k;
	u += b;
	if (c > 0) u++;
	cout << u << "\n";
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
ll mod = 998244353;
#define EPS 1e-1
#define PI 3.14159265

#define iofile freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define fastio ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
using namespace std;

ll fastpow(ll base, ll pow)
{
    if (!base)
        return 0;
    if (!pow)
        return 1;
    if (pow == 1)
        return base;
    ll x = fastpow(base, pow / 2) % mod;
    x *= x;
    x %= mod;
    if (pow % 2)
        x *= base;
    return x % mod;
}

ll inverse(ll x)
{
    return fastpow(x, mod - 2) % mod;
}

ll fact[(int)1e6 + 5], inv[(int)1e6 + 5];
void init()
{
    fact[0] = inv[0] = 1;
    for (int i = 1; i <= 1e6; i++)
    {
        fact[i] = (i * fact[i - 1]) % mod;
        inv[i] = inverse(fact[i]);
    }
}

void factorize(ll x, map<int, int> &ss)
{
    while (x % 2 == 0)
        ss[2]++, x /= 2;
    for (int i = 3; i <= sqrt(x); i += 2)
        while (x % i == 0)
            ss[i]++, x/= i;
    if (x > 2)
        ss[x]++;
}

ll ncr(ll n, ll r)
{
    return ((fact[n] * inv[r]) % mod * inv[n - r]) % mod;
}

ll npr(ll n, ll r)
{
    return (fact[n] * inv[n - r]) % mod;
}

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


ll n, a, b, c;

ll solve(int idx, int last)
{
    if (idx == n)
        return 0;
    int res = 0;
    if (last == 0)
        res = max(b, c);
    else if (last == 1)
        res = max(a, c);
    else if (last == 2)
        res = max(a, b);
    return res;
}

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


Measured memory_bytes: 4992
#include <iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
    double a[100000],max=-10000,min=100000000,b;
    int i=0;
    while(cin>>a[i]){
        i++;
    }
    for(int j=0;j<i;j++){
        if(a[j]>max){
            max=a[j];
        }
        if(a[j]<min){
            min=a[j];
        }
    }double ans=max-min;
    printf("%.2lf",ans);
    cout<<endl;
    return 0;
}

Measured memory_bytes: 3228
import sys
sys.setrecursionlimit(10**6)
from sys import stdin
input = stdin.readline

n = int(input())
adjacency = [[] for i in range(n+1)] #adjacency[i]は頂点iと隣接する頂点のリスト
distance = {} # distance[(i,j)](i,jは隣接した頂点)は頂点i,jを結ぶ辺の長さ
for i in range(n-1):
    line = list(map(int, input().split()))
    adjacency[line[0]].append(line[1])
    adjacency[line[1]].append(line[0])
    distance[(line[0], line[1])] = line[2]
    distance[(line[1], line[0])] = line[2]
q, k = map(int, input().split())
x = []
y = []
for i in range(q):
    line = list(map(int, input().split()))
    x.append(line[0])
    y.append(line[1])

k_distance = [-1 for i in range(n+1)] # k_distance[i]は頂点i,kの距離
k_distance[k] = 0
reached = {k}
def dfs(v, d): # 現在いる頂点vと頂点v,k間の距離dを入力すると頂点vと隣接する未到達の頂点のk_distanceを計算してappendする
    for neighbor in adjacency[v]:
        if not neighbor in reached:
            reached.add(neighbor)
            k_distance[neighbor] = d + distance[(v, neighbor)]
            dfs(neighbor, k_distance[neighbor])
    return
dfs(k, 0)
for i in range(q):
    print(k_distance[x[i]] + k_distance[y[i]])


Measured memory_bytes: 207860
#include <bits/stdc++.h>
using namespace std;
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; }

int main(void){
  int64_t N, A, B;
  cin >> N >> A >> B;

  int64_t syou, amari, kotae;
  syou = N / (A + B);
  amari = N % (A + B);
  if(amari <= A){
    kotae = syou * A + amari; 
  }
  else{
    kotae = syou * A + A;
  }
  cout << kotae << endl;
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ASC(x) sort(ALL((x)))
#define DESC(x) sort(ALL((x)),greater<ll>())
#define REV(x) reverse(ALL((x)))
#define pb push_back

int main()
{
    ll N;
    cin >> N;
    vec A(N);
    REP(i,0,N) cin >> A[i];

    ll xsum = 0;
    REP(i,0,N) xsum ^= A[i];
    REP(i,0,N) PS(xsum^A[i]);
    PR("");

    return 0;
}

/*



*/

Measured memory_bytes: 4796
#include <bits/stdc++.h>
#define N 1000000

using namespace std;
typedef long long int ll;

int main()
{
//    freopen("out.txt","w",stdout);
    int t,arr[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    scanf("%d",&t);
    printf("%d\n",arr[t-1]);
    return 0;
//    fclose(stdout);
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int N;
    scanf("%d", &N);
    vector<int> H(N), A(N);
    vector<long long> dp(2*N, 0);
    int base = 1;
    while (base <= N) {
        base <<= 1;
    }
    vector<long long> tree(2*base, 0);
    for (int i = 0; i < N; ++i) {
        scanf("%d", &H[i]);
    }
    for (int i = 0; i < N; ++i) {
        scanf("%d", &A[i]);
        dp[i] = A[i];
    }
    
    for (int i = 0; i < N; ++i) {
        int x = base + H[i];
        long long best = 0;
        while (x > 1) {
            if (x & 1) {
                best = max(best, tree[x-1]);
            }
            x >>= 1;
        }
        dp[H[i]] = best + A[i];
        for (int k = base + H[i]; k >= 1; k >>= 1) {
            tree[k] = max(tree[k], dp[H[i]]); 
        }
    }
    cout << tree[1];
}

Measured memory_bytes: 9088