akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

//#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

//?????????s???????????????f?????¨???t??????????????? 
string replaceAll(string s, string f, string t) {
	string::size_type pos = s.find(f);
	while (pos != string::npos) {
		s.replace(pos, f.size(), t);
		pos = s.find(f, pos + t.size());
	}
	return s;
}

signed main() {
	int n; cin >> n; cin.ignore();
	rep(i, 0, n) {
		string s; getline(cin, s);
		cout << replaceAll(s, "Hoshino", "Hoshina") << endl;
	}
	return 0;
}

Measured memory_bytes: 3132
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <queue>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>

inline long long int power10(long long int i){
  long long int ans = 1;
  for(long long int j = 0; j < i; j++){
    ans *= 10;
  }

  return ans;
}

long long int table[10][10];

int main(){

  long long int N, highest, lowest, digits;

  scanf("%lld", &N);

  for(long long int i = 0; i < 10; i++){
    for(long long int j = 0; j < 10; j++){
      table[i][j] = 0;
    }
  }

  for(long long int i = 1; i <= N; i++){
    //std::cerr << i << std::endl;
    // calculate digits
    digits = 0;
    for(long long int j = 0; j <= 8; j++){
      if(i < power10(j)){
        digits = j;
        break;
      }
    }
    //std::cerr << "digits" << digits << std::endl;

    // calculate lowest
    lowest = i % 10;

    // calculate highest
    if(digits == 1){
      highest = i;
    }
    else{
      highest = i / power10(digits-1);
    }

    //std::cerr << i << " " << digits <<  " " << highest << " " << lowest << std::endl;

    table[lowest][highest]++;
  }

  // calculate answer
  long long int ans = 0;
  for(long long int Al = 1; Al < 10; Al++){
    for(long long int Ah = 1; Ah < 10; Ah++){
      ans += table[Al][Ah] * table[Ah][Al];
    }
  }

  std::cerr << "Answer: " << std::endl;
  std::cout << ans << std::endl;
  
  return 0;
}


Measured memory_bytes: 256
from collections import Counter
n = int(input())
a = [int(x) for x in input().split()]

A = Counter(a)
a_sorted = sorted(A.keys(), reverse=True)

ans = 0
tmp = 0
for i in a_sorted:
    if A[i] >= 4 and tmp == 0:
        ans = i**2
        break
    elif A[i] >= 2 and tmp == 0:
        tmp = i
    elif A[i] >= 2 and tmp != 0:
        ans = tmp * i
        break
print(ans)



Measured memory_bytes: 18600
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List

main :: IO ()
main = do
  [n,m] <- getl $ split toInt
  unless (n == 0 && m == 0) $ do
    print $ solve n m
    main
    
solve :: Int -> Int -> Int
solve n m = potato m (-1) n [1..n]

potato :: Int -> Int -> Int -> [Int] -> Int
potato m ix n xs
  | n == 1 = head xs
  | otherwise = potato m (dix - 1) (n - 1) ys
  where
    ys = delete (xs !! dix) xs
    dix = (ix + m) `mod` n
    
toInt :: String -> Int
toInt s = read s

split :: (String -> a) -> String -> [a]
split f = map f . words

getl :: (String -> a) -> IO a
getl f = f <$> getLine

Measured memory_bytes: 5504
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
ll kake(ll x){
  return x * x * x * x * x;
}
signed main(){
  init_io();
  ll x;
  set<ll> st;
  cin >> x;
  map<ll,ll> mp;
  for(ll i=1;kake(i)<=1e18;i++){
    st.insert(kake(i));
    mp[kake(i)] = i;
  }
  for(ll i=-1;abs(kake(i))<=1e18;i--){
    st.insert(kake(i));
    mp[kake(i)] = i;
  }
  st.insert(0ll);
  for(auto b:st){
    auto itr = st.find(x+b);
    if(itr!=st.end()){
      cout << mp[*itr] <<" "<<mp[b]<<endl;
      return 0;
    }
  }
}


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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);


struct x{
  int c;
  int s;
  int f;
};

int main(){
  int n;
  int c, s, f;
  scanf("%d", &n);

  vector<x> v(n - 1);
  REP (i, n - 1) {
    scanf("%d %d %d", &c, &s, &f);
    v[i] = {c, s, f};
  }

  REP (i, n) {
    int now = 0;
    FOR (j, i, n - 1) {
      if (now < v[j].s) {
        now = v[j].s;
      } else {
        if ((now - v[j].s) % v[j].f > 0)
          now += v[j].f - (now - v[j].s) % v[j].f;
      }
      now += v[j].c;
    }
    cout << now << endl;
  }
}


Measured memory_bytes: 256
import java.util.*;
public class Main {

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);

        String S = scan.next();
        String sss;
        int dif;
        int min = 1000000;

        for(int i = 0; i<  S.length()-2;i++){

            sss = S.substring(i, i+3);
            dif = 753 - Integer.parseInt(sss);
            if(dif < 0) dif = -dif;
            if(dif < min) min = dif;
        }

        System.out.println(min);

    }
}

Measured memory_bytes: 23636
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();
        if(k==1){
            System.out.println(0);
        }else{
            System.out.println(n-k);
        }
        
    }
}

Measured memory_bytes: 22996
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
int kaijo(int n){
	int ans = 1;
	if (n != 0){
		for (int i = 0; i < n; i++){
			ans *= (n - i);
		}
	}
	else{
		ans = 1;
	}
	return ans;
}

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

