akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main()
{
    long long int a, b, k, p;
    scanf("%lld%lld%lld", &a, &b, &k);

    if(a>=k)
        printf("%lld %lld\n", a-k, b);
    else if(a+b >= k)
    {
        p = k - a;
        b = b - p;
        printf("0 %lld\n", b);
    }

    else
    {
        printf("0 0\n");
    }
    return 0;
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/04/20  Problem: ABC 051 B / Link: http://abc051.contest.atcoder.jp/tasks/abc051_b  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N;

LL ans = 0LL;

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

	cin >> N;
	string s;
	cin >> s;
	int x = 0;
	FOR(i, 0, N) {
		if (s[i] == 'I')x++;
		else x--;
		ans = max(ans, (LL)x);
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
//value at the index->find_by_order(index), index->order_of_key(elme) [both in O(logn)]
//mt19937 mt(chrono::high_resolution_clock::now().time_since_epoch().count());
//cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
#define setbits(x)      __builtin_popcountll(x)
#define leadzero(x)     __builtin_clz(x)
#define trailzero(x)    __builtin_ctz(x)
#define bitsparity(x)   __builtin_parity(x)
#define mod             1000000007
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll              long long 
#define pre(y,x)        fixed<<setprecision(y)<<x
#define dbg1(x)         cerr << "|" << #x << ": " << (x) << "|\n";
#define dbg2(x,y)       cerr << "|" << #x << ": " << (x) << "|" << #y << ": " << (y) << "|\n";
#define dbg3(x,y,z)     cerr << "|" << #x << ": " << (x) << "|" << #y << ": " << (y) << "|" << #z << ": " << (z) << "|\n";
#define ff              first
#define ss              second
#define pb              push_back
#define eb              emplace_back
#define popb            pop_back
#define all(v)          v.begin(), v.end()
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll; 
typedef pair<string, string> pss; 
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef vector<pii> vii;
typedef vector<pll> vll; 
typedef vector<ll> vl; 
typedef vector<vl> vvl;
typedef vector<string> vs;
ll power(ll a,ll b){if(b==0) return 1;ll res;while(b>0){if(b&1) res *= a;a *= a;b >>=1;}return res;}
int is(int n){if(n==1) return 0;for(int i=2;i*i<=n;i++){if(n%i==0) return false;}return true;}
bool ispoweroftwo(ll x){ return (x&&!(x&(x-1)));}
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
const int inf = 1e9;
const double pi = acos(-1);
const ll INF = 1e18;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////

inline void solve(){
		int x;
		cin >> x;
		cout << (x==0?"1":"0") ;
}	
int main(){
		FIO;
//		int t; cin >> t;
//		while(t--)
		solve();
		return 0;	
}
/*

*/

Measured memory_bytes: 3644
X,N = map(int,input().split())

L = list(map(int,input().split()))

if N == 0:print(X)
else:
    for i in range(0,100):
        if not X-i in L:
            print(X-i)
            break
        if not X+i in L:
            print(X+i)
            break

Measured memory_bytes: 61892
a = 2, 3, 5

def f(n):
  m = memo.get(n)
  if m is None:
    nd = m = n * d
    for p, c in zip(a, b):
      p *= d
      k, r = divmod(nd, p);
      m = min(m, f(k) + r + c, r and f(k + 1) + p - r + c or m)
    memo[n] = m
  return m

t = int(input())
for _ in range(t):
  n, *b, d = map(int, input().split())
  memo = {0: 0, 1: d}
  print(f(n))


Measured memory_bytes: 10880
#define rep(i,n) for(i=0;i<(n);++i)
#include<iostream>
#include<string>
#include<cstdint>
#include<algorithm>
#include<bitset>
using namespace std;

int main(){
    int i,j,k;
    string s;
    cin >> s;
    string str[7];
    str[0]="SUN";
    str[1]="MON";
    str[2]="TUE";
    str[3]="WED";
    str[4]="THU";
    str[5]="FRI";
    str[6]="SAT";
    rep(i,7){
        if(str[i]==s){
            cout<< (7-i);
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 1e2 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int l, r;
	cin >> l >> r;
	LL ans = INF;
	for (int i = 0; l + i <= r; i++)
	{
		int x = l + i;
		for (int j = 1; j <= 3000 && x + j <= r; j++)
		{
			int y = x + j;
			ans = min(ans, 1LL * x * y % 2019);
		}
		if (ans == 0) break;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.Arrays;

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

        int[] arr = new int[5];
        for (int i = 0; i < 5; i++) {
            arr[i] = -sc.nextInt();
        }

        Arrays.sort(arr);

        StringBuilder sb = new StringBuilder("");
        sb.append(-arr[0]);
        for (int i = 1; i < 5; i++) {
            sb.append(' ');
            sb.append(-arr[i]);
        }
        System.out.println(sb);
    }
}

Measured memory_bytes: 25976
#include <iostream>
#include <cmath>
#include <algorithm>
#define N (1<<19)
#define INF 2147483647
using namespace std;
void Update(int,int);
int Find(int,int,int,int,int);
int tree[N],n,N1=N;
int main(){
  int q,com,x,y;
  if(N1%2==1) N1-=1;
  cin >> n >> q;
  for(int i=0;i<2*n-1;i++) Update(i,INF);
  while(q--){
    cin >> com >> x >> y;
    if(com==0) Update(x,y);
    else{
      int r=Find(x,y+1,0,0,N1/2);
      cout << r << endl;
    }
  }
  return 0;
}
void Update(int x,int y){
  x+=N1/2-1;
  tree[x]=y;
  while(x>0){
    x=(x-1)/2;
    tree[x]=min(tree[x*2+1],tree[x*2+2]);
  }
}
int Find(int a,int b,int k,int l,int r){
  if(r<=a||b<=l) return INF;
  if(a<=l&&r<=b) return tree[k];
  else{
    int vl=Find(a,b,k*2+1,l,(l+r)/2);
    int vr=Find(a,b,k*2+2,(l+r)/2,r);
    return min(vl,vr);
  }
}

Measured memory_bytes: 2744
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
  string s;
  cin>>s;
  int i=0,j=s.length()-1;
  int cnt=0;
  while(i<=j)
  {
      if(s[i]!=s[j])
         cnt++;
         
        i++;
        j--;
  }
  
  printf("%d",cnt);
  
}

Measured memory_bytes: 256
//naveen mall
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb               push_back
#define sz(c)            (int)c.size()
#define len(c)           (int)c.length()
#define vec              vector
#define int              long long int
#define all(c)           c.begin(), c.end()
#define rall(c)          c.rbegin(), c.rend()
#define trav(a,i)        for(auto i: a)
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define invect(v,n)       for(int i=0;i<n;i++ ){int arb;cin>>arb;v.pb(arb);}
#define inset(s,n)        fl(i,0,n){int aset;cin>>aset;s.insert(aset);}
#define display(c)        trav(c,i) cout<<i<<" ";cout<<"\n";
#define F                 first
#define S                 second
#define pii               pair<int,int>
#define PB                pop_back
#define endl              "\n"
#define what(x) cerr <<	 #x << " is " << x << endl;
int sum() { return 0; }template<typename T,typename... Args>T sum(T a, Args... args) { return a + sum(args...); }
#define p   200005



  
void solve()
{   
int n,k;
cin>>n>>k;
cout<<min(n%k,k-n%k);

}
signed main()
{fast
	int t;
	//cin>>t;
	t=1;
	while(t--)
	{
solve();}
  
}












Measured memory_bytes: 256
X = gets.to_i
max = Math.sqrt(X).floor
ans = 1

for num in 2..max
	constat = X
	exp = 0

	while (constat/num).floor > 0
		constat = constat / num
		exp += 1
	end

	if ans < num **exp
		ans = num **exp
	end
end

print ans


Measured memory_bytes: 1788
//#pragma once
#include <stdio.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>

using namespace std;

typedef pair<long long, long long> pl;

long long N, M, k, a, b, c, d, e, H, W,X;
long long A[200000] = {};
long long B[20000] = {};
long long C[20000] = {};
bool f;
bool ff;
string S, SS;
set <long long>sll;
pl buf;
vector <long long>vl[7];


int main() {

	cin >> N;
	a = 0;
	b = 100000000000;
	c = 0;
	d = 0;

	for (int i = 0; i < N; i++) {
		cin >> A[i];
		c += abs(A[i]);
		if (A[i] < 0) {
			a++;
		}
		if (A[i] == 0) {
			d = 1;
		}

		b = min(abs(A[i]), b);

	}
	
	if (a % 2 == 0 || d==1) {
		cout << c << endl;
	}
	else {
		cout << c - 2*b << endl;
	}

	return 0;
}

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

using namespace std;

int main() {
   string s,t;
   cin >> s >> t ;
   int a,b;
   cin >> a >> b;
   string u;
   cin >> u;
   
   if(s==u) {
       a--;
   }else{
       b--;
   }

   cout << a << " " << b << endl;

   return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
using namespace std;
// #include "prettyprint.hpp"

int main() {
  int A[3];
  cin >> A[0] >> A[1] >> A[2];

  sort(A, A + 3);
  cout << A[0] * A[1] / 2 << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
int s[100000];
int t[100000];
int u[100000];
int main(){
	int a,b;
	while(scanf("%d%d",&a,&b),a){
		for(int i=0;i<a;i++){
			scanf("%d%d%d",s+i,t+i,u+i);
		}
		double L=0;
		double R=1000000;
		for(int i=0;i<50;i++){
			double M=(L+R)/2;
			double now=b;
			int last=0;
			bool ok=true;
			for(int j=0;j<a;j++){
				now+=M*(s[j]-last);
				now=min(now,(double)b);
				now+=(M-u[j])*(t[j]-s[j]);
				now=min(now,(double)b);
				if(now<0){ok=false;break;}
				last=t[j];
			}
			double n2=now;
			last-=86400;
			for(int j=0;j<a;j++){
				now+=M*(s[j]-last);
				now=min(now,(double)b);
				now+=(M-u[j])*(t[j]-s[j]);
				now=min(now,(double)b);
				if(now<0){ok=false;break;}
				last=t[j];
			}
			if(n2>now)ok=false;
			if(ok)R=M;
			else L=M;
		}
		printf("%.12f\n",R);
	}
}

Measured memory_bytes: 2088
import java.util.Scanner;
public class Main {
private static Scanner sc;

public static void main(String[] args){
	sc = new Scanner(System.in);
	while(true){
		int n=sc.nextInt();
	if(n==0){
		break;
		}
	int [] s= new int[n];
	for(int i=0;i<n;i++){
		s[i]=sc.nextInt();
	}
	for(int i=1;i<n;i++){
		for(int j=0;j<n-i;j++){
			if(s[j]>s[j+1]){
				int c= s[j];
				s[j]=s[j+1];
				s[j+1]=c;
			}
		}
	}
	int sum=0;
	for(int i=1;i<n-1;i++){
		sum+=s[i];
	}
	System.out.println(sum/(n-2));
	}
	
	
}
}

Measured memory_bytes: 21180
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  string t;
  cin>>s>>t;
  int a,b;
  cin>>a>>b;
  string u;
  cin>>u;
  if(s==u){
    a=a-1;
  }
  else{
    b=b-1;
  }
  cout<<a<<" "<<b;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		int max = -1000000000;
		int min = 1000000000;
		long total = 0;

		for(int i = 0 ; i < n ; i++) {
			a[i] = sc.nextInt();
			max = Math.max(max, a[i]);
			min = Math.min(min, a[i]);
			total += a[i];
		}
		System.out.println(min + " " + max + " " + total);
	}
}

Measured memory_bytes: 41420
#include <iostream>
#include <sstream>
#include <string>
using namespace std;
int main(){
	string s;
	int i;
	getline(cin, s);
	for(i=0;i<s.size();i++)
	if(s[i]==','||s[i]=='.')s[i]=' ';
	stringstream ss;
	ss<<s;
	int f=0;
	while(ss>>s)
		if(s.size()>=3&&s.size()<=6){
			cout<<((f==1)?" ":"")<<s;
			f=1;
		}
	cout<<endl;
}

Measured memory_bytes: 1196
a=[[true,true],[true,false],[false,true],[false,false]]
n=gets.to_i
s=gets.chomp
1.upto(n-2) do |i|
  4.times do |j|
    if s[i]==?o
      if a[j][i]==true
        a[j]<< a[j][i-1]
      else
        a[j]<< !a[j][i-1]
      end
    else
      if a[j][i]==true
        a[j]<< !a[j][i-1]
      else
        a[j]<< a[j][i-1]
      end
    end
  end
end
u=[]
4.times do |j|
  g=a[j]
  if (g[-1]&&((s[-1]==?o&&(g[-2]==g[0])) || (s[-1]==?x&&(g[-2]!=g[0]))))||(!g[-1]&&((s[-1]==?x&&(g[-2]==g[0])) || (s[-1]==?o&&(g[-2]!=g[0]))))
    if (g[0]&&((s[0]==?o&&(g[-1]==g[1])) || (s[0]==?x&&(g[-1]!=g[1]))))||(!g[0]&&((s[0]==?x&&(g[-1]==g[1])) || (s[0]==?o&&(g[-1]!=g[1]))))
      u=g
      break
    end
  end
end

puts u==[] ? -1:u.map{|i|i ? ?S:?W}.*("")

Measured memory_bytes: 10632
M = 1000000007
N = gets.to_i
xs = []
(0...N).each{
  x = gets.to_i
  xs << [x, 0]
}
(0...N).each{
  x = gets.to_i
  xs << [x, 1]
}
xs.sort!

ans = 1
box = 0
bt = nil
xs.each{ |x,t|
  #p [ans, box, bt, [x,t]]
  if !bt
    box = 1
    bt = t
    next
  end
  
  if t == bt
    box += 1
  else
    ans = (ans * box) % M
    box -= 1
    if box == 0
      bt = nil
    end
  end
}
p ans

Measured memory_bytes: 19320
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
int a,b,c;
cin>>a>>b>>c;
if(a==b)
cout<< c <<endl;
else if(b==c)
cout<< a <<endl;
else if(c==a)
cout<< b <<endl;
} 


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

N, M = list(map(int, input().split()))

minimum, maximum = 0, N+1

for i in range(M):
    L, R = list(map(int, input().split()))
    if minimum < L:
        minimum = L
    if R < maximum:
        maximum = R

print(max(maximum-minimum+1, 0))


Measured memory_bytes: 46056
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<queue>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int> >;
using pii = pair<int, int>;
using ppi = pair<pii, int>;

int f_dir[2][4] = {{-1, 0, 1, 0}, {0, 1, 0, -1}}; //↑→↓←
int e_dir[2][8] = {{-1, -1, -1, 0, 0, 1, 1, 1}, {-1, 0, 1, -1, 1, -1, 0, 1}};
bool is_in_field(int y, int x, int h, int w){
  return (y >= 0 && y < h && x >= 0 && x < w);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  string s ; cin >> s;
  if(s == "ABC") cout << "ARC" << endl;
  else cout << "ABC" << endl;

  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}


Measured memory_bytes: 3680
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#define int  long long int
	#define pb push_back
	#define fe first
    #define lb lower_bound 
    #define ub upper_bound
    #define pii pair<pair<int,int>,pair<int,int> >
	#define se second
	#define endl "\n"
	#define pi pair<int, int>
	#define vi vector<int> 
	#define vvi vector<vi>
    #define bs   binary_search
	#define rep(i,a,b) for(int i=a;i<b;i++)
	#define rep1(i,a,b) for(int i=a;i<=b;i++)	
    #define all(c) (c).begin(),(c).end()
    #define sz(x)       (int)x.size() 
	#define PI 3.14159265358979323846
    
	const int N =1e6;
    
     int mod= 1e9+7;
     
     int dx[4]={0,0,+1,-1};
     int dy[4]={+1,-1,0,0};
   
    void solve(){
        int n;
        cin>>n;
        
        int m=(1<<n);
        multiset<int > mt;
        
        rep(i,0,m){
			 int x;
			 cin>>x;
			 mt.insert(x);
	  }
	  
	  vi v;
	  auto it=mt.end();
	  it--;
	  v.pb(*it);
	  mt.erase(it);
	  
	  rep(i,0,n){
		  
		  vi wyn=v;
		  
		  rep(j,0,sz(v)){
			  auto it = mt.lb(v[j]);
			  
			  if(it == mt.begin()){
				  cout<<"No\n";
				  return;				  
			  }
			  
			  it--;
				  
				  wyn.pb(*it);
				  mt.erase(it);		  	  
		  }
		  
		  sort(all(wyn));
		  reverse(all(wyn));
		   //~ swap(v,wyn);	
		   v=wyn;  
	  }
	  
	  
	  cout<<"Yes\n";
	  
	  
	  
  }
	
		  
   
   
   
   
      int32_t main() {
	    cool;
	    int t=1;
        //cin>>t;
	    while(t--)
	       solve();
	       
	       
	       return 0;	   
	   }


Measured memory_bytes: 16684
/*
* @Author Silviase(@silviasetitech)
* For ProCon
*/

import java.util.*;
import java.lang.*;
import java.math.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
       int[] ar = new int[5];
       int minamari = 10;
       int sum = 0;
       for (int i = 0; i < 5; i++) {
           ar[i] = sc.nextInt();   
           if (ar[i] % 10 != 0) {
               minamari = Math.min(minamari, ar[i]%10);
               ar[i] = ar[i]/10*10+10;
           }
           sum += ar[i];
       }
       
       System.out.println(sum + minamari  - 10);

        sc.close();
    }

}





