akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<iostream>
#include<queue>
#include<map>
#include<cmath>
#include<set>
#include<stack>
#define ll long long
#define pb push_back
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)>(y)?(y):(x))
#define cls(name,x) memset(name,x,sizeof(name))//0或-1
#define fs first
#define sc second
#define mp make_pair
#define L(x) (1<<x)
using namespace std;
const int inf=1e9+10;
const ll llinf=1e16+10;
const int maxn=2e5+10;
const int maxm=2e5+10;
const int mod=1e9+7;
int n,m;
int vis[maxn];
int main()
{
    //freopen("in.txt","r",stdin);
    while(~scanf("%d %d",&n,&m))
    {
        cls(vis,0);
        for(int i=1;i<=m;i++)
        {
            int a,b;
            scanf("%d %d",&a,&b);
            if(a==1)
            vis[b]++;
            if(b==n)
            vis[a]++;
        }
        int flag=0;
        for(int i=2;i<=n-1;i++)
            if(vis[i]==2)
                flag=1;
        printf("%s\n",flag?"POSSIBLE":"IMPOSSIBLE");
    }
    return 0;
}


Measured memory_bytes: 1152
import java.util.Scanner;
 
public class Main {
 
	static Scanner scanner;
 
	public static void main(String[] args) {
	    scanner = new Scanner(System.in);
 
	    String s=gs();
	    //int r=gi();
	    //int c=gi();
 
	    //System.out.print(String.valueOf(c));
 
        if (s.charAt(0)==s.charAt(1) && s.charAt(1)== s.charAt(2)) {
        	System.out.print("No");
        }else {
        	System.out.print("Yes");
        }
 
 
	}
	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}
 
	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}
 
	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}
 
	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35296
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main (){
    int N, K, Q;
    cin>>N>>K>>Q;
    int *A = new int[Q];
    for(int i=0;i<Q;i++)cin>>A[i];

    int *point = new int[N];
    for(int i=0;i<N;i++)point[i]=K;
    
    for(int i=0;i<Q;i++){
        point[A[i]-1]++;
    }
    
    
    for(int i=0;i<N;i++){
        point[i]-=Q;
        if(point[i]>0){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
        
    }
    //for(int i=0;i<N;i++)cout<<point[i]<<endl;
    
    return 0;
}

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

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

using namespace std;

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

    while (a) {

        vector<int> d(a, 0), c(b, 0);
        rep(i, a) {
            cin >> d[i];
        }
        rep(i, b) {
            cin >> c[i];
        }

        rep(i, a) {
            rep(j, b) {
                if (d[i] == c[j]) {
                    c[j] = 0;
                    break;
                }
            }
        }

        int ans = 0;
        rep(i, a) {
            ans += d[i];
        }
        rep(i, b) {
            ans += c[i];
        }

        cout << ans << endl;
        cin >> a >> b;
    }

    return 0;
}



Measured memory_bytes: 3096
#include <stdio.h>
 
