akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		int k = sc.nextInt();
		
		boolean[] array = new boolean[101];
		Arrays.fill(array, false);
		
		int min = Math.min(a, b);
		
		for (int i = 1; i <= min; i++) {
			if (a % i == 0 && b % i == 0) {
				array[i] = true;
			}
		}
		
		int count = 0;
		
		for (int i = 100; i >= 0; i--) {
			if (array[i]) {
				if (++count == k) {
					System.out.println(i);
					break;
				}
			}
		}
	}
}


Measured memory_bytes: 24148
package main

import "fmt"

func main() {
	var O, E string
	fmt.Scan(&O, &E)
	for i := 0; i < len(O); i++ {
		fmt.Print(string(O[i]))
		if i < len(E) {
			fmt.Print(string(E[i]))
		}
	}
	fmt.Println()
}


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

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

using namespace std;
using lint=long long;

template<class G>
class Fenwick_tree{
	vector<G> a;
public:
	Fenwick_tree(int n):a(n){}
	void add(int i,G val){
		for(i++;i<=a.size();i+=i&-i) a[i-1]+=val;
	}
	G sum(int l,int r)const{
		if(l==0){
			G res{};
			for(;r>0;r-=r&-r) res+=a[r-1];
			return res;
		}
		return sum(0,r)-sum(0,l);
	}
	int lower_bound(G val)const{
		if(val<=G{}) return 0;
		int x=0,k;
		for(k=1;k<=a.size();k<<=1);
		for(k>>=1;k>0;k>>=1) if(x+k<=a.size() && a[x+k-1]<val) val-=a[x+k-1], x+=k;
		return x;
	}
	int upper_bound(G val)const{
		if(val<G{}) return 0;
		int x=0,k;
		for(k=1;k<=a.size();k<<=1);
		for(k>>=1;k>0;k>>=1) if(x+k<=a.size() && a[x+k-1]<=val) val-=a[x+k-1], x+=k;
		return x;
	}
};

