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

typedef vector<int> vi;
vi v;
int n,sum;

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    while(cin >> n)
    {
        v = vi(n+2,0); sum = 0;
        for(int i = 1; i <= n; i++)
        {
            cin >> v[i];
            sum += abs(v[i]-v[i-1]);
        }
        sum += abs(v[n]);
        for(int i = 1; i <= n; i++)
            cout << sum - abs(v[i]-v[i-1]) - abs(v[i]-v[i+1]) + abs(v[i+1]-v[i-1]) << '\n';
    }
    return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main() {
    ios_base::sync_with_stdio(false), cin.tie(nullptr);    
    long long n;
    cin >> n;
    long long l, val, pval = 1;
    for (l = 2; l < 12; l++) {
        val = (pow(26, l) - 1) / 25;
        if (val > n) {
            break;
        }
        pval = val;
    }
    l--;
    val = n - pval;
    string ans;
    while (l--) {
        ans += 97 + (val % 26);
        val /= 26;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 4040
#include <iostream>
#include <vector>

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

int main() {
  int N;
  cin >> N;
  vector<int> v(N);
  vector<int> c(N);
  rep(i, N) {
    cin >> v.at(i);
  }
  rep(i, N) {
    cin >> c.at(i);
  }
  int sumv = 0;
  int sumc = 0;
  rep(i, N) {
    if (v.at(i) >= c.at(i)) {
      sumv += v.at(i);
      sumc += c.at(i);
    }
  }
  cout << (sumv - sumc) << endl;
}


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

n = int(input())
lis = list(map(int, input().split()))

su1 = sum(lis)
su2 = sum(lis[1::2])

ans = [0] * n
ans[0] = su1 - 2 * su2

for i in range(1, n):
    ans[i] = 2 * lis[i - 1] - ans[i - 1]

print(*ans)


Measured memory_bytes: 14124
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
ll gcd(ll x,ll y){
	if (y >0){
		gcd(y,x%y);
	}else{
		return x;
	}
}
ll lcm (ll x,ll y){
	return x/gcd(x,y)*y;
}


int main(){
	ll a1,a2,a3,m1,m2,m3;
	while(cin>>a1>>m1>>a2>>m2>>a3>>m3,a1||a2||a3||m1||m2||m3){
		ll x,y,z,a,b,c;
		a =b = c = x = y = z = 1;
		x =(a1*x)%m1;
		y =(a2*y)%m2;
		z =(a3*z)%m3;
		for(;x !=1;a++){
			x =(x*a1)%m1;
		}
		for(;y !=1;b++){
			y =(y*a2)%m2;
		}
		for(; z!=1;c++){
			z =(z*a3)%m3;
		}
		ll cnt =lcm(lcm(a,b),c);
		cout <<cnt<<endl;
	}
	return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define INF 0x3f3f3f3f
#define PI acos(-1.0)
#define eps 1e-8
#define R freopen("555input.txt","r",stdin);
#define W freopen("555output.txt","w",stdout);
//
#define N 100005
#define MAXN 100000
int  ans,i,j,k,n,a[N],b[N],f,g;
int  gcd(int a,int b){return b==0?a:gcd(b,a%b);}

int main()
{
    
    scanf("%d%d",&n,&k);
    for(i=0; i<n; i++){
        scanf("%d",&a[i]);
        if(a[i]>=k)b[j++]=a[i];}
    if(n==1)if(a[0]==k){printf("POSSIBLE\n");return 0;}
    else {printf("IMPOSSIBLE\n");return 0;}
    g=gcd(a[0],a[1]);
    for(i=2;i<n;i++)
       g=gcd(g,a[i]);
    for(i=0;i<j;i++)
    if(gcd(b[i],k)%g==0){printf("POSSIBLE\n");return 0;}
    printf("IMPOSSIBLE\n");
    return 0;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
typedef pair<int,int>P;
typedef pair<int,P>P2;
#define F first
#define S second

signed main(){
  int n;
  cin>>n;
  int a[n];
  r(i,n)cin>>a[i];

  r(i,n)r(j,n){
    swap(a[i],a[j]);
    int f=0;
    r(k,n-1)if(a[k]>a[k+1])f=1;
    if(!f){
      cout<<"YES"<<endl;
      return 0;
    }
    swap(a[i],a[j]);
  }
  cout<<"NO"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <cmath>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>func(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p;
}

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  int ans=0;
  if(a+b<c){ans=a+b+1+b;}
  else{ans=b+c;}
  cout<<ans<<endl;
  return 0;
}

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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

// x^n
ll mod_pow(ll x, ll n) {
  if (n == 0) return 1;
  ll res = mod_pow(x * x % MOD, n / 2);
  if (n & 1) res = res * x % MOD;
  return res;
}

// x^{-1}
ll inv(ll x) { return mod_pow(x, MOD - 2); }

ll fact[100001];
ll fact_inv[100001];

void init_fact() {
  fact[0] = fact_inv[0] = 1;
  REP(i, 100000) {
    fact[i + 1] = fact[i] * (i + 1) % MOD;
    fact_inv[i + 1] = fact_inv[i] * inv(i + 1) % MOD;
  }
}

ll nCr(ll n, ll r) {
  if (n < r || n < 0 || r < 0) return 0;
  return fact[n] * fact_inv[r] % MOD * fact_inv[n - r] % MOD;
}

ll nPr(ll n, ll r) { return nCr(n, r) * fact[r] % MOD; }

int n, k;
vector<int> G[100000];
ll ans = 1;

// v:頂点, p:vの親
// vの子頂点たちの塗り方
// 自分が根の場合→_{k-1}P_{c}
// 自分が根でない場合→_{k-2}_P_{c}
void dfs(int v, int p) {
  int c = 0;  // vの子の数
  REP(i, G[v].size()) {
    if (G[v][i] == p) continue;
    c++;
    dfs(G[v][i], v);
  }
  if (p == -1) {  // 自分が根
    ans = ans * nPr(k - 1, c) % MOD;
  } else {  // そうでない
    ans = ans * nPr(k - 2, c) % MOD;
  }
}

int main() {
  init_fact();
  cin >> n >> k;
  REP(i, n - 1) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  dfs(0, -1);
  // 根の塗り方はk通り
  cout << k * ans % MOD << endl;
  return 0;
}

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

int main()
{
    int n;
    scanf("%d", &n);
    int r;
    scanf("%d", &r);
    --n;
    int maxv=-2000000000, minv=r, x;
    while(n--)
    {
        scanf("%d", &x);
        maxv=max(maxv, x-minv);
        minv=min(minv, x);
    }
    printf("%d\n", maxv);
    return 0;
}



Measured memory_bytes: 3228
use std::cmp;
use std::collections::HashMap;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        d: u64,
        n: usize
    }

    let mut ans = 0;
    let mut unit = 1;
    for i in 0..d {
        unit *= 100;
    }

    ans = unit * n;
    if ans % (unit * 100) == 0 {
        ans += unit;
    }
    println!("{}", ans);
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


Measured memory_bytes: 8572
#include <iostream>
using namespace std;
int main() {
    int a , b;
    cin>> a >> b;
    while (a > 0 || b > 0 ) {
	    
	    for (int i=1; i<=a; i++) {
		    for (int j=1; j<=b; j++) {
				cout <<'#';  
			}
			cout<< endl;	        
		}
		cout<< endl;
		cin>> a >> b;
	}
	
	
}
    


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

int main(){
  int N,m;
  cin >> N;
  for(int i = 0; i < N; i ++){
    string S;
    cin >> S;
    if(S == "Y"){
      m ++;
      break;
    }
  }
  if(m == 0){
    cout << "Three" << endl;
  }
  else if(m == 1){
    cout << "Four" << endl;
  }
}

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

signed main() {
  int n;
  cin>>n;
  int a0,ma=0;
  pair<int,int> p[n];
  vector<pair<int,int>> q;
  for(int i=0;i<n;i++){
    cin>>a0;
    p[i]=make_pair(a0,i);
    if(ma<a0){
      q.push_back(make_pair(a0,i));
      ma=a0;
    }
  }
  int ans[n]={},j=0;
  sort(p,p+n);
  ans[q[j].second]+=p[0].first*n;
  for(int i=1;i<n;i++){
    if(q[j].first<p[i].first)j++;
    ans[q[j].second]+=(p[i].first-p[i-1].first)*(n-i);
  }
  for(int i=0;i<n;i++)cout<<ans[i]<<endl;

  
  return 0;
}


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

int main()
{
    int a, b, c, k ;
    cin >> a >> b >> c ;
    cin >> k ;
    while(k--)
    {
        if(c<=b || c<=a)
            c*=2;
        else if(b<=a)
            b*=2;
        else
            c*=2;
    }
    if(c>b && b>a)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}


Measured memory_bytes: 3628
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush, heapify
import math
import itertools
import random
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
INF = float('inf')
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    W,H,N = inputMap()
    x_hidari = 0
    x_migi = W
    y_shita = 0
    y_ue = H
    
    for i in range(N):
        x,y,a = inputMap()
        
        if a == 1:
            if x_hidari < x:
                x_hidari = x
        elif a == 2:
            if x_migi > x:
                x_migi = x
        elif a == 3:
            if y_shita < y:
                y_shita = y
        else:
            if y_ue > y:
                y_ue = y
                
    #print("{} {} {} {}".format(x_hidari,x_migi,y_ue,y_shita))
    xxx = x_migi-x_hidari
    yyy = y_ue-y_shita
    if xxx < 0 or yyy < 0:
        print(0)
        sys.exit()
    
    print(xxx * yyy)
    
    
if __name__ == "__main__":
	main()


Measured memory_bytes: 38768
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstdlib>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <string>
#include <iomanip>
#include <deque>
using namespace std;
#define int long long
int n;
int ps[300000];
int mas[300000];
int get(int l, int r) {
	return ps[r] - ps[l - 1];
}
int ans = 1234567890123456789;
void bet(int a, int b) {
	ans = min(ans, abs(a - b));
}
signed main() {
#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	int n;
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> mas[i];
		ps[i] = ps[i - 1] + mas[i];
	}
	
	for (int i = 1; i <= n - 1; ++i) {
		int f = get(1, i);
		int s = get(i + 1, n);
		bet(f, s);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3840
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class Main {
	final int _intMax = Integer.MAX_VALUE; // =2147483647>10^9
	final int _intMin = Integer.MIN_VALUE;
	final long _longMax = Long.MAX_VALUE; // =9223372036854775807L>10^18
	final long _longMin = Long.MIN_VALUE;
	static boolean bElapsed = false;

	void solve() {
		Counter c = new Counter();
		int n = readNum();
		int[] ia = readNums();
		for (int i = 0; i < ia.length; i++) {
			c.add(ia[i]);
		}
		int ans = 0;
		for (Object o : c.keySet()) {
			int key = (Integer) o;
			int cnt = c.get(o);
			if (key > cnt)
				ans += cnt;
			else if (key < cnt)
				ans += cnt - key;
		}
		pln(ans);
	}

	class Counter {
		Map<Object, Integer> map = new HashMap<>();

		public void add(Object o) {
			Integer v = map.get(o);
			if (v == null)
				map.put(o, 1);
			else
				map.put(o, v + 1);
		}

		public int get(Object o) {
			Integer v = map.get(o);
			if (v == null)
				return 0;
			else
				return v;
		}

		public Set<Object> keySet() {
			return map.keySet();
		}
	}

	int abs(int a) {
		return (a >= 0) ? a : -a;
	}

	long abs(long a) {
		return (a >= 0) ? a : -a;
	}

	int max(int a, int b) {
		return (a > b) ? a : b;
	}

	long max(long a, long b) {
		return (a > b) ? a : b;
	}

	int min(int a, int b) {
		return (a < b) ? a : b;
	}

	long min(long a, long b) {
		return (a < b) ? a : b;
	}

	int pint(String s) {
		return Integer.parseInt(s);
	}

	long plong(String s) {
		return Long.parseLong(s);
	}

	String readLine() {
		try {
			return _in.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	int readNum() {
		String line = readLine();
		return pint(line);
	}

	long readLong() {
		String line = readLine();
		return plong(line);
	}

	String[] readFlds() {
		String line = readLine();
		return line.split(" ");
	}

	int[] readNums() {
		String[] flds = readFlds();
		int[] nums = new int[flds.length];
		for (int i = 0; i < flds.length; i++)
			nums[i] = pint(flds[i]);
		return nums;
	}

	long[] readLongs() {
		String[] flds = readFlds();
		long[] nums = new long[flds.length];
		for (int i = 0; i < flds.length; i++)
			nums[i] = pint(flds[i]);
		return nums;
	}

	void p(char c) {
		_out.print(c);
	}

	void pln(char c) {
		_out.println(c);
	}

	void p(double d) {
		_out.print(d);
	}

	void pln(double d) {
		_out.println(d);
	}

	void p(long l) {
		_out.print(l);
	}

	void pln(long l) {
		_out.println(l);
	}

	void p(String s) {
		_out.print(s);
	}

	void pln(String s) {
		_out.println(s);
	}

	static BufferedReader _in;
	static PrintWriter _out;

	public static void main(String[] args) {
		long start = System.currentTimeMillis();
		_in = new BufferedReader(new InputStreamReader(System.in));
		_out = new PrintWriter(System.out);
		new Main().solve();
		_out.flush();
		long end = System.currentTimeMillis();
		if (bElapsed)
			System.err.println((end - start) + "ms");
	}
}


Measured memory_bytes: 44756
S=input()
N=len(S)
if S[0]==S[N-1]:
    a=S[0]
    count=0
    for i in range(N):
        if S[i]==a:
            count+=1
    num=N-(count*2-1)
elif N%2==1:
    f=True
    i=0
    a=S[0]
    while(i<N):
        if S[i]!=a:
            f=False
            break
        i+=2
    if f:
        num=0
    else:
        num=N-2
else:
    s=S[0]+S[-1]
    if S==s*(N//2):
        num=0
    else:
        num=N-2
if num%2==1:
    print("First")
else:
    print("Second")


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

public class Main{

    public static void main(String[] args){
		new Main().run();
    }

    void run(){
      Scanner sc=new Scanner(System.in);
      String s=sc.next();
      String t=sc.next();
      int[][] dp=new int[s.length()][t.length()];
      for(int sum=0;sum<=s.length()+t.length()-2;++sum){
          for(int i=0;i<=sum;++i){
          int j=sum-i;
          if(i>=s.length()||j>=t.length())continue;
          dp[i][j]=Math.max(dp[i][j],(i>0?dp[i-1][j]:0));
          dp[i][j]=Math.max(dp[i][j],(j>0?dp[i][j-1]:0));
          if(s.charAt(i)!=t.charAt(j))continue;
          dp[i][j]=Math.max(dp[i][j],(i>0&&j>0?dp[i-1][j-1]:0)+1);
          }
      }
      String ans="";
      int curVal=dp[s.length()-1][t.length()-1];
      int curI=s.length(),curJ=t.length();
      out:for(int sum=s.length()+t.length()-2;sum>=0;--sum){
          for(int i=0;i<=sum;++i){
            int j=sum-i;
            if(i>=curI||j>=curJ)continue;
            if(dp[i][j]==curVal&&s.charAt(i)==t.charAt(j)){
                curI=i;
                curJ=j;
                --curVal;
                ans=String.valueOf(s.charAt(i))+ans;
                continue out;
            }
	    }
	}

	System.out.println(ans);
    }
}


Measured memory_bytes: 86348
def readinput():
    s=input()
    t=input()
    return s,t

def main(s,t):
    if(len(t)==len(s)+1):
        if(t[0:len(t)-1]==s):
            return True
        else:
            return False
    else:
        return False
    

if __name__=='__main__':
    s,t=readinput()
    ans=main(s,t)
    if(ans==True):
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 9072
#include <bits/stdc++.h>
#define all(v) (v).begin(),(v).end()
using namespace std;
using LL = long long;
const int INF = 1e9;

int main(void) {
    int A, B;
    cin >> A >> B;
    for (int i = 1; i <= 3; i++) {
        if (i != A && i != B) {
            cout << i << endl;
            break;
        }
    }
    return 0;
}



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

    //long long
    using ll = long long;

    // pair<int, int>
    using PII = pair<int, int>;

    //最大値、mod
    const int MOD = 1000000007;
    const int INF = 1000000000;
    const long long LINF = 1e18;

    //出力系
    #define print(x) cout << x << endl
    #define prints(x) cout << fixed << setprecision(10) << x << endl
    #define printc(x) cout << setw(2) << setfill('0') << x << endl;
    #define yes cout << "Yes" << endl
    #define YES cout << "YES" << endl
    #define no cout << "No" << endl
    #define NO cout << "NO" << endl
    
    // begin() end()
    #define all(x) (x).begin(),(x).end()

    //for
    #define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

    //最大公約数 
    unsigned gcd(unsigned a, unsigned b) {
      if(a < b) return gcd(b, a);
      unsigned r;
      while ((r=a%b)) {
        a = b;
        b = r;
      }
      return b;
    }

    // 最小公倍数
    unsigned lcm(unsigned a, unsigned b){
        return a / gcd(a, b) * b; 
    }

    // a = max(a, b), a = min(a, b)
    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 dx[4] = {0, 0, 1, -1}, dy[4] = {1, -1, 0, 0};









int main(){
  ll N;
  cin >> N;
  int ans = INF;
  for(ll i = 1; i * i <= N; i++){
    if(N % i == 0) {
      ll a = N / i;
      string x = to_string(i);
      string y = to_string(a);
      ans = min(ans, max((int)x.length(), (int)y.length()));
      if(x.length() == y.length()) break;
    }
  }

  print(ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>

int main(){
    ll N, M;
    cin >> N >> M;
    VL l(N,0), r(N,0);
    ll L, R;
    rep(i,0,M){
        cin >> L >> R;
        L--; R--;
        l[L]++; r[R]++;
    }
    rep(i,0,N) if(l[i] > 0) L = i;
    rep(i,0,N) if(r[i] > 0){R = i; break;}
    
    ll ans = 0;
    rep(i,L,R+1) ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4820
#include<iostream>

using namespace std;

int r, c, fields[11][100001];

int main(){

  while(1){
    cin >> r >> c;
    if(r==0 && c==0)break;
    for(int i=0;i<r;i++){
      for(int j=0;j<c;j++){
        cin >> fields[i][j];
      }
    }
    int mx=0;
    for(int i=0;i<(1<<r);i++){
      int sm=0;
      for(int j=0;j<c;j++){
        int lsm=0;
        for(int k=0;k<r;k++){
          lsm += (1&(i>>k))^fields[k][j];
        }
        sm+=max(lsm, r-lsm);
      }
      mx=max(mx, sm);
    }
    cout << mx << endl;
  }
}


Measured memory_bytes: 3508
#include <bits/stdc++.h>
#define rep0(i,n) for (int i = 0; i < (n); ++i)  //0index
#define rep1(i,n) for (int i = 1; i < (n); ++i)  //1index
#define REP(i,a,b) for (int i = a; i < (b); ++i)  //
#define all(x) (x).begin(),(x).end()
#define put(x) cout << x << endl;
const int INF = 1000000007;  //MOD
typedef long long ll;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }  //GCD
ll dp[100010][3];
ll task[100010][3];
int main(){
    int n;
    cin >> n;
    rep0(i,n)cin >> task[i][0] >> task[i][1] >> task[i][2];
    rep0(j,n){
        rep0(k,3){
            rep0(l,3){
                if(k == l)continue;
                else chmax(dp[j+1][k],dp[j][l] + task[j][k]);
            }
        }
    }
    ll ans = 0;
    rep0(m,3){
        chmax(ans,dp[n][m]);
    }
    cout << ans << endl;
    return 0;
} 

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

int main()
{
	int N;
	int ac, wa, tle, re;
	cin >> N;
	ac = wa = tle = re = 0;
	for (int i = 0; i < N; i++)
	{
		string S;
		cin >> S;
		if (S == "AC")
			ac++;
		else if (S == "WA")
			wa++;
		else if (S == "TLE")
			tle++;
		else
			re++;
	}
	cout << "AC x " << ac << endl;
	cout << "WA x " << wa << endl;
	cout << "TLE x " << tle << endl;
	cout << "RE x " << re << endl;
}

Measured memory_bytes: 3636
#include <climits>
#include <cstdio>
long c;

void merge(int A[], int left, int mid, int right) {
  int n1 = mid - left;
  int n2 = right - mid;
  int L[n1 + 1], R[n2 + 1];
  for (int i = 0; i < n1; i++) {
    L[i] = A[left + i];
  }
  for (int i = 0; i < n2; i++) {
    R[i] = A[mid + i];
  }
  L[n1] = INT_MAX;
  R[n2] = INT_MAX;
  int i = 0, j = 0;
  for (int k = left; k < right; k++) {
    c++;
    if (L[i] <= R[j]) {
      A[k] = L[i];
      i++;
    } else {
      A[k] = R[j];
      j++;
    }
  }
}

void mergeSort(int A[], int left, int right) {
  // printf("left:%d, right:%d\n", left, right);
  if (left + 1 < right) {
    int mid = (left + right) / 2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

int main() {
  int n;
  scanf("%d", &n);
  int A[n];
  for (int i = 0; i < n; i++) {
    scanf("%d", &A[i]);
  }
  mergeSort(A, 0, n);

  printf("%d", A[0]);
  for (int i = 1; i < n; i++) {
    printf(" %d", A[i]);
  }
  printf("\n");

  printf("%ld\n", c);
}


Measured memory_bytes: 6472
#include<bits/stdc++.h>
#define endl '\n'
#define mod (int)(1e9+7)
#define fastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
using namespace std;
int gcd(int a, int b){
    return b == 0 ? a : gcd(b, a%b);
}
int lcm(int a, int b){
    return (a*b)/gcd(a,b);
}
int ncr(int n, int k){
    int res = 1;
    if ( k > n - k )
        k = n - k;

    for (int i = 0; i < k; ++i){
        res *= (n - i);
        res /= (i + 1);
    }
    return res;
}
int fibonacci(int n){
    double phi = (1 + sqrt(5))/(double)2;
    int nth_fib = round(pow(phi,n)/sqrt(5));
    return nth_fib;
}
int inv_mod(int a){
    int res = 1;
    int mod_temp = mod-2;
    while(mod_temp){
        if(mod_temp&1){
            res = ((res%mod)*(a%mod))%mod;
        }
        a = ((a%mod)*(a%mod))%mod;
        mod_temp >>= 1;
    }
    return res%mod;
}
signed main(){

#ifndef ONLINE_JUDGE
   // freopen("input.txt","r", stdin);
#endif
    fastIO

    int n;
    cin >> n;
    int ans = 0,count = 0;
    while(n>0){
        count++;
        n /= 2;
    }
    count--;
    cout << ((int)pow(2,count+1) -  1) << endl;


    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  ll n, m;
  cin >> n >> m;
  vector<bool> to(n, false), from(n, false);
  REP(i, m){
    ll a, b;
    cin >> a >> b;
    a--; b--;
    if(a == 0) to[b] = true;
    if(b == n-1) from[a] = true; 
  }
  REP(i, n){
    if(to[i]&&from[i]){
      cout << "POSSIBLE" << endl;
      return 0;
    }
  }
  cout << "IMPOSSIBLE" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define reppe(i,a,b) for(int i = (int)(a) ; i <= (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repme(i,a,b) for(int i = (int)(a) ; i >= (int)(b) ; --i)

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

int main() {
    int N; cin >> N;
    map<string, int> m;
    vector<string> v;
    int maxI = 0;
    repp(i,0,N) {
        string s; cin >> s;
        ++m[s];
        maxI = max(maxI, m[s]);
        if(m[s]==1)v.push_back(s);
    }
    sort(v.begin(), v.end());
    repp(i, 0, v.size()) {
        string x = v[i];
        if(m[x] == maxI) cout << x << endl;
    }

}



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

int main() {
	int a, b, c, d;
	int L, R;
	cin >> a >> b >> c >> d;
	L = a+b;
	R = c+d;
	if (L > R) {
		cout << "Left" << endl;
	} else if (L == R) {
		cout << "Balanced" << endl;
	} else {
		cout << "Right" << endl;
	}
}


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

const int NMAX = 1e6 + 5;
int a[NMAX], res, n, freq[NMAX], x;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
        x = a[i];
        for(int j = 2; j * j <= x; j++) {
            if(x % j == 0) {
                freq[j]++;
                while(x % j == 0) {
                    x /= j;
                }
            }
        }
        if(x > 1) {
            freq[x]++;
        }
    }
    res = a[1];
    for(int i = 2; i <= n; i++) {
        res = __gcd(res, a[i]);
    }
    if(res > 1) {
        cout << "not coprime\n";
    } else {
        for(int i = 1; i <= 1000000; i++) {
            if(freq[i] > 1) {
                cout << "setwise coprime\n";
                return 0;
            }
        }
        cout << "pairwise coprime\n";
    }
    return 0;
}

Measured memory_bytes: 11388
//g++ -std=c++14 test.cpp -o test.out
//問題URL
//https://atcoder.jp/contests/abc172/tasks/abc172_d

//ポイント：
//「1~N全部に対して、約数の個数を求める」という操作はO(NlogN)でできる

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N;

LL ans = 0;

void solve(){
	//iの約数の個数をf[i]に求める
	vector<LL> f(N+1,0);
	for(int i=1;i<=N;i++){
		//1以上N以下の、iの倍数を小さいものから順にインクリメントしていく
		for(int j=i;j<=N;j+=i) f[j]++;
	}
	for(int i=0;i<=N;i++) ans += i*f[i];
}

int main(){
	cin >> N;

    solve();

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

Measured memory_bytes: 81020
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp> 
//using namespace __gnu_pbds; 
using namespace std; 
typedef long long ll;
typedef unsigned long long int ull;
// PB-DS 
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
#define ff first
#define ss second
#define pb push_back
#define Inf  1000000000000000000
#define inf -1000000000000000000
#define mod 1000000007

ll mulmod(ll x,ll y){
  return (x%mod*y%mod)%mod;
}
 
ll addmod(ll x,ll y){
  return (x%mod+y%mod)%mod;
}
 
long long  power(long long  x,long long  y) { 
    long long  res = 1;      
    while (y > 0) 
    { 
        if (y & 1) 
            res = res*x;  
        y = y>>1;  
        x = x*x;  
    } 
    return res; 
}


void testcases(int Case){
  
  
  ll A,V;
  ll B,W;
  ll T;
  cin >> A >> V;
  cin >> B >> W;
  cin >> T;
  if(A==B){
    cout << "YES" << endl;
  }
  else
  if(A>B){
    swap(A,B);
  }
  if((A+V*T)>=(B+W*T)){
    cout << "YES" << "\n";
  }
  else
    cout << "NO" << "\n";
}

  
int main()
{
 // sieve();
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
    ll t;
    t = 1;
    //cin >> t;
    ll Case =1 ;
    while(t--)
    {
      testcases(Case++);
    }
}

Measured memory_bytes: 3656
def make_tables(n, p):
    fac = [1, 1]  # 階乗テーブル
    ifac = [1, 1]  # 逆元の階乗テーブル
    inverse = [0, 1]  # 逆元テーブル

    for i in range(2, n+1):
        fac.append((fac[-1] * i) % p)
        inverse.append((-inverse[p % i] * (p//i)) % p)
        ifac.append((ifac[-1] * inverse[-1]) % p)
    return fac, ifac

def cmb(n, r, p, fac, ifac):
    if r < 0 or r > n:
        return 0
    return fac[n] * ifac[r] * ifac[n-r] % p


def resolve():
    n, k = map(int, input().split())
    p = 10 ** 9 + 7
    
    k = min(n-1, k)
    sum = 0
    fac, ifac = make_tables(n, p)
    for i in range(0, k+1):
        sum += cmb(n, i, p, fac, ifac) * cmb(n-1, i, p, fac, ifac) % p

    print(sum % p)



if __name__ == "__main__":
    resolve()


Measured memory_bytes: 81136
#include<bits/stdc++.h>
#define ll long long
#define RE return
using namespace std;
int main()
{
    cin.sync_with_stdio(false);
    ll a,b,n;
    cin>>n>>a>>b;
	ll ans;
	ll s=n/(a+b);
	ans=s*a;
	s=n%(a+b);
	if(s>=a) ans+=a;
	else ans+=s;
    cout<<ans<<endl;
    RE 0;
}


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

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

	vector<int> h(N);
	REP(i, N) {
		cin >> h[i];
	}	

	int dp[100001];
	dp[N-1] = 0;
	dp[N-2] = abs(h[N-1] - h[N-2]);

	for (int i = N-3; i >= 0; i--) {
		dp[i] = min(dp[i+1]+abs(h[i+1]-h[i]), dp[i+2]+abs(h[i+2]-h[i]));
	}
	cout << dp[0] << endl;
}


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

int main () {

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

    deque<int> deq;

    for (int i = 0; i < n; i++) {

        int a;
        scanf("%d", &a);

        if (n % 2 == i % 2) deq.push_back(a);
        else deq.push_front(a);
    }

    for (int i = 0; i < n; i++) {
        printf("%d", deq[i]);
        printf((i == n - 1)? "\n" : " ");
    }

    return 0;
}

Measured memory_bytes: 2944
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc090_b
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);
            int sum = 0;
            for (int i = a; i <= b; i++)
            {
                string str = i.ToString();
                if (str[0] == str[4] && str[1] == str[3])
                {
                    sum++;
                }
            }
            Console.WriteLine(sum);
        }
    }
}

Measured memory_bytes: 29976
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

template<class T>
struct Vec2
{
	Vec2(T _x = T(0), T _y = T(0)) : x(_x), y(_y) {}

	T length() const { return sqrt(dot(*this)); }

	Vec2 operator+(const Vec2& rhs) const { return Vec2(x + rhs.x, y + rhs.y); }
	Vec2 operator-(const Vec2& rhs) const { return Vec2(x - rhs.x, y - rhs.y); }
	Vec2 operator*(T s) const { return Vec2(x*s, y*s); }
	T dot(const Vec2& rhs) const { return x*rhs.x + y*rhs.y; }
	T cross(const Vec2& rhs) const { return x*rhs.y - y*rhs.x; }

	T x, y;
};

template<class T>
T cross(const Vec2<T> &O, const Vec2<T> &A, const Vec2<T> &B)
{
	return (A - O).cross(B - O);
}

typedef Vec2<double> VecD;

void CutConvexPolygon(vector<VecD>& poly, const VecD& A, const VecD& B)
{
	vector<VecD> poly2;
	for (size_t i = 0; i < poly.size() - 1; i++) {
		if (cross(A, B, poly[i]) >= 0) {
			poly2.push_back(poly[i]);
		}
		if (cross(A, B, poly[i]) * cross(A, B, poly[i + 1]) < 0) {
			VecD d = poly[i + 1] - poly[i];
			double d1 = (cross(poly[i], poly[i + 1], A));
			double d2 = -(cross(poly[i], poly[i + 1], B));
			if (d1 == 0 && d2 == 0) continue;
			double t = d1 / (d1 + d2);
			poly2.push_back(A + (B - A)*t);
		}
	}
	if (poly2.size() < 3) {
		poly.clear();
		return;
	}
	poly2.push_back(poly2.front());
	poly.swap(poly2);
}

double solve(
	vector<VecD> poly, const VecD& P1, const VecD& P2
)
{
	CutConvexPolygon(poly, P1, P2);
	vector<pair<double, double> > areas;
	for (size_t i = 1; i < poly.size(); i++) {
		double a = cross(VecD(), poly[i - 1], poly[i]);
		areas.push_back(make_pair(fabs(a), a));
	}
	sort(areas.begin(), areas.end());
	double area = 0.0;
	for (size_t i = 0; i < areas.size(); i++) {
		area += areas[i].second;
	}
	return 0.5 * fabs(area);
}

int main()
{
	int N, Q;
	cin >> N;
	vector<VecD> poly(N);
	for (int i = 0; i < N; i++) {
		cin >> poly[i].x >> poly[i].y;
	}
	poly.push_back(poly.front());
	cin >> Q;
	for (int i = 0; i < Q; i++) {
		VecD P1, P2;
		cin >> P1.x >> P1.y >> P2.x >> P2.y;
		cout << fixed << setprecision(10) << solve(poly, P1, P2) << endl;
	}

	return 0;
}


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

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int a = Integer.parseInt(str[0]);
    int b = Integer.parseInt(str[1]);
    
    System.out.println(a>=13?b:a>=6?b/2:0);
  }
}

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

using namespace std;
typedef pair<int, int> P;
char maze[1005][1005];
int d[1005][1005];
int dirx[4] = {0, -1, 0, 1};
int diry[4] = {1, 0, -1, 0};
int h, w, n, hard; 
int si, sj;
const int INF = 1<<30;
int tot = 0; 

void BFS(int ai, int aj){
	queue<P> que;
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			d[i][j] = INF;
		}
	}
	que.push(P(ai, aj));
	d[ai][aj] = 0;
	while(!que.empty()){
		P a = que.front();
		que.pop();
		int x = a.first, y = a.second;
		if(maze[x][y]-'0' == hard){
			tot += d[x][y];
			si = x; sj = y;
			break;
		}
		for(int i = 0; i < 4; i++){
			int dx = x+dirx[i], dy = y+diry[i];
			if(dx>=0 && dx<h && dy>=0 && dy<w && maze[dx][dy]!='X' && d[dx][dy]==INF){
				d[dx][dy] = d[x][y]+1;
				que.push(P(dx, dy));
			}
		}
	}
}

int main(int argc, char const *argv[]){
	while(scanf("%d%d%d", &h, &w, &n) != EOF){
		getchar();
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				scanf("%c", &maze[i][j]);
				if(maze[i][j] == 'S'){
					si = i; sj = j;
				}
			}
			getchar();
		}
		tot = 0;
		hard = 1;
		for(int i = 0; i < n; i++){
			BFS(si, sj);
			hard++;
		}
		cout << tot << endl;
	}
	return 0;
}

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

int main(void)
{
    int n;
    long a;
    long max_value = LONG_MIN;
    long min_value = LONG_MAX;
    long sum = 0;

    cin >> n;

    for (int i = 0; i < n && cin >> a; i++) {
        sum += a;
        max_value = max(max_value, a);
        min_value = min(min_value, a);
    }

    cout << min_value << " " << max_value << " " << sum << endl;

    return 0;
}


Measured memory_bytes: 3092
from collections import Counter

n = int(input())
a = list(map(int,input().split()))
ac = Counter(a)
an = len(ac)
a_mostcommon = ac.most_common()
cnt = 0
for i in range(an):
  num, count = a_mostcommon[i]
  if count > num:
    cnt += count - num
  elif count < num:
    cnt += count

print(cnt)

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

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define erep(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
const int mod = 1e9+7;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pi;
typedef long long i64;

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

  int m[] = {1, 6000, 4000, 3000, 2000};
  rep(i, 0, 4) {
    int t, n;
    cin >> t >> n;
    cout << (m[t] * n) << endl;
  }
}



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

signed main(){
	int n,m;
	while(cin >> n >> m,n){
		int a[1010],ans = -1;
		for(int i = 0;i < n;i++){
			cin >> a[i];
		}
		for(int i = 0;i < n;i++){
			for(int j = i + 1;j < n;j++){
				if(a[i] + a[j] <= m){
					ans = max(ans,a[i] + a[j]);
				}
			}
		}
		if(ans >= 0) cout << ans << endl;
		else cout << "NONE" << endl;
	}
}


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

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define pp pop_back
#define pf push_front
#define sqr(a) (a)*(a)
#define mpr(a,b) make_pair(a, b)
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;

typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef map<int, int> mpii;
typedef map<string, int> mpsi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef queue<int> qi;
typedef queue<ll> qll;
typedef queue<pair<int, int>> qpi;
typedef priority_queue<int> pqi;
typedef priority_queue<ll> pqll;
typedef priority_queue<pair<int,int>> pqpi;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T> T gcd(T a, T b){return b ? gcd(b, a % b) : a;}
template<class T> T lcm(T a, T b){return a*(b/gcd(a,b));}
template<class T, class TT>bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0, 31, 28, 31, 30, 31,30, 31, 31, 30, 31, 30, 31};

int main()
{
	ll n;
	cin >> n;
	ll k = n,s=0;
	while(k > 0)
	{
		s += k % 10;
		k /= 10;
	}
	if(n % s ==0)
		cout << "Yes";
	else
		cout << "No";
	getchar();
	getchar();
	return 0;
	//freopen("Ganiyev.txt", "r", stdin);
	//freopen("Asadullo.txt", "w", stdout);
	//ios::sync_with_stdio(0);
	//cin.tie(0);cout.tie(0);
	
	
	
	
	
	
	
	
	
	
}

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

int main() {
    int n; cin >> n;
    while (n != 0) {
        int max_s = 0, min_s = 1000, sum_s = 0;
        for (int i = 0; i < n; ++i) {
            int s; cin >> s;
            max_s = max(max_s, s);
            min_s = min(min_s, s);
            sum_s += s;
        }
        int ans = (sum_s - max_s - min_s) / (n - 2);
        cout << ans << endl;
        
        cin >> n;
    }
    return 0;
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header

int main() {
	int n, max =0, ans=1;
	cin >> n;
	loop(i, 1, n+1){
		int k =i;
		int cnt = 0;
		while(1){
			if(k%2 != 0) break;
			else{
				cnt++;
				k/=2;
			}
		}
		if(max < cnt){
			max = cnt;
			ans = i;
		}
	}
	cout << ans << endl;
	return 0;
}

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

const int MOD = 1000000007;
const int INF = 1e9;

int main(){
  int n,x,t;
  cin >> n >> x >> t;

  int ans = 0;
  if(n % x == 0) ans = n / x * t;
  else ans = (n / x + 1) * t;

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3596
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll n,m;
int main(){
	scanf("%lld%lld",&n,&m);
    printf("%lld",max(n+m,max(n+n-1,m+m-1)));
}

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

const int N = 110;

char a[N], b[N], c[N];

int main(){
    int n;
    scanf("%d%s%s%s", &n, a, b, c);
    int ans = 0;
    for (int i = 0; i < n; ++ i){
        if (a[i] == b[i] && b[i] == c[i]) continue;
        if (a[i] != b[i] && a[i] != c[i] && b[i] != c[i]){
            ans += 2;
        }
        else{
            ans += 1;
        }
    }
    printf("%d\n", ans);
    return 0;
}

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

string s;

signed main(){
  
  cin>>s;
  
  int cnt = 0;
  int ans = 0;
  
  for(int i=s.size()-1;i>=0;i--){
    
    if( i && s[i] == 'C' && s[i-1] == 'B' ){
      
      cnt++;
      
      i--;
      
    }
    else if( s[i] == 'B' || s[i] == 'C' ){
      
      cnt = 0;
            
    }
    else{
      ans += cnt;
    }

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


Measured memory_bytes: 640
($aa,$bb) = map { $_ - 0 } split(/\s+/o,scalar(<>));

my $gc = &gcd($aa,$bb);
my $f = &factr($gc);
my @ks = keys %{$f};
my $r = 2 + $#ks;
$r = 1 if $#ks == 0 and $ks[0] eq '1';
print "$r\n";

exit(0);

sub gcd {
  my $mm = shift;
  my $nn = shift;
  if( $mm < $nn ){
    my $dum = $mm ;
    $mm = $nn;
    $nn = $dum;
  }
  while($nn != 0){
    my $rr = $mm % $nn;
    $mm = $nn;
    $nn = $rr;
  }
  return $mm;
}

sub factr {
  my $n0 = shift;
  my %f = ();
  
  while($n0>1){
    if( $n0 == 2 or $n0 == 3 or $n0 == 5 or $n0 == 7 or $n0 == 11 or $n0 == 13 or $n0 == 17 or $n0 == 19 ){
      $f{$n0} += 1;
      last;
    }
    my $n1 = 1+int(sqrt($n0));
    my $f1 = 0;
    for(my $i=1;$i<=$n1;$i+=2){
      my $ii = $i;
      $ii = 2 if $i==1;
      if( $n0 % $ii == 0 ){
        $f1 = $ii;
        last;
      }
    }
    if( $f1 == 0 ){
      $f{$n0} += 1;
      last;
    }
    $f{$f1} += 1;
    $n0 /= $f1;
  }
  return \%f;
}



Measured memory_bytes: 512
#include<stdio.h>
int main(void)
{
	char c;
	scanf("%c",&c);
	if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o') {
		printf("vowel\n");
	}
	else {
		printf("consonant\n");
	}
	return 0;
}

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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...) 6;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

typedef tuple<long long, int, int> ti;

int c[55], d[55];
long long dist[55][2505];
vector<ti> adj[55];

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

    int n, m, s;
    cin >> n >> m >> s;
    for (int i=0; i<m; i++) {
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        u--, v--;
        adj[u].emplace_back(v, a, b);
        adj[v].emplace_back(u, a, b);
    }
    for (int i=0; i<n; i++)
        cin >> c[i] >> d[i];

    memset(dist, 127, sizeof(dist));
    priority_queue<ti, vector<ti>, greater<ti>> pq;
    dist[0][min(s, 2500)] = 0;
    pq.emplace(0, 0, min(s, 2500));
    while (!pq.empty()) {
        auto [di, u, amt] = pq.top();
        pq.pop();
        if (di > dist[u][amt])
            continue;
        // buy coins
        if (di + d[u] < dist[u][min(amt + c[u], 2500)]) {
            dist[u][min(amt + c[u], 2500)] = di + d[u];
            pq.emplace(dist[u][min(amt + c[u], 2500)], u, min(amt + c[u], 2500));
        }
        // move elsewhere
        for (auto [v, a, b] : adj[u])
            if (amt >= a && di + b < dist[v][amt - a]) {
                dist[v][amt - a] = di + b;
                pq.emplace(dist[v][amt - a], v, amt - a);
            }
    }

    for (int i=1; i<n; i++)
        cout << *min_element(dist[i], dist[i] + 2505) << "\n";

    return 0;
}


Measured memory_bytes: 6256
//simple caluculator

#include<iostream>
using namespace std;

int main()
{
int a,b;
char op;
while(1){
cin>>a>>op>>b;

if(op=='+')
cout<<a+b<<endl;
else if(op=='-')
cout<<a-b<<endl;
else if(op=='*')
cout<<a*b<<endl;
else if(op=='/')
cout<<a/b<<endl;
else if(op=='?')
return 0;
}

return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
#include<map>  
#include<set>
#include<iterator>
#include<list>
#include<utility>
#include<cstdlib>
#include<queue>
#include<stack>
#include<bitset>
//#include<bits/stdc++.h>
#define PI  2*acos(0.0)
#define pb push_back

       
using namespace std;
using ll = long long;
using lli = long long int;
using ld = long double;



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

int n,m;
cin>>n>>m;
if(n==m) cout<<"Yes"<<"\n";
else  cout<<"No"<<"\n";









	
	
	return 0;
	
	
	       /***Israil Hosen
	            Computer Science & Engineering
	         University Of Rajshahi.
	         ***/
	
	
	
}

Measured memory_bytes: 3132