int main(void) {
	int n,k,x,y,sum,k1,k2;
	scanf("%d %d %d %d",&n,&k,&x,&y);
	if(n>k){
		k2=n-k;
		sum=x*k+y*k2;
		printf("%d\n",sum);
	}
	else if(n<=k){
		k2=0;
		k1=n;
		sum=x*k1+y*k2;
		printf("%d\n",sum);
	}
 
 
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<stack>
#include<list>
#include<map>
#include<set>
#include<string>
#include <sstream>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;


int main(){
  long ii,jj,kk;
  vector<int> ret;
  stack<int> s[1001];
  
  int n,q,c,t,x;

  cin >> n >> q;

  for(ii=0;ii<q;ii++){
    //cout << ii << endl;
    cin >> c;
    switch(c){

    case 0:
      cin >> t >> x;
      s[t].push(x);
      break;

    case 1:
      cin >> t;
      if(!s[t].empty()){
        cout << s[t].top() << endl;
      }
      break;

    case 2:
      cin >> t;
      if(!s[t].empty()){
        s[t].pop();
      }
      break;

    }
  }
  
  return 0;
}



Measured memory_bytes: 4372
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//cout << fixed << setprecision(10);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int dp[50001];

int main () {
  int h, n;
  cin >> h >> n;
  vi a(n), b(n);
  rep(i,n) {
    cin >> a[i] >> b[i];
  }

  rep(i,50000) dp[i] = INF;
  dp[0] = 0;
  rep(i,h+1) {
    rep(j,n) {
      if (dp[i] == INF) continue;
      chmin(dp[i+a[j]], dp[i]+b[j]); 
    }
  }

  int ans = INF;
  for (int i = h; i < h+*max_element(rng(a)); ++i) {
    chmin(ans, dp[i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
class UnionFind:
    def __init__(self, n):
        self.v = [-1] * n

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

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

        if x == y:
            return False
        else:
            if self.v[x] > self.v[y]:
                x, y = y, x
            self.v[x] += self.v[y]
            self.v[y] = x
            return True

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

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


def main():
    from operator import itemgetter
    import sys
    input = sys.stdin.readline

    N = int(input())

    ps = []
    xs = set()
    ys = set()
    for i in range(N):
        x, y = map(int, input().split())
        ps.append((x, y))
        xs.add(x)
        ys.add(y)

    xs = tuple(sorted(xs))
    ys = tuple(sorted(ys))

    dx = {e: i for i, e in enumerate(xs)}
    dy = {e: i for i, e in enumerate(ys)}

    uf = UnionFind(N * 2)
    for x, y in ps:
        uf.unite(dx[x], dy[y] + N)

    def make_edges(xs, d, *, add_val=0):
        xes = []
        for x0, x1 in zip(xs, xs[1:]):
            xes.append((abs(x1 - x0), d[x0] + add_val, d[x1] + add_val))
        return xes

    xes = make_edges(xs, dx)
    yes = make_edges(ys, dy, add_val=N)

    # Kruskal
    # 最小コストの辺から順に使用する
    # 同じ連結成分に属していればつながない(閉路を作らない)
    # コスト昇順ソート済みの辺リストを使用する
    ret = 0
    # joined = set()
    for cost, a, b in sorted(xes + yes, key=itemgetter(0)):
        # if (a in joined) or (b in joined): continue
        if uf.same(a, b): continue
        uf.unite(a, b)
        ret += cost
    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 81972
using System;

namespace Test
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            Console.ReadLine();
            var inputs = Console.ReadLine().Split(' ');

            var nums = Array.ConvertAll(inputs,int.Parse);
            Array.Sort(nums);
            var sum = 0L;
            Array.ForEach(nums,x=>sum+=x);

            Console.WriteLine("{0} {1} {2}", nums[0], nums[nums.Length - 1], sum);
        }
    }
}

Measured memory_bytes: 7820
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e8;
const ll INF = 1e16;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    string s;
    cin >> s;
    int N = s.size();
    //解は[l,r]に存在する
    int l = 1, r = N;
    while(l < r){
        int n = (l+r+1)/2;
        //全て0にできるか判定
        bool able = true;
        if(N-n < n-1){
            int sum = 0;
            rep(i, N-n+1){
                int x = s[i]-'0';
                if((x+sum)%2 == 0) continue;
                else sum++;
            }
            rep2(i, N-n+1, n-1){
                int x = s[i]-'0';
                if((x+sum)%2 != 0) able = false;
            }
        }
        if(able) l = n;
        else r = n-1;
    }
    cout << l << endl;
}

Measured memory_bytes: 512
package main

import "fmt"

func findSumOfDigits(n int) int{
	sum := 0
	for n > 0 {
		sum += n % 10
		n /= 10
	}
	return sum
}

func main() {
	var (
		n, a, b, total int
	)
	fmt.Scan(&n, &a, &b)
	for i := 1; i <= n; i++ {
		sum := findSumOfDigits(i)
		if a <= sum && sum <= b {
			total += i
		}
	}
	fmt.Println(total)
}


Measured memory_bytes: 512
n=int(input())
a=list(map(int,input().split()))
q=int(input())
action=[]
for i in range(q):
    b,c=map(int,input().split())
    action.append([b,c])

kazu=[0]*(10**5+1)

for i in range(n):
    kazu[a[i]]+=1


s=sum(a)

for i in range(q):
    s+=(action[i][1]-action[i][0])*kazu[action[i][0]]
    kazu[action[i][1]]+=kazu[action[i][0]]
    kazu[action[i][0]]=0
    print(s)


Measured memory_bytes: 95620
use std::collections::VecDeque;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
  let n:usize = read();
  let mut que = VecDeque::new();
  for i in 0..n {
    if (i + n) % 2 == 0 {
      que.push_back(read::<usize>());
    } else {
      que.push_front(read::<usize>());
    }
  }
  for i in que {
    print!("{} ", i);
  }
  println!("");
}

Measured memory_bytes: 4244
ans = []

loop do
	n,k = gets.split.map(&:to_i)
	if n==0 && k==0
		break
	end

	list = Array.new
	max = 0
	sum =0
	
	(n).times do |i|
		num = gets.to_i
		if i<k
			sum+= num
			list.push(num)
		else
			list.push(num)
			sum += num
			sum -= list.shift
			
			if max< sum
				max = sum
			end

		end
	end
	ans.push(max)
end

ans.each do |num|
	puts num
end

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

#define ll long long
#define pb push_back


int main() {
	vector<int> v;
	for (int i = 1; i < 10; i++){
		for (int j = i; j < 10; j++){
			v.push_back(i * j);
		}
	}
	int n;
	cin >> n;
	if (count(v.begin(), v.end(), n) == 0){
		cout << "No";
	} else {
		cout << "Yes";
	}
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define INF 1145141919
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
int ny, nx;
typedef long long int ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

int ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}

ll llmax(ll a, ll b){
    if(a>b) return a;
    else return b;
}

////////////////////////////////////////////////////////////////////
int main()
{
    ll N; cin >> N;
    vector<ll> traffic(5);
    REP(i,5) cin >> traffic[i];
    ll small = *min_element(traffic.begin(), traffic.end());

    if(N%small==0) cout << N/small + 4 << endl;
    else cout << N/small + 5 << endl;

    return 0;
}