Measured memory_bytes: 3244
#include <iostream>
#define mod 1000000007
using namespace std;
int n,k,a[101];
long long int dp[101][100001],prefix[101][100001];
int main() {
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i+=1){
	    scanf("%d",&a[i]);
	}
	for(int i=0;i<=n;i+=1){
	    prefix[i][0]=1;
	    dp[i][0]=1;
	}
	for(int j=0;j<=k;j+=1){
	    prefix[0][j]=1;
	}
	for(int i=1;i<=n;i+=1){
	    for(int j=1;j<=k;j+=1){
	        if(j-a[i]<1){
	            dp[i][j]=(prefix[i-1][j])%mod;
	        }
	        else{
	            dp[i][j]=(prefix[i-1][j]-prefix[i-1][j-a[i]-1]+mod)%mod;
	        }
	        prefix[i][j]=(prefix[i][j-1]+dp[i][j])%mod;
	    }
	}
	printf("%lld",dp[n][k]);
	return 0;
}


Measured memory_bytes: 158080
N,A,B=map(int,input().split())
point=0
suma=0
for num in range(N+1):
  great_num=num
  S=0
  while(True):
    if num==0:
      break
    else:
      S=S+num%10
      num=num//10
  if A<=S and S <= B:
    suma=suma+great_num
print(suma)    

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;


public class Main {
	
	static int a, b, x;
	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
	    BufferedReader in = new BufferedReader(reader);
		
		String s = in.readLine();
		String[] as = s.split(" ");
		a = Integer.parseInt(as[0]);
		b = Integer.parseInt(as[1]);
		x = Integer.parseInt(as[2]);

//		output(a);
		solve();
	}

	private static void solve() {
		String ans = "NO";
		if (a+b>=x && a <= x) ans = "YES";
		
		System.out.println(ans);
		
	}
//
//	private static void insertionSort(int[] a, int n) {
//		// TODO Auto-generated method stub
//		for(int i = 1; i < n; i++) {
//			int v = a[i];
//			int j = i - 1;
//			while(j >= 0 && a[j] > v) {
//				a[j+1] = a[j];
//				j--;
//			}
//			a[j+1] = v;
//			output(a);
//		}
//	}

	private static void output(int[] a) {
		// TODO Auto-generated method stub
		for(int i = 0; i < a.length-1; i++) {
			System.out.print(a[i] + " ");
			
		}
		
		System.out.println(a[a.length-1]);
	}
	
	
}

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

#pragma GCC optimize("O3,Ofast,no-stack-protector,unroll-loops,fast-math,-ffp-contract=off")

const long long maxn = 2e6 + 10;
const long long mod = 1e9 + 7;

long long r1, r2, c1, c2;
long long ans;
long long fact[maxn];

void in();
void solve();
void out();
void pp();
long long kolle(long long r, long long c);
long long choose(long long a, long long b);
long long pwr(long long a, long long b);

int main(){
    in();
    solve();
    out();
}

void in(){
    ios::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    cin >> r1 >> c1 >> r2 >> c2;
}

void solve(){
    pp();
    ans = kolle(r2, c2) - kolle(r1 - 1, c2) - kolle(r2, c1 - 1) + kolle(r1 - 1, c1 - 1);
    ans = (ans + 2 * mod) % mod;
}

void pp(){
    fact[0] = 1;
    for(long long i = 1 ; i < maxn; i++)
        fact[i] = (i * fact[i - 1]) % mod;
}

long long choose(long long b, long long a){
    return (((fact[a] * pwr(fact[b], -1)) % mod) * pwr(fact[a - b], -1)) % mod;
}

long long pwr(long long a, long long b){
    if(b < 0)
        return pwr(a, mod - 1 + b);
    if(b == 0)
        return 1;
    long long c = pwr(a, b / 2);
    if(b % 2)
        return (((c * c) % mod) * a) % mod;
    return (c * c) % mod;
}

long long kolle(long long r, long long c){
    long long ans = 0;
    for(long long i = 0; i <= r; i++){
        ans += choose(i + 1, c + i + 1);
        ans %= mod;
    }
    return ans;
}

void out(){
    cout << ans;
}



Measured memory_bytes: 15872
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <algorithm>
#include <set>
#include <cmath>
#include <iomanip>
#define REP(i, n) for(int i=0; i<n; i++)
#define REPR(i, n) for(int i=n; i>=0; i--)
#define FOR(i, m, n) for(int i=m; i<n; i++)
#define FORR(i, m, n) for(int i=m; i>=n; i--)
#define INF 999999999
#define ll long long
#define VSORT(v) sort(v.begin(), v.end())
#define pb(a) push_back(a)
using namespace std;

#ifdef INPUT
#include <sstream>
stringstream input(R"(
2 10
20 20
)");
#define cin input
#endif

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

	vector<int> a(n);
	REP(i,n)
		cin >> a[i];
	sort(a.begin(), a.end());

	int count = 0;
	REP(i,n-1)
	{
		x -= a[i];
		if(x<0)
			break;
		count++;
	}

	if (x==a[n-1])
		count++;
	cout << count << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String c1 = scanner.nextLine();
        String c2 = scanner.nextLine();
        for (int i = 0; i < 3; i++) {
            if (c1.charAt(i) != c2.charAt(2 - i)) {
                System.out.println("NO");
                return;
            }
        }
        System.out.println("YES");
    }
}


Measured memory_bytes: 22740
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        n: usize,
        p: [usize; n],
    }
    let mut c = 0;
    for i in 0..n {
        if p[i] != i + 1 {
            c += 1;
        }
    }
    println!("{}", if c <= 2 { "YES" } else { "NO" });
}