Measured memory_bytes: 21844
from dataclasses import dataclass


@dataclass
class Monster:
    health: int
    strength: int

    def attack(self, other: "Monster"):
        other.health -= self.strength

    def is_dead(self) -> bool:
        return self.health <= 0


def battle(first: Monster, second: Monster) -> bool:
    while True:
        first.attack(second)
        if second.is_dead():
            return True

        second.attack(first)
        if first.is_dead():
            return False


def main():
    a, b, c, d = map(int, input().split())

    t_monster = Monster(health=a, strength=b)
    a_monster = Monster(health=c, strength=d)

    if battle(t_monster, a_monster):
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 10688
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

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

#define FOR(i,s,e) for(int i=(s);i<(int)(e);i++)
#define FOE(i,s,e) for(int i=(s);i<=(int)(e);i++)
#define REP(i,n)   FOR(i,0,n)
#define ALL(x) (x).begin(), (x).end()
#define CLR(s) memset(s,0,sizeof(s))
#define PB push_back


int find_max(int n, int k, set<int> &s) {
    if (n == 0) return s.size();
    //REP(_, s.size()) printf(" "); for(auto &x : s) printf("%d,", x); printf("     --      %d %d\n", n, k);
    int ans = 0;
    FOE(i, k + 1, n) {
        if (s.find(i) == s.end()) {
            s.insert(i);
            int cur = find_max(n - i, i, s);
            //REP(_, s.size()) printf("-");
            //printf("%d %d ... %d -> %d\n", n, k, i, cur);
            ans = max(ans, cur);
            s.erase(i);
        }
    }
    //REP(_, s.size()) printf(" ");
    return ans;
}