Measured memory_bytes: 256
#pragma region RegionDefs
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,l,r) for(int i=(l),i##_len=(r);i<i##_len;++i)
#define all(x) begin(x),end(x)
using namespace std;
const int INF = 1e9;
template<class T=int> using V = vector<T>;
template<class T=int> using PQ = priority_queue<T>;
template<class T=int> using PQG = priority_queue<T, V<T>, greater<T>>;
typedef long long ll;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail)
{
    cin >> head;
    in(move(tail)...);
}
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
//時間が厳しいとき使う
#define INI(...) int __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
template<class T>bool chmax(T &a, const T &b) {if (a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if (a>b) {a=b; return 1;} return 0;}
#define y0 y__0
#define y1 y__1
#define j0 j__0
#define j1 j__1
#define YN(e) cout << ((e) ? "YES" : "NO") << endl
#define yn(e) cout << ((e) ? "Yes" : "No") << endl
#pragma endregion RegionDefs

ll n, m, q;
vector<ll> a;
vector<ll> b;
vector<ll> c;
vector<ll> d;

ll dfs(ll dep, ll* r, ll mx)
{
    if (dep >= n) return mx;
    if (dep == 0)
    {
        r[0] = 1;
        return dfs(1, r, 0);
    }
    else
    {
        ll s = mx;
        reps(i, r[dep-1], m+1)
        {
            r[dep] = i;
            ll temp = mx;
            rep(j, q)
            {
                if (b[j] == dep && i - r[a[j]] == c[j])
                {
                    temp += d[j];
                }
            }
            chmax(s, dfs(dep+1, r, temp));
        }
        return s;
    }
}

void solve()
{
    cin >> n >> m >> q;
    rep(i, q)
    {
        IN(w, x, y, z);
        a.push_back(w-1);
        b.push_back(x-1);
        c.push_back(y);
        d.push_back(z);
    }
    cout << dfs(0, new ll[10], 0) << endl;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 3624
/*
"Won't stop until I'm phenomenal."
- Phenomenal, Eminem
 */
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define ff first
#define Shazam ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL);
#define ss second
#define all(c) c.begin(),c.end()
#define endl "\n"
#define test() int t; cin>>t; while(t--)
#define fl(i,a,b) for(int i = a ; i <b ;i++)
#define get(a) fl(i,0,a.size())  cin>>a[i];
#define pra(a) fl(i,0,a.size()) cout<<a[i]<<" ";	cout<<endl;
#define pr(a,n) fl(i,0,n) cout<<a[i]<<" ";	cout<<endl;
const ll INF = 2e18;
const int inf = 2e9;
const int mod1 = 1e9 + 7;



int main(){
    Shazam;
    int n,m; cin>>n>>m;
    for(int i = 1 ; i <= (m)/2; i++){
        cout<<i<<" "<< (m/2)*2 +1 -i + 1<<endl;
    }
    for(int i = 1; i <=(m+1)/2; i++){
        cout<<(m/2)*2 + 1 + (m+1)/2 - i + 1 <<" "<<(m/2)*2 + 1 + (m+1)/2+ i<<endl;
    }
    return 0;
}

Measured memory_bytes: 3644
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		ArrayList<Long> a = new ArrayList<Long>();
		ArrayList<Long> b = new ArrayList<Long>();
		int min = Integer.MAX_VALUE;
		Scanner scan = new Scanner(System.in);
		long n = scan.nextLong();
		double m = Math.sqrt(n);
		for (long i = 1; i <= m+1; i++) {
			if (n%i == 0) {
				a.add(i);
				b.add(n/i);
			}
		}
		for (int i = 0; i < a.size(); i++) {
			int ans = Fnum(a.get(i), b.get(i));
			if (ans < min) {
				min = ans;
			}
		}
		System.out.println(min);
	}

	public static int Fnum(long x, long y) {
		String s = String.valueOf(x);
		String t = String.valueOf(y);
		int A = s.length();
		int B = t.length();
		return Math.max(A, B);
	}
}


Measured memory_bytes: 23124
#include <iostream>
#include <iomanip>

int main(int argc, char const *argv[])
{
    int a, b;
    int d, r;
    double f;

    std::cin >> a >> b;

    std::cout << a / b << " " << a % b << " " << std::fixed << std::setprecision(5) << (double)a / b << std::endl;

    return 0;
}



Measured memory_bytes: 3284
#include <bits/stdc++.h>
#define nl ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long
#define all(v) (v).begin(), (v).end()
#define allr(v) (v).rbegin(), (v).rend()

using namespace std;

