akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;
class Main
{
    static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	static FastScanner sc=new FastScanner(br);
    static PrintWriter out=new PrintWriter(System.out);
	static Random rnd=new Random();
	
    public static void main(String args[]) throws Exception
    {
		int n=sc.nextInt();long[] a=new long[n],b=new long[n];long res=0,sum=0;
		for(int i=0;i<n;i++)
		{
			a[i]=sc.nextLong();b[i]=sc.nextLong();
		}
		for(int i=n-1;i>=0;i--)
		{
			a[i]+=sum;
			if(a[i]%b[i]==0)
			{
				continue;
			}
			long now=b[i]-(a[i]%b[i]);
			sum+=now;
		}
		out.println(sum);out.close();
    }
}
class FastScanner
{
    BufferedReader in;
    StringTokenizer st;

    public FastScanner(BufferedReader in) {
        this.in = in;
    }
	
    public String nextToken() throws Exception {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }
	
	public String next() throws Exception {
		return nextToken().toString();
	}
	
    public int nextInt() throws Exception {
        return Integer.parseInt(nextToken());
    }

    public long nextLong() throws Exception {
        return Long.parseLong(nextToken());
    }

    public double nextDouble() throws Exception {
        return Double.parseDouble(nextToken());
    }
}

Measured memory_bytes: 29208
#include <cstdio>
#include <vector>
#include <algorithm>

int parent[20][100000];
int depth[100000];
std::vector<int> edge[100000];

void dfs(int v, int p, int d)
{
  parent[0][v] = p;
  depth[v] = d;
  for (auto to : edge[v])
  {
    if (to != p) dfs(to, v, d + 1);
  }
}

int lca(int u, int v)
{
  if (depth[u] > depth[v]) std::swap(u, v);
  for (int k = 0; k < 18; ++k)
  {
    if ((depth[v] - depth[u]) >> k & 1) v = parent[k][v];
  }
  if (u == v) return u;
  for (int k = 17; k >= 0; --k)
  {
    if (parent[k][u] != parent[k][v])
    {
      u = parent[k][u];
      v = parent[k][v];
    }
  }
  return parent[0][u];
}

int main()
{
  int n, u, v;
  scanf("%d%d%d", &n, &u, &v);
  --u, --v;
  for (int i = 0; i < n - 1; ++i)
  {
    int a, b;
    scanf("%d%d", &a, &b);
    --a, --b;
    edge[a].emplace_back(b);
    edge[b].emplace_back(a);
  }

  dfs(v, -1, 0);
  for (int k = 0; k < 18; ++k)
  {
    for (int j = 0; j < n; ++j)
    {
      if (parent[k][j] < 0) parent[k + 1][j] = -1;
      else parent[k + 1][j] = parent[k][parent[k][j]];
    }
  }

  std::vector<int> leaf;
  std::vector<int> lcav;
  for (int i = 0; i < n; ++i)
  {
    if (edge[i].size() == 1)
    {
      int ansc = lca(i, u);
      if (ansc == v) continue;
      int tak_to_lca = depth[u] - depth[ansc];
      int aok_to_lca = depth[ansc];
      if (aok_to_lca <= tak_to_lca) continue;
      leaf.emplace_back(i);
      lcav.emplace_back(ansc);
    }
  }

  int ans = 0;
  for (int i = 0; i < leaf.size(); ++i)
  {
    int r = depth[u] - depth[lcav[i]];
    r += depth[leaf[i]] - depth[lcav[i]];
    r += (depth[leaf[i]] - r) - 1;
    if (r > ans) ans = r;
  }
  
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 17536
#include<bits/stdc++.h>
using namespace std;
#define int long long 
const int INF = 1e9;
const int MOD = INF+7;
#define rep(i,N) for(int (i)=0;(i)<(N);++(i))
#define rrep(i,N) for(int (i)=(N-1);(i)>0;--i)
#define FOR(i,j,N) for(int (i)=(j);(i)<(N);++(i))
#define put(n) cout<<(n)<<endl;
#define all(v) v.rbegin(),v.rend()
#define MP make_pair
#define pb push_back
using P = pair<int,int>;
//c

signed main(){
    string S;
    cin >> S;
    int ans = 0;
    for(int i=0;i<S.size()-1;i++){
        if(S[i] == S[i+1]){
            if(S[i+1] == '0') S[i+1] = '1';
            else S[i+1] = '0';
            ans++;
        }
    }
    cout << ans << endl;
}


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

int main(){
    ll a, b, c; cin >> a >> b >> c;
    ll ans = 0;
    if(c >= b && b >= a) // c >= b >= a
    {
        ans = ans * 10 + c;
        ans = ans * 10 + b;
        ans = ans + a;
        cout << ans << endl;
        return 0;
    }

    if(c >= a && a >= b) // c >= b >= a
    {
        ans = ans * 10 + c;
        ans = ans * 10 + a;
        ans = ans + b;
        cout << ans << endl;
        return 0;
    }

    if(b >= c && c >= a)
    {
        ans = ans * 10 + b;
        ans = ans * 10 + c;
        ans = ans + a;
        cout << ans << endl;
        return 0;
    }

    if(b >= a && a >= c)
    {
        ans = ans * 10 + b;
        ans = ans * 10 + a;
        ans = ans + c;
        cout << ans << endl;
        return 0;
    }

    if(a >= c && c >= b)
    {
        ans = ans * 10 + a;
        ans = ans * 10 + c;
        ans = ans + b;
        cout << ans << endl;
        return 0;
    }

    if(a >= b && b >= c)
    {
        ans = ans * 10 + a;
        ans = ans * 10 + b;
        ans = ans + c;
        cout << ans << endl;
        return 0;
    }


    return 0;
}

Measured memory_bytes: 256
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_imports)]
use std::collections::HashSet;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::collections::VecDeque;
use std::cmp::{max, min};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        n: usize,
        ss: [chars; n]
    }
    let mut ss = ss;
    /*
    let vs = (b'a'..b'z' + 1).map(|c| c as char)
                    .collect::<Vec<_>>();
    */

    //let mut ms = Vec::new();
    for i in 0..ss.len() {
        ss[i].sort();
        /*
        let mut m = String::new();
        for j in 0..ss[i].len() {
            m.push(ss[i][j]);
        }
        ms.push(m);
        */
    }
    ss.sort();
    let mut m = ss[0].clone();
    let mut cnt: u64 = 0;
    let mut ans = 0;
    for i in 1..n {
        if m == ss[i] {
            cnt+=1;
        } else {
            ans += (cnt + 1) * cnt / 2;
            cnt = 0;
        }
        m = ss[i].clone();
    }
    ans += (cnt + 1) * cnt / 2;
    println!("{}", ans);
    /*
    for i in 0..n {
        let mut cnt = 0;
        for j in 0..n {
            if ms[i] == ms[j] {
                cnt += 1;
            }
        }
    }
    */
}