map<int, int> dp;

int find(int n) {
    auto it = dp.find(n);
    if (it != dp.end()) return it->second;
    set<int> s;
    return dp[n] = find_max(n, 0, s);
}

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

    LL N;
    while (cin >> N) {
        LL r = N;
        int ans = 0;
        for (LL p = 2; p * p <= N; p++) {
            if (N % p == 0) {
                int e = 0;
                for (; N % p == 0; N /= p) {
                    ++e;
                }
                //cout << e << " " << find(e) << endl;
                ans += find(e);
            }
        }
        if (N > 1) ans ++;

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


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define int long long 
#define uint unsigned long long 
#define double long double 
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define sett(c) (c).resize(unique(all(c))-(c).begin())
#define sz(a) (int)(a).size()
#define hell 1000000007
#define pi pair<int,int>
#define vi vector<int> 
#define vb vector<bool> 
#define vpi vector<pair<int,int>> 
#define x first 
#define y second 
#define endl '\n'
#define forn(i,n) for(int i = 0 ; i < n ; i++ )
#define for1(i,n) for(int i = 1 ; i < n ; i++ )
#define fore(i,a,b) for(int i = a ; (a>b)?(i>=b):(i<=b) ; (a>b)?(i--):(i++) ) 
 
using namespace std;
const int MAX = 1e6;

long long binpow(long long a, long long b) {

    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a ;
        a = a * a ;
        res %= hell;
        a %= hell;
        b >>= 1;
    }
    return res;
}