Measured memory_bytes: 2120
#include<stdio.h>
int main() {
	int hideo = 0, ruio = 0, masatoy = 0, nagase = 0, a[101] = { 0 }, p[101] = { 0 };
	int temp = 0, max[101] = { 0 },sum=1,text=0;
	scanf("%d", &hideo);
	for (int i = 1; i <= hideo*(hideo - 1) / 2; i++) {
		scanf("%d %d %d %d", &a[1], &a[2], &a[3], &a[4]);
		if (a[3] > a[4]) {
			p[a[1]] += 3;
		}
		else if (a[4] > a[3]) {
			p[a[2]] += 3;
		}
		else {
			p[a[1]]++;
			p[a[2]]++;
		}
	}
	for (int i = 1; i <= hideo; i++) {
		for (int i = 1; i <= hideo; i++) {
			if (temp < p[i]) {
				temp = p[i];
			}
		}
		for (int i = 1; i <= hideo; i++) {
			if (temp == p[i]) {
				max[i] = sum;
				text++;
				p[i] = -1;
			}
		}
		sum += text;
		temp = 0;
		text = 0;
	}
	for (int i = 1; i <= hideo; i++) {
		printf("%d\n", max[i]);
	}
}

Measured memory_bytes: 2748
#include <bits/stdc++.h>
using namespace std;
#define show(x) cout << #x << " : " << x << endl

int main ()
{
    int n, i, in;
    cin >> n;
    int a[n+1];
    for(i = 1; i <= n; i++)
    {
        cin >> in;
        a[in] = i;
    }
    for(i = 1; i <= n; i++) cout << a[i] << ' ';
    cout << endl;
}


Measured memory_bytes: 1152
#include<stdio.h>
#include<stdlib.h>

int binarySearch(int *,int);

int n,q;

int main(){
  int s[100000],t[50000],i,j,count;

  scanf("%d",&n);
  if(n < 1 || 100000 < n)exit(0);
  
  for(i = 0; i < n; i++){
    scanf("%d",&s[i]);
    if(s[i] < 0 || 1000000000 < s[i])exit(0);
  }
  
  scanf("%d",&q);
  if(q < 1 || 50000 < q)exit(0);
  
  for(i = 0; i < q; i++){
    scanf("%d",&t[i]);
    if(t[i] < 0 || 1000000000 < t[i])exit(0);
    for(j = 0;j < i; j++){
      if(t[i] == t[j])exit(0);
    }
  }

  count = 0;
  for(i = 0; i < q; i++){
    count += binarySearch(&s[0],t[i]);
  }
  printf("%d\n",count);
  
  return 0;
}

int binarySearch(int *s,int key){
  int left,right,middle;

  left = 0;
  right = n;
  
  while(left < right){
    middle = (left + right)/2;
    if(s[middle] == key){
      return 1;
    }
    else if(s[middle] < key){
      left = middle + 1;
    }
    else if(s[middle] > key){
      right = middle;
    }
  }
  
  return 0;
}



Measured memory_bytes: 2280
#include <iostream>
#include <cmath>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <cstring>

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define pii pair < int, int >
#define pll pair < long long, long long>
#define ull unsigned long long
#define vi vector <int>
#define sz(a) (int)a.size()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x))
#define fname "searching"

const int inf = (int)1e9;
const ll INF = (ll)1e18;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int mod = (int)1e9 + 7;

int n;
ll a[110];

ll lcm(ll x, ll y){
	// cout << x << " " << y << " " << __gcd(x, y) << "\n";
	// cout << x / __gcd(x, y) * y << "\n";
	return x / __gcd(x, y) * y;
}