Measured memory_bytes: 16764
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m; cin>>n>>m;
	vector<bool> solved(n + 1, false);
	vector<int> pen(n + 1, 0);
	int ac = 0, res = 0;
	for(int i =0; i<m; i++){
		int task; string verdict; cin>>task>>verdict;
		if(!solved[task] && verdict == "AC"){
			ac++;
			solved[task] = true;
		}
		if(verdict == "WA" && !solved[task]){
			pen[task]++;
		}
	}
	for(int i =1; i<=n; i++){
		if(solved[i]){
			res += pen[i];
		}
	}
	
	cout<<ac<<" "<<res;
	return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int a[100001];
int main(){
    int n;
    cin>>n;
    rep(i,n){
        cin>>a[i];
        --a[i];
    }
    int cur=0,cnt=0;
    while(1){
        if(cur==1||cnt==n+1) break;
        cur=a[cur];++cnt;
    }
    if(cnt<n+1)cout<<cnt<<endl;
    else cout<<-1<<endl;
    return 0;
}

Measured memory_bytes: 640
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

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

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

fn main() {
    let v = read_vec::<usize>();
    let (n, q) = (v[0], v[1]);
    let s = read::<String>().chars().collect::<Vec<_>>();

    let mut count = vec![0; n - 1];
    for i in 0..s.len() - 1 {
        if s[i] == 'A' && s[i + 1] == 'C' {
            count[i] += 1;
        }
    }
    // println!("{:?}", &count);
    let mut sum = vec![0; n];
    for i in 1..n {
        sum[i] = sum[i - 1] + count[i - 1];
    }
    // println!("{:?}", &sum);

    for i in 0..q {
        let v = read_vec::<usize>();
        let (l, r) = (v[0] - 1, v[1] - 1);
        println!("{}", sum[r] - sum[l]);
    }
}


Measured memory_bytes: 4860
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N;
	cin>>N;
	vector<int> weight(N,0);
	for(int i=0;i<N;i++){
		cin>>weight[i];
	}
	int oversum = accumulate(weight.begin(),weight.end(),0);
	int mindif = 0x3f3f3f3f;
	for(int i=0;i<N-1;i++){
		int sum1=0 ;
		for(int j =0;j<=i;j++){
			sum1+=weight[j];
		}
		int sum2= oversum - sum1;
		int tmp = abs(sum1-sum2);
		mindif = min(mindif,tmp);
	}
	cout<<mindif<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using P = pair<int,int>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvd = vector<vector<double>>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int INF =1001001001;

int main()
{
   int n, k;
   cin >> n >> k;
   vector<int> a(n);
   rep(i,n) cin >> a[i];

   //d[i] 石の残り枚数がiの時に勝てるか否か
   bool dp[k+1];
   rep(i,k+1) dp[i] = false;
   
   for(int i =1; i <= k; i++)
   {
      for(int j = 0; j < n; j++)
      {
         if(i - a[j] >= 0) dp[i] |= !dp[i - a[j]];
      }
   }
   
   if (dp[k]) cout << "First" << endl;
   else cout << "Second" << endl;
}


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