bool comp(const pi& a , const pi& b ){
        return a.y < b.y;
}

int ncr(int n , int r ){
	r = min(r,n-r);
	int res = 1 ;
	for(int i = 1 ; i <= r ; i++ ){
		( res *= n-i+1 )%= hell;
		res /= i ;
	}
	return res ;
}

void solve(){
        int n ; cin >> n ;
        forn(i,50001){
			if( (int)(i*1.08) == n){
				cout << i << endl ;
				return; 
			}
		}
		cout << ":(" << endl;
}
 
int32_t main(){
        
        ios_base::sync_with_stdio(false);
        cin.tie(nullptr);
        cout.tie(nullptr);
        cout << fixed;
        cout.precision(10);
 
#ifdef LOCAL_DEFINE
        //freopen("input.txt","rt",stdin);
        //freopen("output.txt","w",stdout);
#endif
 
        int t = 1;
        //cin >> t ;
        while(t--){
                solve();
        }
#ifdef LOCAL_DEFINE
        cout << "Time elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms.\n";
#endif
 
        return 0;
}


Measured memory_bytes: 256
w, h, n = list(map(int, input().split()))
data1 = [0]
data2 = [w]
data3 = [0]
data4 = [h]
for i in range(n):
    x, y, a = list(map(int, input().split()))
    if a == 1:
        data1.append(x)
    elif a == 2:
        data2.append(x)
    elif a == 3:
        data3.append(y)
    else:
        data4.append(y)
data1.sort()
data2.sort()
data3.sort()
data4.sort()
x = (data2[0] - data1[-1])
y = (data4[0] - data3[-1])
if x < 0 or y < 0:
    print(0)
    exit()
print(x*y)


Measured memory_bytes: 3064
#define MOD 1000000007
#include <bits/stdc++.h>
#include <numeric>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
class DSU{
		vector<int> _rank,_parent,_size;
		int _Size;
	public:
		DSU(int n): _rank(n,0), _parent(n), _size(n,1), _Size(n){
			iota(_parent.begin(),_parent.end(),0);
		}
		int size(){
			return _Size;
		}
		int size(int i){
			return ((i<0||i>=_size.size())?-1:_size[i]);
		}
		int Find(int x){
			if(x!=_parent[x]){
				_parent[x]=Find(_parent[x]);
			}
			return _parent[x];
		}
		int Union(int x,int y){
			x=Find(x);
			y=Find(y);
			if(_rank[x]<_rank[y]){
				_parent[x]=y;
				_size[y]+=_size[x];
				--_Size;
				return y;
			}
			else if(_rank[x]>_rank[y]){
				_parent[y]=x;
				_size[x]+=_size[y];
				--_Size;
				return x;
			}
			else if(x!=y){
				_parent[y]=x;
				_size[x]+=_size[y];
				--_Size;
				++_rank[x];
				return x;
			}
			return -1;
		}
};
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n,m;
	cin>>n>>m;
	DSU d(n);
	while(m--){
		int a,b;
		cin>>a>>b;
		d.Union(--a,--b);
	}
	cout<<d.size()-1<<endl;
}