int main(){
	// freopen("input.txt", "r", stdin);
	// freopen(fname".in", "r", stdin);
	// freopen(fname".out", "w", stdout);
	scanf("%d", &n);
	for(int i = 0; i < n; ++i){
		cin >> a[i];
		// cout << a[i];
	}
	ll l = a[0];
	for(int i = 0; i < n; ++i){
		// cout << l << " " << a[i] << " ";
		l = lcm(l, a[i]);
		// cout << l << "\n";
	}
	// cout << lcm(10, 1000000000000000000) << "\n";
	cout << l;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int p[5];
  int k, ans;
  int max=0;
  int min=0;
  for(int i=0;i<5;i++){
    cin >> p[i];
    if(max < p[i]){
      max = p[i];
    }
    if(min > p[i] || i==0){
      min = p[i];
    }
  }
  cin >> k;
  //cout << "max:" << max << " min" << min << endl;
  ans = max -min;
  //cout << "ans:" << ans << endl;
  if(ans > k){
    cout << ":(" << endl;
  }else{
    cout << "Yay!" << endl;
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 5LL << 60;
const ll mod = 1e9 + 7;

int N;

void dfs(string s, char max, int depth) {
	if(depth == N)
		cout << s << "\n";
	else {
		for(char alphabets = 'a'; alphabets <= max + 1; alphabets++)
			if(alphabets == max + 1)
				dfs(s + alphabets, alphabets, depth + 1);
			else
				dfs(s + alphabets, max, depth + 1);
	}
}

int main() {
	cin >> N;

	dfs("a", 'a', 1);
	return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define ll long long
#define all(a) (a).begin(),(a).end()

using namespace std;

int main(int argc, char const *argv[]) {
  string S;
  std::cin >> S;
  for (size_t i = 0; i < S.size(); i++) {
    if(i%2==0){
      printf("%c",S[i]);
    }
  }
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
/**Classes and Structs**/
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
/**End**/
                                       /**Definitions**/
                                       const long long int mod1=1000000007;
                                       const int MAX=100005;
                                       #define pb push_back
                                       #define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
                                       typedef long long int ll;
                                       typedef unsigned long long int ull;
                                       typedef unordered_map<int,int,custom_hash> mii;
                                       typedef unordered_map<ll,int,custom_hash> mli;
                                       typedef unordered_map<int,ll,custom_hash> mil;
                                       typedef unordered_map<ll,ll,custom_hash> mll;
                                       /**End**/
/**Custom Functions**/
ll gcd(ll a,ll b){
    ll c;
     while(b){
        c=b;
        b=a%b;
        a=c;
     }
     return a;
}
ll power1(ll a,ll b){
     if(b==0) return 1;
     else if(b%2) return a*power1(a,b-1);
     else {
        ll temp=power1(a,b/2);
        return temp*temp;
     }
}
ll power2(ll a,ll b,ll m){
     if(b==0) return 1;
     else if(b%2) return (a*power2(a,b-1,m))%m;
     else{
        ll temp=power2(a,b/2,m);
        return (temp*temp)%m;
     }
}
/**End**/
int main()
{
fast;
ll t=1;
//cin>>t;
while(t--){
    string s;
    cin>>s;
    sort(s.begin(),s.end());
    if(s[0]==s[1]&&s[2]==s[3]&&s[0]!=s[2]){cout<<"Yes"<<endl;}
    else cout<<"No"<<endl;
}
}


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

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

double pi = 3.141592653589793138;
int main(){
    ll a,b; std::string s;
    while(1==1){
        cin >> a >> s >> b;
        if(s=="+")cout<<a+b<<endl;
        else if(s=="-") cout<<a-b<<endl;
        else if(s=="*") cout<<a*b<<endl;
        else if(s=="/") cout<<a/b<<endl;
        else break;
    }
    return 0;
}


Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
int main(){
int p[7] = {0,9,9,909,909,90909,90909};
  int n;
  cin>>n;
  int d=(int)log10(n)+1;
  if(d%2==0){
  cout<<p[d]<<endl;
  }
  else{
  cout<<p[d-1]+(n-(int)pow(10,d-1))+1<<endl;
  }
  return 0;
}

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

int main() {
    vector <int> g1{1, 3, 5, 7, 8, 10, 12};
    vector <int> g2{4, 6, 9, 11};
    vector <int> g3{2};
    int x, y;
    int xg=-1;
    cin >> x >> y;
    for (int p : g1) {
        if (x==p) xg=0;
    }
    if (xg==-1) {
        for (int p : g2) {
            if (x==p) xg=1;
        }
    }
    if (xg==-1) {
        for (int p : g3) {
            if (x==p) xg=2;
        }
    }
    switch(xg) {
        case 0:
            for (int p : g1) {
                if (y==p) {
                    cout << "Yes\n";
                    return 0;
                }
            }
            break;
        case 1:
            for (int p : g2) {
                if (y==p) {
                    cout << "Yes\n";
                    return 0;
                }
            }
            break;
        case 2:
            for (int p : g3) {
                if (y==p) {
                    cout << "Yes\n";
                    return 0;
                }
            }
            break;
    }
    cout << "No\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <math.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <sstream>
#include <string>
using namespace std;
#define FOR(I,N) for(int I = 0; I < (int)(N); I++)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 30)
typedef pair<int, int> P;
string itos(int i){
  stringstream ss;
  ss << i;
  return ss.str();
}
int stoi(string str){
	stringstream ss;
	ss << str;
	int val;
	ss >> val;  // 10
	return val;
}
int main(void){
	int N;
	while(cin >> N){
		if(N == 0)break;
		string S, L;
		cin >> S;
		for(int i = 0; i < N; i++){
			int cnt = 1;
			for(int j = 0; j < S.size(); j++){
				if(S[j] == S[j+1]){
					cnt++;
				}else{
					L.append(itos(cnt));
					L.push_back(S[j]);
					cnt = 1;
				}
			}
			cnt = 1;
			S = L;
			L.clear();
		}
		FIN(S);
	}

	return 0;	
}

Measured memory_bytes: 1360
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <utility>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
typedef long long int ll;

int main() {
  int N;
  string S;
  cin>>N>>S;
  
  vector<int> v(S.size());
  rep(i,S.size()){
    v[i]=S[i]-'A';
    v[i]+=N;
    if(v[i]>25)
      v[i]-=26;
  }
  
  rep(i,S.size()){
    S[i]=char(v[i]+'A');
  }
  
  cout<<S<<endl;
}


Measured memory_bytes: 384
//9650762
#include<bits/stdc++.h>
using namespace std;
//#define Fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
typedef vector<int>Vl;
typedef pair<int,int>PII;
typedef vector<PII>Vll;
typedef vector<pair<int,pair<int,int> > >Vlll;
typedef priority_queue<int>PQL;
typedef map<int,int>MP;
#define S second
#define F first
#define mp make_pair
#define ms(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define sl(n) scanf("%lld",&n)
#define pl(n) printf("%lld",n)
const int mod=1e9+7;
const int sze=1e6+2;
int sieve_size;
bitset<sze>bs;
Vl primes;

int power(int x,int n)
{
	if(n==0)return 1;
	int p=power(x,n/2)%mod;
	p=(p*p)%mod;
	if(n&1)
		p=(p*x)%mod;
		
	return p;	
}

void sieve(int upperbound)
{
 	sieve_size=upperbound+1;
 	bs.set();
 	bs[0]=bs[1]=0;
 	for(int i=2;i<=sieve_size;i++)
 	{
		if(bs[i])
		{
			for(int j=i*i;j<=sieve_size;j=j+i)
			{
			   	bs[j]=0;
				
			}
			primes.pb(i);	
		}	
	}
}

int lcm(int arr[],int n){
	
	unordered_map<int,int>x;
	for(int k=0;k<n;k++)
	{
		int ele=arr[k];
		for(int i=0;primes[i]*primes[i]<=ele;i++){
		  int p=primes[i];
		  int count=0;
		  while(ele%p==0){
			  ele=ele/p;
			  count++;
		  }
		  if(count!=0)x[p]=max(x[p],count);	
			
			
		}
		if(ele!=1)x[ele]=max(x[ele],(int)1);//special case;;and number is prime itself;;
		
	}
	
	int ans=1;
	for(auto it:x){
		ans=ans*power(it.F,it.S);
		ans=ans%mod;
	}
	return ans;
}

signed main()
{
	sieve(1000005);
	int n;
	sl(n);
	int arr[n];
	int ans=0;
	for(int i=0;i<n;i++)
	{
		sl(arr[i]);	
	}
	int l=lcm(arr,n);
	for(int i=0;i<n;i++){
		int d=power(arr[i],mod-2);
		ans+=(l*d)%mod;
		//ans+=(l/arr[i]);
		
	}
	cout<<ans%mod<<endl;
  return 0;
}


Measured memory_bytes: 1528
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int MOD = 1000000007;
const int INF = 1e15;
using Graph = vector<vector<int>>;

signed main() {
  int X, N;
  cin >> X >> N;
  vector<bool> fg(120);
  for( int i = 0; i < N; i++ ){
    int P;
    cin >> P;
    fg[P] = 1;
  }
  int sa = 10000;
  int ans = -1;
  for( int i = 110; i >= 0; i-- ){
    if( abs(i-X) <= sa && fg[i] == false ){
      sa = abs(i-X);
      ans = i;
    }
  }
  cout << ans << endl;

}


Measured memory_bytes: 3600
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<string>
#include<cmath>
#include<queue>
#include<vector>
#include<sstream>
#include<algorithm>
#include<stack>
#include<bitset>
#include<map>
#include<unordered_map>
#include<set>
#define rep(i,n) for(int i=0;(i)<(n);i++)
#define rep1(i,n) for(int i=1;(i)<=(n);i++)
#define mst(a,b) memset(a,b,sizeof(a))
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define dbg(a) cout<<"* "<< #a <<" : "<<a<<endl
#define fr first
#define se second
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ls x<<1
#define rs x<<1|1
#define lowbit(x) x&(-x)
#define ac cout<<ans<<endl
//#define DEBUG 0
using namespace std;
const double pi=acos(-1.0);
const double eps=1e-6;
const ull hashp=1e7+19;
const ll INF=0x3f3f3f3f3f3f3f3fll;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;
const int maxn=2e5+100;
char s[maxn];
void solve()
{
	int n;scd(n);
	scanf("%s",s+1);
	if(n&1){
		printf("No\n");
		return ;
	}
	rep1(i,n/2){
		if(s[i]!=s[i+n/2]){
			printf("No\n");
			return ;
		}
	}
	printf("Yes\n");
}
int main(){
    //IOS;
    //freopen("D://data.txt","r",stdin);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<vector>
#define inf 2147483647
#define rep(i,a,b) for(int i=a;i<b;i++)
#define  rr read()
#define ll long long
#define repb(i,a,b) for(int i=a;i<=b;i++)
#define CloseIo   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
int read()
{
    char ch = getchar();
	int x = 0, f = 1;
    while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
    while('0' <= ch && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
    return x * f;
}
vector<ll>v[10],v1,v2;
 
int main()
{
CloseIo;
ll a[10],k;
rep(i,0,3)
scanf("%lld",&a[i]);
scanf("%lld",&k);
rep(i,0,3)
{
	 rep(j,0,a[i])
	 {
	 ll t;
	 scanf("%lld",&t);
	 v[i].push_back(t);
	 	
	 }
//	 sort(v[i].begin(),v[i].end(),cmp);
}
//printf("\n\n\n");
rep(i,0,v[0].size())
rep(j,0,v[1].size())
{
	v1.push_back(v[0][i]+v[1][j]);
}
sort(v1.begin(),v1.end(),greater<ll>());
v1.resize(k);
rep(i,0,v1.size())
rep(j,0,v[2].size())
{
	v2.push_back(v1[i]+v[2][j]);
}
sort(v2.begin(),v2.end(),greater<ll>());
rep(i,0,k)
printf("%lld\n",v2[i]);
}
 

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

#define int long long int
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repm(a,b,c) for(int a=(b-1);a>=c;a--)
#define pb push_back
#define str string
#define sf(a) scanfs("%d",&a)
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()

using namespace std;

const int INF = 1e18 + 9;
const int Mod = 1e9 + 7;
inline int replac(str s){double ans=0;rep(i,0,s.length()){ans+=(s[i]-'0')*pow(10,s.length()-i-1);}return (int)ans;}
inline string numstr(int m){str s="";while(m>0){char c;int a=m/10;if(a>0)a=m%(a*10);else a=m;c=(char)('0'+a);s+=c;m/=10;}str st="";for(int i=s.size()-1;i>=0;i--){st+=s[i];}return st;}
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
const int MAX_N=100005;
struct UFF{
    int par[MAX_N];
    int ran[MAX_N];
    void init(int n){
        rep(i,0,n){
            par[i] = i;
            ran[i] = 0;
        }
    }
    int _find(int x){
        if(par[x] == x){
            return x;
        } else {
            return par[x] = _find(par[x]);
        }
    }
    void unite(int x,int y){
        x = _find(x);
        y = _find(y);
        if(x==y)return;

        if(ran[x] < ran[y]) {
            par[x] = y;
        } else {
            par[y] = x;
            if(ran[x] == ran[y]){
                ran[x]++;
            }
        }
    }
    bool same(int x,int y){
        return _find(x) == _find(y);
    }
};

struct edge{
    int from,to,cost;
    edge(){}
    edge(int a,int b,int c){
        from=a;
        to=b;
        cost=c;
    }
    ///sort?????????cost????????????????????????
    const bool operator<(const edge &r) const {
        return cost < r.cost;
    }
};
UFF uf;
edge E[100005];
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;///dot and branch
    cin >> n >> k;
    uf.init(n);
    rep(i,0,k){
        int x,y,z;
        cin >> x >> y >> z;
        E[i] = edge(x,y,z);
    }
    sort(E,E+k);
    int res = 0;
    rep(i,0,k){
        edge e = E[i];
        if(!uf.same(e.from,e.to)){
            uf.unite(e.from,e.to);
            res += e.cost;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 5676
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

int main(void){

    int n, m;
    cin >> n >> m;

    string s, t;
    cin >> s >> t;

    ll ans = lcm(n, m);

    if(ans == n){
        for(int i = 0; i < m; i++){
            if(t[i] != s[(n / m) * i]){
                cout << -1 << endl;
                return 0;
            }
        }
        cout << ans << endl;
    } else if(ans == m){
         for(int i = 0; i < n; i++){
            if(s[i] != t[(m / n) * i]){
                cout << -1 << endl;
                return 0;
            }
        }
        cout << ans << endl;
    } else {
        ll step = lcm(ans / n, ans / m);

        for(int i = 0; i * step <= ans; i++){
            // cout << s[ans / n * i] << " " << t[ans / m * i] << endl;
            if(s[(ans / m * i)] !=  t[ans / n * i]){
                cout << -1 << endl;
                return 0;
            }
        }

        cout << ans << endl;
    }
}


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

using namespace std;

int main(){
  string s,t;
  cin>>s>>t;
  map<string  , int  > mp;
  int a,b;
  cin>>a>>b;
  mp[s]=a;
  mp[t]= b;
  string tt;
  cin>>tt;
  mp[tt] -=1;
  cout<<mp[s]<<" "<<mp[t]<<endl;
  
  
  
  
}

Measured memory_bytes: 3592
from fractions import gcd
from functools import reduce


def lcm(a, b):
    return a * b // gcd(a, b)


def main():
    n = int(input())
    a = list(map(int, input().split()))
    m = reduce(lcm, a) - 1
    ans = 0
    for aa in a:
        ans += m % aa
    print(ans)


if __name__ == '__main__':
    main()



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

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;i++)
#define rep2(i, m, n) for(int i=m;i<n;i++)
#define rrep(i, n, m) for(int i=n;i>=m;i--)
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll MOD = 1000000007;
#ifdef __DEBUG

#include "cpp-pyprint/pyprint.h"

#endif

ll dp[100005][13];

void Main() {
    int n;
    cin >> n;
    vector<double> V(n);
    for (int i = 0; i < n ; ++i) {
        cin >> V[i];
    }

    sort(V.begin(), V.end());

    double pre = V[0];
    for (int j = 1; j < n; ++j) {
        pre = (pre + V[j])/2;
    }
    cout << pre << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int a,b;
	char op,n;
	scanf("%d%c%c%d",&a,&n,&op,&b);
	while(op != '?'){	
		if(op == '+')printf("%d\n",a+b);
		else if(op == '-')printf("%d\n",a-b);
		else if(op == '*')printf("%d\n",a*b);
		else if(op == '/')printf("%d\n",a/b);
		scanf("%d%c%c%d",&a,&n,&op,&b);
	}
	return 0;
}



Measured memory_bytes: 2032
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
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(){
	bool flag = true;
	while(1){
		int kin;
		cin >> kin;
		if(kin==0) break;
		if(!flag) cout << endl;
		flag = false;
		int t10,t50,t100,t500;
		int u10=0,u50=0,u100=0,u500=0;
		int a1,a2,a3,a4;
		cin >> t10 >> t50 >> t100 >> t500;
		int nowmin = 99;
		FOR(i,0,t10+1){
			FOR(j,0,t50+1){
				FOR(k,0,t100+1){
					FOR(l,0,t500+1){
						int sum = i*10+j*50+k*100+l*500;
						int turi = sum-kin;
						if(turi<0) continue;
						u500 = turi/500; turi -= u500*500;
						u100 = turi/100; turi -= u100*100;
						u50 = turi/50; turi -= u50*50;
						u10 = turi/10;
						if((u500>0&&l>0)||
							(u100>0&&k>0)||
							(u50>0&&j>0)||
							(u10>0&&i>0)){
							continue;
						}else{
							if(nowmin>(t10+t50+t100+t500-i-j-k-l+u10+u50+u100+u500)){
								nowmin = (t10+t50+t100+t500-i-j-k-l+u10+u50+u100+u500);
								a1 = i; a2 = j; a3 = k; a4 = l;
							}
						}
					}
				}
			}
		}
	if(a1!=0) cout << 10 << " " << a1 << endl;
	if(a2!=0) cout << 50 << " " << a2 << endl;
	if(a3!=0) cout << 100 << " " << a3 << endl;
	if(a4!=0) cout << 500 << " " << a4 << endl;
	}
}

Measured memory_bytes: 1164
#include"iomanip"
#include"iostream"
#include"limits"
#include"cmath"
#include"vector"
#include"algorithm"
#include"list"
#include"queue"
#include"stack"
#include"set"
#include"unordered_set"
#include"map"
#include"unordered_map"
#include"string"
#include"cstring"
#include"assert.h"
using namespace std;
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define mp make_pair
#define pb push_back
#define mset(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll ci[12][12];
ll re[210][210];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll h,w;
	cin>>h>>w;
	for(int i=0;i<10;++i)for(int j=0;j<10;++j)cin>>ci[i][j];
	for(int k=0;k<10;++k)for(int i=0;i<10;++i)for(int j=0;j<10;++j)if(ci[i][k]+ci[k][j]<ci[i][j])ci[i][j]=ci[i][k]+ci[k][j];
	ll ans=0;
	for(int i=0;i<h;++i)for(int j=0;j<w;++j)
	{
		int x;
		cin>>x;
		if(x!=-1)
		{
			ans+=ci[x][1];
		}
	}
	cout<<ans<<'\n';
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;



int main(){

	int x;
	cin >> x;
	if(x==3 || x==5 || x==7){
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
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; }
//#define int long long

void solve() {
	string s;
    cin >> s;
    int n = (int)s.size();
    int ans = 0, p = 0, g = 0;
    rep(i, n) {
        if(s[i] == 'g') {
            if(p + 1 <= g) {
                ++ans; ++p;
            } else {
                ++g;
            }
        } else {
            if(p + 1 <= g) {
                ++p;
            } else {
                --ans; ++g;
            }
        }
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 512
// header {{{
using namespace std;

// C++
#include <algorithm>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <streambuf>
#include <string>
#include <utility>
#include <vector>

#pragma GCC optimization_level 3

// util {{{
#define print(x)	        cout << (x)
#define printvec(x)       for(int i = 0;i < (x).size();i++)cout << (x).at(i) << " ";cout << endl
#define println(x)	        cout << (x) << endl
#define printn		        cout << endl
#define read(x)	            cin >> (x)
#define readvec(x)        for(int i = 0; i < (x).size();i++)cin >> (x).at(i)

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

#define all(x) 		        (x).begin(),(x).end()
#define vint                vector<int>
#define outif(x,y,z)        if(x) cout<<(y)<<endl; else cout<<(z)<<endl
#define loop 		        while(true)

// }}}

// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}

//--------------------------------------------------------------------

void solve() {
    vector<char> scores;
    loop{
        int m,f,r;
        read(m);
        read(f);
        read(r);
        if(m == f && f == r && r == -1)break;
        if((m == -1 || f == -1) || (m + f < 30)){
            scores.push_back('F');
        } else if(m + f >= 80){
            scores.push_back('A');
        } else if(m + f >=65 && m + f < 80) {
            scores.push_back('B');
        }else if((m + f >= 50 && m + f < 65) || (m + f >=30 && m + f < 50 && r >= 50)){
            scores.push_back('C');
        } else if(m + f >=30 && m + f < 50) {
            scores.push_back('D');
        }
    };
    rep(i,scores.size()){
        println(scores.at(i));
    }
}

signed main() {
    solve();
    return 0;
}


Measured memory_bytes: 3160
/*#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include<bits/stdc++.h>
#define ll long long
#define inf 1000000005
#define mod 1000000007
#define put putchar('\n')
#define F(i,a,b) for (int i=(a);i<=(b);i++)
#define D(i,a,b) for (int i=(a);i>=(b);i--)
#define go(i,t) for (int i=head[t];i;i=Next[i])
#define sqr(x) ((x)*(x))
#define re register
#define mp make_pair
#define fi first
#define se second
#define pa pair<int,int>
#define pb push_back
#define be begin()
#define en end()
#define ret return puts("-1"),0;
#define N 500055
//#define int ll
using namespace std;
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){char c=getchar();int tot=1;while ((c<'0'|| c>'9')&&c!='-') c=getchar();if (c=='-'){tot=-1;c=getchar();}
int sum=0;while (c>='0'&&c<='9'){sum=sum*10+c-'0';c=getchar();}return sum*tot;}
inline void wr(int x){if (x<0) {putchar('-');wr(-x);return;}if(x>=10)wr(x/10);putchar(x%10+'0');}
inline void wrn(int x){wr(x);put;}inline void wri(int x){wr(x);putchar(' ');}
inline void wrn(int x,int y){wri(x);wrn(y);}inline void wrn(int a,int b,int c){wri(a);wrn(b,c);}
int n,m,fa[N],in1[N],ans,x,y;
int nedge,head[N*2],to[N*2],Next[N*2];
#define V to[i]
void add(int a,int b){
   Next[++nedge]=head[a];head[a]=nedge;to[nedge]=b;
}
vector<int> a[N];
int root=-1;
int dfs(int x,int fa){
    int res=0;
    int flag=0;
    go(i,x){
        if(V==fa)
            continue;
        int res1=dfs(V,x);
        if(res1==0&&flag==1) res++;
        if(res1==0&&flag==0) flag=1;
        res+=res1;
    }
    return res;
}
int main(){
    n=read();
    int u,v;
    for(int i=1;i<n;i++){
        u=read();v=read();
    	add(v,u);in1[u]++;
        add(u,v);in1[v]++;
    }
    for(int i=0;i<n;i++)
        if(in1[i]>=3){
            root=i;
            break;
        }
    if(root==-1){
    	wrn(1);
        return 0;
    }
    wrn(dfs(root,-1));
}

Measured memory_bytes: 26240
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
N = int(input())
ans =[[0,0,0],
      [0,0,0],
      [0,0,0]]
# print(ans)

d = []
for i in range(N):
  d.append(int(input()))

for i in d:
  for j in range(len(a)):
    if a[j] == i:
      ans[0][j] = 1
  for j in range(len(b)):
    if b[j] == i:
      ans[1][j] = 1
  for j in range(len(c)):
    if c[j] == i:
      ans[2][j] = 1
# print(ans)
answer = "No"
# 横
if ans[0][0] == 1 and ans[0][1] == 1 and ans[0][2] == 1:
  answer = "Yes"
if ans[1][0] == 1 and ans[1][1] == 1 and ans[1][2] == 1:
  answer = "Yes"
if ans[2][0] == 1 and ans[2][1] == 1 and ans[2][2] == 1:
  answer = "Yes"
if ans[0][1] == 1 and ans[1][1] == 1 and ans[2][2] == 1:
  answer = "Yes"

# 縦
if ans[0][0] == 1 and ans[1][0] == 1 and ans[2][0] == 1:
  answer = "Yes"
if ans[0][1] == 1 and ans[1][1] == 1 and ans[2][1] == 1:
  answer = "Yes"
if ans[0][2] == 1 and ans[1][2] == 1 and ans[2][2] == 1:
  answer = "Yes"

# 斜め
if ans[0][2] == 1 and ans[1][1] == 1 and ans[2][0] == 1:
  answer = "Yes"
if ans[0][0] == 1 and ans[1][1] == 1 and ans[2][2] == 1:
  answer = "Yes"

print(answer)

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

long long from1[100005];
long long fromN[100005];
long long N;

//        to
vector<long long>way[100005];

void dfs1(long long pa, long long cur, long long cost){
	from1[cur] = cost;
	for(int i = 0; i < way[cur].size(); i++){
		if(way[cur][i] != pa){
			dfs1(cur, way[cur][i], cost + 1);
		}
	}
}

void dfsN(long long pa, long long cur, long long cost){
	fromN[cur] = cost;
	for(int i = 0; i < way[cur].size(); i++){
		if(way[cur][i] != pa){
			dfsN(cur, way[cur][i], cost + 1);
		}
	}
}

int main(){
	cin >> N;
	for(long long i = 0; i < N-1; i++){
		long long a, b;
		cin >> a >> b;
		a--;b--;
		way[a].push_back(b);
		way[b].push_back(a);
	}

	dfs1(-1, 0, 0);
	dfsN(-1, N-1, 0);

	long long count1 = 0;
	long long countN = 0;

	for(long long i = 1; i < N - 1; i++){
		//cout << "from1[" << i << "] = " << from1[i] << endl;
		//cout << "fromN[" << i << "] = " << fromN[i] << endl;
		if(from1[i] <= fromN[i]){
			count1++;
		}else{
			countN++;
		}
	}
	if(count1 > countN){
		cout << "Fennec" << endl;
	}else{
		cout << "Snuke" << endl;
	}
}


Measured memory_bytes: 13568
N=int(input())
A=list(map(int,input().split()))
cum=[A[i] for i in range(N)]
for i in range(1,N):
    cum[i]=max(cum[i],cum[i-1])

res=0
for i in range(N):
    res+=max(0,cum[i]-A[i])

print(res)


Measured memory_bytes: 106628
/*ex6_2
series2*/
 
#include <stdio.h>
#include <string.h>
#define SIZE 102
int main(void){
    //各文字の箱を作って読み取り
    char inputs[SIZE];
    fgets(inputs,SIZE,stdin);//改行コードまでの文字列の入力を代入
    printf("%c",inputs[0]);//最初の文字の出力
    printf("%d",strlen(inputs)-3);//前後及び最後の改行コードをなくしたもの
    printf("%c",inputs[strlen(inputs)-2]);//最後の文字の出力
    printf("\n");
    return 0;
}

Measured memory_bytes: 128
#include<cstdio>
int main(){
    int n,smin[26],si[26];
    char s[51];
    scanf("%d",&n);
    for(int i=0;i<26;i++)smin[i]=1e9;
    for(int i=0;i<n;i++){
        scanf("%s",s);
        for(int i=0;i<26;i++)si[i]=0;
        for(int i=0;s[i]!='\0';i++)si[s[i]-'a']++;
        for(int i=0;i<26;i++)if(si[i]<smin[i])smin[i]=si[i];
    }
    for(int i=0;i<26;i++){
        for(int j=0;j<smin[i];j++)printf("%c",'a'+i);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
  int X,Y,Z;
  cin >> X >> Y >> Z;
  int res = 0;
  X = X - Y - 2 * Z;
  while (X >= 0){
    res++;
    X = X - Y - Z;
  }
  cout << res;
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace ABC125A
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Split(' ').ToArray();

            var A = int.Parse(line[0]);
            var B = int.Parse(line[1]);
            var T = int.Parse(line[2]);

            Console.WriteLine((T / A) * B);
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define ll long long
# define INF 0x3f3f3f3f 

using namespace std;

int dis[12345];

int main() {
    ll val = 1e18L;

    int n;
    cin >> n;
    ll ans = 1LL;
    vector <ll> vec(n);
    int cond = 0;
    for(int i = 0; i < n; i++){
        cin >> vec[i];
        if(!vec[i]) cond = 1;
    }
    if(cond){
         cout << 0;
            return 0;
    }
    for(int i = 0; i < n; i++){
       
        if(val/vec[i] < ans){
            cout << -1;
            return 0;
        }
        
        ans *= vec[i];
    }
    cout << ans;

}


Measured memory_bytes: 4052
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second

int main(void) {
	int n; cin >> n;
	vp p(n);
	rep(i,n) cin >> p[i].se >> p[i].fi;
	SORT(p);
	int t=0;
	rep(i,n){
		t += p[i].se;
		if(t>p[i].fi){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}




Measured memory_bytes: 1792