int main(){     
    string s;
    cin >> s;
    for(int i=0; i<3; i++) {
        cout << s[i];
    }
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD 1000000007
 
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template <class T>
void print(T& x){printf("%d\n", x);}
void printvec(vector<int> a){
    rep(i, a.size()-1){
        printf("%d ", a[i]);
    }
    printf("%d\n", a[a.size()-1]);
}
 
int main()
{
    int N, M;
    cin >> N;
    vector<int> a(N);
    rep(i, N) cin >> a[i];
    cin >> M;
    vector<int> b(M);
    rep(i, M) cin >> b[i];
    sort(a.begin(), a.end());

    bool flag=true;
    int left, right, mid;
    for(int i: b){
        flag=true;
        left=0; right=N-1; mid=(left+right)/2;
        while(1){
            if(left>right){
                flag=false;
                break;
            }
            if(a[mid]==i){
                break;
            }else if(a[mid]<i){
                left = mid + 1;
                mid = (left+right)/2;
            }else if(a[mid]>i){
                right = mid - 1;
                mid = (left+right)/2;
            }
        }
        if(flag==false) break;
    }
    if(flag) printf("1\n");
    else printf("0\n");

    return 0;
}


Measured memory_bytes: 4376
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define INF 10000000000000000LL
#define ll  long long 
const int inf =INT_MAX;
const int MAX=3e5+9;
const ll MOD=1e9+7;
const int TOT_PRIMES=1e6+9;
const int MAX_A=71;
const int LN=20;
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a, b;
    cin>>a>>b;
    cout<<a*b<<endl;
    return 0;
}

Measured memory_bytes: 3640
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

bool isKaibun(string s)
{
    int n = s.size();
    for(int i = 0; i < n/2; i++){
        if(s[i] != s[n-1-i]){
            return false;
        }
    }
    return true;
}