int main(){
	int n; scanf("%d",&n);
	vector<int> a(n);
	rep(i,n) scanf("%d",&a[i]);

	vector<pair<int,int>> p(n);
	rep(i,n) p[i]={a[i],i+1};
	sort(p.begin(),p.end());

	lint ans=0;
	Fenwick_tree<int> F(n+1);
	F.add(0,1);
	rep(i,n){
		int idx=p[i].second;
		int k=F.sum(0,idx);
		int l=F.lower_bound(k);
		int r=F.upper_bound(k);
		ans+=lint(i+1)*(idx-l)*(r-idx);
		F.add(idx,1);
	}
	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 3328
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

import collections

n = ni()
a = na()

c = collections.Counter(a)

k = 0
for i,j in sorted(c.items())[::-1]:
    if j < 2:
        continue
    if k > 0:
        print(k*i)
        exit()
    elif j >= 4:
        print(i*i)
        exit()
    else:
        k = i

print(0)

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

template<class like_bool> inline void YES(like_bool condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class like_bool> inline void Yes(like_bool condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class like_bool> inline void POSS(like_bool condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class like_bool> inline void Poss(like_bool condition){ if(condition)cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class like_bool> inline void First(like_bool condition){ if(condition)cout << "First" << endl; else cout << "Second" << endl; }
int character_count(string text, char character){ int ans = 0; for(int i = 0; i < text.size(); i++){ ans += (text[i] == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}};
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
long gcd(long a, long b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }}
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcount(n)

struct road{
    int goal;
    long cost;
};

int main(){
    int N, M;
    cin >> N >> M;
    vector<road> roads[N];
    for(int i = 0; i < M; i++){
        int start, goal;
        long cost;
        cin >> start >> goal >> cost;
        roads[goal - 1].push_back({start - 1, -cost});
    }
    vector<long> distances(N, 1e18);
    distances[N - 1] = 0;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            for(int k = 0; k < roads[j].size(); k++){
                if(distances[j] != 1e18 && distances[roads[j][k].goal] > distances[j] + roads[j][k].cost){
                    distances[roads[j][k].goal] = distances[j] + roads[j][k].cost;
                    if(i == N - 1){
                        cout << "inf" << endl;
                        return 0;
                    }
                }
            }
        }
    }
    cout << -distances[0] << endl;
}


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

#define int long long 

signed main()
{
    int n,m;
    cin >> n >> m;

    vector<pair<int,int>> a(n);
    for(int i = 0; i < n; ++i)
    {
        cin >> a[i].first >> a[i].second;
    }
    sort(a.begin(),a.end());
    
    int ans = 0;
    
    auto it = a.begin();
    priority_queue<int> pq;

    for(int i = 1; i <= m; ++i)
    {
        while(it != a.end() && it->first <= i)
        {
            pq.push(it->second);
            ++it;
        }
        if(!pq.empty())
        {
            ans += pq.top();
            pq.pop();
        }
    }
    cout << ans;
}

Measured memory_bytes: 2936
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecb vector<bool>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}
void comb(vector<vector<long long int>> &v)
{
	for (size_t i = 0; i < v.size(); i++)
	{
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (size_t k = 1; k < v.size(); k++)
	{
		for (size_t j = 1; j < k; j++)
		{
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}
ll repeat_squaring(ll n, ll p, ll m)
{
	if (p == 0)
		return 1;
	if (p % 2 == 0)
	{
		ll t = repeat_squaring(n, p / 2, m);
		return t * t % m;
	}
	return n * repeat_squaring(n, p - 1, m);
}

int main()
{
	str s;
	cin >> s;
	for (size_t i = 1; i < s.size(); i++)
	{
		if (s[i - 1] == s[i])
		{
			cout << "Bad" << endl;
			return 0;
		}
	}
	cout << "Good" << endl;

	return 0;
}

Measured memory_bytes: 256
//07
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
  for(int n;cin>>n,n;){
    bool t[201]={};
    for(int i=0;i<n;i++){
      int c;
      cin>>c;
      t[c]=true;
    }
    vector<int> h[2];
    for(int i=1;i<=2*n;i++){
      h[t[i]].push_back(i);
    }
    int f=-1;
    for(int p=1;h[0].size()&&h[1].size();p=!p){
      int pc=upper_bound(h[p].begin(),h[p].end(),f)-h[p].begin();
      if(pc!=h[p].size()){
	f=h[p][pc];
	h[p].erase(h[p].begin()+pc);
      }else{
	f=-1;
      }
    }
    cout<<h[0].size()<<endl;
    cout<<h[1].size()<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define inf 1000000007
#define LINF 1000000000000000007mope
#define ll long long
using namespace std;
int dp[305][305][305];
bool used[305][305][305];
int midlo[305],midhi[305],leflo[305],lefhi[305];
vector< pair<int,int> > cons[305];
void addtonext(int i,int j,int k,int ma){
	if(used[i][j][k] == false){
		dp[ma+1][j][k] += dp[i][j][k];
		dp[ma+1][j][k] %= inf;
		dp[i][ma+1][k] += dp[i][j][k];
		dp[i][ma+1][k] %= inf;
		dp[i][j][ma+1] += dp[i][j][k];
		dp[i][j][ma+1] %= inf;
		used[i][j][k] = true;
	}
}
signed main(){
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int mope,rr,xx;
		cin>>mope>>rr>>xx;
		cons[rr].pb( mp(mope,xx) );
	}
	for(int i=0;i<=n;i++){
		for(int j=0;j<=n;j++){
			for(int k=0;k<=n;k++){
				if( i!=0 && i==j)used[i][j][k]=true;
				if( j!=0 && j==k)used[i][j][k]=true;
				if( k!=0 && k==i)used[i][j][k]=true;
			}
		}
	}
	dp[0][0][0] = 1;
	for(int i=1;i<=n;i++){
		midlo[i]=0;
		midhi[i]=i-1;
		leflo[i]=0;
		lefhi[i]=i-2;
		for(int j=0;j<cons[i].size();j++){
			int cl = cons[i][j].first;
			int cx = cons[i][j].second;
			if( cx == 1 ){
				midhi[i]=min(midhi[i],cl-1);
				lefhi[i]=min(lefhi[i],cl-2);
			}
			if( cx == 2 ){
				midlo[i]=max(midlo[i],cl);
				lefhi[i]=min(lefhi[i],cl-1);
			}
			if( cx == 3 ){
				midlo[i]=max(midlo[i],cl+1);
				leflo[i]=max(leflo[i],cl);
			}
		}
		//cout<<i<<" "<<midlo[i]<<" "<<midhi[i]<<endl;
		//cout<<i<<" "<<leflo[i]<<" "<<lefhi[i]<<endl;
	}
	for(int i=0;i<=n;i++){
		for(int j=midlo[i];j<=max(0,min(i-1,midhi[i]));j++){
			for(int k=leflo[i];k<=max(0,min(j-1,lefhi[i]));k++){
				int ma = max(i,max(j,k));
				addtonext(i,j,k,ma);
				addtonext(i,k,j,ma);
				addtonext(j,i,k,ma);
				addtonext(j,k,i,ma);
				addtonext(k,i,j,ma);
				addtonext(k,j,i,ma);
			}
		}
	}
	ll ans = 0;
	for(int i=midlo[n];i<=max(0,midhi[n]);i++){
		for(int j=leflo[n];j<=max(0,min(i-1,lefhi[n]));j++){
			ans += dp[n][i][j];
			ans += dp[n][j][i];
			ans += dp[i][n][j];
			ans += dp[i][j][n];
			ans += dp[j][n][i];
			ans += dp[j][i][n];
			ans %= inf;
		}
	}
	if( midlo[n] == 0 && leflo[0] == 0 ){
		ans = ans + 3LL * inf - 3 * dp[n][0][0];
		ans %= inf;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 137728
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int S, W;
    cin >> S >> W;

    if (W >= S) cout << "unsafe" << endl;
    else cout << "safe" << endl;
    
}


Measured memory_bytes: 3640
H, N = list(map(int, input().split()))
w = []
v = []
for _ in range(N):
    v1, w1 = list(map(int, input().split()))
    w.append(w1)
    v.append(v1)
    
INF = 1e15
dp = [[INF]*(H+1) for _ in range(N+1)]
for i in range(N+1):
    dp[i][0] = 0
for j in range(H+1):
    c = j//v[0]*w[0]
    if j%v[0]!=0:
        c += w[0]
    dp[1][j] = c

for i in range(1,N):
    for j in range(H+1):
        if j<v[i]:
            tmp = j//v[i]*w[i]
            if j%v[i]!=0:
                tmp += w[i]
            dp[i+1][j] = min(dp[i][j], tmp)
        else:
            dp[i+1][j] = min(dp[i][j], dp[i+1][j-v[i]]+w[i])
print(dp[-1][-1])

Measured memory_bytes: 374808
import math
n, a, b = map(int, input().split())
v = list(map(int, input().split()))
v.sort(reverse=True)
dict_num = dict()
def combi(x, y):
    return math.factorial(x) / (math.factorial(x - y) * math.factorial(y))
for i in v:
    if i in dict_num:
        dict_num[i] += 1
    else:
        dict_num[i] = 1
ans = 0
ans_max = 0.0
for i in range(a,b+1):
    k = v[:i]
    ans_max = max(ans_max, sum(k) / i)
for i in range(a,b+1):
    k = v[:i]
    if ans_max == (sum(k) / i) :
        p = 1
        index = 0
        while index < len(k):
            count = 1
            while index + 1 < len(k) and k[index] == k[index + 1]:
                count += 1
                index += 1
            p *= combi(dict_num[k[index]], count)
            index += 1
        ans += p
print(ans_max)
print(int(ans))

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

int keta_sum(int x);

int main(){
    int n,a,b;

    cin >> n >> a >> b ;

    vector<int> v(n);

    for(int i=1;i<n+1;i++){
        v[i-1] = keta_sum(i);
    }

    int all_sum=0;

    for(int i=0;i<n;i++){
        if(a<=v[i] && v[i]<=b){
            all_sum += i+1;
        }
    }

    cout << all_sum << endl;

}

int keta_sum(int x){
    int s = 0;
    while(x!=0){
        s += x%10;
        x /= 10;
    }

    return s;
}

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

int main() {
	int n,m,x,y;
	cin>>n>>m>>x>>y;
	for(int i=0;i<n;i++){
	    int a;
	    cin>>a;
	    x=max(x,a);
	}
	for(int j=0;j<m;j++){
	    int a;
	    cin>>a;
	    y=min(y,a);
	}
	if(x<y){
	    cout<<"No War"<<endl;
	}else{
	    cout<<"War"<<endl;
	}
}

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

int solve(int N, int M, int P){
  int i, buf, sum = 0;
  int x[N];
  double prize;
  for(i = 0; i < N; i++){
    scanf("%d", &buf);
    x[i] = buf;
    sum += buf;
  }
  
  prize = sum * (100 - P);
  if(x[M - 1] == 0) return 0;
  prize /= x[M - 1];
  
  prize = floor(prize);
  
  return (int)prize;
}

int main(void){
  int N, M, P;
  while(1){
    scanf("%d %d %d", &N, &M, &P);
    if(N == 0 && M == 0 && P == 0) break;
    printf("%d\n", solve(N, M, P));
  }
  return 0;
}


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


    class Program
    {
        static void Main(string[] args)
        {
            int Input = int.Parse(Console.ReadLine());
            double pai = 3.1415;
            double R = (double)(Input * 2) * pai;
            
            Console.WriteLine(string.Format("{0:F}",R));
        }
    }



Measured memory_bytes: 27616
#! /usr/bin/env python
# -*- coding: utf-8 -*-

import os
import sys
import itertools
import math
from collections import Counter, defaultdict

class Main(object):
    
    def __init__(self):
        pass

    def solve(self):
        '''
        insert your code
        '''
        while True:
            w, h = map(int, raw_input().split())
            if w == h == 0:
                break
            can_move = [[[False, False, False, False] for j in xrange(w)] for i in xrange(h)]
            for i in range(h):
                if i != 0:
                    hol = map(int, raw_input().split())
                    for j in range(w):
                        if hol[j] == 1:
                            can_move[i-1][j][3] = False
                            if i <= h - 1:
                                can_move[i][j][1] = False
                        else:
                            can_move[i-1][j][3] = True
                            if i <= h - 1:
                                can_move[i][j][1] = True
                ver = map(int, raw_input().split())
                for j in range(w-1):
                    if ver[j] == 1:
                        can_move[i][j][0] = False
                        can_move[i][j+1][2] = False
                    else:
                        can_move[i][j][0] = True
                        can_move[i][j+1][2] = True
            # print can_move

            q = [(0, 0, 1)]
            d = [(0, 1), (-1, 0), (0, -1), (1, 0)]
            visited = set([(0, 0)])
            while q:
                y, x, dist = q.pop(0)
                # print y, x, dist
                if (y, x) == (h - 1, w - 1):
                    print dist
                    break
                else:
                    for i, (dy, dx) in enumerate(d):
                        if 0 <= y + dy < h and 0 <= x + dx < w and can_move[y][x][i] and (y + dy, x + dx) not in visited:
                            q.append((y + dy, x + dx, dist + 1))
                            visited.add((y + dy, x + dx))
            else:
                print 0
        return None

if __name__ == '__main__':
    m = Main()
    m.solve()

Measured memory_bytes: 4972
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main()
{
    string s,a,b ,A,B; cin >> s; string s2 = s; ll x = s.size();
    reverse(s2.begin() , s2.end());
    if(s2 == s)
    {
        ll d = (x - 1) / 2;
        ll D = (x + 3 ) / 2;
        a = s.substr(0, d);
        b = s.substr(D - 1, x);
        //cout << "eta a" << ' ' << a << ' ' << "te B" << ' ' << b << '\n';
        A = a; B = b;
        reverse(A.begin() , A.end());
        reverse(B.begin() , B.end());
        if(a == A && b == B)
        {
            return cout << "Yes\n" , 0;
        }


    }
    return cout << "No\n" , 0;

}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();

        int[] h = new int[n];
        for(int i = 0 ; i < n ; i++){
        	h[i] = sc.nextInt();
        }
        Arrays.sort(h);

        long ans = 0;

        for(int i = n-1-k ; i >= 0 ; i--){
        	ans += h[i];
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 66040
# -*- coding: utf-8 -*-

# 素因数分解(試し割り法)
def prime_factorize(n):
    result = []
    if n % 2 == 0:
        t = 0
        while n % 2 == 0:
            n //= 2
            t += 1
        result.append((2, t))
    for i in range(3, int(n ** 0.5) + 1, 2):
        if n % i != 0:
            continue
        t = 0
        while n % i == 0:
            n //= i
            t += 1
        result.append((i, t))
        if n == 1:
            break
    if n != 1:
        result.append((n, 1))
    return result

n = int(input())
ans = 0
for p, e in prime_factorize(n):
    i = 1
    while e >= i:
        ans += 1
        e -= i
        i += 1
print(ans)


Measured memory_bytes: 9440
#include <iostream>
#include <vector> 
#include <cmath>
#include <algorithm>
#include <set>
#include <string>
#include <map>
#include <cerrno>
#include <stdio.h>
#include <stdlib.h>
#include <cfenv>
#include <stack>
#include <math.h>
#include <iomanip>
#include <limits>
#include <queue>
#define ll long long int
#define pb push_back
#define mp make_pair

using namespace std;

int main(){
    int r;
    cin >> r;
    cout << 3*r*r << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using vc = vector<char>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;} 
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N;
        cin >> N;
        vll A(N);
        rep(i, 0, N) cin >> A[i];
        ll mx = A[0];

        ll ans = 0;
        rep(i, 0, N) {
                if (A[i] <= mx) {
                        ans += mx - A[i];
                } else {
                        mx = A[i];
                }
        }

        cout << ans << endl;
}


Measured memory_bytes: 4824
#include<stdio.h>

int main(void)
{
	int j[200],k[200];
	int i=0,l=0,kai[200]={0},x;
	do
	{
	   scanf("%d %d",&j[l],&k[l]);
	   if(j[l]<0||1000000<j[l]||k[l]<0||1000000<k[l])break;
	   l=l+1;
	
	}while(i !=1);
   for(i=0;i<l;i++)
   {
	   x=j[i]+k[i];

       
		 do{
			   x=x/10;
			   kai[i]=kai[i]+1;
	       }while(x!=0);
   }
	for(i=0;i<l;i++)
	{
		printf("%d\n",kai[i]);
    }
  return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    string s,t;
    cin >> s >> t;
    ll si=s.size(), ti=t.size();
    ll ans=100000;
    rp(i,si-ti+1){
        ll ctr=0;
        rp(j,ti){
            if(s[i+j]!=t[j]) ctr++;
        }
        chmin(ans,ctr);
    }
    print(ans);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
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; }
using namespace std;

int n;
double x[1010],y[1010],r[1010],dist[1010];
double graph[1010][1010];

const double inf=1e10;
typedef pair<double,int> pa;

inline double get(int i, int j){
    return max<double>(hypot(x[i]-x[j],y[i]-y[j])-r[i]-r[j],0);
}

signed main(void){
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);

    double sx,sy,tx,ty; cin>>sx>>sy>>tx>>ty;
    cin>>n; x[0]=sx; y[0]=sy; x[n+1]=tx; y[n+1]=ty; r[0]=r[n+1]=0;
    rep(i,n)cin>>x[i+1]>>y[i+1]>>r[i+1];
    rep(i,n+2)rep(j,n+2)graph[i][j]=get(i,j);

    rep(i,n+1)dist[i+1]=inf;
    priority_queue<pa,vector<pa>,greater<pa>> que; que.push(pa(dist[0],0));

    while(que.size()){
        pa p=que.top(); que.pop();
        int v=p.second; if(dist[v]<p.first)continue;
        rep(i,n+2){
            if(chmin<double>(dist[i],dist[v]+graph[v][i]))que.push(pa(dist[i],i));
        }
    }

    cout<<setprecision(30)<<dist[n+1]<<endl;
    return 0;

}

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

using ll = long long int;
const int mod = 1e9+7;
const int inf = 1e9+5;


int main(){
	
	int n, K;
	cin>>n>>K;
	vector<int>arr(n);
	for(int i = 0; i < n; i++){
		cin>>arr[i];
	}
	vector<int>dp(n, inf);
	dp[0] = 0;
	for(int i = 0; i < n; i++){
		for(int k = i+1; k <= i+K; k++){
			if(k < n){
				dp[k] = min(abs(arr[k]-arr[i])+dp[i], dp[k]);
			}
		}
	}
	cout<<dp[n-1]<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        500005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>
 
using namespace std;
 
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
 
int power(int a,int n)
{
    a %= mod;
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return (a*(power((a*a)%mod,n/2)%mod))%mod;
    return power((a*a)%mod,n/2)%mod;
}
const int inf = (int) 1e18;
 
int inverse(int x){
    return power(x,mod-2)%mod;//little fermat....
}   
int bno[maxn],ans[maxn],cnt[maxn];

void solve(){
    int n,q;
    cin >> n >> q;
    int bsiz = sqrt(n);
    vector<int>v(n+5);
    FOR(i,1,n+1)cin >> v[i];
    FOR(i,1,n+1){
        bno[i] = (i-1)/bsiz+1;
    }
    vector<pair<pii,int>>u;
    FOR(i,1,q+1){
        int l,r;
        cin >> l >> r;  
        u.pb({{l,r},i});
    }
    sort(u.begin(),u.end());
    int ci = 0,cl = 1,cr = 1,tot = 1;
    cnt[v[1]] = 1;
    FOR(i,1,n+1){
        if(ci == sz(u))break;
        vector<pair<pii,int>>a;
        while(ci < sz(u) && bno[u[ci].f.f] == i){
            a.pb({{u[ci].f.se,u[ci].f.f},u[ci].se});
            ci++;
        }
        sort(a.begin(),a.end());
        for(auto &x:a){
            int l = x.f.se,r = x.f.f,ind = x.se;
            while(cr < r){
                cr++;
                if(cnt[v[cr]] == 0)tot++;
                cnt[v[cr]]++;
            }
            while(cl < l){
                cnt[v[cl]]--;
                if(cnt[v[cl]] == 0)tot--;
                cl++;
            }
            while(cl > l){
                cl--;
                if(cnt[v[cl]] == 0)tot++;
                cnt[v[cl]]++;
            }
            while(cr > r){
                cnt[v[cr]]--;
                if(cnt[v[cr]] == 0)tot--;
                cr--;
            }
            ans[ind] = tot;
        }
    }
    FOR(i,1,q+1)cout << ans[i] << "\n";
}
signed main()
{
    showoff;
    int T = 1;
    //cin >> T;
    FOR(t,1,T+1){   
        solve();
        //cout << "\n";
    }
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...
 



Measured memory_bytes: 31244
//  ROAD TO GREEN
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>
#include <queue>
#include <set>
#include <bitset>

#define ll long long
#define uint unsigned int
#define ull unsigned ll
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define speedhack() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define do(x) for(int i = 1; i <= x; i++){ solve(); }
#define s(x) x.size()

using namespace std;
const ll MAXN = 2e9+2;
const ll SIZE = 1e5+2;
const ll mod = 1e9+7;

void solve(){
	int a[4];
	for(int i = 1; i <= 3; i++){
		cin >> a[i];
	}
	int mins = 301;
	for(int i = 1; i <= 3; i++){
		for(int j = 1; j <= 3; j++){
			if(i != j){
				if(a[i]+a[j] < mins)
				mins = a[i]+a[j];
			}
		}
	}
	cout << mins << endl;
}	

int main(){ 
	speedhack()
	// int it; cin >> it;
	int it = 1;
	do(it);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>  // ver2.1.9
#define int long long
#define endl "\n"
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define Pii pair<int,int>
#define Tiii tuple<int,int,int>
#define PQi priority_queue<int>
#define PQir priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define sortr(v) sort(v,greater<>())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define dem(a,b) ((a+b-1)/(b))
#define Vout(a) rep(lZ,0,a.size()-1)cout<<a[lZ]<<' ';cout<<a.back()<<endl
#define VVout(a) rep(lW,0,a.size()){Vout(a[lW]);}
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
using namespace std;
 
int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm
void uniq(Vi &v){sort(ALL(v)); v.erase(unique(ALL(v)),v.end());}  //  uniqのやつ
 
int mypow(int x, int n, int m){  //  累乗x^n(mod m)  O(log(n))
if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}
 
signed main() {
  cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(12);
  int n;
  cin >> n;
  int ans = 1;
  Vi a(n),ar(n),b(n),br(n),memo(n);
  
  rep(i,0,n) cin >> memo[i];
  a[0] = memo[0];
  
  rep(i,1,n){
    if(memo[i] > memo[i-1]) a[i] = memo[i];
    else ar[i] = memo[i];
  }
  
  //Vout(a);
  //Vout(ar);
  
  rep(i,0,n) cin >> memo[i];
  
  b[n-1] = memo[n-1];
  
  repreq(i,n-2,0){
    if(memo[i] > memo[i+1]) b[i] = memo[i];
    else br[i] = memo[i];
  }
  
  //Vout(b);
  //Vout(br);
  
  rep(i,0,n){
    if(a[i]!=0 && b[i]!=0) {
      if(a[i]!=b[i]) {ans = 0;break;}
    }
    
    if(a[i]!=0 && b[i]==0) {
      if(a[i] > br[i]) {ans = 0;break;}
    }
    
    if(a[i]==0 && b[i]!=0) {
      if(b[i] > ar[i]) {ans = 0;break;}
    }
    
    if(a[i]==0 && b[i]==0) {
      ans *= min(ar[i],br[i]);
      ans %= MOD;
    }
    
  }
  cout << ans << endl;  
  return 0;
}

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



int main() {
  string s;
  cin >> s;
  
  map<string, int> mp;
  mp["SUN"] = 7;
  mp["MON"] = 6;
  mp["TUE"] = 5;
  mp["WED"] = 4;
  mp["THU"] = 3;
  mp["FRI"] = 2;
  mp["SAT"] = 1;
  
  cout << to_string(mp.at(s)) << endl;  
  
}

Measured memory_bytes: 256
ENV[Z='RUBY_THREAD_VM_STACK_SIZE']||exec({Z=>?5*8},'ruby',$0)
require 'set'
def dfs(z,c)
	f=S[c]
	r=[0,c]
	G[c].each{|e|
		next if e==z
		t=dfs(c,e)
		r=[r,[t[0]+f,t[1]]].max
	}
	r
end
N=gets.to_i
G=Hash.new{|h,k|h[k]=Set.new}
(N-1).times{
	a,b=gets.split.map(&:to_i)
	G[a-1]<<b-1
	G[b-1]<<a-1
}
A=gets.chomp
(p A.count(?W);exit) if A.count(?W)<2
r=N-1
Q=N.times.select{|i|G[i].size==1&&A[i]==?B}
while !Q.empty?
	c=Q.shift
	r-=1
	G[c].each{|e|
		G[e].delete c
		Q<<e if G[e].size==1&&A[e]==?B
	}
	G.delete c
end
r*=2
S={}
G.keys.each{|k|
	G.delete k if G[k].empty?
	r+=S[k]=((A[k]==?B?0:1)+G[k].size)%2
}
p r-dfs(-1,dfs(-1,G.each_key.first)[1])[0]*2

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

int main(){
	
	int A, B, C, K;
	string result;
	cin >> A >> B >> C >> K;

	while(K > 0){
		
		if(B <= A || C <= B){
			if(B <= A){
				B *= 2;
			}
			else{
				C *= 2;
			}
			K--;
		}
		else{
			break;
		}
	}
	
	result = (A < B && B < C) ? "Yes" : "No";
	cout << result;
	return 0;
}


Measured memory_bytes: 3600
$cache = {}

def lucas(n)
  return $cache[n] if $cache.key?(n)

  if n == 0
    2
  elsif n == 1
    1
  else
    x = lucas(n - 1) + lucas(n - 2);
    $cache[n] = x
    x
  end
end

n = gets.strip.to_i
puts lucas(n)


Measured memory_bytes: 1788
/**
*    author:  souzai32
*    created: 15.08.2020 17:48:49
**/

#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
typedef long long ll;
using namespace std;

int main() {

    vector<bool> prime(int(1e5+1),false);
    prime.at(2)=true;
    for(int i=3; i<1e5; i+=2){
        prime.at(i)=true;
        for(int j=3; j*j<=i; j+=2){
            if(prime.at(j)){
                if(i%j==0){
                    prime.at(i)=false;
                    break;
                }
            }
        }
    }

    vector<int> p2017(int(1e5+1));
    for(int i=3; i<int(1e5+1); i++){
        p2017.at(i)=p2017.at(i-1);
        if(prime.at(i)&&prime.at((i+1)/2)) p2017.at(i)++;
    }

    int q,l,r;
    int ans;
    cin >> q;
    rep(i,q){
        cin >> l >> r;
        ans=p2017.at(r)-p2017.at(l-1);
        cout << ans << endl;
    }

    return 0;
}

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

int main() {

	int N;
	cin >> N;

	int d[50] = { 0, };
	for (int i = 0; i < N; i++) {
		cin >> d[i];
	}

	int sum = 0;

	for (int j = 0; j <N-1; j++) {
		for (int k = j+1; k < N; k++) {
			sum += d[j] * d[k];
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
n = int(input())
a = []
for i in range(n):
  a.append(input())
for i in range(n):
  k = list(a[i])
  k.sort()
  k = ''.join(k)
  a[i] = k
a.sort()
k = 1
s = 0
for i in range(n-1):
  if a[i] == a[i+1]:
    k += 1
  else:
    s += k*(k-1)/2
    k = 1
s += k*(k-1)/2
print(int(s))

Measured memory_bytes: 10584
#include <iostream>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
using namespace std;


int main()
{
	int a1, a2, a3, b1, b2, b3,sameCt =0,diffCt =0;
	cin >> a1 >> b1 >> a2 >> b2 >> a3 >> b3;
	int a[6] = { a1, b1, a2, b2, a3, b3 };

	int i, j, tmp;
	printf("\n");
	for (i = 0; i < 6 - 1; i++) {
		for (j = i + 1; j < 6; j++) {
			if (a[i] > a[j]) {
				tmp = a[i];
				a[i] = a[j];
				a[j] = tmp;		
			}
		}
	}

	int cop=0, cop2=0,tmpct=0;
	
	for (i = 0; i < 6; i++)
	{
		if (a[i] == a[i + 1])sameCt++;
		else diffCt++;
		if (sameCt == 1 && tmpct == 0) { cop = a[i]; tmpct += 1; }
		if (sameCt == 2 && tmpct == 1){cop2 = a[i]; tmpct += 1;}
	}
	cout << (sameCt == 2 && diffCt == 4 && cop != cop2 ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<cmath>
using namespace std;
int main(int argc,char* argv[])
{
  int length,input;
  double d1,d2,d3,d4,temp;d1=0;d2=0;d3=0;d4=0;
  vector<int> vec1,vec2;
  cin >> length;
  for(int i=0;i<length;i++)
  {
    cin >> input;
    vec1.push_back(input);
  }
  for(int i=0;i<length;i++)
  {
    cin >> input;
    vec2.push_back(input);
  }
  for(int i=0;i<length;i++)
  {
    d1+=abs(vec1[i]-vec2[i]); 
    d2+=pow(abs(vec1[i]-vec2[i]),2.0); 
    d3+=pow(abs(vec1[i]-vec2[i]),3.0);
    temp=abs(vec1[i]-vec2[i]);
    if(temp>=d4) d4=temp;
  }
    printf("%.8lf\n%.8lf\n%.8lf\n%.8lf\n",d1,sqrt(d2),pow(d3,1.0/3.0),d4);
}

Measured memory_bytes: 3372
//## MohK
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int x;
    cin>>x;
    int a[x];
    int b=0;
    int c=99999999999;
    for(int i=1;i<=x;i++)
    {
        cin>>a[i];
        if(a[i]>=b)
        {
            b=a[i];
        }
        if(a[i]<=c)
        {
            c=a[i];
        }
    }
    cout<<b-c;


    return 0;
}


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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> a(n);
    bool f0 = true;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] != 0) f0 = false;
    }

    if (f0) {
        cout << "Yes" << endl;
        return 0;
    }

    if (n % 3 != 0) {
        cout << "No" << endl;
        return 0;
    }

    map<ll, int> cnt;
    for (ll x : a) cnt[x]++;
    if (cnt.size() > 3) {
        cout << "No" << endl;
    } else if (cnt.size() == 1) {
        cout << (a[0] == 0 ? "Yes" : "No") << endl;
    } else if (cnt.size() == 2) {
        vector<ll> v;
        for (auto& p : cnt) v.push_back(p.first);
        if (v[0] == 0) {
            cout << (cnt[v[1]] == cnt[v[0]] * 2 ? "Yes" : "No") << endl;
        } else if (v[1] == 0) {
            cout << (cnt[v[0]] == cnt[v[1]] * 2 ? "Yes" : "No") << endl;
        } else {
            cout << "No" << endl;
        }
    } else {
        vector<ll> v;
        for (auto& p : cnt) v.push_back(p.first);
        if ((v[0] ^ v[1]) == v[2]) {
            cout << ((cnt[v[0]] == cnt[v[1]] && cnt[v[1]] == cnt[v[2]]) ? "Yes" : "No") << endl;
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 5760
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<set>
#include<map>
#include<string>
#include<vector>

using namespace std;

const int MX = 100005;

int N;
int cnt[13];

int main()
{
	int N, a;
	scanf("%d", &N);
	for(int i = 1; i <= N; i++) scanf("%d", &a), cnt[a]++;
	cnt[0]++;
	int ans = 0;
	if( cnt[12] >= 2 || cnt[0] >= 2) return !printf("0\n");
	for(int i = 0; i < 1<<13; i++){
		int chk[25] = {};
		int cur = 50;
		for(int j = 0; j < 13; j++){
			if( cnt[j] == 0 ) continue;
			if( cnt[j] == 1 && i & 1<<j ) chk[j] = 1;
			else if( cnt[j] == 1 ) chk[24-j] = 1;
			else if( cnt[j] == 2 ) chk[j] = chk[24-j] = 1;
			else return !printf("0\n");
		}
		for(int i = 0; i <= 24; i++){
			for(int j = i+1; j <= 24; j++){
				if( chk[i] && chk[j] ) cur = min(cur, min(24-(j-i), j-i));
			}
		}
		if( cur < 50 ) ans = max(ans, cur);
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 256
#include<stdio.h>
int f(int n){
	int num=0;
	while(n%2==0){
		n/=2;
		num++;
	}
	return num;
}
int main()
{
	int n;
	scanf("%d",&n);
	int i,t=1;
	int max=f(1);
	for(i=1;i<=n;i++){
		if(f(i)>=max) {
			max=f(i);
			t=i;
		}
	}
	printf("%d",t);
	return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
#define REP(i,n,N) for(ll i=(n);i<(N);i++)
#define RREP(i,n,N) for(ll i=(N-1);i>=(n);i--)
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(), (v).end()
#define MCP(a,b) memcpy(b,a, sizeof(b))
#define p(s) cout<<(s)<<endl
#define p2(a,b) cout<<(a)<<" "<<(b)<<endl
typedef long long ll;
using namespace std;
const ll mod = 1e9+7;
const ll inf =1e18;

ll N;
string w[50];

int main(){
    while(cin>>N && N != 0){
        REP(i,0,N){
            cin>>w[i];
        }

        REP(i,0,N){

            ll cnt = 0;
            ll v = 0;
            bool f = false;

            REP(j,i,N){
                if(v < 1){
                    if(cnt < 5){
                        cnt += w[j].size();
                    }

                    if(cnt == 5){
                        v++;
                        cnt = 0;
                    }else if(cnt > 5){
                        v = 0;
                        cnt = 0;
                        break;
                    }
                }else if(v < 2){
                    if(cnt < 7){
                        cnt += w[j].size();
                    }

                    if(cnt == 7){
                        v++;
                        cnt = 0;
                    }else if(cnt > 7){
                        v = 0;
                        cnt = 0;
                        break;
                    }
                }else if(v < 3){
                    if(cnt < 5){
                        cnt += w[j].size();
                    }

                    if(cnt == 5){
                        v++;
                        cnt = 0;
                    }else if(cnt > 5){
                        v = 0;
                        cnt = 0;
                        break;
                    }
                }else if(v < 4) {
                    if(cnt < 7){
                        cnt += w[j].size();
                    }

                    if(cnt == 7){
                        v++;
                        cnt = 0;
                    }else if(cnt > 7){
                        v = 0;
                        cnt = 0;
                        break;
                    }
                }else if(v < 5){
                    if(cnt < 7){
                        cnt += w[j].size();
                    }

                    if(cnt == 7){
                        v++;
                        cnt = 0;
                    }else if(cnt > 7){
                        v = 0;
                        cnt = 0;
                        break;
                    }
                }

                if(v == 5){
                    cout<<i+1<<endl;
                    f = true;
                    break;
                }
            }

            if(f) break;
        }
    }

    return 0;
}


Measured memory_bytes: 3116
s = input()
x = list()
cnt = 0
for i in range(len(s)):
    if s[i] == "A" or s[i] == "T" or s[i] == "G" or s[i] == "C":
        cnt += 1
        if i == len(s) - 1:
            x.append(cnt)
    else:
        x.append(cnt)
        cnt = 0
print(max(x))

Measured memory_bytes: 9124
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  if(1<=n && n<10){
    cout << n << endl;
  }
  else if(10<=n && n<100){
    cout << 9 << endl;
  }
  else if(100<=n && n<1000){
    cout << n-99+9 << endl;
  }
  else if(1000<=n && n<10000){
    cout << 909 << endl;
  }
  else if(10000<=n && n<100000){
    cout << n-9999+909 << endl;
  }
  else if(n==100000){
    cout << 90909 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
local n = io.read("*n", "*l")
local titles = {}
local len = {}
for i = 1, n do
  local title, l = io.read():match("(%w+) (%d+)")
  len[i] = tonumber(l)
  titles[title] = i
end
local ret = 0
local p = titles[io.read()]
for i = p + 1, n do
  ret = ret + len[i]
end
print(ret)


Measured memory_bytes: 888
// Copyright 2020 yaito3014
#include <bits/stdc++.h>
using namespace std;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> ans(N);
  for (int i = 1; i < N; ++i) {
    int A;
    cin >> A, --A;
    ++ans[A];
  }
  for (auto& e : ans)cout << e << '\n';
}


Measured memory_bytes: 3984
#include <stdio.h>
#define P 1000000007LL
long long a[1010][1010];
long long b2[1010][1010];
long long bk[1010][1010];

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

long long powmod(long long a,long long b){
	if(b==0)return 1;
	if(b%2==1)return (powmod(a,b-1)*a)%P;
	long long r=powmod(a,b/2);
	return (r*r)%P;
}

main(){
	int N;
	long long x,y,z;
	scanf("%d%lld%lld%lld",&N,&x,&y,&z);
	long long fac[1010];
	long long ifac[1010];
	fac[0]=1;
	for(int i=1;i<=N;i++)fac[i]=(fac[i-1]*i)%P;
	for(int i=0;i<=N;i++)ifac[i]=powmod(fac[i],P-2);
	long long k=x+z-y;
	if(k<0)k=-k;
	
	for(int m=1;m<=N;m++){
		for(int i=0;i*m<=N;i++){
			if(i==0)b2[m][i]=bk[m][i]=1;
			else{
				b2[m][i]=bk[m][i]=0;
				for(int j=1;j<=i;j++){
					if(gcd(j*m,k)==j){
						long long mul=fac[i-1];
						mul=(mul*ifac[i-j])%P;
						mul=(mul*powmod(m,j-1))%P;
						bk[m][i]+=(mul*bk[m][i-j])%P;
						bk[m][i]%=P;
					}
					if(gcd(j*m,2)==j){
						long long mul=fac[i-1];
						mul=(mul*ifac[i-j])%P;
						mul=(mul*powmod(m,j-1))%P;
						b2[m][i]+=(mul*b2[m][i-j])%P;
						b2[m][i]%=P;
					}
				}
			}
		}
	}
	for(int n=0;n<=N;n++){
		for(int m=0;m<=N;m++){
			if(m==0)a[n][m]=(n==0?1:0);
			else{
				a[n][m]=0;
				for(int i=0;n-i*m>=0;i++){
					long long mul=(b2[m][i]*bk[m][i])%P;
					mul=(mul*fac[n])%P;
					mul=(mul*ifac[n-i*m])%P;
					mul=(mul*ifac[i])%P;
					mul=(mul*powmod(ifac[m],i))%P;
					mul=(mul*powmod(fac[m-1],i))%P;
					a[n][m]+=(mul*a[n-i*m][m-1])%P;
					a[n][m]%=P;
				}
			}
		}
	}
	if(x>0||y>0||z>0)printf("%lld\n",a[N][N]);
	else{
		long long ans=a[N][N];
		ans=(ans*ifac[N])%P;
		ans=(ans*powmod(N,N))%P;
		printf("%lld\n",ans);
	}
}

Measured memory_bytes: 23920
/**
 *	author:   fractal
 *	timus:    288481RF
 *	created: 08/22/20 18:02:54
**/

#include <bits/stdc++.h>
using namespace std;

#define F first
#define S second 
#define mp make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define speed_up ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define sz(x) (int)x.size()
#define szc(x) (int)strlen(x)
#define all(x) x.begin(), x.end()
#define debug cerr << "OK\n";
#define ub upper_bound
#define lb lower_bound 
 
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef set <int> si;
typedef set <ll> sll;
typedef multiset <int> msi;
typedef multiset <ll> msll;
typedef map <int, int> mi;
typedef map <ll, int> mll;
 
const int N = 1e6 + 2;
const int M = 1e5;
const int mod = 0;
const int inf = 2e9 + 3;
const ll INF = 1e16;

string s;

int main() {
	cin >> s;
	int sum = 0;
	for (auto it : s)
		sum += it-'0';
	if (sum % 9 == 0)
		cout << "Yes\n";
	else
		cout << "No\n";
}


Measured memory_bytes: 3744
import scala.io.StdIn.{readLine,readInt}

object Main {
  val t = new Array[Int](10001)

  def getMin(x:Int,y:Int) = if(x<y) x else y

  def scan(a:Array[Int], used:Array[Boolean],i:Int, size:Int, min:Int, sum:Int):(Int,Int,Int) = {
    if(used(i)) (size,sum,min)
    else {
      used(i) = true
      val w = a(i)
      scan(a, used, t(w), size+1, getMin(min, w), sum+w)
    }
  }

  def getCost(a:Array[Int],min:Int,n:Int) = {
    var ans = 0
    val used = (0 until a.length).map(_=>false).toArray
    val b = a.sorted.clone

    (0 until n).foreach{ i => t(b(i))=i }

    for(i<-0 until n) {
      if(!used(i)) {
        val (size, s, m) = scan(a,used,i,0,10000,0)
        ans += getMin(s+(size-2)*m, m+s+(size+1)*min)
      }
    }
    ans
  }

  def main(args:Array[String]) = {
    val n = readInt
    val a = readLine.split(" ").map(_.toInt)
    val min = a.min
    println(getCost(a,min,n))
  }
}

Measured memory_bytes: 44628
#include <iostream>
#include <numeric>
#include <array>

using namespace std;

int main(int argc, char* argv[]){
    array<int, 5> cook_times;
    int min_residual = 10;
    for (auto&& cook_time: cook_times){
        cin >> cook_time;
        int residual = cook_time % 10;
        if (residual != 0){
            cook_time = cook_time + (10 - residual);
            if (residual < min_residual){
                min_residual = residual;
            }
        }
    }
    cout << accumulate(cook_times.begin(), cook_times.end(), 0) - (10 - min_residual) << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main()
{
	string str;
	cin >> str;

	bool C = false, F = false;

	for (auto& c:str){
		if (c == 'C'){
			C = true;
		}
		if (C){
			if (c == 'F'){
				F = true;				
			}
		}
	}

	if (F){
		cout << "Yes";
	}
	else{
		cout << "No";
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


ll dp[4000][4000],dp2[4000][4000];
int main(){
    int n,m;
    cin>>n>>m;
    --n;
    --m;
    rep(i,n+1){
        dp[0][i]=1;
    }
    rep(i,m)rep(j,4000){
        if(j<n)(dp[i+1][j+1]+=dp[i][j])%=mod;
        if(j>0)(dp[i+1][j-1]+=dp[i][j])%=mod;
        (dp[i+1][j]+=dp[i][j]*2)%=mod;
    }
    rep(i,n){
        dp2[0][i]=1;
    }
    rep(i,m)rep(j,4000){
        if(j<n-1)(dp2[i+1][j+1]+=dp2[i][j])%=mod;
        if(j>0)(dp2[i+1][j-1]+=dp2[i][j])%=mod;
        (dp2[i+1][j]+=dp2[i][j]*2)%=mod;
    }
    ll ans=0;
    rep(i,n+1)ans+=dp[m][i];
    rep(i,n)ans+=mod-dp2[m][i];
    cout<<4*ans%mod<<endl;
    return 0;
}

Measured memory_bytes: 188672