// 2^N < 3*10^4なので、すべての状態をチェックしてもいけそう？
int main() {
  size_t N = 0;
  std::cin >> N;

  std::vector<uint16_t> one_graph(N);  // 1で接続
  std::vector<uint16_t> zero_graph(N);  // 0でつながる
  for (size_t i = 0; i < N; ++i) {
    size_t A;
    std::cin >> A;
    for (size_t j = 0; j < A; ++j) {
      int x, y;
      std::cin >> x >> y;
      if (y == 1) {
        one_graph[i] |= size_t(1) << (x - 1);
      } else if (y == 0) {
        zero_graph[i] |= size_t(1) << (x - 1);
      }
    }
  }

  size_t result = 0;
  for (uint16_t flags = 1; flags < (1 << N); ++flags) {
    [&] {
      size_t count = 0;
      for (size_t i = 0; i < N; ++i) {
        // 正直者の発言が状態と矛盾するかを調べる
        if (flags & (1 << i)) {
          const uint16_t one = one_graph[i];
          const uint16_t zero = zero_graph[i];
          if ((flags & one) != one || (~flags & zero) != zero) {
            return;
          }
          count++;
        }
      }
      result = std::max(result, count);
    }();
  }

  std::cout << result;

  return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<ll> A(N);
  vector<ll> B(N);
  vector<ll> C(N);
  
  for(int i = 0;i<N;i++){
    cin >> A[i];
  }
  for(int i = 0;i<N;i++){
    cin >> B[i];
  }
  for(int i = 0;i<N;i++){
    cin >> C[i];
  }
  sort(A.begin(),A.end());
  sort(B.begin(),B.end());
  sort(C.begin(),C.end());
  
  A.push_back(10000000000);
  
  vector<ll> Bs(N);
  vector<ll> Bl(N);
  
  int c = 0;
  for(int i = 0;i<N;i++){
    if(A[i] < B[0]) c++;
    else break;
  }
  Bs[0] = c;
  for(int j = 1;j<N;j++){
    for(int i = c;i<N+1;i++){
      if(A[i] < B[j]) c++;
      if(A[i] >= B[j]){
        Bs[j] = c;
        break;
      }
    }
  }

  
  reverse(B.begin(),B.end());
  reverse(C.begin(),C.end());
  C.push_back(0);
  int d = 0;
  for(int i = 0;i<N;i++){
    if(C[i] > B[0]) d++;
    else break;
  }
  
  Bl[0] = d;
   for(int j = 1;j<N;j++){
    for(int i = d;i<N+1;i++){
      if(C[i] > B[j]) d++;
      if(C[i] <= B[j]){
        Bl[j] = d;
        break;
      }
    }
  }
  reverse(Bl.begin(),Bl.end());
  
  ll ans = 0;
  for(int i = 0;i<N;i++){
    ans += Bs[i]*Bl[i];
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 4976
#include <bits/stdc++.h>
using namespace std;
int n,x,y,a[2005];
int main(){
	scanf("%d%d%d",&n,&x,&y);
	for (int i=1;i<=n;++i) scanf("%d",&a[i]);
	if (n==1) printf("%d\n",abs(a[n]-y)); else
	printf("%d\n",max(abs(a[n]-y),abs(a[n]-a[n-1])));
	return 0;
}

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

public class Main {

    public static void main(String[] args) throws IOException {

        BufferedReader std = new BufferedReader(new InputStreamReader(System.in));
        while(true){
            String[] line = std.readLine().split(" ");
            int a = Integer.parseInt(line[0]);
            int b = Integer.parseInt(line[2]);
            
            if(line[1].equals("+")) System.out.println(a + b);
            else if (line[1].equals("-")) System.out.println(a - b);
            else if (line[1].equals("*")) System.out.println(a * b);
            else if (line[1].equals("/")) System.out.println(a / b);
            else break;
        }
        
    }
}

Measured memory_bytes: 24184
#include <iostream>
using namespace std;
typedef unsigned long long u64;
 
int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b;
  cin >> a >> b;
  cout << (a+b>=24 ? a+b-24 : a+b) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b) - 1; (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    int s,a,b;
    cin >> s;
    a = s / 100;
    b = s % 100;
    if (a <= 12 && a > 0 && b <= 12 && b > 0) {
        cout << "AMBIGUOUS" << endl;
    }else if(a <= 12 && a > 0){
        cout << "MMYY" << endl;
    }else if(b <= 12 && b > 0){
        cout << "YYMM" << endl;
    }else{
        cout  << "NA" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  long long int n,soma=0;
  cin>>n;
  for(long long int i=1;i<=n;i++){
    if(i%3!=0&&i%5!=0) soma+=i;
  }
  cout<<soma<<endl;
  return 0;
}

Measured memory_bytes: 3540
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define VMAX 10000
int main(){
  unsigned short *A,*B;
  int C[VMAX +1];
  int n,i,j;
  scanf("%d",&n);
  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  for ( i = 0; i <= VMAX; i++ ) C[i] = 0;

  for ( i = 0; i < n; i++ ){
    scanf("%hu", &A[i + 1]);
    C[A[i + 1]]++;
  }

  for ( i = 1; i <= VMAX; i++ ) C[i] = C[i] + C[i - 1];

  for ( j = 1; j <= n; j++ ){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", B[i]);
  }
  printf("\n");

  return 0;
}

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

typedef long long int ll;

ll MOD = 1000000007;
ll INF = 100000000000;
double PI = 3.1415926535;


ll modpow(ll a,ll n,ll m){//modpow(a,n,m) := a ^ n (mod m)
  ll res = 1;
  while(n > 0){
    if(n & 1)res = res * a % m;
    a = a * a % m;
    n >>= 1;
  }
  return res;
}

ll modinv(ll a,ll p){//modinv(a,p) := pを法とするaの逆元(※pは素数でなければならない)
    ll res = modpow(a,p-2,p);
    return res;
}

ll modCON(ll n,ll r,ll m){
   ll res = 1;
   for(int i = 1;i <= n;i++){
      res *= i;
      res %= m;
   }
   for(int i = 1;i <= r;i++){
      res *= modinv(i,m);
      res %= m;
   }
   for(int i = 1;i <= n-r;i++){
      res *= modinv(i,m);
      res %= m;
   }
   return res;
}


int main(){
 ll X,Y;
 cin >> X >> Y;
 if(X < Y){
    swap(X,Y);
 }
 bool frag = 0;
 ll A = 0,B = 0;//A = (1,2),B = (2,1)
 ll x = X,y = Y;
 while(x || y){
    if(y >= x){
       A++;
       y -= 2;
       x -= 1;
       if(x <= 0 || y <= 0){
          break;
       }
    }else{
       B++;
       x -= 2;
       y -= 1;
       if(x < 0 || y < 0){
          break;
       }
    }
 }
 if(A * 2 + B == Y && B * 2 + A == X){
    frag = 1;
 }
 //cout << frag << endl;
 //cout << A << ' ' << B << endl;
 if(frag){
    cout << modCON(A+B,min(A,B),MOD) << endl;
 }else{
    cout << 0 << endl;
 }
}

Measured memory_bytes: 256
#include <iostream>
#include <unordered_map>
#define rep(i, n) for (int i = 1; i <= n; i++)

using namespace std;

const int K = 110, N = 110;

int a[K][N];

unordered_map<int, int> mp;

int main() {
	int n, k;
	cin >> n >> k;
	
	rep (i, k) {
		int d;
		cin >> d;
		rep (j, d) {
			cin >> a[i][j];
			mp[a[i][j]]++;
		}
	}
	
	int cnt = 0;
	rep (i, n) {
		if (!mp[i]) cnt++;
	}
	
	cout << cnt << '\n';
	
	return 0;
}

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

int main() {
	string S;
	cin >> S;
	if (S.size() % 2 == 1) {
		cout << "No" << endl;
      return 0;
	}
	else {
		for (int i = 0; i < S.size(); i++) {
			if ((i % 2 == 0 && S[i] != 'h') || (i % 2 == 1 && S[i] != 'i')) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
#define M 1000000007
#define all(a) (a).begin(),(a).end()
#define rep(i,n) reps(i,0,n)
#define reps(i,m,n) for(int i=(m);i<(n);i++)
int main(){
  ll n,m;cin>>n>>m;
  priority_queue<ll> p;
  rep(i,n){
    ll a;cin>>a;
    p.push(a);
  }
  rep(i,m){
    p.push(p.top()/2);p.pop();
  }m=0LL;
  while(!p.empty()){
    m+=p.top();p.pop();
  }
  cout<<m;
}

Measured memory_bytes: 1400
N, Ma, Mb = map(int,input().split())
rate = Ma / Mb
a = [0] * N
b = [0] * N
c = [0] * N
MA = 0
MB = 0
MC = 0
for i in range(N):
    a[i], b[i], c[i] = map(int, input().split())
    MA += a[i]
    MB += b[i]
    MC += c[i]
    
dp = [[[MC for i in range(MB+1)] for j in range(MA+1)] for k in range(N+1)]
dp[0][0][0] = 0

for it_N in range(N):
    for it_MA in range(MA+1):
        for it_MB in range(MB+1):
            if it_MA >= a[it_N] and it_MB >= b[it_N]:
                if dp[it_N][it_MA-a[it_N]][it_MB-b[it_N]] != MC:
                    dp[it_N+1][it_MA][it_MB] = min(dp[it_N][it_MA-a[it_N]][it_MB-b[it_N]] + c[it_N], dp[it_N][it_MA][it_MB])
                else:
                    dp[it_N+1][it_MA][it_MB]=dp[it_N][it_MA][it_MB]
            else:
                dp[it_N+1][it_MA][it_MB]=dp[it_N][it_MA][it_MB]

ans = -1
for a in range(1, MA+1):
    for b in range(1, MB+1):
        if a/b == rate and dp[N][a][b] != MC:
            if ans == -1:
                ans = dp[N][a][b]
            else:
                ans = min(dp[N][a][b], ans)
print(ans)


Measured memory_bytes: 26216
#include "bits/stdc++.h"
#define allr(x) x.rbegin(), x.rend()
#define all(x) x.begin(), x.end()
#define sp " "
#define double long double
#define pb push_back
#define ff first
#define int long long
#define ss second
#define vi vector<int>
#define mem(ara, a) memset(ara, a, sizeof(ara))

long long inf = 2e18;
long long minf = -inf;

using namespace std;

signed main()
{

    ios::sync_with_stdio(false);
    cin.tie(0);
    int a , b;
    string s,sr,t;
    cin >> s >> sr;
    if (s==s){
        cin >> a >> b;
    }
    else if (s!=s){
        cin >> b >> a;
    }
    cin >> t;
    if (t==s){
        cout << a-1 << " " << b << endl;
    }
    else if (t!=s){
        cout << a << " " << b-1 << endl;
    }

}


Measured memory_bytes: 256
n = int(input())
dat = []
for i in range(n):
    t = input().split()
    dat.append((t[0], int(t[1])))
m = input()
f = False
res = 0
for i in range(n):
    if f:
        res += dat[i][1]
    else:
        if m == dat[i][0]:
            f = True
print(res)


Measured memory_bytes: 38384
n = int(input())
a=[0]*(n+1)
for i in range(2,n+1):
    x=i
    for j in range(2,n+1):
        while x%j==0:
            a[j]+=1
            x//=j
def num(n):
    return len(list(filter(lambda x: x>=n-1,a)))

print(num(75) + num(25) * (num(3)-1) + num(15)*(num(5)-1) + num(5)*(num(5)-1)*(num(3)-2)//2)

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

int main(){

	int i,n;
	double v,t,y;

	while(scanf("%lf",&v)!=EOF){

		t=v/9.8;
		y=4.9*t*t;

		n=(int)ceil(((y+5.0)/5.0));

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

	}


	return 0;

}

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

using namespace std;

int main(){
  string s,t; cin >> s >> t;
  bool frg= true;
  for(int i=0;i<s.length();i++){
      if(s[i]!=t[i]) frg=false;
  }
  if(frg) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
#define repr(i,k,n) for(int i = (k); i < (n); i++)
#define rep(i,n) repr(i,0,n)
#define ALL(a) begin(a),end(a)
const int INF = 114514810;
const int MOD = 1000000007;
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
int ctoi(const char c){
    switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
  }
}
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int A,B,C,D;
	char ABCD[4];
	cin >> ABCD;
	A=ctoi(ABCD[0]);
	B=ctoi(ABCD[1]);
	C=ctoi(ABCD[2]);
	D=ctoi(ABCD[3]);
	if (A+B+C+D==7){
		cout << A << "+" << B << "+" << C << "+" << D << "=7" << endl;
		exit(0);
	}else if (A+B+C-D==7){
		cout << A << "+" << B << "+" << C << "-" << D << "=7" << endl;
		exit(0);
	}else if (A+B-C+D==7){
		cout << A << "+" << B << "-" << C << "+" << D << "=7" << endl;
		exit(0);
	}else if (A+B-C-D==7){
		cout << A << "+" << B << "-" << C << "-" << D << "=7" << endl;
		exit(0);
	}else if (A-B+C+D==7){
		cout << A << "-" << B << "+" << C << "+" << D << "=7" << endl;
		exit(0);
	}else if (A-B+C-D==7){
		cout << A << "-" << B << "+" << C << "-" << D << "=7" << endl;
		exit(0);
	}else if (A-B-C+D==7){
		cout << A << "-" << B << "-" << C << "+" << D << "=7" << endl;
		exit(0);
	}else{
		cout << A << "-" << B << "-" << C << "-" << D << "=7" << endl;
		exit(0);
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
clock_t __my_start_clock = clock();
#else
#define eprintf(...)
#endif

#define TIMESTAMP(x) eprintf("["#x"] Time : %.3lf s.\n", (clock() - __my_start_clock)*1.0/CLOCKS_PER_SEC)
#define TIMESTAMPf(x,...) eprintf("[" x "] Time : %.3lf s.\n", __VA_ARGS__, (clock() - __my_start_clock)*1.0/CLOCKS_PER_SEC)

using namespace std;

#ifdef LOCAL
static struct __timestamper {
  string what;
  __timestamper(const char* what) : what(what){};
  __timestamper(const string& what) : what(what){};
  ~__timestamper(){
    TIMESTAMPf("%s", what.data());
	}
} __TIMESTAMPER("end");
#else 
struct __timestamper {};
#endif

typedef long long ll;
typedef long double ld;

struct pt {
  double x, y;
  pt operator-(const pt&a) {
    return {x - a.x, y - a.y};
  }
  double dist() {
    return sqrt(x * x + y * y);
  }
};

double my_tan(double x) {
  if (x > M_PI / 2 - 0.0001) {
    double y = M_PI / 2- x;
    return 1.0 / y - y / 3 - y * y *y / 45;
  }
//  if (x < 0.1) {
//    return x;// + x * x * x / 3 + 2 * x * x * x * x * x / 15;
//  }
//  eprintf("%lf\n", x);
  return tan(x);
}

int main() {
#ifdef LOCAL
  freopen("d.in", "r", stdin);
//  freopen("d.out", "w", stdout);
#endif

  int n, L;
  while (scanf("%d%d", &n, &L) == 2) {
    vector<pt> p(n);
    vector<double> ang(n);
    vector<int> t(n);
    for (int i = 0; i < n; i++) {
      scanf("%d", &t[i]);
    }
    sort(t.begin(), t.end());
    for (int i = 0; i < n; i++) {
      ang[i] = M_PI * t[i] / L;
      p[i].x = cos(2 * M_PI * t[i] / L);
      p[i].y = sin(2 * M_PI * t[i] / L);
    }

    double ans_x = 0;
    double ans_y = 0;

    for (int i = 0; i < n; i++) {
      double weight = 0;
      double cur = 0;
      vector<double> cur2(n);
      vector<double> t(n);
      for (int j = n - 1; j >= 1; j--) {
        double b = ang[j] - ang[0];
        if (b < 0) b += M_PI;
        b /= 2;
        cur2[j] = cur;
        t[j] = my_tan(b);
        cur += 1.0 / t[j];
      }
      for (int j = 1; j < n; j++) {
        weight -= t[j] * cur2[j];
      }
      weight += (n - 1) * 1.0 * (n - 2) / 2;
//      eprintf("%lf\n", weight);
      weight /= n - 2;
      weight /= n - 1;
      ans_x += p[0].x * weight * 3 / n;
      ans_y += p[0].y * weight * 3 / n;
      rotate(p.begin(), p.begin() + 1, p.end());
      rotate(ang.begin(), ang.begin() + 1, ang.end());
//      break;
    }

    printf("%.18lf %.18lf\n", ans_x, ans_y);
    break;
  }

  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define res register int
#define ll long long 
#define N 100050
using namespace std;
int a[N],b[N],n,m,ans;
map<int,int>lisan;
int main()
{
	scanf("%d",&n);
	for(res i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		b[i]=a[i];
	}
	
	sort(b+1,b+1+n);
	
	for(res i=1;i<=n;i++)
	lisan[b[i]]=i;
	
	for(res i=1;i<=n;i++)
	{
		int tem=abs(i-lisan[a[i]]);
		if(tem%2>0)
		ans++;
	}
	printf("%d",ans/2);
}


Measured memory_bytes: 5760
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
	string s; cin >> s;
	cout << s.substr(0, 4) << ' ' << s.substr(4) << endl;
}

Measured memory_bytes: 256
#include <iostream>

int N;
int x, y, z;

int main() {
    std::cin >> N;

    for(int i = 0; i<N; ++i) {
        std::cin >> x >> y >> z;
        
        int a = std::min(x, std::min(y, z));
        int c = std::max(x, std::max(y, z));
        int b = (x + y + z) - (a + c);

        if(a*a + b*b == c*c) {
            std::cout << "YES" << std::endl;
        } else {
            std::cout << "NO" << std::endl;
        }
    }
}


Measured memory_bytes: 2988
using System;

namespace ABC095
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            var cost = 700;

            if(S[0] == 'o') cost = cost + 100;
            if (S[1] == 'o') cost = cost + 100;
            if (S[2] == 'o') cost = cost + 100;

            Console.WriteLine(cost);
        }
    }
}


Measured memory_bytes: 25752
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;
using P = pair<int, int>;
const long long INF = 100000000;
//ダイクストラ法の練習

int main(){
  int N,M;
  cin >> N >> M;
  vector<vector<int>> edge(101, vector<int> (0));
  vector<vector<int>> L(101, vector<int> (101) );
  rep(i, M){
    int a, b,c;
    cin >>a>>b>>c;
    edge[a].push_back(b);
    edge[b].push_back(a);
    L[a][b] = c;
    L[b][a] = c;
  }
  
  vector<vector<int>> min_dist(101, vector<int> (101));
  
  //スタートがi
  for(int i = 1; i < N; i++){
    
    //int i = 1;//テスト
  
      //準備
      priority_queue<P, vector<P>, greater<P>> pq;//pair<仮の距離、頂点>仮の距離が小さい順に並ぶ
      vector<int> dist(N+1, INF);//スタートからの最短距離を更新し続ける
        
  
  
      //初期条件
      dist[0] = 0;//頂点0は使わない
      dist[i] = 0;//頂点iまでの距離は0
      pq.push(make_pair(dist[i], i));
            
      //jが確定するまで続ける
      while(!pq.empty()){
        P p = pq.top();//仮距離最小を取り出す
        pq.pop();//削除する
        int v = p.second;//頂点を取り出す
        //更新しない場合
        //if(dist[v] < p.first){
         // continue;
       // }
        //更新する場合,vから行けるすべての頂点に対して
        for(int u:edge[v]){
          if(dist[v]+L[v][u] < dist[u]){
            dist[u] = dist[v]+L[v][u];
          
            pq.push(make_pair(dist[u], u));
          }
        }
      }
    //記録する
    for(int j = i+1; j <= N; j++){
      min_dist[i][j] = dist[j];
      min_dist[j][i] = dist[j];
    }      
  }
  
  int counter = 0;
  for(int i = 1; i <= N; i++){
    for(int j: edge[i]){
      bool x = false;
      for(int s = 1; s <= N; s++){
        if(min_dist[s][i]+ L[i][j] == min_dist[s][j]){
          x = true;
        }
      }
      if(x){
        counter++;
      }
    }
  }
   cout << M-counter/2 << endl;

    
  
  //rep(i, N+1){
 //  rep(j, N+1){
    //cout << min_dist[i][j] << " ";  
   //}
   // cout << endl;
  //}
}





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

int main(){
    long long n,k;cin>>n>>k;
    vector<long long>a(n),b(40,0),c(40,1),d(40,0);
    for(int i=0;i<n;++i){
        cin>>a[i];
        int cnt=0;
        while(a[i]>0){
            if(a[i]%2==1)b[cnt]++;
            a[i]/=2;
            cnt++;
        }
    }
    long long m=k+1;
    int co=0;
    while(m>0){
        if(m%2==1)d[co]++;
        co++;
        m/=2;
    }
    for(int i=1;i<40;++i)c[i]=c[i-1]*2;
    long long ans=0;
    for(int i=0;i<40;++i){
        if(d[i]==1){
            long long sum=0;
            for(int j=0;j<i;++j){
                sum+=c[j]*max(b[j],n-b[j]);
            }
            sum+=c[i]*b[i];
            for(int j=i+1;j<40;++j){
                if(d[j]==0)sum+=c[j]*b[j];
                else sum+=c[j]*(n-b[j]);
            }
            ans=max(ans,sum);
        }
    }
    cout<<ans<<endl;
}


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

int main() {
int num;
cin >> num;
vector<int> vec; // int型の配列変数vecを宣言
 vec = {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};
cout << vec.at(num-1)<< endl;
}


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

int main() {
    int a, b;
    cin >> a >> b;
    if ((a + b) % 2 == 0){
        int x = (a + b) / 2;
        cout << x << endl;
    } 
    else {
        int y = (a + b + 1) / 2;
        cout << y << endl;
    }
}

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

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<string>vst;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
#define all(ct) ct.begin() , ct.end()
#define endl "\n"
#define fr(i,a) for(auto i:a)
#define f(i,a,b) for(int i=a;i<b;++i)
#define fd(i,a,b) for(int i=a;i>=b;--i)
#define pb push_back
#define in(d,v) d.find(v)!=d.end()
#define mp make_pair
#define size(a) int(a.size())

const ll mod = 1e9 + 7;
const ll inf = ll(1e18);
const double PI = acos(-1);

ll modexp(ll x, ll n, int md) {
    if (n == 0)return 1;
    if (n % 2 == 0)return modexp((x * x) % md, n / 2, md);
    return (x * modexp((x * x) % md, n / 2, md)) % md;
}


int main(){
    fastio;
    //clock_t tm = clock();
    int x;
    cin>>x;
    if(x<30)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    //cout<<((clock()-tm)*1.0)/CLOCKS_PER_SEC<<endl;
}

Measured memory_bytes: 3632
n, a, b = map(int, input().split())
def sum_product_mod(a, n, m):
    """aから一つずつ引いたのをn回掛ける"""
    res = a
    for i in range(1, n):
        res = res * (a - i) % m
    return res

def pow_mod(n, p, m):
    res = 1
    while p > 0:
        if p & 1:
            res = res * n % m
        p >>= 1
        n = n * n % m
    return res

MOD = 10 ** 9 + 7
all_comb = pow_mod(2, n, MOD) - 1
a_comb = sum_product_mod(n, a, MOD) * pow_mod(sum_product_mod(a, a, MOD), MOD-2, MOD)
b_comb = sum_product_mod(n, b, MOD) * pow_mod(sum_product_mod(b, b, MOD), MOD-2, MOD)
ans = (all_comb - a_comb - b_comb) % MOD
# print(all_comb, a_comb, b_comb)
print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	static int cnt = 1;

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int k = sc.nextInt();
		if (k <= n)
			div(n, k);
		System.out.println(cnt);
	}

	private static void div(int n, int k) {
		cnt++;
		int val = n / k;
		if (k <= val) {
			div(val, k);
		}
	}

}

Measured memory_bytes: 21844
/*
	
	@Raghul
*/
#include <bits/stdc++.h> 
using namespace std; 
#define ll long long
ll ans[100005];
map <char,ll> m;
ll fastpow(ll a,ll b){
	if(b==0)
		return 1LL;
	ll temp=fastpow(a,b/2);
	temp=temp*temp;
	if(b%2==1)
		temp=temp*a;
	return temp;
}	
bool comp(string s1, string s2){
	for(int i=0;i<min(s1.length(),s2.length());i++){
		if(m[s1[i]]!=m[s2[i]]){
			return m[s1[i]]<m[s2[i]];
		}
	}
	return 1;
}
void solve(){
	ll n,h,w;
	cin>>n>>h>>w;
	ll cnt = 0;
	while(n--){
		ll a,b;
		cin>>a>>b;
		if(a>=h&&b>=w)	cnt++;
	}
	cout<<cnt;
}
int main(){ 
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T;
    T = 1;
    while(T--){
    	solve();
    }
	return 0; 
} 

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

ll r(ll x, ll y) {
  if (y == 0) return 1;
  else if (y % 2 == 0) return r(x, y/2) * r(x, y/2) % mod;
  else return x * r(x, (y-1)/2) % mod * r(x, (y-1)/2) % mod;
}

int main() {
  string n;
  cin >> n;
  if (n == "ABC") cout <<"ARC" <<endl;
  else cout << "ABC" <<endl;
}

Measured memory_bytes: 3628
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>		//UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>		//do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)
#define ALL(u) (u).begin(),(u).end()

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

typedef pair<int, int> PII;

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;

const int MR = 26;
const int MS = 2e5 + 10;

vector<int> pos[MR];

char s[MS];

bool done[MS];

string bfs()
{
	vector<PII> Q;
	Q.push_back(MP(-1, -1));

	int p = 0;

	while (true)
	{
		auto akt = Q[p]; p++;

		REP(i, MR)
		{
			int wsk = upper_bound(pos[i].begin(), pos[i].end(), akt.first) - pos[i].begin();
			if (wsk == pos[i].size())
			{
				string res = "";
				res += i + 'a';
				int tmp = akt.first;
				while (tmp != -1)
				{
					res += s[tmp];
					akt = Q[akt.second];
					tmp = akt.first;
				}

				reverse(res.begin(), res.end());

				return res;
			}

			if (!done[pos[i][wsk]])
			{
				Q.push_back(MP(pos[i][wsk], p - 1));
				done[pos[i][wsk]] = 1;
			}
		}
	}

	return "";
}

int main()
{
	scanf("%s", s);

	int n = strlen(s);

	REP(i, n)
		pos[s[i] - 'a'].push_back(i);

	printf("%s\n", bfs().c_str());

	return 0;
}

Measured memory_bytes: 3700
A, B, C, X, Y = map(int, input().split())

if A + B >= C * 2:
    if X > Y:
        ans = min((C * (Y * 2) + A * (X - Y)), C * X * 2)
    else:
        ans = min((C * (X * 2) + B * (Y - X)), C * Y * 2)
else:
    ans = A * X + B * Y

print(ans)

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

const int mod = 2019;

typedef long long ll;

int l, r;
vector <int> un;
int res = mod;

int main()
{
    cin >> l >> r;
    for (int i = 0; i < mod; i++) {
        int nl = l / mod * mod + i;
        while (nl < l) nl += mod;
        if (nl <= r) un.push_back(nl);
        int nr = r / mod * mod + i;
        while (nr > r) nr -= mod;
        if (l <= nr) un.push_back(nr);
    }
    sort(un.begin(), un.end()); un.erase(unique(un.begin(), un.end()), un.end());
    for (int i = 0; i < un.size(); i++)
        for (int j = i + 1; j < un.size(); j++)
            res = min(res, int(ll(un[i]) * un[j] % mod));
    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 256
import sys
readline = sys.stdin.readline

N = int(readline())
A = list(map(int, readline().split()))

if N % 2 == 0:
    dp = [[0, 0] for i in range(N)]
    dp[1] = [A[0], A[1]]
    for i in range(3, N, 2):
        dp[i][0] = dp[i - 2][0] + A[i - 1]
        dp[i][1] = max(dp[i - 2][0] + A[i], dp[i - 2][1] + A[i])
    print(max(dp[N - 1]))

else:
    dp = [[0, 0, 0] for i in range(N)]
    dp[0] = [A[0], 0, 0]

    for i in range(2, N, 2):
        dp[i][0] = dp[i - 2][0] + A[i]
        dp[i][1] = max(dp[i - 2][0], dp[i - 2][1] + A[i - 1])
        dp[i][2] = max(dp[i - 2][1] + A[i], dp[i - 2][2] + A[i])

    print(max(dp[N - 1]))

Measured memory_bytes: 113020
import sys
sys.setrecursionlimit(10**7)
s = list(input())
t = list(input())

if s == t: print(0), sys.exit()

cnt = 0
for i in range(len(s)):
    if t[i] != s[i]:
        t[i] = s[i]
        cnt += 1
print(cnt)

Measured memory_bytes: 12356
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  string str;
    
  cin >> N ;
  
  int ans = 0;
  int curr = 0;
  for(int i =0; i<N; i++){
    str = to_string(i+1);
    curr = (int)(str.length());
    if( curr%2 == 1){
      ans++;
    }
  }
  cout << ans;
}

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

const int MAXN = 5010*5010;
long long dp[MAXN]; //dp[remain_thisround] = got_on_nextround;
long long n, maxnum;
void update(int price, long long gain) {
	for (int i=0; i+price<=n; i++)
		if (dp[i] >= 0) {
			dp[i+price] = max(dp[i+price], dp[i]+gain);
			maxnum = max(maxnum, dp[i+price] + n-(i+price));
		}
}

int main() {
	cin>>n;
	maxnum = n;
	int Xina, Yina, Zina;
	int Xinb, Yinb, Zinb;
	cin>>Xina>>Yina>>Zina;
	cin>>Xinb>>Yinb>>Zinb;
	memset(dp, 0xff, sizeof(dp)); dp[0] = 0;
	// cout<<dp[1]<<" "<<dp[125]<<endl;
	if (Xina < Xinb)
		update(Xina, Xinb);
	if (Yina < Yinb)
		update(Yina, Yinb);
	if (Zina < Zinb)
		update(Zina, Zinb);

	n = maxnum;
	memset(dp, 0xff, sizeof(dp)); dp[0] = 0;
	if (Xinb < Xina)
		update(Xinb, Xina);
	if (Yinb < Yina)
		update(Yinb, Yina);
	if (Zinb < Zina)
		update(Zinb, Zina);

	cout<<maxnum<<endl;
	return 0;
}

Measured memory_bytes: 196352
#include <bits/stdc++.h>
using namespace std;
int main(){
  int x,num;
  cin >> x;
  num = x;
  int fx = 0;
  for(int i = 0; i < 8; i++){
    int place = x%10;
    fx += place;
    x = x/10;
  }
  if(num % fx == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int a[3];
	int q = 0;

	cin >> a[0] >> a[1] >> a[2];

	for (int i = 0; i < 3; i++)
	{
		if (a[i] == 5)q++;
		else if (a[i] == 7)q += 3;
	}

	if (q == 5)cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
}


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

using namespace std;

using   ll=long long;
using   ld=long double;

#define fast           ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl           "\n"
#define long long      int 
#define pb             push_back
#define mp             make_pair
#define ff             first
#define ss             second
#define pll            pair<ll,ll>
#define ALL(v)         v.begin(),v.end()
#define ALLR(v)        v.rbegin(),v.rend()
#define pii            3.14159265358979323
#define inf 		   LLONG_MAX
#define ones(x)		   __builtin_popcount(x)

void solve()
{
	ll n,a,b;
	
	cin>>n>>a>>b;
	
	if(a==0)
	{
		cout<<0;
		return;
	}
	
	cout<<(n/(a+b))*a+min(n%(a+b),a)<<endl;
}
 
signed main()
{
 
    fast;
 
    ll t;
    
    t=1;
    
    //cin>>t;
    
    while(t--)
    {
        solve();
    }
 
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
using static Func;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	uint[] GU => Strs.Select(uint.Parse).ToArray();
	decimal[] GD => Strs.Select(decimal.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	static T[] ConstantArray<T>(int n, T val) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = val; return a; }
	static T[] MakeArray<T>(int n, Func<int, T> f) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = f(i); return a; }
	static T[] Recurse<T>(int n, T a0, Func<int, T, T> f) { var a = new T[n]; a[0] = a0; for (var i = 1; i < n; i++) a[i] = f(i, a[i - 1]); return a; }
	static T[] Accumulate<T>(IList<T> a, T zero, Func<T, T, T> f) { var s = new T[a.Count + 1]; s[0] = zero; for (var i = 0; i < a.Count; i++) s[i + 1] = f(s[i], a[i]); return s; }
	static ulong One(int k) => 1ul << k;
	static ulong All(int k) => One(k) - 1;
	static bool Has(ulong s, int k) => (s & One(k)) != 0;
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var N = F;
		WriteLine(180 * (N - 2));
	}
}
static class Func { }


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n;
	cin>>n;
	long long a,b;
	cin>>a>>b;
	if(n>1&&b>=a||n==1&&a==b)
	cout<<(n-2)*(b-a)+1<<endl;
	else
	cout<<"0"<<endl;
	return 0;
}

