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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

vi a, dep;
vvi inv;
vector<bool> ok;

void dfs(int i, int d) {
  dep[i] = d;
  for (auto &j : inv[i]) dfs(j, d + 1);
}

void use(int i, int d) {
  ok[i] = true;
  if (d > 0)
    for (auto &j : inv[i]) use(j, d - 1);
}

struct N {
  int i, d;
};

bool operator<(const N &l, const N &r) {
  return l.d > r.d;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  a.resize(n);
  dep.resize(n);
  ok.resize(n);
  ll ans = 0;
  for (int i = 0; i < n; i++) cin >> a[i];
  if (a[0] != 1)
    ans++;
  for (int i = 0; i < n; i++) {
    a[i]--;
  }
  a[0] = 0;
  inv.resize(n);
  for (int i = 1; i < n; i++) {
    inv[a[i]].push_back(i);
  }
  multiset<N> q;

  dfs(0, 0);
  for (int i = 0; i < n; i++) {
    if (dep[i] <= k) ok[i] = true;
    else q.insert(N{i, dep[i]});
  }

  vvi p(n);
  for (int i = 0; i < n; i++) {
    p[i].resize(20);
    p[i][0] = a[i];
  }
  for (int j = 1; j < 20; j++) {
    for (int i = 0; i < n; i++) {
      p[i][j] = p[p[i][j - 1]][j - 1];
    }
  }
  if (k == 1) {
    for (int i = 0; i < n; i++) if (!ok[i]) ans++;
    cout << ans << endl;
    return 0;
  }

  while (q.size()) {
    N now = *q.begin();
    q.erase(q.begin());
    if (ok[now.i]) {
      continue;
    }
    int k2 = k - 1;
    int keta = 0;
    int t = now.i;
    while (k2) {
      if (k2 % 2)
        t = p[t][keta];
      k2 >>= 1;
      keta++;
    }
    use(t, k - 1);
    ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 26112
/*ॐॐ*/
/* I have already deleted My old account because somebody stole my code
and i have no idea how. If you are copying this code atleast make it look different.
Change variable names or change some Data structres or anything just make sure MOSS do not
Detect Anything.
Yours Faithfully
Shobhit Yadav */
/*my variables are anime character */

/* I do not fear this new challenge. Rather like a true warrior I will rise to meet it. 
                                       -Prince Vegeta  */

 /* “Strength is the only thing that matters in this world. Everything else is just a delusion for the weak.” – Vegeta */

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define vll vector<ll>
#define pll pair<ll , ll> 
#define vpll vector<pll>
#define umpll unordered_map<ll , ll>
#define mpll map<ll , ll>
#define sll set<ll>
#define stll stack<ll>
#define FIO  ios_base::sync_with_stdio(false);  cin.tie(0); cout.tie(0);



ll N,T,A,B,C,D;
/*ll freq[200005];*/
void solve(){
   /*memset(freq,0,sizeof(freq));*/
   cin>>A>>B>>C>>D;

   ll mul1 = A*C;
   ll mul2 = A*D;

   ll mul3 = B*C;
   ll mul4 = B*D;

   ll mul5 = max(mul1 , mul2);
   ll mul6 = max(mul3 , mul4);

   cout<<max(mul5,mul6)<<'\n';
  
}



int main(){
  
  FIO 
  
 solve();

  return 0;
}

Measured memory_bytes: 3648
package main

import (
	"fmt"
)

func main() {
	var a, b, c string
	fmt.Scan(&a, &b, &c)

	if a[len(a)-1] == b[0] && b[len(b)-1] == c[0] {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 512
#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>

using namespace std;
using ll = long long;

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

#include <iostream>

int main()
{
	int X, A;
	cin >> X >> A;

	if (X < A) { cout << 0 << endl; }
	else { cout << 10 << endl; }
}

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

int main(void) {
	long long n, a, min_a;
	scanf("%lld", &n);
	
	for (int i = 0; i < 5; i++) {
		scanf("%lld", &a);
		if (i == 0)
			min_a = a;
		else
			min_a = min_a > a ? a : min_a;
	}
	
	printf("%lld\n", n / min_a + (n % min_a ? 1 : 0) + 4);
	
	return 0;
}

Measured memory_bytes: 128
//-----Rashish-----//
#include<bits/stdc++.h>
typedef long long ll;

using namespace std;

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define endl '\n'
#define ALL(a)              a.begin(), a.end()
#define ALLN(a, n)          (a, a+n)
#define MAX                 10000007
#define MIN                 -10000007
#define ff              first
#define ss              second
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

ll hcf(ll n1, ll n2) {if (n2 != 0)return hcf(n2, n1 % n2); else return n1;}
ll fact(ll n) { ll i = 1, co = 1; for (i = 1; i <= n; i++)co *= i; return co;}
ll isprime(ll n) {
  if (n <= 1) return 0; if (n <= 3) return 1; if (n % 2 == 0 || n % 3 == 0) return 0;
  for (ll i = 5; i <= sqrt(n); i += 6) { if (n % i == 0 || n % (i + 2) == 0) return 0; } return 1;
}
ll sod(ll n) {ll sum = 0; while (n) {sum += n % 10; n /= 10;} return sum;}




int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  freopen("error.txt", "w", stderr);
#endif

  int t;
  t = 1;
  //cin>>t;
  while (t--) {
    ll n, x, t;
    cin >> n >> x >> t;
    ll q = ceil((double)n / x);
    // cout << q;
    cout << q*t << endl;



  }

  return 0;
}


Measured memory_bytes: 3760
#include <iostream>

using namespace std;

int main()
{
    int shu[10];
    for(int i=0;i<5;i++)
    {
        cin>>shu[i];
    }
    int k;
    cin>>k;
    if(shu[4]-shu[0]>k)
        cout<<":("<<endl;
    else
        cout<<"Yay!"<<endl;
    return 0;
}


Measured memory_bytes: 256
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val N = sc.nextInt
  val scores = (0 until N)
    .map { _ => (sc.nextLong, sc.nextLong) }
    .toArray
    .sortWith { _._1 < _._1 }
  val (_, acc) = scores.foldLeft { (0L, 0L) } {
    case ((rAcc, cnt), (r, s)) => (r, cnt + r - rAcc)
  }
  println(scores.last._2 + acc)
}


Measured memory_bytes: 77572
/*
 Abu Jafor Mohammad Saleh
 ios_base :: sync_with_stdio(false);
 cin.tie(NULL);
 */

#include<cstdio>
#include<iomanip>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<algorithm>
#include<set>
#include<queue>
#include<deque>
#include<stack>
#include<list>
#include<iostream>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<iterator>
#include<limits>
#include <algorithm>
#include <unordered_map>
#define f first
#define s second
#define MOD 1000000007
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
//#include<bits/stdc++.h>
using namespace std;

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


int main()
{
    fast;
    int n;
    cin>>n;
    int a[n+1];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    
    int c= 0;
    int x =1;
    for(int i=0;i<n;i++)
    {
        if(a[i]==x)
        {
            x++;
            c++;
        }
    }
    if(c==0)
        cout<<-1<<endl;
    else
    cout<<n-c<<endl;
        
}



Measured memory_bytes: 1024
import java.util.Scanner;

// this file implements the merge sort
public class Main {
	
	public static int compare_count = 0;
	public static void merge(int [] arr, int lo, int mid, int hi) {
		// now the arr[lo ... mid] arr[mid+1 ... hi] are ordered;
		int n_l = mid - lo + 1;
		int n_r = hi - mid;
		int[] L = new int[n_l+1];
		int[] R = new int[n_r+1];
			
		for(int i = 0; i < n_l; i++) {
			L[i] = arr[lo+i];
		}
		
		for(int j = 0; j < n_r; j++) {
			R[j] = arr[mid + j + 1]; 
		}
		
		
		//this is a tricky point!! 
		L[n_l] = Integer.MAX_VALUE;
		R[n_r] = Integer.MAX_VALUE;
		
		//now do the merge
		int i = lo;
		int l_i = 0, r_i = 0;
		while(i <= hi) {
			compare_count++;
			if(L[l_i] < R[r_i]) {
				arr[i] = L[l_i];
				l_i ++;
			}else {
				arr[i] = R[r_i];
				r_i++;
			}
			
			i++;
		}
		
		return;
	}
	
	
	public static void merge_sort(int [] arr, int lo, int hi) {
		if(lo == hi) {
			return ;
		} // which means eveything is ordered
		
		int mid = (lo + hi) >> 1;
		
		merge_sort(arr, lo, mid);
		merge_sort(arr, mid+1, hi);
		merge(arr, lo, mid, hi);
		
	}
	
	
	
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		int n = cin.nextInt();
		int [] arr = new int[n];
		
		for(int i = 0 ; i < n; i++) {
			arr[i] = cin.nextInt();
		}
		
		merge_sort(arr, 0, arr.length-1);
		
		for(int i = 0; i < arr.length; i++) {
			System.out.print(arr[i]);
			if(i < arr.length-1) {
				System.out.print(" ");
			}else {
				System.out.println();
			}
		}
		
		
		System.out.println(compare_count);
	}
}

Measured memory_bytes: 170168
//Catchharsh
#include<bits/stdc++.h>
#define ll long long int 
#define ld long double
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define F first
#define S second
#define sz(x) x.size()
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define see(x) cout<<#x<<" = "<<x<<endl
const ll MOD = 1e9+7;
const ll INF = 1011111111;
const ll LLINF = 1000111000111000111LL;
const ld EPS = 1e-10;
const ld PI = 3.14159265358979323;
using namespace std;
ll power (ll base,ll exponent)
{
    ll ans=1;
    //base%=MOD;
    //exponent%=(MOD-1);
    while(exponent!=0)
    {
      if(exponent&1) ans=(1LL*ans*base);
      base=(1LL*base*base);
      exponent>>=1;
    }
    return ans;
}
ll a[200005];
int32_t main()
{   
     IOS;
     
     ll n,m,i,j,k;
     cin>>n;
     for(i=0;i<n-1;i++)
     {
     	cin>>j;
     	a[j]++;
     }
     for(i=1;i<=n;i++) cout<<a[i]<<endl;

     
     cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';             
}

Measured memory_bytes: 5280
N, M = map(int, input().split())

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

    # divisors.sort()
    return divisors

divisors = make_divisors(M)
divisors.sort()

for idx, a in enumerate(divisors):
    # print(a)
    if M / a >= N:
        continue
    else:
        if idx-1 < 0:
            print(1)
            exit()
        else:
            print(divisors[idx-1])
            exit()
        break
       
print(divisors[-1])

Measured memory_bytes: 38640
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <set>
#include <iomanip>
using namespace std;

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

void print_v(vector<int> v){
    for(int i=0; i<v.size(); i++){
        cout << char(v[i]+97);
    }
    cout << endl;
}

int main()
{
    vector<int> nums;
    nums.push_back(3);
    nums.push_back(5);
    nums.push_back(7);
    ll cross=10;
    for(int i=1; i<9; i++){
        vector<int> tmp;
        for(auto v:nums){
            tmp.push_back(v+cross*3);
            tmp.push_back(v+cross*5);
            tmp.push_back(v+cross*7);
        }
        for(auto v:tmp){
            nums.push_back(v);
        }
        cross*=10;
    }
    sort(nums.begin(), nums.end());
    ll N;
    cin >> N;
    int ans=0;
    for(auto v:nums){
        bool flag=1;
        if(v>N) break;
        string s=to_string(v);
        vector<int> cnt(3,0);
        for(int i=0; i<s.size(); i++){
            char c=s[i];
            if(c=='3') cnt[0]++;
            else if(c=='5') cnt[1]++;
            else if(c=='7')cnt[2]++;
            else{
                flag=0;
                continue;
            }
        }
        if(flag==0) continue;
        sort(cnt.begin(), cnt.end());
        if(cnt[0]>0){
            ans++;
        }
    }
    cout << ans << endl;


    return 0;
}


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

int main(){
    int n, A[100];
  cin >> n;
  for ( int i = 0; i < n; i++ ) cin >> A[i];
  
      for ( int i = n-1; i >= 0; i-- ){
       if ( i != n-1) cout << " ";
       cout << A[i];
  }
  cout << endl;
    
    return 0;
}

Measured memory_bytes: 1160
use std::vec::Vec;
use std::cmp::*;

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

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

fn main() {
  let (n, x) = {
    let v: Vec<usize> = read_vec();
    (v[0], v[1])
  };

  let l: Vec<u64> = read_vec();

  let mut count = 1;
  let mut d = 0;
  for i in 0..n {
    d = d + l[i];
    if d <= x as u64 {
      count += 1;
    }
  }

  println!("{}", count);
}


Measured memory_bytes: 4352
import scala.collection.mutable.Stack
import scala.io.StdIn.{readInt, readLine}

object Main extends App {

  class Node {
    var id = -1
    var parent = -1
    var left = -1
    var right = -1
  }

  val n = readInt
  val nodes = Array.fill[Node](n)(new Node)
  for (_ <- 0 to n - 1) {
    val Array(id, left, right) = readLine.split(" ").map(_.toInt)
    nodes(id).id = id
    nodes(id).left = left
    nodes(id).right = right
    if (left != -1) nodes(left).parent = id
    if (right != -1) nodes(right).parent = id
  }

  val root = nodes.filter(_.parent == -1)(0)
  preOrder(nodes, root)
  inOrder(nodes, root)
  postOrder(nodes, root)

  def preOrder(nodes: Array[Node], root: Node) = {
    println("Preorder")
    val stack = new Stack[Int]
    stack.push(root.id)
    while (!stack.isEmpty) {
      val id = stack.pop
      if (id != -1) {
        print(s" ${id}")
        stack.push(nodes(id).right)
        stack.push(nodes(id).left)
      }
    }
    println()
  }

  def inOrder(nodes: Array[Node], root: Node) = {
    println("Inorder")
    val visited = Array.fill[Boolean](nodes.length)(false)
    val stack = new Stack[Int]
    stack.push(root.id)
    while (!stack.isEmpty) {
      var id = nodes(stack.top).left
      while (id != -1 && !visited(id)) {
        stack.push(id)
        id = nodes(id).left
      }
      id = stack.pop
      print(s" ${id}")
      visited(id) = true
      id = nodes(id).right
      if (id != -1 && !visited(id)) {
        stack.push(id)
      }
    }
    println()
  }

  def postOrder(nodes: Array[Node], root: Node) = {
    println("Postorder")
    val visited = Array.fill[Boolean](nodes.length)(false)
    val stack = new Stack[Int]
    stack.push(root.id)
    while (!stack.isEmpty) {
      val id = stack.top
      val right = nodes(id).right
      if (right != -1 && !visited(right)) {
        stack.push(right)
      }
      val left = nodes(id).left
      if (left != -1 && !visited(left)) {
        stack.push(left)
      }
      if (isLeaf(left, right) || childrenVisited(visited, left, right)) {
        print(s" ${id}")
        visited(id) = true
        stack.pop
      }
    }
    println()
  }

  def isLeaf(left: Int, right: Int): Boolean = {
    left == -1 && right == -1
  }

  def childrenVisited(visited: Array[Boolean], left: Int, right: Int): Boolean = {
    val leftVisited = if (left == -1) true else visited(left)
    val rightVisited = if (right == -1) true else visited(right)
    leftVisited && rightVisited
  }
}



Measured memory_bytes: 44112
import sys,bisect
input = sys.stdin.readline
n = int(input())
p = tuple(map(float,input().split()))

dp = [[0.0]*(n+1) for i in range(n+1)]
dp[0][0] = 1.0
for i in range(1,n+1):
    for j in range(i+1):
        dp[i][j] = dp[i-1][j]*(1-p[i-1])
        if j > 0:
            dp[i][j] += dp[i-1][j-1]*p[i-1]

res = 0.0
for i in range((n+1)//2,n+1):
    res += dp[-1][i]
print(res)

Measured memory_bytes: 113372
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

void print_lcs(int y, int x, vector<vector<int>> &lcslen, string &s, string &t) {
	int l = lcslen[y][x];
	if (l== 0)
		return;

	if (lcslen[y - 1][x] == l) {
		print_lcs(y - 1, x, lcslen, s, t);
	}
	else if (lcslen[y][x - 1] == l) {
		print_lcs(y, x - 1, lcslen, s, t);
	}
	else {
		print_lcs(y-1, x-1, lcslen, s, t);
		cout << s[y - 1];
	}
}

int main()
{
	string s, t;
	cin >> s >> t;

	int ns = s.size();
	int nt = t.size();

	vector<vector<int>> dp(ns + 1, vector<int>(nt + 1, 0));
	for (int i = 0; i <= ns; i++) {
		dp[i][0] = 0;
	}
	for (int i = 0; i <= nt; i++) {
		dp[0][i] = 0;
	}

	for (int i = 1; i <= ns; i++) {
		for (int j = 1; j <= nt; j++) {
			dp[i][j] = max(dp[i][j], max(dp[i][j - 1], dp[i - 1][j]));
			if (s[i - 1] == t[j - 1]) {
				dp[i][j] = dp[i - 1][j - 1] + 1;
			}
		}
	}

	
	print_lcs(ns, nt, dp, s, t);
	cout << endl;
	

	return 0;

}

Measured memory_bytes: 35712
import java.util.*;
public class Main {
	public static void main(String[] args) {
	
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		if(a + b >= 10){
			System.out.print("error");
		}else{
System.out.print(a+b);
}

	}
}

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

int main() {
  int N,M;cin>>N>>M;
  vector<int> L(M,0);
  for(int i=0; i<N; i++){
    int K;cin>>K;
    for(int j=0; j<K; j++){
      int a;cin>>a;L.at(a-1)++;
    }
  }
  int c=0;
  for(int i:L){
    if(i==N)c++;
  }
  cout<<c<<endl;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
h=list(map(int,input().split()))
path={}
for i in range(1,n+1):
  path[i]=[]
for i in range(m):
  a,b=map(int,input().split())
  path[a]+=[b]
  path[b]+=[a]
ans=0
for i in range(1,n+1):
  good=True
  for j in path[i]:
    if h[i-1]<=h[j-1]:
      good=False
      break
  if good:
    ans+=1
print(ans)

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

#define ll long long
#define ar array
const int Mnx = 2e5;
int n, m;
ll k, a[Mnx+1], b[Mnx+1];

int main(){
    cin >> n >>  m >> k;
    for(int i=0; i<n; ++i){
        cin >> a[i+1];
        a[i+1] += a[i];
    }
    for(int i=0; i<m; ++i){
        cin >> b[i+1];
        b[i+1] += b[i];
    }
    int ans = 0;
    for(int i=0,j=m; i<=n; ++i){
        if(a[i]>k)
            break;
        while(a[i]+b[j]>k)
            --j;
        ans = max(i+j, ans);
    }
    cout << ans;
}

Measured memory_bytes: 6772
# include <stdio.h>
# include <string.h>

char *rotation(char s[]){
    char tmp_1, tmp_2;
    tmp_2 = s[0];
    for (int i = 0; i < strlen(s)-1; ++i){
        tmp_1 = s[i+1];
        s[i+1] = tmp_2;
        tmp_2 = tmp_1;
    }
    s[0] = tmp_1;

    return s;
}

int main(){
    char S[100], T[100];

    scanf("%s", S);
    scanf("%s", T);

    int flg = 0;
    for (int i = 0; i < strlen(T); ++i){
        *S = *rotation(S);
        int ct = 0;
        for (int i = 0; i < strlen(T); ++i){
            if (S[i] == T[i]) ct++;
        }
        if (ct == strlen(T)){
            flg = 1;
            break;
        }
    }

    if (flg == 1) printf("Yes");
    else printf("No");

    return 0;
}

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

int main()
{
    int N;
    cin >> N;
    int A[N+1], B[N+1], C[N+1];
    for(int i = 0; i < N; ++i) cin >> A[i];
    for(int i = 0; i < N; ++i) cin >> B[i];
    for(int i = 0; i < N-1; ++i) cin >> C[i];

    long long ans = 0;
    for(int i = 0; i < N; ++i) {
        int num = A[i] - 1;
        ans += B[num];
        if(i < N-1 && num + 1 == A[i+1] - 1) {
            ans += C[num];
        }
    }

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

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#pragma warning(disable:4996)

int main()
{

	int Debt = 100000;
	int Weeks = 0;
	scanf("%d", &Weeks);

	for (int nCnt = 0; nCnt < Weeks; nCnt++)
	{
		Debt += Debt * 0.05f;
		if (Debt % 1000 > 0)
			Debt += 1000 - (Debt % 1000);
	}

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

	return 0;
}

Measured memory_bytes: 1020
package main

import (
	"fmt"
)

type line struct {
	s string
}

func main() {
	var n, m int
	// n = 1
	fmt.Scan(&n, &m)

	lines := []line{}
	for i := 0; i < n; i++ {
		l := line{}
		fmt.Scan(&l.s)
		lines = append(lines, l)
	}
	// fmt.Println(lines)

	test := func(lines []line) []string {
		var image []string
		for _, l := range lines {
			image = append(image, l.s)
			image = append(image, l.s)
		}
		return image
	}

	for _, l := range test(lines) {
		fmt.Println(l)
	}
}


Measured memory_bytes: 512
#include<stdio.h>
int main(){
	char str[50];
	int a,b;
	if(scanf("%d %d",&a,&b)==1);
	if(scanf("%s",str)==1);;
	if(str[b-1]>=97&&str[b-1]<=122){
      str[b-1]=str[b-1]-32;
	}
  	else{
	str[b-1]=str[b-1]+32;
	  }
	  printf("%s",str);
printf("\n");
return 0;

}

Measured memory_bytes: 128
import java.util.Scanner;

public  class Main {
    public static void main(String[] args) {
     Scanner sc = new Scanner(System.in);
     int S = sc.nextInt();
     int h = S / 3600;
     int m = S % 3600 / 60;
     int s = S % 3600 % 60;
     System.out.println(h + ":" +  m + ":"  + s );
    }
}



Measured memory_bytes: 26400
t='.'
b=t*101
q=range(101)
for s in[*open(i:=0)][1:]:
 a=[i];i+=1
 for x,y,z,c in zip(b,t+s,s,q):a+=min(c+(t>z<x),a[-1]+(t>z<y)),
 b,q=s,a[1:]
print(a[-2])

Measured memory_bytes: 9132
#include <iostream>
#include <memory>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <array>
#include <sstream>

using namespace std;

vector<string> split(const string &s, char delim);

int main(int argc, const char * argv[]) {
    int N;
    string skss;
    vector<int> sks;
    
    cin >> N;
    
    string tmp;
    for (int i = 0; i < 2 * N; i++) {
        cin >> tmp;
        sks.push_back(atoi(tmp.c_str()));
    }
//    cin >> skss;
//    auto v = split(skss, ' ');
//    for_each(v.begin(), v.end(), [&](string s) {
//        sks.push_back(atoi(s.c_str()));
//    });
    
    sort(sks.begin(), sks.end());
    reverse(sks.begin(), sks.end());
    
    int sum = 0;
    for (int i = 0; i < N; i++) {
        sum += min(sks[i*2], sks[i*2+1]);
    }
    
    cout << sum << endl;
    
    return 0;
}

vector<string> split(const string &s, char delim) {
    vector<string> v;
    stringstream ss(s);
    string x;
    while (getline(ss, x, delim)) {
        if (!x.empty()) {
            v.push_back(x);
        }
    }
    return v;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define rep(i,N) for(int i=0;i<N;i++)
using namespace std;
long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;


int main(){

int N;
cin>>N;
int  T;
cin>>T;
int  weight[N],value[N];
rep(i,N){
cin>>weight[i]>>value[i];
}

//最後の料理は必ずT-1分時点で行うとして最後にどの料理を注文するかを全探索する。

//i番目の料理を最後に注文する場合、それ以外の料理はT-1分時点で完食しないといけない
//i番目以外の料理でT-1分以内に完食できる美味しさの合計の最大値+value[i]
//=満足度の最大


long long dp1[3010][3010];
//DP1[i][j] = 1～i 番目の料理で j 分以内に完食できる美味しさの合計の最大値

for(int k=0;k<=T;k++)dp1[0][k]=0;
//rep(i,N)dp[i][0]=0;
for(int i=0;i<N;i++){
    for(int k=0;k<=T-1;k++){
        if(weight[i]<=k){   
        dp1[i+1][k]=max(dp1[i][k],dp1[i][k-weight[i]]+value[i]);
        }
        else {
        dp1[i+1][k]=dp1[i][k];
        }
    }
}

long long dp2[3010][3010];
for(int k=0;k<=T;k++)dp2[N+1][k]=0;
//DP2[i][j] = i～N 番目の料理で j 分以内に完食できる美味しさの合計の最大値
for(int i=N+1;i>1;i--){
    for(int k=0;k<=T-1;k++){
        if(weight[i-2]<=k){   
        dp2[i-1][k]=max(dp2[i][k],dp2[i][k-weight[i-2]]+value[i-2]);
        }
        else {
        dp2[i-1][k]=dp2[i][k];
        }
    }
}
long long ans=0;
//i番目以外の料理でT-1分以内に完食できる美味しさの合計の最大値
//=dp1[i-1][j]+dp2[i+1][T-1-j]
for(int i=1;i<=N;i++){
    rep(j,T)ans=max(ans,dp1[i-1][j]+dp2[i+1][T-1-j]+value[i-1]);
}


cout<<ans<<endl;

return 0;
}
/*
2 60
10 10
100 100

110

3 60
10 10
10 20
10 30

60

3 60
30 10
30 20
30 30

50

10 100
15 23
20 18
13 17
24 12
18 29
19 27
23 21
18 20
27 15
22 25

145
*/


Measured memory_bytes: 141824
#include <iostream>
#include <vector>
using namespace std;
int main()
{
  int N, Q;
  cin >> N >> Q;
  string S;
  cin >> S;
  vector<int> l(Q), r(Q);
  for (int i = 0; i < Q; i++)
  {
    cin >> l[i] >> r[i];
    l[i]--;
    r[i]--;
  }
  vector<int> sum(N);
  sum[0] = 0;
  for (int i = 1; i < N; i++)
  {
    sum[i] = sum[i - 1];
    if (S[i - 1] == 'A' && S[i] == 'C')
      sum[i]++;
  }
  for (int i = 0; i < Q; i++)
    cout << sum[r[i]] - sum[l[i]] << endl;
  return 0;
}

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

using namespace std;

int main()
{
long double L,l,r,ans;
  cin >> L;
  l = L/3.0;
  r = L - l*2.0;
  ans = l*l*r;

  cout << fixed << setprecision(7) << ans;
  return 0;

}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int s;
	double w, h;
	char dummy;
	
	while ( cin >> s >> dummy >> w >> dummy >> h ) {
		double bmi = w / (h*h);
		if (bmi >= 25.0) cout << s << endl;
	}
	
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<string> ss(n);
  vector<int> ps(n);
  for (int i = 0; i < n; i++) {
    cin >> ss[i] >> ps[i];
  }
  
  vector<pair<string, int>> qs(n);
  for (int i = 0; i < n; i++) {
    qs[i] = {ss[i], ps[i]};
  }
  
  sort(qs.begin(), qs.end(), [](auto &p, auto &q) {
    return (p.first == q.first) ? (p.second > q.second) : (p.first < q.first);
  });
  
  for (auto &q : qs) {
    int i = 0;
    for (int j = 0; j < n; j++) {
      if (q.first == ss[j] && q.second == ps[j]) {
        i = j;
      }
    }
    cout << i + 1 << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
//
//  main.cpp
//  APG4b
//
//  Created by 安藤光希 on 2020/03/21.
//  Copyright © 2020 安藤光希. All rights reserved.
//


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

int main() {
    
    int N;
    cin >> N;
    
    vector<int> mochi(N);
    for (int i=0; i<N; i++){
        cin >> mochi.at(i);
    }
    
    sort(mochi.begin(), mochi.end());
    mochi.erase(std::unique(mochi.begin(), mochi.end()), mochi.end());
    
    cout << mochi.size() << endl;
    
}
/*
7
50
100
80
30
 */


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

namespace edamat {
using u64 = uint_fast64_t;

constexpr u64 M = (1UL << 61) - 1;
constexpr u64 POSITIVISER = M * 3;
constexpr u64 MASK30 = (1UL << 30) - 1;
constexpr u64 MASK31 = (1UL << 31) - 1;

class rolling_hash {
    static u64 get_base() {
        u64 z = (static_cast<uint64_t>((::std::chrono::system_clock::now()
                                            .time_since_epoch()
                                            .count()) &
                                       ((1LL << 32) - 1))) +
                0x9e3779b97f4a7c15;
        z = (z ^ (z >> 30)) * 0xbf58476d1ce4e5b9;
        z = (z ^ (z >> 27)) * 0x94d049bb133111eb;
        return z;
    }

    static u64& B() {
        static u64 B_ = (get_base()) % (M - 2) + 2;
        return B_;
    }
    static ::std::vector<u64>& p() {
        static ::std::vector<u64> p_{1, B()};
        return p_;
    }

    static inline u64 mul(u64 x, u64 y) {
        u64 a = x >> 31, b = x & MASK31, c = y >> 31, d = y & MASK31,
            e = b * c + a * d;
        return (a * c << 1) + b * d + ((e & MASK30) << 31) + (e >> 30);
    }

    static inline u64 calc_mod(u64 val) {
        val = (val & M) + (val >> 61);
        if(val > M) val -= M;
        return val;
    }

   public:
    ::std::vector<u64> hash;
    ::std::string str;
    explicit rolling_hash(const ::std::string& s) : str(s) {
        if(p().size() <= s.size()) {
            int l = p().size();
            p().resize(s.size() + 1);
            for(int i = l; i < p().size(); ++i) {
                p()[i] = calc_mod(mul(p()[i - 1], p()[1]));
            }
        }
        hash.resize(s.size() + 1, 0);
        for(int i = 0; i < s.size(); ++i) {
            hash[i + 1] = calc_mod(mul(hash[i], B()) + s[i]);
        }
    };

    u64 get(int l, int r) {
        return calc_mod(hash[r] + POSITIVISER - mul(hash[l], p()[r - l]));
    }

    // 最長共通接頭辞
    int get_lcp(int x, int y) {
        int len = ::std::min((int)size() - x, (int)size() - y) + 1;
        int l = 0, r = len;
        while(r - l > 1) {
            int m = (l + r) >> 1;
            if(get(x, x + m) != get(y, y + m))
                r = m;
            else
                l = m;
        }
        return l;
    }
    size_t size() {  // strのsizeを返す
        return str.size();
    }
};
}  // namespace edamat

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

    char s[N];
    scanf("%s", s);
    std::string S{s};
    edamat::rolling_hash rh(S);

    int ans = 0;
    for(int i = 0; i < N - ans; i++) {
        for(int j = 0; j < i - ans; j++) {
            if(S[i] != S[j]) continue;
            ans = std::max<int>(ans, std::min<int>(rh.get_lcp(i, j), i - j));
        }
    }
    printf("%d\n", ans);
};

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

using namespace std;

void solve(int N, vector<int> d) {
  sort(d.begin(), d.end());
  auto result = unique(d.begin(), d.end());
  d.erase(result, d.end());
  cout << d.size() << endl;
}

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

  int N;
  cin >> N;
  vector<int> d(N);
  for(int i = 0 ; i < N ; i++){
    cin >> d[i];
  }
  solve(N, move(d));
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
    final Scanner sc = new Scanner(System.in);
    final long DEVISOR = 1000000000+7;
    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        long n = sc.nextLong();
        long k = sc.nextLong();

        long ans = 0;
        for (long i = k; i <= n+1; i++) {
            long max = i*(2*n-i+1)/2 ;
            long min = i*(i-1)/2;
            ans += (max - min + 1) % DEVISOR;
        }
        System.out.println(ans% DEVISOR);
    }
}


Measured memory_bytes: 35808
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	while(1)
	{
		c-=b;
		if(c<=0) break;
		a-=d;
		if(a<=0) break;
	}
	if(a<=0) cout<<"No";
	if(c<=0) cout<<"Yes";
}

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

int main() {
	int n;
  	cin>>n;
  
  vector<string> s(n);
  vector<long double> x(n);
  
  rep(i,n){
  	cin>>x[i]>>s[i];
  }
  
  long double ans=0;
  
  rep(j,n){
  	if(s[j]=="JPY"){
     	ans+=x[j]; 
    }
    
    else{
    	ans+=x[j]*380000;
    }
   }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 3796
import math

x = int(input())
if x <= 3:
    print(x)
#elif x%2 == 0:
#    x += 1
else:
    if x%2 == 0:
        x += 1
    cnt = 0
    max_search = math.ceil(math.sqrt(x))
    while cnt < max_search-2:
        cnt = 0
        max_search = math.ceil(math.sqrt(x))
        for i in range(2, max_search):
            if x % i == 0:
                break
            else:
                cnt += 1
        x += 2
    print(x-2)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define rep(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
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>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//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; }

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;}

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

  vi cnt(26,INF);
  for (char c = 'a'; c <= 'z'; c++) {
    rep(i,n) {
      cnt[c-'a'] = min(cnt[c-'a'],(int)count(ALL(s[i]),c));
    }
  }

  string ans;
  for (char c = 'a'; c <= 'z'; c++) {
    if (cnt[c-'a']!=INF) {
      rep(i,cnt[c-'a']) {
        ans.push_back(c);
      }
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

type Item struct {
	Value  int
	Weight int
}

func main() {
	var ItemNumber int
	var MaxWeight int
	const maxW = 100000

	sack := []Item{}

	fmt.Scanln(&ItemNumber, &MaxWeight)

	dp := make([]int, maxW+1)
	fill(dp, math.MaxInt64)
	dp[0] = 0

	for i := 0; i < ItemNumber; i++ {
		X := Item{}
		fmt.Scanln(&X.Weight, &X.Value)
		sack = append(sack, X)
	}
	value := Knapsack(sack, dp,ItemNumber,MaxWeight)
	fmt.Print(value)
}

func Knapsack(sacks []Item,dp []int, N int, W int) int{
	const maxW = 100000
	for i := 0; i < N; i++ {
		w := sacks[i].Weight
		v := sacks[i].Value
		for j := maxW - v; j >= 0; j-- {
			if dp[j] == math.MaxInt64  {
				continue
			}

			if dp[j]+w <= W {
				dp[j+v] = min(dp[j+v], dp[j]+w)
			}
		}
	}
	i := maxW
	for dp[i] == math.MaxInt64 {
		i--
	}
	return i
}


func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func fill(a []int, x int) {
	for i := 0; i < len(a); i++ {
		a[i] = x
	}
}


Measured memory_bytes: 2712
#include <iostream>
#include <string>
#include <list>

int main (){
    int a,b,c;
    std::cin >> a >> b >> c;
    if (a+b+c>21) { std::cout << "bust" << std::endl; }
    else { std::cout << "win" << std::endl; }
    
  
  return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    string str;
    cin >> str;
    int q;
    cin >> q;
    while (q--)
    {
        string op;
        cin >> op;
        if (op == "print")
        {
            int a, b;
            cin >> a >> b;
            cout << str.substr(a, b - a + 1) << endl;
        }
        else if (op == "reverse")
        {
            int a, b;
            cin >> a >> b;
            reverse(str.begin() + a, str.begin() + b + 1);
        }
        else
        {
            int a, b;
            cin >> a >> b;
            string p;
            cin >> p;
            for (int i = a; i <= b; i++)
            {
                str[i] = p[i - a];
            }
        }
    }
}



Measured memory_bytes: 3216
using System;

namespace _4_C
{
    class Program
    {
        static void Main(string[] args)
        {
            bool[] x = new bool[244140700];
            int n = int.Parse(Console.ReadLine());
            for (int i = 0; i < n; i++)
            {
                string[] s = Console.ReadLine().Split();
                int now = 0;
                int a = 1;
                for (int j = 0; j < s[1].Length; j++)
                {
                    switch (s[1][j])
                    {
                        case ('A'):
                            {
                                now += a;
                                break;
                            }
                        case ('C'):
                            {
                                now += a * 2;
                                break;
                            }
                        case ('G'):
                            {
                                now += a * 3;
                                break;
                            }
                        case ('T'):
                            {
                                now += a * 4;
                                break;
                            }
                    }
                    a *= 5;
                }
                if (s[0] == "insert")
                {
                    x[now] = true;
                }
                else
                {
                    Console.WriteLine(x[now] ? "yes" : "no");
                }
            }
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 374280
#include<iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    int sum=1;
    int i=0;
    while (sum<b)
    {
        sum--;
        sum+=a;
        i++;
    }
    cout<<i<<endl;

    return 0;
}


Measured memory_bytes: 888
#include <stdio.h>

int main(void)
{
	int n, noa;
	int i;
	
	while (scanf("%d", &n) != EOF) {
		noa = 2;
		if (n == 0)
			noa = 0;
		for (i = 1; i < n; i++)
			noa += i + 1;
		printf("%d\n", noa);
	}

	return 0;
}

Measured memory_bytes: 592
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;

#define ll long long
#define pal pair<ll,ll>
#define pad pair<double,double>
#define PB push_back
#define MP make_pair
#define F first
#define S second

const ll MOD = 1e9+7;
const ll INF = 1e18;
const double EPS = 1e-8;

long long pow(long long x, long long n) {
    long long ret = 1;
    while (n > 0) {
        if (n & 1) ret = ret * x % MOD;
        x = x * x % MOD;
        n >>= 1;
    }
    return ret;
}

template<typename T,typename U>
bool chmax(T& max, const U& x){
	if(max<x){
		max = x;
		return true;
	}
	return false;
}

template<typename T,typename U>
bool chmin(T& min, const U& x){
	if(min>x){
		min = x;
		return true;
	}
	return false;
}


int main(){
	ll x,y;
	cin >> x >> y;
	for(ll i=0;i<=100;i++){
		for(ll j=0;j<=100;j++){
			if(i+j==x && 2*i+4*j==y){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define mod (int)1000000007
// Big two primes
#define MAX 100002
#define X 1011001110001111ll
#define M 26388279066623ll
#define all(a) a.begin(),a.end()
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
#define ll long long
#define pb emplace_back
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define in(x) scanf("%d", &x)
#define rr return 0
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define inf (int)(1e18)
#define ini(a, i) memset(a, i, sizeof(a))
#define vi vector<int>
#define fi first
#define se second
#define endl "\n"
#define pi pair<int, int>
#define vii vector<pi>
const int MAXN = (int)((1e5) + 10);
int gcd(int a,int b) { if (a == 0) return b; return gcd(b%a, a);}
int max(int a,int b){if(a>b) return a; else return b;}
//int min(int a,int b){if(a<b) return a; else return b;}
bool isPrime(int N){ for(int i=2;i*i<=N;++i){if(N%i==0) return false;}return true;}
//int cbrt(int x){ int lo=1,hi=min(2000000ll,x)while(hi-lo>1){int mid=(lo+hi)/2;if(mid*mid*mid<x){lo=mid;}else hi=mid;}if(hi*hi*hi<=x) return hi;else return lo;}

int main()
{

    fio;

    int k;
    string s;
    cin>>k;
    cin>>s;

    if(s.size() <= k)
        cout<<s<<endl;

    else
    {
        string str = s.substr(0, k);
        str += "...";
        cout<<str<<endl;
    }
    rr;
}


Measured memory_bytes: 3660
N = int(input())
D = [list(map(int,input().split())) for i in range(N)]

first,second = False,False
for i in range(N):
    if D[i][0]==D[i][1] and first and second:
        print("Yes")
        exit(0)
    elif D[i][0]==D[i][1] and first:
        second = True
    elif D[i][0]==D[i][1] and first!=True:
        first = True
    else:
        first,second = False,False

print("No")

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

using namespace std;

int main(){

  int A, B, C, D;

  cin >> A >> B >> C >> D;


  while(A > 0 and C > 0){
    C -= B;
    if(C <= 0)break;
    A -= D;
  }

  if( A <= 0)cout << "No" << endl;
  else cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define ii pair<int,int>
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define INF 100000000000000000
#define int long long int
#define modulo 1000000007
using namespace std;

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    string s;
    cin>>s;
    char pre='1';
    int ans=0;
    for(int i=0;i<n;i++){
        if(pre==s[i])continue;
        pre=s[i];
        ans++;
    }
    cout<<ans;
}


Measured memory_bytes: 512
from collections import Counter
N,M = map(int,input().split())
primes = []
d = 2
while d**2<=M:
    if M % d == 0:
        M //= d
        primes.append(d)
    else:
        d += 1

if M != 1:
    primes.append(M)

cnt = Counter(primes)

def choose(n,k):
    import math
    return math.factorial(n)//(math.factorial(n-k)*math.factorial(k))
ans = 1
for v in cnt.values():
    ans *= choose(v+(N-1),v)
mod = 10**9 +7
ans %= mod
print(ans)


Measured memory_bytes: 114524
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
using namespace std;
 
int w[10000]={0},s[10000]={0};
 
int main ()
{
	int a,b,c,d,e,f,i,j,k=0,mxw=0,mxs=0;
	cin>>a>>b>>c>>d>>e>>f;
	for(i=0;i<=f/100;i++)
		for(j=0;j<=f/100;j++)
		{
			w[i*a+j*b]=1;
		}	
//	cout<<mxw<<endl;
	for(i=0;i<=3000;i++)
		for(j=0;j<=3000;j++)
		{
			if(i*c+j*d>3000)
				continue;
			s[i*c+j*d]=1;
		}
	int tw,ts;
	double mx=0;
	for(i=1;i<=f/100;i++)
		for(j=0;j<=3000;j++)
		{
			if(w[i]!=1||s[j]!=1)
				continue;
			if(j+i*100>f)
				continue;
			if(e*i<j)
				continue;
			if(j*1.0/(i*1.0)>=mx)
			{
		//		cout<<i<<j<<endl;
				tw=i;
				ts=j;
				mx=j*1.0/(i*1.0);
			}
			
		}
	if(tw==0)
		tw=a;
	printf("%d %d\n",tw*100+ts,ts);
	return 0;
} 

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

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

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

    return arr

n = int(input())
if n == 1:
    print(0)
    
else:
    a = factorization(n)
    result = 0
    
    for i in range(len(a)):
        j = 1
        while(1):
            a[i][1] -= j
            if a[i][1] < 0:
                break
            result += 1
            j += 1
            
    print(result)

Measured memory_bytes: 9500
#include<stdio.h>
#include<stdlib.h>
int asc(const void *a, const void *b) {
  return *(int *)a - *(int *)b;
}
int main(void){
    int n,i,k=0;
    scanf("%d",&n);
    long int a[n];
    for(i=0;i<n;i++){
        scanf("%ld",&a[i]);
    }
    qsort(a,n,sizeof(long int),asc);
    for(i=0;i<n-1;i++){
        if(a[i]==a[i+1]){
            k = 1;
            break;
        }
    }
    if(k==0){
    puts("YES");}
    else{
        puts("NO");
    }
    return 0;
}

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

long long n, a[101001], ans =0;

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

cin >> n;

for(int i =1; i<=n; i++){
    cin >> a[i];
}

for(int i =1; i<=n; i++){
    ans+=a[i]/2;
    a[i]-= (a[i]/2)*2;
    if(a[i+1]&& a[i]){
        ans++;
        a[i+1]--;
    }

}


cout << ans << endl;

return 0;}


Measured memory_bytes: 1024
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		BinaryTree tree = new BinaryTree();
		Scanner sc = new Scanner(System.in);
		int count = sc.nextInt();
		for(int i=0;i<count;i++) {
			String order = sc.next();
			if(order.equals("insert")) {
				tree.insert(new BinaryTree().new Node(sc.nextLong()));
			}
			if(order.equals("print")) {
				tree.inOrder(tree.root);
				System.out.println();
				tree.preOrder(tree.root);
				System.out.println();
			}
		}
	}
}

class BinaryTree {
	
	Node root;
	
	class Node{
		Node left;
		Node right;
		long value;
		public Node(long value) {
			super();
			this.value = value;
		}
		
		
		
	}
	
	/*
	 * public void insert(Node node, long value) { if(root == null) { root = new
	 * Node(value); return; } if(node.value>value) { if(node.left == null) {
	 * node.left = new Node(value); }else { insert(node.left,value); } }else {
	 * if(node.right == null) { node.right = new Node(value); }else {
	 * insert(node.right,value); } } }
	 */
	
//	public void insert(long value) {
//		Node node;
//		Node parent = null;
//		if(root == null) {
//			root = new Node(value);
//			return;
//		}
//		node = root;
//		while(node !=null) {
//			parent = node;
//			if(node.value>value) {
//				node = node.left;
//			}else {
//				node = node.right;
//			}
//		}
//		
//		node = new Node(value);
//		if(parent.value>node.value) {
//			parent.left = node;
//		}else {
//			parent.right = node;
//		}
//		
//	}
	//t root  x=node y=parent
	public void insert(Node n) {
		Node node = root;
		Node parent = null;
		
		while(node !=null) {
			parent = node;
			if(node.value>n.value) {
				node = node.left;
			}else {
				node = node.right;
			}
		}
		if(parent==null) {
			root = n;
		}else if(parent.value>n.value) {
			parent.left = n;
		}else {
			parent.right = n;
		}
		
	}
	
	public void preOrder(Node n) {
		if(n == null) {
			return;
		}
		System.out.print(" "+n.value);
		preOrder(n.left);
		preOrder(n.right);
	}
	
	public void inOrder(Node n) {
		if(n == null) {
			return;
		}
		inOrder(n.left);
		System.out.print(" "+n.value);
		inOrder(n.right);
	}
	

}



Measured memory_bytes: 308640
#include <iostream>
#include <vector>
using namespace std;
int main()
{
    string B;
    cin >>B;
  if(B=="A")
  {
    cout << "T" << endl;
  }
     if(B=="G")
  {
    cout << "C" << endl;
  }
     if(B=="C")
  {
    cout << "G" << endl;
  }
     if(B=="T")
  {
    cout << "A" << endl;
  }
   
}


Measured memory_bytes: 256
import sys
N,M = map(int,input().split())
if M == 0:
    print('%d %d' % (0,0))
    sys.exit(0)
Liste = dict()
Question = [0] * M
ACorWE = [0] * M
correct = 0
penalty = 0
for i in range(M):
    Question[i], ACorWE[i]= map(str, input().split())
Question = [int(element) for element in Question]
for _ in Question:
    Liste[_] = [0] 
for i in range(M):
    Liste[Question[i]].append(ACorWE[i])
for liste in Liste:
    while 0 in Liste[liste]:
        Liste[liste].remove(0)
AC = []
for key in Liste:
    if 'AC' in Liste[key]:
        correct += 1
        AC.append(key)
j = 0
for key in AC:
    while Liste[key][j] != 'AC' and j<len(Liste[key]):
        penalty += 1
        j += 1 
    j = 0         
print('%d %d' % (correct,penalty))

Measured memory_bytes: 36860