Measured memory_bytes: 4516
#include<stdio.h>

int CheckSum(int, int, int[]);

int main(){
  int i, j, k, x, n, s, count, data[11];

  while(1){
    scanf("%d %d", &n, &s);
    if(n == 0 && s == 0) break;

    for(i=0; i<n; i++) data[i] = i;

    count = 0;
    count += CheckSum(n, s, data);

    while(1){
      for(i=n-1, j=9, x=-1; i>=0; i--, j--){
	if(data[i] != j){
	  x = i;
	  break;
	}
      }

      if(x == -1) break;
      for(i=x, j=1, k=data[x]; i<n; i++, j++)
	data[i] = j + k;

      count += CheckSum(n, s, data);
    }
    printf("%d\n", count);
  }

  return 0;
}

int CheckSum(int n, int sum, int data[]){
  int i, _sum;

  for(i=0, _sum=0; i<n; i++)
    _sum += data[i];

  if(sum == _sum) return 1;
  else return 0;
}

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

using namespace std;

vector<int> a[222222];
int main()
{

int n,m; cin>>n>>m;
int is1,is2;

for(int i=1; i<m+1;i++){ cin>>is1>>is2; a[is2].push_back(is1); }

    if(!a[n].empty())
    {
        for(int j=0;j<a[n].size();j++)
        if(!a[a[n][j]].empty()){
                for(int l=0;l<a[a[n][j]].size();l++)
                    if(a[a[n][j]][l]==1){cout<<"POSSIBLE"<<endl; return 0;}}
    }

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


Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
int tot,n,a[N<<1],b[N],nex[N],bk[N],pre[N];
ll k,A,B;
bool vis[N];
ll getdis(int s,int t)
{
    if(s==0) s=n;
    ll ans=0;
    while(s!=t)
    {
        ans+=nex[s];
        s=(s+nex[s])%n;
        if(s==0) s=n;
    }
    return ans;
}
void getAns(int now)
{
    for(int i=now;i<=n;i++)
    {
        int x=a[i];
        if(pre[x])
        {
            while(b[tot]!=x) pre[b[tot]]--,tot--;
            pre[x]--;tot--;
        }
        else b[++tot]=x,pre[x]++;
    }
}
int getPos(int now,ll k)
{
    while(k>=nex[now])
    {
        k-=nex[now];
        now=(now+nex[now])%n;
        if(now==0) now=n;
    }
    return now;
}
int main()
{
    scanf("%d%lld",&n,&k);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]),a[i+n]=a[i];
    if(n==1)
    {
        if(k&1) printf("%d\n",a[1]);
        return 0;
    }
    for(int i=n<<1;i>=1;i--)
    {
        if(i<=n)
            nex[i]=bk[a[i]]-i+1;
        bk[a[i]]=i;
    }
    int now=1;
    while(!vis[now])
    {
        vis[now]=true;
        now=(now+nex[now])%n;
        if(now==0) now=n;
    }
    A=getdis(1,now);
    B=getdis(now+nex[now],now)+nex[now];
    k*=n;
    k--;
    if(k<=A)
        getAns(getPos(1,k));
    else
        getAns(getPos(now,(k-A)%B));
    for(int i=1;i<=tot;i++)
        printf(i==tot?"%d\n":"%d ",b[i]);
}


Measured memory_bytes: 6400
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)

	ans := true
	for k, v := range split(s) {
		i := k + 1
		if i % 2 == 0 {
			if v == "R"  {
				ans = false
			}
		} else {
			if v == "L"  {
				ans = false
			}
		}
	}
	if ans {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")

}