Measured memory_bytes: 256
import math

a,b,c=map(float,input().split())
h=b*math.sin(math.pi*c/180)
s=a*h/2
l=a+b+math.sqrt(a**2+b**2-2*a*b*math.cos(math.pi*c/180))
print(s)
print(l)
print(h)



Measured memory_bytes: 5692
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In,' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var H = cin.ReadLong;
            var length = Convert.ToString(H,2).Length;
            var ans = Math.Pow(2,length) -1 ;
            WriteLine(ans);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream,char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }

        public string Read
        {
            get
            {
                if(inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for(int i = 0;i < tmp.Length;i++)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }

        
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }

}

Measured memory_bytes: 11348
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,k;
cin>>n>>k;
int arr[n];
for(int i=0;i<n;i++)
cin>>arr[i];
int dp[n+2];
for(int i=0;i<=n;i++)dp[i]=1000000000;;
dp[0]=0;
for(int i=0;i<n;i++)
{
    int a,b;
    for(int j=i+1;j<i+1+k&&j<n;j++)
    {
        
     dp[j]=min(dp[j],dp[i]+abs(arr[j]-arr[i]));   
    }
    
}
cout<<dp[n-1];
}


Measured memory_bytes: 1024
#include <chrono>

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <time.h>
#include <random>
#include <string>
#include <cassert>
#include <vector>
#include <ostream>
#include <istream>
#include <stack>
#include <deque>
#include <queue>
#include <functional>