int main(void)
{
    string s;
    cin >>s;

    int n = s.size();
    if(isKaibun(s) && isKaibun(s.substr(0, (n-1)/2)) && isKaibun(s.substr((n+2)/2, (n-1)/2))){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 256
/*-------enazuma11----------------*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(v) v.begin(),v.end()
#define inc(a,n) sort(a,a+n)
#define dec(a,n) sort(a,a+n,greater<int>() )
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define F first
#define S second
#define M 1000000007
 
/* int x[]={-1,-1,0,1,1,1,0,-1};
int y[]={0,1,1,1,0,-1,-1,-1};
*/
/* int x[]={-1,0,1,0};
int y[]={0,1,0,-1};
*/
const int N=1e5+5;
ll a[N][3];
ll n;
ll dp[N][3];
ll get(ll i,ll c)
{
	if(dp[i][c]!=-1)
	return dp[i][c];
	if(i==n-1)
	{
		return dp[i][c]=a[i][c];
	}
	ll ans=-1e16;
	if(c==0)
	{
		ans=max(get(i+1,1),get(i+1,2));
	}else if(c==1)
	ans=max(get(i+1,0),get(i+1,2));
	else
	ans=max(get(i+1,0),get(i+1,1));
	return dp[i][c]=a[i][c]+ans;
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int t=1;
//	cin>>t;
	while(t--){
		cin>>n;
		ll i,j;
		rep(i,0,n)
		{
			rep(j,0,3){
			cin>>a[i][j];
				dp[i][j]=-1;
			}
		}
		ll ans=max(get(0,0),max(get(0,1),get(0,2)));
		cout<<ans<<'\n';
	}
	return 0;
}


Measured memory_bytes: 9600
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
    int N,K;
    cin>>N>>K;
    long long int ans=2000000000000000000;
    long long int ima=0;
    long long int lis[200000];
    for(int i=0;i<N;i++)cin>>lis[i];
    for(int i=K-1;i<N;i++){
            /*
        if(i<K){
            ima+=lis[i];
        }
        else{
            ima+=lis[i];
            ima-=lis[i-K];
        }
        */
        if(lis[i-K+1]<=0&&0<=lis[i]){
            //printf("[%lld][%lld]\n",lis[i]*2+lis[i-K+1]*-1,lis[i]+lis[i-K+1]*-2);
            ans=min(ans,lis[i]*2+lis[i-K+1]*-1);
            ans=min(ans,lis[i]+lis[i-K+1]*-2);
        }
        else if(lis[i]<=0){
            ans=min(ans,lis[i-K+1]*-1);
        }
        else{

            ans=min(ans,lis[i]);
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>

int main()
{
	int n,b,i,j,k,l;
	int p[1001]={0};
	long long int a;
	
	scanf("%d",&n);
	
	for (i=2;i<=n;i++)
	{
		b=i;
		
		for(j=2;j<=b;j++)
		{
			k=0;
			while(b%j==0)
			{
				b/=j;
				k++;
			}
			if(k!=0) p[j-1]+=k;
		}
	}
	
	a=1;
	for(i=1;i<=n;i++)
	{
		a=a*(p[i-1]+1)%1000000007;
	}
	//a%=1000000007;
	printf("%d",a);

	return 0;
}



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

int main(){
  int N;
  cin >> N;
  while(N>1){
    if(N%10==9){
      cout << "Yes";
      return 0;
    }
    N/=10;
  }
  cout << "No";
  return 0;
}


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

 using namespace std;
 typedef long long ll;

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

   vector<int> A(N), B(N);
   int max_A = 0, max_i;
   for (int i = 0; i < N; i ++) {
     cin >> A.at(i) >> B.at(i);
     if (A.at(i) > max_A) {
       max_A = A.at(i);
       max_i = i;
     }
   }

   cout << max_A + B.at(max_i) << endl;
  }


Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
#define MAX 200000


int main(){
  
  char S[MAX];
  scanf("%s",S);
  int n = strlen(S), i;
  int flag = 1;
  for(i = n-1; i>=0;){
    if(S[i]=='m'){
      if(i<4){
        flag = 0;
        break;
      }
      if(S[i-4]!='d'||S[i-3]!='r'||S[i-2]!='e'||S[i-1]!='a'){
        flag = 0;
        break;
      }
      i -= 5;
    }else if(S[i]=='e'){
      if(i<4){
        flag = 0;
        break;
      }
      if(S[i-4]!='e'||S[i-3]!='r'||S[i-2]!='a'||S[i-1]!='s'){
        flag = 0;
        break;
      }
      i -= 5;
      
    }else if(S[i]=='r'){
      if(i<5){
        flag = 0;
        break;
      }
      if(S[i-1]!='e'){
        flag = 0;
        break;
      }
      if(S[i-2]=='s'){
        if(S[i-5]!='e'||S[i-4]!='r'||S[i-3]!='a'){
          flag = 0;
          break;
        }
        i -= 6;
      }else if(S[i-2]=='m'){
        if(i<6){
          flag = 0;
          break;
        }
        if(S[i-6]!='d'||S[i-5]!='r'||S[i-4]!='e'||S[i-3]!='a'){
          flag = 0;
          break;
        }
        i -= 7;
      }else {
        flag = 0;
        break;
      }
    }else{
      flag = 0;
      break;
    }
  }
  
  if(flag) puts("YES");
  else puts("NO");
  
  return 0;
}


Measured memory_bytes: 1764
S = input()

if S == "SSS":
    print(0)
    exit()
elif S == "RSS" or S == "SRS" or S == "SSR" or S == "RSR":
    print(1)
    exit()
elif S == "RRS" or S == "SRR":
    print(2)
    exit()
else:
    print(3)
    exit()


Measured memory_bytes: 9032
#include <stdio.h>
#include <iostream>
using namespace std;

void insertionsort(int *num, int n) {
    for(int i=0; i<n; i++) {
        int v = num[i];
        int j = i - 1;

        while(j>=0 && num[j]>v) {
            num[j+1] = num[j];
            j--;
        }
        num[j+1] = v;
        for(int m=0; m<n; m++) {
            printf("%d", num[m]);
            if(m!=n-1) {
                printf(" ");
            }
        }
        printf("\n");
    }
}

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

    int num[n];
    for(int i=0; i<n; i++) {
        cin >> num[i];
    }
    insertionsort(num, n);
}


Measured memory_bytes: 3164
#include<iostream>
using namespace std;
int main() {
	int n,m;
	cin >>n>>m;
	int i,j,k;
	int mat[100][100]={{}};
	int vec[100]={};
	for(i=0;i<n;i++) {
		for(j=0;j<m;j++) {
			cin >> mat[i][j];
		}
	}
	for(j=0;j<m;j++) cin >> vec[j];
	for(i=0;i<n;i++) {
		int ip=0;
		for(j=0;j<m;j++) {
			ip+=mat[i][j]*vec[j];
		}
		cout << ip << endl;
	}
}


Measured memory_bytes: 3136
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
using namespace std;
int main()
{
    string str1;
    string str2;
    cin >> str1;
    cin >> str2;
    str1 = str1+str1;
    for(int i = 0; i < str1.size()/2; i++)
    {
        string jud = "";
        for(int j = i; j < i + str1.size()/2; j++)
        {
            jud += str1[j];
        }
        //cout<<jud<<endl;
        //jud += '\n';
        if(jud == str2)
        {
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}


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

int main() {
	int n;
	cin >> n;
	double a[n];
	for (int i = 0; i < n; ++i) cin >> a[i];


	double sum = 0;
	for (int i = 0; i < n; ++i) sum += (double)a[i];
	sum /= n;

	double sa = 100000000;
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		if (abs(a[i] - sum) < sa) {
			sa = abs(a[i] - sum);
			ans = i;
		}
		
	}
	cout << ans << endl;

	return 0;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

const ll MOD = 1e9 + 7;

pll normalize(pll a) {
	ll x = a.xx, y = a.yy;
	ll g = __gcd(x,y);
	x /= g, y /= g;
	if (x < 0 || (x == 0 && y < 0)) x = -x, y = -y;
	return {x,y};
}

pll perp(pll a) {
	return normalize(make_pair(-a.yy,a.xx));
}

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

	ll n; cin >> n;
	
	vl p2(n+1);
	p2[0] = 1;
	FOR(i,1,n+1) p2[i] = 2*p2[i-1] % MOD;
	
	map<pll,ll> cnt;
	pll zero(0,0);
	ll z = 0;
	
	while (n--) {
		pll p;
		cin >> p.xx >> p.yy;

		if (p == zero) {
			z++;
			continue;
		}

		p = normalize(p);
		cnt[p]++;
		cnt[perp(p)] += 0;
	}

	ll res = 1;
	for (auto pr: cnt) {
		pll a = pr.xx, b = perp(a);
		ll c = pr.yy;
		
		if (a > b) continue;
		ll d = cnt[b];
		
		ll cur = (p2[c] + p2[d] - 1) % MOD;
		res = res*cur % MOD;
	}
	
	res = (res + z-1) % MOD;
	if (res < 0) res += MOD;
	cout << res << endl;
}



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

int main (){

    string w,tmp="abcdefghijklmnopqrsuvwxyz";
    cin >> w;
    map<char,int>m;
    for(int i = 0; i < w.size(); i++) {
        m[w[i]]++;
    }

    for(int i = 0; i < 26; i++) {
        if(m[tmp[i]] % 2 == 1) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}


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


void solve(long long A, long long B){
    cout <<  pow(A, 2) - B << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


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

int main(){
    int x;
    cin >> x;
    int h, m, s;
    h = x / 3600;
    m = (x - h*3600) / 60;
    s = x - h*3600 - m*60;
    cout << h << ":" << m << ":" << s << endl;
    return 0;
}


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

int main(){
    int A, B, count=0, num;
    cin >> A >> B;
    for(int i=1; i<10; i++){
        for(int j=0; j<10; j++){
            for(int k=0; k<10; k++){
                num = i*10001 + j*1010 + k*100;
                if(A <= num && num <= B) count++;
            }
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
// CPP program to print the Kth prime greater than N 
#include <bits/stdc++.h> 
using namespace std; 

// set the MAX_SIZE of the array to 10^6 
const int MAX_SIZE = 1e6; 

// initialize the prime array 
bool prime[MAX_SIZE + 1]; 

void sieve() 
{ 

	// set all numbers as prime for time being 
	memset(prime, true, sizeof(prime)); 

	for (int p = 2; p * p <= MAX_SIZE; p++) { 

		// if prime[p] is not changed, then it is a prime 
		if (prime[p] == true) { 

			// update all multiples of p 
			for (int i = p * p; i <= MAX_SIZE; i += p) 
				prime[i] = false; 
		} 
	} 
} 
// Function to find the kth prime greater than n 
int kthPrimeGreaterThanN(int n, int k) 
{ 

	int res = -1; 
	// looping through the numbers greater than n 
	for (int i = n + 1; i < MAX_SIZE; i++) { 

		// decrement k if i is prime 
		if (prime[i] == true) 
			k--; 

		// store the kth prime greater than n 
		if (k == 0) { 
			res = i; 
			break; 
		} 
	} 

	return res; 
} 

// Driver code 
int main() 
{ 

	sieve(); 
	int n;
	cin >> n;
	if(prime[n] == true) cout << n << "\n";

	// Print the kth prime number greater than n 
	else cout << kthPrimeGreaterThanN(n, 1) << "\n";
	return 0; 
} 



Measured memory_bytes: 1280
import java.util.Scanner;

public class Main {

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

		// 整数の入力
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();

		if(N * A < B){
			System.out.println(N * A);
		}else{
			System.out.println(B);
		}

		sc.close();
	}
}


Measured memory_bytes: 22484
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<queue>
#include<utility>

using namespace std;

int n;

int c;

int ice[10];

int main(void)
{
	while (cin >> n, n)
	{
		for (int i = 0; i < n; i++)
		{
			cin >> c;

			ice[c]++;
		}

		for (int i = 0; i < 10; i++)
		{
			if (ice[i] == 0)
			{
				cout << "-" << endl;

				continue;
			}

			for (int j = 0; j < ice[i]; j++)
			{
				cout << "*";
			}

			cout << endl;
		}

		fill(&ice[0], &ice[10], 0);
	}

	return 0;
}


Measured memory_bytes: 3052
def main():
    #import sys
    #input = sys.stdin.readline
    ABCD = input()
    A = int(ABCD[0])
    B = int(ABCD[1])
    C = int(ABCD[2])
    D = int(ABCD[3])
    op_max = format(7,"03b")
    for i in range(int(op_max,2)+1):
        res = A
        now = format(i,"03b")
        op_s = []
        for j in range(len(now)):
            if now[j] == "0":
                op_s.append("+")
            elif now[j] == "1":
                op_s.append("-")
        if op_s[0] == "+":
            res += B
        elif op_s[0] == "-":
            res -= B
        if op_s[1] == "+":
            res += C
        elif op_s[1] == "-":
            res -= C
        if op_s[2] == "+":
            res += D
        elif op_s[2] == "-":
            res -= D
        if res == 7:
            print(str(A)+op_s[0]+str(B)+op_s[1]+str(C)+op_s[2]+str(D)+"=7")
            exit()


if __name__ == "__main__":
    main()


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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define FOR(i,m,n) for(int i=(m) ; i<(n) ; i++)
#define FORR(i,m,n) for(int i=(m) ; i>=(n) ; i--)

typedef long long ll;
typedef unsigned long long ull;

const int INF = 999999999;

int main(){
   int n;
   cin >> n;
   cout << n/3;
   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

const int N = 200010;
VI e[N];
ll c[N], ans[N];

void dfs(int now, int past, ll x){
    x += c[now];
    ans[now] = x;
    for (int next : e[now]){
        if (next == past) continue;
        dfs(next, now, x);
    }
}

int main() {
    int n, q;
    cin >> n >> q;
    REP(i,n-1){
        int u = in() - 1, v = in() - 1;
        e[u].push_back(v);
        e[v].push_back(u);
    }
    REP(i,q){
        int x = in() - 1, v = in();
        c[x] += v;
    }
    dfs(0, -1, 0);
    REP(i,n) printf("%lld ", ans[i]);
    cout << endl;

    return 0;
}


Measured memory_bytes: 25600
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;
const int MOD = 1000000007;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }


#include <iomanip>

int main()
{
	int n; cin >> n;
	vector<double> va(n);

	REP(i, n)
	{
		cin >> va[i];
		va[i] = (double)1 / va[i];
	}

	double ans = accumulate(ALL(va), (double) 0);
	ans = (double)1 / ans;

	cout << setprecision(15) << ans << endl;
}


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

int main() {
  
  int a,b,c,d,e;
  cin>>a>>b>>c>>d>>e;
  
  if(a==0){
    cout<<1<<endl;
  }
  else if(a==0){
    cout<<1<<endl;
  }
  else if(b==0){
    cout<<2<<endl;
  }
  else if(c==0){
    cout<<3<<endl;
  }
  else if(d==0){
    cout<<4<<endl;
  }
  else if(e==0){
    cout<<5<<endl;
  }
}

Measured memory_bytes: 3584
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define rep(n, i) Rep(0, n-1, i)
#define INF 10000000

using namespace std;

int train(int as[], int n, bool new_flag[], int now_index, int ans){
    if (now_index == 1) return ans;
    if (new_flag[now_index]) return -1;
    else {
        new_flag[now_index] = true;
        return train(as, n, new_flag, as[now_index], ans+1);
    }
}

void solve(void){
    int n;
    cin >> n;
    int as[n];
    rep(n, i) {
        cin >> as[i];
        as[i]--;
    }
    bool flags[n];

    rep(n ,i) flags[as[i]] = true;
    if (!flags[1]) cout << -1 << endl;
    else {
        int ans = 0;
        bool new_flag[n];
        fill(new_flag, new_flag+n, false);
        ans = train(as, n, new_flag, 0, ans);
        cout << ans << endl;
    }
}

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


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
int main(){
  int A,B,X;
  cin >> A >> B >> X;
  string res = "YES";
  if(A > X) res = "NO";
  if(A+B < X) res = "NO";
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <map>
#include <queue>
#include <cmath>
#include <iomanip>
#include <set>
#include <functional>
#include <list>

#define MOD (1000000000 + 7)

using namespace std;

typedef long long ll;
typedef pair<ll, ll> tup;
const int MAX = 3000000;

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

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

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

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

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

map<ll,ll> prime;//素因数分解でそれぞれの素数がいくつ出てきたかを保存するmap

//O(√n)
//整列済み(mapはkeyで自動で整列される)
void prime_factorize(ll n){
    if(n<=1) return;
    ll l=sqrt(n);
   for(ll i=2;i<=(ll)(l);i++) { //
        if(n%i==0){
            prime_factorize(i);prime_factorize(ll(n/i));return;
        }
    }
    //mapでは存在しないkeyの場合も自動で構築される
    prime[n]++;return;
} 

vector<ll> divisor;
void list_divisor(ll n) {
    divisor.clear();
    for(int i = 1; i*i <= n; i++) {
        if(n % i == 0) {
            divisor.push_back(i);
            if(i*i != n) divisor.push_back(n/i);
        }
    }
    sort(divisor.begin(), divisor.end());
}

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

    ll ret = 999999;
    for(ll i = 1; i*i <= N; i++) {
        if(N%i == 0) {
            ll maxv = max(i, N/i);
            ret = min((ll)log10(maxv), ret);
        }
    } 

    cout << ret+1 << endl;
}


Measured memory_bytes: 3880
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

A = [a-1 for a in A]
cnt = 0
tmp = -1000000
for a in A:
    cnt += B[a]
    if a-tmp==1:
        cnt+=C[a-1]
    tmp=a
print(cnt)


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

int a,b,c,x,y;

int main()
{
    scanf("%d%d%d%d%d",&a,&b,&c,&x,&y);
    int ans=min(min(x,y)*2*c, (b+a)*min(x, y));
    if(x>y){
        ans+=min(a*(x-y), c*2*(x-y));
    }
    else{
        ans+=min(b*(y-x), c*2*(y-x));
    }
    cout<<ans<<endl;
}


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

int main() {
  long long int X,Y;
  int i;
  i = 0;
  double r = 1.01;
  cin >> X;
  Y = 100;
  
  while (Y < X) {
    Y *= r;
    i++;
  }
  cout << i << endl;
}


Measured memory_bytes: 3624
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq
ceil = math.ceil
class unionfind():
    def __init__(self,n):
        self.n = n
        self.par = list(range(n))
        self.size = [1]*n
        self.rank = [0]*n

    def root(self,x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.root(self.par[x])
            return self.par[x]

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

    def unite(self,x,y):
        x = self.root(x)
        y = self.root(y)
        if x==y:return
        else:
            if self.rank[x] < self.rank[y]:
                 x,y = y,x
            if self.rank[x] == self.rank[y]:
                self.rank[x]+=1
            self.par[y] = x
            self.size[x] +=self.size[y]
    def get_size(self,x):
        x = self.root(x)
        return self.size[x]
    def parent_set(self):
        for x in range(self.n):
            self.root(x)
        s = set()
        for par in self.par:
            s.add(par)
        return s
n,m = ma()
uf = unionfind(n)
for i in range(m):
    x,y,z = ma()
    uf.unite(x-1,y-1)
s = uf.parent_set()
print(len(s))


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;
const ll INF=1000000000000000;

vector<ll> pw2(51,1); vector<ll> pw10(19,1);
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll mid(ll x,ll y,ll z){return x>y?y>=z?y:min(z,x):x>=z?x:min(y,z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll myceil(ll x,ll y){if(x<=y) return 1;else if(x%y==0) return x/y;else return x/y+1;}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> divisor(ll x){vector<ll> div;
	for(ll i=1;i*i<=x;i++){if(x%i==0){div.pb(i);if(i*i!=x)div.pb(x/i);}}
	sort(div.bg,div.ed);return div;}


int main(){
	string s; cin>>s;
	rep(i,s.sz){
		if(s[i]=='9') s[i]='-';
	}
	rep(i,s.sz){
		if(s[i]=='1') s[i]='9';
	}
	rep(i,s.sz){
		if(s[i]=='-') s[i]='1';
	}
	cout<<s;
}

Measured memory_bytes: 256
#import 
s=input()
#=int(input())
#=map(int,input().split())
#=list(map(int,input().split()))
#=[list(map(int,input().split())) for _ in range()]

if 'RRR' in s:
    print(3)
elif 'RR' in s:
    print(2)
elif 'R' in s:
    print(1)
else:
    print(0)

Measured memory_bytes: 8948
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;

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

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}

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

    cout << (a + b) * h / 2 << endl;
}

Measured memory_bytes: 256
N, M, K = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)
B = gets.split.map(&:to_i)

# t = 0
# read = 0
# while(t < K)
#     k = -1
#     if A.empty? && B.empty?
#         break
#     elsif A.empty?
#         k = B.shift
#     elsif B.empty?
#         k = A.shift
#     elsif A[0] < B[0]
#         k = A.shift
#     elsif A[0] >= B[0]
#         k = B.shift
#     else
#         puts "something is wrong"
#     end
#     if t + k <= K
#         read += 1
#         t += k
#     else
#         break
#     end
# end
# puts read

sumA = Array.new(1,0)
s = 0
A.size.times do |i|
    s += A[i]
    sumA.push s
end
# puts sumA

sumB = []
s = 0
B.size.times do |i|
    s += B[i]
     sumB.push s
end

max_read = -1
(A.size+1).times do |i|
    if sumA[i] > K
        # puts "braked. " + sumA[i].to_s
        break
    end
    b_time = K-sumA[i]
    # print "sumA[" + i.to_s + "] : " + sumA[i].to_s + "  b_time: " + b_time.to_s + "  "
    bi = sumB.bsearch_index{|b| b > b_time}
    bread = -1
    if bi.nil?
        bread = sumB.size
    elsif bi == 0
        bread = 0
    else
        bread = bi
    end
    read = i + bread
    if read > max_read
        max_read = read
    end
    # puts "Aread:" + i.to_s + "  Bread:" + bread.to_s
end
puts max_read

Measured memory_bytes: 45068
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define N 8
#define NOT -1
#define FREE 1

bool X[N][N];
// rowはクイーンの置いてあるところ
int row[N],col[N],dpos[2*N-1],dneg[2*N-1];

void queen(int i);
void printfield();

int main(){
    int k; cin >> k;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            X[i][j] = false;
        }
    }

    for(int i = 0; i < N; i++){
        row[i] = FREE; col[i] = FREE;
    }

    for(int i = 0; i < 2*N-1; i++){
        dpos[i] = dneg[i] = FREE;
    }

    for(int i = 0; i < k; i++){
        int r,c; cin >> r >> c;
        X[r][c] = true;
    }
    
    queen(0);
    return 0;
}

void queen(int i){
    if(i == N){
        printfield(); return;
    }

    for(int j = 0; j < N; j++){
        if(col[j] == NOT || dpos[i+j] == NOT || dneg[i-j+N-1] == NOT) continue;
        // cout << i << " " << j << endl;
        // i,jにおく
        row[i] = j; col[j] = dpos[i+j] = dneg[i-j+N-1] = NOT;
        // 次の行
        queen(i+1);
        // 失敗　i,jのクイーンを取り除く
        row[i] = col[j] = dpos[i+j] = dneg[i-j+N-1] = FREE;
    }

}
void printfield(){
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            if(X[i][j] && row[i] != j) return; //一行に二つ置いてある
        }
    }

    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            cout << ((row[i] == j) ? "Q" : ".");
        }
        cout << endl;
    }
}


Measured memory_bytes: 3092