func split(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
// const int MOD = 1e9 + 7;

int main() {
    string S;
    cin >> S;
    map<char, int> m;
    for (auto i : S) {
        m[i]++;
    }

    for (auto i : m) {
        if (i.second != 2) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph= vector<vector<int>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
 
 int n,m,q ;
 ll ans=-INF;
vector<int> A ;
vector<int> a(50),b(50),c(50),d(50) ;
void dfs(int i,int x){
  if(i==n){
   ll now=0 ; 
   rep(j,q){
   if(A[b[j]]-A[a[j]]==c[j]) 
     now+=d[j] ; 
   }
  chmax(ans,now) ;
  return  ;
  }
  rep2(j,x,m){
   A.pb(j) ;
   dfs(i+1,j) ;
   A.ppb() ;
  }
}

int main(){
cin>>n>>m>>q ;
rep(i,q){
    cin>>a[i]>>b[i]>>c[i]>>d[i] ;
   a[i]--;b[i] -- ;
   }
  dfs(0, 1) ;
  cout<<ans<<endl ;
  return 0;
  }

Measured memory_bytes: 3644
#include <iostream>

using namespace std;

int main ()
{
    int x,a;
    cin>>x>>a;
    int shuma=0;
    for(int i=0;i<2;i++)
    {
        if(a>x)
        {
            shuma+=a;
            a--;
        }
        else
        {
            shuma+=x;
            x--;
        }
    }
    cout<<shuma<<endl;
    return 0;
}


Measured memory_bytes: 256
import datetime

# if not (datetime.datetime.strptime('2019/04/30', '%Y/%m/%d') - datetime.datetime.strptime(input(), '%Y/%m/%d')):
#     print('Heisei')
# else:
#     print('TBD')
a  = (datetime.datetime.strptime('2019/04/30', '%Y/%m/%d') - datetime.datetime.strptime(input(), '%Y/%m/%d')).days
if a >= 0:
    print('Heisei')
else:
    print('TBD')

Measured memory_bytes: 4704
from math import gcd

k = int(input())

res = 0
for a in range(1, k + 1):
    for b in range(1, k + 1):
        for c in range(1, k + 1):
            g1 = gcd(a, b)
            g2 = gcd(g1, c)
            res += g2
print(res)


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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

#define REP(i, n) for(ll i = 0 ; i < n; i++)

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

ll diff(ll x, ll y ){
    if( x > y ) { return x - y;}
    else { return y - x;}
}

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll N;
    ll K;

    cin >> K >> N;
    vector<ll> array(N, 0);

    REP(i,N){ cin >> array[i]; }

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

    ll m = 0;
    REP(i, N){
        if( i != array.size()-1 ){
            m = max( m , diff(array[i] ,array[i+1%N]));
        }else{
            m = max(m, (K - array[i]) + array[0]);
        }
    }

    cout << K - m << endl;
}


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

using namespace std;

int a[100010];
int dp[100010];

int32_t main()
{
    int n,k;
    cin >> n >> k;

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

    dp[0] = 0;

    for(int i=1;i<n;i++)
    {
        int cnt = k;
        dp[i] = 2e9;

        for(int j=i-1;j>=0 && cnt--;j--)
            dp[i] = min(dp[i],dp[j]+abs(a[j]-a[i]));
    }

    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>

#define R register
#define maxn 100010
typedef long long ll;
struct Poi {
	int x, y, id;
} p[maxn];
int Fa[maxn];
inline int Find(R int x)
{
	return Fa[x] == x ? x : Fa[x] = Find(Fa[x]);
}
inline bool cmp1(const Poi &a, const Poi &b)
{
	return a.x < b.x;
}
inline bool cmp2(const Poi &a, const Poi &b)
{
	return a.y < b.y;
}
struct edge {
	int a, b, w;
	inline bool operator < (const edge &that) const {return w < that.w;}
} e[maxn << 1];
int main()
{
	R int n, ecnt = 0; scanf("%d", &n);
	for (R int i = 1; i <= n; ++i) scanf("%d%d", &p[i].x, &p[i].y), p[i].id = Fa[i] = i;
	std::sort(p + 1, p + n + 1, cmp1);
	for (R int i = 1; i < n; ++i) e[++ecnt] = (edge) {p[i].id, p[i + 1].id, p[i + 1].x - p[i].x};
	std::sort(p + 1, p + n + 1, cmp2);
	for (R int i = 1; i < n; ++i) e[++ecnt] = (edge) {p[i].id, p[i + 1].id, p[i + 1].y - p[i].y};
	std::sort(e + 1, e + ecnt + 1);
	R ll ans = 0;
	for (R int i = 1; i <= ecnt; ++i)
	{
		R int f1 = Find(e[i].a), f2 = Find(e[i].b);
		if (f1 != f2)
		{
			ans += e[i].w;
			Fa[f1] = f2;
		}
	}
	printf("%lld\n", ans);
	return 0;
}

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

public class Test
{
	public static void Main()
	{
		// my code goes here
		
		int k = int.Parse(Console.ReadLine());
		var c = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
		int a = c[0];
		int b = c[1];
		int counter = 0;
		for(int i=a;i!=b+1;i++){
			if(i%k==0){
				counter++;
			}
		}
		
		if(counter==0){
			Console.WriteLine("NG");
		}else{
			Console.WriteLine("OK");
		}
		
	}
}

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

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

    int ans=0;

  int a,b,c;
  cin>>a>>b>>c;

  for(int i=a; i<=b; i++) {
      if(i%c==0) {
          ans++;
      }
  }

  cout<<ans;
}

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

int main(){
    int K;
    string s;
    cin >> s >> K;
    vector<string> v;
    for(int i = 0; i < K; i++){
        for(int j = 0; j < s.size()-i; j++){
            v.push_back(s.substr(j, i+1));
        }
    }
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    vector<string>::iterator it = v.begin() + K-1;
    cout << *it << endl;
    return 0;
}

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

typedef long long ll;
const int MOD = 1e9 + 7;

const int N = 80 + 5;
const int MAXSUM = 160 * 80;

int g[N][N];
bool dp[N][N][MAXSUM];

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int h,w;
	cin >> h >> w;
	for(int i = 1;i <= h; ++i){
		for(int j = 1;j <= w; ++j){
			cin >> g[i][j];
		}
	}
	for(int i = 1;i <= h; ++i){
		for(int j = 1;j <= w; ++j){
			int x;
			cin >> x;
			g[i][j] = abs(g[i][j] - x);
		}
	}

	dp[0][1][0] = 1;
	
	for(int i = 1;i <= h; ++i){
		for(int j = 1;j <= w; ++j){
			for(int bal = 0; bal < MAXSUM; ++bal){
				if(dp[i-1][j][bal] || dp[i][j-1][bal]){
					dp[i][j][(abs(bal + g[i][j]))] = 1;
					dp[i][j][(abs(bal - g[i][j]))] = 1;
				}
			}
		}
	}
	
	int ans = -1;
	for(int i = 0;i < MAXSUM; ++i){
		if(dp[h][w][i]){
			ans = i;
			break;
		}
	}
	cout << ans << '\n';
}


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

using namespace std;

typedef long long ll;
#define mod 1000000007
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define repc(i, a, b, c) for (ll i = a; (c > 0 ? i < b : i > b) and c != 0; i += c)
#define fi first
#define si second
#define pb push_back
#define all(name) (name.begin(), name.end())
#define fact(n) vector<ll> ft(1, 1LL);rep(i, 1, n+1)ft.pb((ft[i-1]*i)%mod);
#define mod_in(a) power(a, mod - 2)
#define ncr(n, r) ((ft[n]*mod_in((ft[r]*ft[(n)-(r)])%mod))%mod)
#define deb(x) cerr << "[" << #x << " " << x << "]\n";
// #define int ll

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




void solve() {
    ll n;
    cin >> n;
    ll a = n/3, b = n/5, c = n/15;
    deb(a);deb(b);deb(c);
    cout << (n*(n+1LL))/2LL + (15LL*(c*(c+1LL)))/2LL - (3LL*(a*(a+1)))/2LL - (5LL*(b*(b+1)))/2LL;
}

signed main() {
    int t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
}


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

using namespace std;

#define rep(i, x)   for (__typeof(x) i = 0; i < x; i++)
#define mp             make_pair
#define pb             push_back
#define fi             first
#define se             second
#define sz(x)          (int)((x).size())
#define all(x)         (x).begin(), (x).end()
#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define eprintf(...)   fprintf(stderr, __VA_ARGS__)
#define debug(x)       { cerr << #x << " = " << x << endl; }
#define repi(i, x)  for (__typeof(x) i = x-1; i >= 0; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
typedef long long      ll;
typedef pair<int, int> ii;
typedef pair<ii, int>  iii;
typedef vector<int>    vi;
typedef vector<ii>     vii;
typedef vector<iii>    viii;
typedef vector<vector<int> > vvi;
const   int            infi = numeric_limits<int>::max();
const   double         eps = 0;
const   int            ms  = 0;


int gcd(int a, int b){
    if(b == 1)return 1;//
    if(b == 0)return a;
    if(a<b){
        int t = a;
        a = b;
        b = t;
    }
    
    return (gcd(b, a%b));

}

int main()
{
    
    int N, X;
    cin >> N >> X;
    vi xs(N);
    //xs.pb(X);
    repi(i, N){
        cin >> xs[i];
    }

    
    int t = X;
    int g = abs(X-xs[0]);
    for(int i = 1; i < N; i++){
        int d = abs(xs[i] - t);
        g = gcd(d, g);
    }
    cout << g << endl;

    return 0;
}

Measured memory_bytes: 640
/* ****mittal**** */
#include<bits/stdc++.h>
#define ll          long long int 
#define pb          push_back
#define endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define jell        998244353
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define repr(i,a,b)   for(ll int i=a;i>=b;i--)
#define lbnd    lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define DEC(N)  cout << std::fixed; cout << setprecision(N);
using namespace std;
ll add(ll x,ll y)
{
return (x%hell+y%hell)%hell;
}
ll mul(ll x,ll y)
{
return ((x%hell)*(y%hell))%hell;
}
ll sub(ll x,ll y)
{
return (x-y+hell)%hell;
}
#define N  100005
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
  // cin>>t;
    for(int ok=1;ok<=t;ok++)
    {
        
     string p,q;
     cin>>p>>q;
     ll n=p.size();
     ll w=0;
     for(int i=0;i<n;i++)
     {
     	if(p[i]!=q[i])
     		w=1;
     }
     if(w)
     {
     	cout<<"No";
     }
     else
     	cout<<"Yes";

    }
    return 0;
}

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