using namespace std;

#define int long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define ld long double

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << " ";
    return a;
}

#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << (x) << "\n";
    const int INF = 1e18;
//    const int mod = 2600000069;
//    const int p = 10;
//    const ld PI = 3.1415926535;
#else
    #define dbg(x)
    const int INF = 1e18;
//    const int mod = 2600000069;
//    const int p = 179;
//    const ld PI = 3.1415926535;
#endif

//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,sse3,sse4")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("fast-math")
//#pragma GCC target("avx2")
//#pragma GCC optimize("section-anchors")
//#pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
//#pragma GCC optimize("vpt")
//#pragma GCC optimize("rename-registers")
//#pragma GCC optimize("move-loop-invariants")
//#pragma GCC optimize("unswitch-loops")
//#pragma GCC optimize("function-sections")
//#pragma GCC optimize("data-sections")

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifdef LOCAL
    #else
//        freopen("capitals.in", "r", stdin);
//        freopen("capitals.out", "w", stdout);
    #endif
    int h, n;
    cin >> h >> n;
    vector<pii> a(n);
    for (int i = 0; i < n; i++) cin >> a[i].first >> a[i].second;
    vector<int> dp(h + 1, INF);
    dp[0] = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < n; j++) {
            dp[min(i + a[j].first, h)] = min(dp[min(i + a[j].first, h)], dp[i] + a[j].second);
        }
    }
    cout << dp[h];
}
/*

*/


Measured memory_bytes: 384