template<typename T>
class segment_tree{
private:
    vector<T> value; // ノードの値を持つ配列
public:
    int leafnum;             // 葉の数
    T m_val;     //最大値
    int bilower(int x){
        int ans = 1;
        while(ans < x) ans <<= 1;
        return ans;
    }
    //constructor
    //nodenumは要素数、maxvalは値の最大値
    segment_tree(int nodenum, T maxval){
        leafnum = bilower(nodenum);
        value = vector<T> (2*leafnum, maxval);
        m_val = maxval;
    }
    void update(int i, T x){
        // i 番目の葉の値を x に変える
        i += leafnum - 1; // i 番目の葉のノード番号
        value[i] = x;
        while (i > 0) {
            i = (i - 1) / 2; // ノード i の親ノードの番号に変える
            value[i] = min(value[i * 2 + 1], value[i * 2 + 2]); // 左右の子の min を計算しなおす
        }
    }
    T query(int a, int b, int k, int l, int r){
        // [a, b)の区間に対するクエリについて
        // ノード k （区間 [l, r) 担当）が答える
        if (r <= a || b <= l) return m_val+1; // 区間が被らない場合は 200001 を返す
        if (a <= l && r <= b) return value[k]; // ノード k の担当範囲がクエリ区間 [a, b)             
        else{ //に完全に含まれる
            T r1 = query(a, b, 2 * k + 1, l, (l + r) / 2); // 左の子に値を聞く
            T r2 = query(a, b, 2 * k + 2, (l + r) / 2, r); // 右の子に値を聞く
            return min(r1, r2); // 左右の子の値の min を取る
        }
    }
};

int main(){
    int n,q; cin >> n >> q;
    segment_tree<ll> seg(n, (1<<31)-1);
    int com,x,y;
    rep(i,q){
        cin >> com >> x >> y;
        if(com == 1){
            cout << seg.query(x,y+1,0,0,seg.leafnum) << endl;
        }else{
            seg.update(x,y);
        }
    }
}


Measured memory_bytes: 7124
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#define pb push_back
#define mod 1000000007
using namespace std;
typedef long long int ll;

int main(void){
  string s;
  cin>>s;
  string ac="AC";
  for(int i=0;i<s.size()-1;i++){
    if(ac==s.substr(i,2)){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
  return 0;
}


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

int main(){
  int n, s=0;
  cin >> n;
  vector<int>A(n+2);
  A[0] = A[n+1] = 0;
  for(int i=1; i<=n; i++){
    cin >> A[i];
    s += abs(A[i] - A[i-1]);
  }
  s += abs(A[n+1] - A[n]);
  int post, now=A[0], next=A[1], ret=0;
  for(int i=1; i<=n; i++){
    post = now;
    now = next;
    next = A[i+1];
    if((now<post && post<=next)||(next<=post && post<now)){
      cout << (s - 2*abs(now - post)) << endl;
    }
    else if((now<next && next<post)||(post<next && next<now)){
      cout << (s - 2*abs(next - now)) << endl;
    }
    else cout << s << endl;
  }
  return 0;
}

Measured memory_bytes: 1664
#include<iostream>

using namespace std;

typedef long long ll;

int main() {
	int n, cnt = 0, mi = 1000000000;
	ll sum = 0;
	cin >> n;
	for (int i = 0, x; i < n; i++) {
		cin >> x;
		cnt += (x < 0);
		sum += abs(x);
		mi = min(mi, abs(x));
	}

	if (cnt & 1) {
		cout << sum - (mi << 1);
	} else {
		cout << sum;
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
class Main {
	
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		Dice[] list = new Dice[n];
		for(int i = 0; i < n; i++) {
			list[i] = new Dice(stdIn.nextInt(),stdIn.nextInt(),stdIn.nextInt(),stdIn.nextInt(),stdIn.nextInt(),stdIn.nextInt());
		}
		for(int i = 0; i < n; i++) {
			for(int j = i+1; j < n; j++) {
				if(solv(list[i],list[j],0)) {
					System.out.println("No");
					return;
				}
			}
		}
		System.out.println("Yes");
	}
	public static boolean solv(Dice f, Dice dice,int count) {
		if(dice.Top == f.Top && dice.S == f.S && dice.Bottom == f.Bottom && dice.E == f.E && dice.N == f.N && dice.W == f.W) return true;
		if(count == 6) return false;
		Dice tmp = new Dice(dice.Top,dice.S,dice.E,dice.W,dice.N,dice.Bottom);
		tmp.TurnN();
		if(solv(f,tmp,count+1)) {
			return true;
		}
		tmp = new Dice(dice.Top,dice.S,dice.E,dice.W,dice.N,dice.Bottom);
		if(solv(f,tmp,count+1)) {
			return true;
		}
		tmp = new Dice(dice.Top,dice.S,dice.E,dice.W,dice.N,dice.Bottom);
		tmp.TurnE();
		tmp = new Dice(dice.Top,dice.S,dice.E,dice.W,dice.N,dice.Bottom);
		tmp.TurnW();
		if(solv(f,tmp,count+1)) {
			return true;
		}
		
		return false;
	}
	
	
	
}

class Dice {
	int Top; //1
	int Bottom; //6
	int N; //   5
	int S; //   2
	int W; //左 4
	int E; //右 3
	Dice(int a, int b, int c, int d, int e, int f) {
		Top = a;
		S = b;
		E = c;
		W = d;
		N = e;
		Bottom = f;
	}
	public void TurnN() {
		int tmp = Top;
		Top = S;
		S = Bottom;
		Bottom = N;
		N = tmp;
	}
	public void TurnW() {
		int tmp = Top;
		Top = E;
		E = Bottom;
		Bottom = W;
		W = tmp;
	}
	public void TurnE() {
		int tmp = Top;
		Top = W;
		W = Bottom;
		Bottom = E;
		E = tmp;
	}
	public void TurnS() {
		int tmp = Top;
		Top = N;
		N = Bottom;
		Bottom = S;
		S = tmp;
	}
	
}

Measured memory_bytes: 98948
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
cnt = 0

for i in range(N):
    if A[i]+A[i+1] >= B[i]:
        if A[i]>B[i]:
            cnt += B[i]
        else:
            A[i+1] = A[i]+A[i+1] - B[i]
            cnt += B[i]
    else:
        cnt += A[i]+A[i+1]
        A[i+1] = 0
    
print(cnt)

Measured memory_bytes: 19156
n = int(input())

res = len(str(n))
for a in range(1,n+1):
	if a * a > n:
		break
	if n%a != 0:
		continue
	b = n//a
	ans = max(len(str(a)), len(str(b)))
	if ans < res:
		res = ans

print(res)

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

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// chmax, chmin
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;
}

template<typename T>
class CumulativeSum {
    const int n;
    std::vector<T> sum_data;
public:
    CumulativeSum(vector<T> data) : n(data.size()) {
        sum_data.resize(n + 1);
        for (int i = 0; i < n; i++) {
            sum_data[i + 1] = sum_data[i] + data[i];
        }
    }

    // 区間 [l, r) 番目の範囲の和を求める．(l = r のときは 0 を返す．)
    T sum(int l, int r) const {
        assert(0 <= l && l <= r && r <= n);
        return sum_data[r] - sum_data[l];
    }
};
typedef CumulativeSum<ll> CumSum;

void solve(long long N, long long Q, std::string S, std::vector<long long> l,
           std::vector<long long> r) {
  vector<ll> O(N);
  for(int i = 0 ; i+1 < S.size() ; i++){
    if( S[i] == 'A' && S[i+1] == 'C' ){
      O[i] = 1;
    }
  }
  CumSum sum(O);
  for(int i = 0 ; i < Q ; i++){
    --l[i];
    cout << sum.sum(l[i], r[i]-1) << endl;
  }

}

int main() {
  long long N;
  scanf("%lld", &N);
  long long Q;
  scanf("%lld", &Q);
  std::string S;
  std::cin >> S;
  std::vector<long long> l(Q);
  std::vector<long long> r(Q);
  for (int i = 0; i < Q; i++) {
    scanf("%lld", &l[i]);
    scanf("%lld", &r[i]);
  }
  solve(N, Q, S, std::move(l), std::move(r));
  return 0;
}


Measured memory_bytes: 4352
n,k=map(int,input().split())
a=list(map(int,input().split()))
x=1
l=[x]
m=[0]*n
m[x-1]=1
for i in range(n+2):
    x=a[x-1]
    if m[x-1]==0:
        m[x-1]+=1
        l.append(x)
    else:
        break
loop=l[l.index(x):]

if l==loop:
    print(loop[k%len(loop)])
else:
    f=l.index(x)
    if f>=k:
        print(l[k])
    else:
        print(loop[(k-f)%len(loop)])


Measured memory_bytes: 32408