akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
#pragma GCC optimize("O2")
typedef long long int ll;
typedef long double ld;
typedef map <ll,ll> mm;
typedef vector <ll> mv;
typedef pair <ll,ll> mp;
typedef set <ll> ms;
typedef multiset <ll> mms;
typedef queue <ll> mq;
typedef deque <ll> mdq;
typedef stack <ll> mst;
typedef priority_queue <ll> mpq;
typedef priority_queue <ll, vector<ll>, greater<ll> > mmh;
typedef complex<double> cd;
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_multiset tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define flush cout.flush();
#define all(v) v.begin(),v.end()
#define pb(v) push_back(v)
#define lb(v) lower_bound(v)
#define ub(v) upper_bound(v)
#define cn continue
#define forl(i,n) for(ll i=0;i<n;i++)
#define forlr(i,n) for(ll i=n-1;i>=0;i--)
#define rev(s) reverse(s.begin(),s.end())
void swap(ll &a,ll &b)
{
	ll tmp=a;
	a=b;
	b=tmp;
}
ll atoistring(string s)
{
	stringstream lol(s);
	ll x;
	lol>>x;
	return x;
}
void pv(mv v)
{
	forl(i,v.size())
	{
		cout<<v[i]<<" ";
	}
	cout<<"\n";
}
void pa(ll *v,ll size)
{
	forl(i,size)
	{
		cout<<v[i]<<" ";
	}
	cout<<"\n";
}
// ll nck(ll N,ll K,ll mod)
// {
// 	if(N<K)
// 	{
// 		return 0;
// 	}
// 	return (((facs[N]*facsinv[N-K])%mod)*facsinv[K])%mod;
// }
ll power(ll x,ll y,ll p)
{
	ll res=1;
	x=x%p;
	while(y>0)
	{
		if(y&1)
		{
			res=(res*x)%p;
		}
		y=y>>1;
		x=(x*x)%p;
	}
	return res;
}
void checkmod(ll &x,ll mod)
{
	if(x>=mod)
	{
		x%=mod;
	}
}
ll ncr(ll n, ll r, ll mod) {
	ll ans = 1;
	forl(i,min(r,n - r)) {
		ans *= n - i;
		checkmod(ans,mod);
		ans *= power(i+1, mod - 2,mod);
		checkmod(ans,mod);
	}
	return ans;
}
ll sumofgp(ll a,ll n,ll m)
{
	// n = number of terms - 1
	if(n<0)
	{
		return 0;
	}
	if(n==0)
	{
		return 1;
	}
	if(n==1)
	{
		return (1+a)%m;
	}
	ll ans;
	if(n%2)
	{
        ans=(1+a)*sumofgp((a*a)%m,(n-1)/2,m);
	}
    else
    {
        ans=1+((a*(1+a))%m)*sumofgp((a*a)%m,n/2-1,m);
    }
    return ans%m;
}
ll power_of_2_not_less(ll n)
{
	if(!n)
	{
		return 1;
	}
	n--;
	n |= n>>1;
	n |= n>>2;
	n |= n>>4;
	n |= n>>8;
	n |= n>>16;
	n |= n>>32;
	n++;
	return n;
}
ll mod = 1e9 + 7;
// void checktime()
// {
// 	struct timespec ts;
// 	printf("Running Program\n");
// 	clock_gettime(CLOCK_MONOTONIC_RAW,&ts);
// 	long double st=ts.tv_nsec/(1e9)+ts.tv_sec;
// 	// Call Funcn Here
// 	clock_gettime(CLOCK_MONOTONIC_RAW,&ts);
// 	long double en=ts.tv_nsec/(1e9)+ts.tv_sec;
// 	printf("Program ended\nTime = %Lf\n",en-st);
// }
int main(void)
{
	fastio
	ll h1, h2, m1, m2, k;
	cin>>h1>>m1>>h2>>m2>>k;
	ll x = h1*60 + m1;
	x -= h2*60 + m2;
	x = abs(x);
	x -= k;
	cout<<x<<"\n";
	return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
bool is_palindrome(string str){
    int len = str.length();
    for(int i = 0; i < len/2;i++){
        if(str[i] != str[len - 1 - i])
            return false;
    }
    return true;
}
int main(){
    string s;
    cin >> s;
    int l = s.length();
    if(!is_palindrome(s) || !is_palindrome(string(s,0,l/2)) || !is_palindrome(string(s,(l+2)/2,l-1)))
        puts("No");
    else
        puts("Yes");
    return 0;

}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define df 0
#define MAX 100010


int main(){
  int i;
  char s[MAX+1];
  scanf(" %s",s);
  int n=strlen(s),count=n/2;
  for(i=0;i<n;i++)
    if(s[i]=='p')count--;
  printf("%d",count);
  return 0;
}


/// confirm df==0 ///


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    if (n < 1200)
        cout << "ABC";
    else
    {
        if (n < 2800)
            cout << "ARC";
        else
            cout << "AGC";
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int a,s[4],i=0,count=0;
    scanf("%d",&a);

    for(i=0;i<4;i++){
        s[i]=a%10;
        a/=10;
    }


    if(s[0]==s[1] && s[1]==s[2])printf("Yes");
    else if(s[1]==s[2] && s[2]==s[3]) printf("Yes");
    else printf("No");


return 0;
}


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

#define FORE(i, a) for (auto i = a.begin(); i != a.end(); ++i)
#define REPU(i, a, b) for (int i = (a); i < (b); ++i)
#define REPD(i, a, b) for (int i = (a); i > (b); --i)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

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

#define DEBUG(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }

void err(vector<string>::iterator it) {}

template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
	cerr << "[DEBUG] " << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
	err(++it, args...);
}

typedef long long ll;
const int MOD = 1000000007;

template<class T, class U> inline T tmin(T a, U b) { return (a < b) ? a : b; }
template<class T, class U> inline T tmax(T a, U b) { return (a > b) ? a : b; }
template<class T, class U> inline void amax(T &a, U b) { if (b > a) a = b; }
template<class T, class U> inline void amin(T &a, U b) { if (b < a) a = b; }
template<class T> inline T tabs(T a) { return (a > 0) ? a : -a; }
template<class T> T gcd(T a, T b) { while (b != 0) { T c = a; a = b; b = c % b; } return a; }

int main(int argc, char *argv[]) {
	ios_base::sync_with_stdio(false);

	int n;

	cin >> n;
	vector<int> a(n + 1), nxt(n + 1), bak(n + 1);
	REPU(i, 1, n + 1) cin >> a[i];
	bak[1] = 0, nxt[n] = n + 1;
	REPU(i, 2, n + 1) {
		int j = i - 1;
		while (j > 0 && a[j] >= a[i]) {
			j = bak[j];
		}
		bak[i] = j;
	}
	REPD(i, n - 1, 0) {
		int j = i + 1;
		while (j <= n && a[j] >= a[i]) {
			j = nxt[j];
		}
		nxt[i] = j;
	}
	ll ans = 0;
	REPU(i, 1, n + 1) {
		ans += 1LL * a[i] * (i - bak[i]) * (nxt[i] - i);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
//typedef
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
//define
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)

int main(){
    ll a;
    long double b,c;
    cin >> a >> b ;

    c=a*b;
    cout << static_cast<ll>(c) << endl;

 return 0;
}

Measured memory_bytes: 3728
require 'tsort'

class Hash
  include TSort
  alias tsort_each_node each_key
  def tsort_each_child(node, &block)
    self[node].each(&block)
  end
end

n, m = gets.split.map(&:to_i)
g = Hash[(1..n).map {|i| [i, []] }]
m.times do
  i, j = gets.split.map(&:to_i)
  g[i] << j
end

c = {}
g.each_strongly_connected_component do |sc|
  sc.sort!
  sc.each do |i|
    c[i] = sc
  end
end

(1..n).each do |i|
  puts c[i] * ' '
end


Measured memory_bytes: 10448
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

namespace B_ABC146
{
    class MainClass
    {

        static int[] s;

        public static void Main(string[] args)
        {
            s = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);
            string t = ReadLine();
            int n = s[0];
            string ans = "";
            for(int i = 0;i<t.Length;i++){
                int a = (int)t[i];
                //WriteLine(a);
                int aans= ((a+n-65)%26)+65;
                //WriteLine(aans);
                //WriteLine(Convert.ToChar(aans));
                ans = ans+Convert.ToChar(aans);
            }
            WriteLine(ans);
        }
    }
}


Measured memory_bytes: 36948
#include<bits/stdc++.h>
#define N 500000
using namespace std;
struct Node{
	int key;
	Node *right,*left,*par;
};
int n;
Node *root,*Nil;

void insert(int k){
	Node *y = Nil;
	Node *x = root;
	Node *z;

	z = (Node*)malloc(sizeof(Node));
	z->key = k;
	z->left = Nil;
	z->right = Nil;
	while(x != Nil){
		y = x;
		if(z->key < x->key) x = x->left; //左の子へ移動
		else x = x->right; //右の子へ移動
	}
	z->par = y;
	
	if(y == Nil) root = z; //Tが空の場合
	else{
	  if(z->key < y->key) y->left = z; //zを左の子にする
	  else y->right = z; //zをyの右の子にする
	 }
	}

void inorder(Node *u){
  if(u == Nil) return;
  inorder(u->left);
  cout << " " << u->key;
  inorder(u->right);
}

void preorder(Node *u){
  if(u == Nil) return;
  cout << " " << u->key;
  preorder(u->left);
  preorder(u->right);
}

int main(){
	int val=0;
	string str;
	
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> str;
		if(str == "insert"){
		  cin >> val;
		  insert(val);
		}else if(str == "print"){
		  inorder(root);
		  cout << endl;
		  preorder(root);
		  cout << endl;
		} 
	}
}



Measured memory_bytes: 26508
#include<stdio.h>

int main(){
	int m,f,r;//テストの点数
	
	scanf("%d %d %d",&m,&f,&r);//最初の入力
	
	while(!(m == -1 && f == -1 && r == -1)){
		if(m == -1 || f == -1){//中間試験、期末試験のいずれかを欠席した場合
			printf("F\n");
		}else{
			if(m + f >= 80){//中間と期末の合計が80以上
				printf("A\n");
			}else if(m + f >= 65){//中間と期末の合計が65以上80未満
				printf("B\n");
			}else if(m + f >= 50 || (m + f >= 30 && r >= 50)){/*中間と期末の合計が50以上65未満
															  又は30以上50未満でも再テストが50以上*/
				printf("C\n");
			}else if(m + f >= 30){//中間と期末の合計が50以上65未満
				printf("D\n");
			}else{//中間と期末の合計が30未満
				printf("F\n");
			}
		}
		scanf("%d %d %d",&m,&f,&r);//入力
	}
}



Measured memory_bytes: 2044
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

int gcd(const int a, const int b) {
	switch (b) {
	case 0: return a;
	default: return gcd(b, a % b);
	}
}
int main() {
	int n;
	std::cin >> n;
	std::vector<int> nums(n);
	for (auto &num : nums) std::cin >> num;
	int g = nums[0];
	for (auto i = 1; i < nums.size(); ++i) {
		g = gcd(nums[i], g);
	}
	std::vector<int> factor;
	auto max = std::ceil(std::sqrt(g));
	for (auto i = 1; i <= max; ++i) {
		if (g % i == 0) {
			factor.push_back(i);
			if (g / i > i) factor.push_back(g / i);
		}
	}
	std::sort(factor.begin(), factor.end());
	for (const auto f : factor) std::cout << f << std::endl;
}


Measured memory_bytes: 3152
#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;
typedef long long ll;
typedef double db;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
#define pb push_back
#define mp make_pair
#define MAX 1000000
#define mod 1000000007
#define all(_) _.begin(), _.end()
#define F first
#define S second
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
ll modex(ll a, ll b, ll m)
{
    ll ans = 1;
    for(; b > 0; b >>= 1, a = (a * a) % m)
        if(b & 1)
            ans = (ans * a) % m;
    return ans;
}
int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    ll n, i;
    string s;
    cin >> s;
    n = s.size();
    vll dp(13, 0);
    if(s[n - 1] != '?')
        dp[s[n - 1] - '0']++;
    else
    {
        for(i = 0; i < 10; i++)
            dp[i]++;
    }
    for(i = n - 2; i >= 0; i--)
    {
        vll b(13, 0);
        for(ll j = 0; j < 13; j++)
        {
            for(ll k = 0; k < 10; k++)
            {
                if(s[i] != '?' && (s[i] - '0') != k)
                    continue;
                ll val = (k * modex(10, n - 1 - i, 13) + j) % 13;
                b[val] = (b[val] + dp[j]) % mod;
            }
        }
        dp = b;
    }
    cout << dp[5] << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7ll;

int R,G,B,N;
int cnt;

int main(){

cin.tie(0);
ios::sync_with_stdio(false);

cin>>R>>G>>B>>N;

for(int r=0; r<=3000; r++){
	for(int g=0; g<=3000; g++){
		int n=N-(r*R+g*G);
		if(n<0) continue;
		else if(n==0) cnt++;
		else if(n%B==0) cnt++;
	}
}

cout<<cnt<<endl;

}



Measured memory_bytes: 256
n,m,k=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
a,b=[0],[0]
for i in range(n):
    a.append(a[i]+A[i])
for i in range(m):
    b.append(b[i]+B[i])

ans=0
j=m
for i in range(n+1):
    if a[i]>k:
        break
    time=a[i]+b[j]
    while time>k:
        j-=1
        time=a[i]+b[j]
    ans=max(ans,i+j)
print(ans)

Measured memory_bytes: 134072
N,H = map(int,input().split())
Ma = 1
B = []
for i in range(N):
    a,b = map(int,input().split())
    B.append(b)
    if a > Ma:
        Ma = a
B.sort()
B.reverse()
i = 0
Mb = B[0]
while Mb > Ma and H > 0:
  i += 1
  H -= Mb
  if i == N:
    Mb = 0
  else:
    Mb = B[i]
if H <= 0:
  print(i)
else:
  print(i+int(-(-H//Ma)))

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

int main() {
	int A, B, C;
	cin >> A >> B >> C;
	for (int i = 0; i < 1000000; i++) {
		if ((A * i - C) % B == 0) {
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
	return 0;
}


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

using namespace std;



typedef long long ll;

const ll nmax=200000;
const ll mod=1000000007;

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

void comint(){
 fac[0]=fac[1]=1;
 finv[0]=finv[1]=1;
 inv[1]=1;
 for(long i=2;i<nmax;i++){
  fac[i]=fac[i-1]*i%mod;
  inv[i]=mod-inv[mod%i]*(mod/i)%mod;
  finv[i]=finv[i-1]*inv[i]%mod;
}
}

auto com(auto n, auto k){
 if(n<k||n<0||k<0) return 0;
 return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}


int main(){
  ll n,m;
  cin >> n >> m;
 
 vector<ll> v;
  
   ll num=0;
  while(m%2==0){
      m/=2;
      num++;
  }
   if(num>0) v.push_back(num);
  
  for(ll i=3;i*i<=m;i+=2){
   if(m%i) continue;
    num=0;
    while(m%i==0){
      m/=i;
      num++;
  }
    v.push_back(num);
  }
  if(m!=1) v.push_back(1);
 
  
   ll ans=1;
  
  comint();
  
  for(auto x:v){
    ans*=com(x+n-1,x);                    
    ans%=mod;
  }
  
   cout << ans << endl;
 }


Measured memory_bytes: 4992
#include <iostream>
#include <vector>
using namespace std;
long long a[100010],b[50] = {},f[2][50];
int main(){
	long long i,j,n,k,x = 0,ans = 0;
	cin >> n >> k; k++;
	for(i=0;i<n;i++){
		long long c,res = 0;
		cin >> a[i];
		c = a[i];
		while(c>0){
			b[res] += c&1;
			c /= 2; res++;
		}
	}
	for(i=49;i>=0;i--){
		f[0][i] = b[i]*(1LL<<i);
		f[1][i] = (n - b[i])*(1LL<<i);
	}
	vector<int> v;
	while(k>0){
		v.push_back(k&1);
		k /= 2;
	}
	while(v.size()<41){
		v.push_back(0);
	}
	for(i=0;i<v.size();i++){
		if(!v[i]) continue;
		long long res = 0;
		for(j=0;j<i;j++){
			res += max(f[0][j],f[1][j]);
		}
		res += f[0][i];
		for(j=i+1;j<v.size();j++){
			res += f[v[j]][j];
		}
		ans = max(ans,res);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
// Sea the world.

#include <cmath>
#include <ctime>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <vector>
#include <string>
#include <bitset>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

using namespace std;

// SELF TEMPLATE CODE BGEIN

#define SZ(x) ((int)((x).size()))
#define OUT(x) printf(#x" %d\n", x)
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repf(i,a,b) for (int i = (a); i <= (b); ++i)
#define repd(i,a,b) for (int i = (a); i >= (b); --i)
#define repcase int t, Case = 1; for (scanf ("%d", &t); t; --t)

typedef long long int64;
typedef pair<int, int> pii;

int sgn(double x) { return (x > 1e-8) - (x < -1e-8); }
int count_bit(int x) { return x == 0? 0 : count_bit(x >> 1) + (x & 1); }

template<class T> inline void to_min(T &a, const T b) { if (b < a) a = b; }
template<class T> inline void to_max(T &a, const T b) { if (b > a) a = b; }

// SELF TEMPLATE CODE END

const int maxn = 100000 + 10;

int a[maxn], b[maxn];

void solve(int n, int m) {
  long long ret = 0;
  rep (i, n) {
    // scanf("%d", &a[i]);
    cin >> a[i];
    ret += a[i];
  }
  rep (i, m) {
    // scanf("%d", &b[i]);
    cin >> b[i];
    ret += b[i];
  }
  sort(a, a + n);
  sort(b, b + m);
  int cnt_b = 0;
  rep (i, n) {
    while (cnt_b < m && b[cnt_b] <= a[i]) ++cnt_b;
    ret += (long long)(m - cnt_b) * a[i];
  }
  int cnt_a = 0;
  rep (i, m) {
    while (cnt_a < n && a[cnt_a] < b[i]) ++cnt_a;
    ret += (long long)(n - cnt_a) * b[i];
  }
  cout << ret << endl;
}

int main() {
  ios::sync_with_stdio(false);

  int n, m;
  // string s;
  while (cin >> n >> m) {
    solve(n, m);
  }
  return 0;
}


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

int rel_l_l( double x0, double y0, double x1, double y1, double x2, double y2, double x3, double y3, double *x, double *y ) {
	double a, b, c, d;
	int rel;

	if ( x0 != x1 ) {
		a = ( y0 - y1 ) / ( x0 - x1 );
		b = ( x0 * y1 - x1 * y0 ) / ( x0 - x1 );
	}
	if ( x2 != x3 ) {
		c = ( y2 - y3 ) / ( x2 - x3 );
		d = ( x2 * y3 - x3 * y2 ) / ( x2 - x3 );
	}

	rel = 0;
	if ( x0 == x1 ) {
		*x = x0;
		if ( x2 == x3 )
			if ( x0 == x2 )
				rel = 2;
			else
				rel = 1;
		else {
			*y = c * *x + d;
			if ( y2 == y3 )
				rel = 3;
		}
	} else {
		if ( x2 == x3 ) {
			*x = x2;
			if ( y0 == y1 )
				rel = 3;
		} else
			if ( a == c )
				if ( b == d )
					rel = 2;
				else
					rel = 1;
			else {
				*x = ( -b + d ) / ( a - c );
				if ( fabs( a * c + 1.0 ) < 1e-12 )
					rel = 3;
			}
		*y = a * *x + b;
	}

	return rel;
}

int main( void ) {
	int q;

	scanf( "%d", &q );
	while ( q-- ) {
		int rel;
		double x0, y0, x1, y1, x2, y2, x3, y3, x, y;

		scanf( "%lf %lf %lf %lf %lf %lf %lf %lf", &x0, &y0, &x1, &y1, &x2, &y2, &x3, &y3 );

		rel = rel_l_l( x0, y0, x1, y1, x2, y2, x3, y3, &x, &y );

		printf( "%d\n", rel == 0 ? 0 : rel == 1 || rel == 2 ? 2 : 1 );
	}

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
random_device rnd;
mt19937 mt(rnd());

const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7;

int main()
{
    int n, m;
    cin >> n >> m;
    map<int, vector<int>> g;
    rep(i, m)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    VI ans(n, -1);
    deque<PII> que;
    que.push_back({0, -2});
    while (!que.empty())
    {
        deque<PII> next;
        while (!que.empty())
        {
            auto cur = que.front().first;
            auto par = que.front().second;
            //cerr << par + 1 << "=>" << cur + 1 << endl;
            que.pop_front();
            if (ans[cur] != -1)
            {
                continue;
            }
            ans[cur] = par;
            for (auto &&x : g[cur])
            {
                next.push_back({x, cur});
            }
        }
        //cerr << "**" << endl;
        que = next;
    }
    cout << "Yes" << endl;
    rep(i, 1, n)
    {
        cout << ans[i] + 1 << endl;
    }
    return 0;
}

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

int main(){
  int a,b,c;
  cin >> a >>b>>c;
  
  if((min(b,c)+a) > max(b,c) ){
    cout << "0" << endl;
  }
  else if( (min(b,c)+a) <= max(b,c)){
    cout << max(b,c)-(min(b,c)+a) <<endl;
  }
  

}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int


def solve(N: int, K: int):
    counts = [0] * (K+1)
    for i in range(K, 0, -1):
        c = pow(K//i, N, MOD)
        for j in range(i+i, K+1, i):
            c -= counts[j]
        counts[i] = c
    ans = 0
    for i, c in enumerate(counts):
        ans = (ans + (i * c) % MOD) % MOD
    print(ans)


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, K)

if __name__ == '__main__':
    main()


Measured memory_bytes: 74560
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

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

using namespace std;

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

    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    ll s = 0;
    Rep (i, N) {
        cin >> A[i];
        s += A[i];
    }

    sort(A.begin(), A.end());
    priority_queue<ll> koho;
    for (ll i = 1; i * i <= s; i++) {
        if (s % i == 0) {
            koho.push(i);
            koho.push(s/i);
        }
    }

    while (!koho.empty()) {
        ll now = koho.top();
        koho.pop();
        // cout << now << "\n";
        vector<ll> B = A;
        ll sub = 0;
        priority_queue<ll> amari;
        Rep (i, N) {
            B[i] %= now;
            sub += B[i];
            amari.push(B[i]);
        }
        while (sub > 0) {
            ll a = amari.top();
            amari.pop();
            a -= now;
            amari.push(a);
            sub -= now;
        }
        ll subans = 0;
        while (!amari.empty()) {
            ll b = amari.top();
            amari.pop();
            if (b > 0) subans += b;
        }
        // cout << subans << "\n";
        if (subans <= K) {
            cout << now << "\n";
            return 0;
        }

    }





}

Measured memory_bytes: 256
N, M = map(int, input().split())
l_max = 0
r_min = 10**5 + 1
for _ in range(M):
    l, r = map(int, input().split())
    l_max = max(l_max, l)
    r_min = min(r_min, r)
if r_min - l_max + 1 > 0:
    print(r_min - l_max + 1)
else:
    print("0")


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

int main() {
	int n, h, w;
	cin >> n >> h >> w;

	int ans = 0;
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		ans += (a >= h && b >= w);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3600
#include <stdio.h>
int main(void){
   int a,b,c,x,y=0;
   scanf("%d %d %d\n",&a,&b,&c);
   for(x=a; x <= b; x++){
       if(c%x==0){
           y++;
       }
   }
    printf("%d\n",y);
    return 0;
}



Measured memory_bytes: 2104
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define PI acos(-1)
#define Mod (int)1000000007
#define INFTY (int)INT_MAX
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Part(vec, b, e) vec.begin() + b, vec.begin() + e
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Count(vec, x) count(vec.begin(), vec.end(), x)
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define Find(vec, s) vec.find(s) != vec.end()

int main() {
	map<string, int> M;
	int q;
	cin >> q;
	Rep(i, q) {
		int n;
		cin >> n;
		if (n == 0) {
			string key;
			int x;
			cin >> key >> x;
			M[key] = x;
		}
		else if (n == 1) {
			string key;
			cin >> key;
			if (M.count(key)) cout << M.at(key) << endl;
			else cout << 0 << endl;
		}
		else if (n == 2) {
			string key;
			cin >> key;
			M.erase(key);
		}
		else if (n == 3) {
			string L, R;
			cin >> L >> R;
			for (auto itr = M.lower_bound(L); itr != M.end() && itr != M.upper_bound(R); itr++) {
				cout << get<0>(*itr) << " " << get<1>(*itr) << endl;
			}
		}
	}
	return 0;
}


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

int arr[203][203] , N , col[203] , dis[203];

signed main(){
	memset(col , -1 , sizeof(col));
	cin >> N;
	for(int i = 1 ; i <= N ; ++i) for(int j = 1 ; j <= N ; ++j){char c; cin >> c; arr[i][j] = c - '0';}
	col[1] = 0; queue < int > q; q.push(1);
	while(!q.empty()){
		int t = q.front(); q.pop();
		for(int j = 1 ; j <= N ; ++j)
			if(arr[t][j])
				if(col[j] != -1 && col[j] == col[t]){puts("-1"); return 0;}
				else if(col[j] == -1){col[j] = col[t] ^ 1; q.push(j);}
	}
	int ans = 0;
	for(int i = 1 ; i <= N ; ++i){
		memset(dis , 0 , sizeof(dis)); q.push(i); dis[i] = 1; int mx = 1;
		while(!q.empty()){
			int t = q.front(); q.pop(); mx = max(mx , dis[t]);
			for(int j = 1 ; j <= N ; ++j) if(arr[t][j] && !dis[j]){dis[j] = dis[t] + 1; q.push(j);}
		}
		ans = max(ans , mx);
	}
	cout << ans; return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

const int N = 1e5+10;
int n,m,v,p,a[N];

inline bool check(int x){
	if (x<=p) return 1;
	if (a[x]+m<a[p]) return 0;
	ll s=0;
	For(i,p,n) if (i!=x) s+=min(m,(a[x]+m)-a[i]);
	return s>=1ll*m*(v-p);
}

int main(){
	n=read(),m=read(),v=read(),p=read();
	For(i,1,n) a[i]=read();
	sort(a+1,a+1+n),reverse(a+1,a+1+n);
	int l=1,r=n,ans=0;
	while (l<=r){
		int mid=l+r>>1;
		if (check(mid)) ans=mid,l=mid+1;
			else r=mid-1;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 4120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXSIZE=10000020;
const int mod=1000000007;
int bufpos;
char buf[MAXSIZE];
#define NEG 0
void init(){
	//freopen("loop.in","r",stdin);
	//freopen("loop.out","w",stdout);
	buf[fread(buf,1,MAXSIZE,stdin)]=' ';
	bufpos=0;
}
#if NEG
int readint(){
	bool isneg;
	int val=0;
	for(;!isdigit(buf[bufpos]) && buf[bufpos]!='-';bufpos++);
	bufpos+=(isneg=buf[bufpos]=='-');
	for(;isdigit(buf[bufpos]);bufpos++)
		val=val*10+buf[bufpos]-'0';
	return isneg?-val:val;
}
#else
int readint(){
	int val=0;
	for(;!isdigit(buf[bufpos]);bufpos++);
	for(;isdigit(buf[bufpos]);bufpos++)
		val=val*10+buf[bufpos]-'0';
	return val;
}
#endif
char readchar(){
	for(;isspace(buf[bufpos]);bufpos++);
	return buf[bufpos++];
}
int readstr(char* s){
	int cur=0;
	for(;isspace(buf[bufpos]);bufpos++);
	for(;!isspace(buf[bufpos]);bufpos++)
		s[cur++]=buf[bufpos];
	s[cur]='\0';
	return cur;
}
ll h[500005],pw[500005];
void work(char *s,bool *ans){
	int n=strlen(s+1);
	pw[0]=1;
	for(int i=1;i<=n;i++){
		h[i]=(h[i-1]*237+s[i]-'a'+1)%mod;
		pw[i]=(pw[i-1]*237)%mod;
	}
	for(int i=1;i<=n;i++)
		for(int j=i*2;j<=n;j+=i){
			//[1,j-i],[i+1,j]
			ll v=(h[j]-h[i]*pw[j-i])%mod;
			if (v<0)
				v+=mod;
			if (v==h[j-i])
				ans[j]=1;
			else break;
		}
}
char s[500005];
bool f1[500005],f2[500005];
int main(){
	init();
	int n=readstr(s+1);
	// printf("%d\n",n);
	bool flag=1;
	for(int i=2;i<=n;i++)
		if (s[i]!=s[1]){
			flag=0;
			break;
		}
	if (flag){
		printf("%d\n1\n",n);
		return 0;
	}
	work(s,f1);
	if (!f1[n]){
		printf("1\n1\n");
		return 0;
	}
	reverse(s+1,s+n+1);
	work(s,f2);
	int ans=0;
	for(int i=1;i<n;i++)
		if (!f1[i] && !f2[n-i])
			ans++;
	printf("2\n%d\n",ans);
}

Measured memory_bytes: 10496
import java.util.Scanner;

class Problem {
    private int N;
    private int Q;
    private String S;
    private int[] rs;
    private int[] ls;
    private int[] memo;
    private Scanner sc;

    Problem() {
        sc = new Scanner(System.in);
        N = sc.nextInt();
        Q = sc.nextInt();
        S = sc.next();
        ls = new int[Q];
        rs = new int[Q];
        for (int i = 0; i < Q; i++) {
            ls[i] = sc.nextInt();
            rs[i] = sc.nextInt();
        }
    }

    void solve() {
        memo = new int[N];

        int c = 0;
        for (int i = 1; i < N; i++) {
            if (S.charAt(i - 1) == 'A' && S.charAt(i) == 'C') {
                c += 1;
            }
            memo[i] = c;
        }

        for (int i = 0; i < Q; i++) {
            int l = ls[i] - 1;
            int r = rs[i] - 1;

            int ans = memo[r] - memo[l];
            System.out.println(ans);
        }
    }
}

public class Main {
    public static void main(String[] args) {
        new Problem().solve();
    }
}


Measured memory_bytes: 81736
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <cmath>

using namespace std;

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

const ll mod = 1000000007;

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

  double a, b, h, m;
  cin >> a >> b >> h >> m;

  pair<double, double> pa = pair<double, double>(cos((h * 60.0 + m) / 720.0 * 3.141592653589793238 * 2.0) * a, sin((h * 60.0 + m) / 720.0 * 3.141592653589793238 * 2.0) * a);
  pair<double, double> pb = pair<double, double>(cos(m / 60.0 * 3.141592653589793238 * 2.0) * b, sin(m / 60.0 * 3.141592653589793238 * 2.0) * b);

  double ans = sqrt((pa.first - pb.first) * (pa.first - pb.first) + (pa.second - pb.second) * (pa.second - pb.second));

  cout << setprecision(16) << ans << endl;

  return 0;
}


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

#define f first 
#define s second 
#define pb push_back               
#define mp make_pair 

using namespace std;                    

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int N = (int)1e5 + 123, mod = (int)1e9 + 7;

int n, l, a[N];
int main(){    
	cin >> n >> l;
	for(int i = 0; i < n; i++)
		cin >> a[i];
	for(int i = 1; i < n; i++){
		if(a[i] + a[i - 1] >= l){
			vector< int > v; 
			v.pb(i - 1);
			for(int j = i; j + 1 < n; j++)
				v.pb(j);
			for(int j = i - 2; j >= 0; j--)
				v.pb(j);
			reverse(v.begin(),v.end());
			cout << "Possible" << endl;
			for(auto x: v)
				cout << x + 1<< endl;
			return 0;
		}
	}
	cout << "Impossible" ;
	return 0;
}


Measured memory_bytes: 1784
#include <iostream>
#include <string>
#include <iomanip>
#include <vector>

using namespace std;
int main(void){

    string s;
    cin >> s;
    
    int zero_start_count = 0;
    int one_start_count = 0;
    for(int i=0; i<s.size(); i++) {
        if(i%2==0) {
            if(s.substr(i,1) == "0") {
                one_start_count++;
            }
            if(s.substr(i,1) == "1") {
                zero_start_count++;
            }
        }
        else {
            if(s.substr(i,1) == "0") {
                zero_start_count++;
            }
            if(s.substr(i,1) == "1") {
                one_start_count++;
            }
        }
    }
    
    if(one_start_count > zero_start_count) cout << zero_start_count << endl;
    else cout << one_start_count << endl;

    return 0;

}


Measured memory_bytes: 512
N = int(input())
AB = [list(map(int, input().split())) for _ in range(N)]

AB.sort(key = lambda x: x[1])

time = 0
ans = "Yes"
for ab in AB:
  time += ab[0]
  if time > ab[1]:
    ans = "No"
    break
print(ans) 

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

// マクロ //
#define rep(v,times) for(int v = 0; v < (int)(times); v++)
#define req(v,first,endplus1) for(int v = first; v < (int)(endplus1); v++)
#define all(x) x.begin(), x.end()
#define sort(x) sort(all(x))
#define uniq(x) x.erase(unique(all(x)), x.end())
#define vsum(x) accumulate(all(x), 0)
#define cou(x) cout << x << endl
#define y() cout << "Yes" << endl
#define n() cout << "No" << endl
#define Y() cout << "YES" << endl
#define N() cout << "NO" << endl
#define x2(x) (x) * (x)

// 型エイリアス //
using lint = long long;
using pii = pair<int, int>;
using vpii = vector<pii>;
using plili = pair<lint, lint>;
using vplili = vector<plili>;
using vi = vector<int>;
using vli = vector<lint>;
using vc = vector<char>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vi>;
using vvli = vector<vli>;
using vvb = vector<vb>;
using vvc = vector<vc>;
using vvs = vector<vs>;
using mii = map<int, int>;
using mili = map<int, lint>;
using mci = map<char, int>;
using mcli = map<char, lint>;
using msi = map<string, int>;
using msli = map<string, lint>;


// 関数 //
template<class T, class Q> lint gcd_(T a, Q b) {
    int t;
    while (b != 0) {
        t = a % b;
        a = b;
        b = t;
    }
    return a;
}

template<class T, class Q> lint lcm_(T a, Q b) {
    return a * b / gcd_(a, b);
}

template<class T, class Q> double distance(T a, Q b) {
    double dist;
    dist = sqrt(x2(a.first - b.first) + x2(a.second - b.second));
    return dist;
}

lint perm(int a) {
    lint perm = 1;
    for (int i = a; i >= 1; i--) {
        perm *= i;
    }
    return perm;
}

lint combination(int n, int m) {
    long double c = 1;
    for (int i = n, k = 1; i > m; i--, k++) {
        c *= i;
        c /= k;
    }
    return (lint)c;
}

template<class T, class Q> inline bool chmin(T& a, Q b) {
    if (a > b) { 
        a = b;
        return true; 
    }
    return false;
}

template<class T, class Q> inline bool chmax(T& a, Q b) {
    if (a < b) { 
        a = b; 
        return true; 
    }
    return false;
}

// 定数 //
const double pi = acos(-1);
const int mod = 1000000007;
const int inf = 1045141919;
const lint linf = ((1LL << 62) - 1);
const int dx4[4] = { 1,0,-1,0 };
const int dy4[4] = { 0,1,0,-1 };
const int dx8[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy8[8] = { 0,1,1,1,0,-1,-1,-1 };

// End of Template //



int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
        
    lint N, D;
    cin >> N >> D;
    int cnt = 0;
    rep(i, N) {
        lint a, b;
        cin >> a >> b;
        if (a * a + b * b <= D * D) cnt++;
    }
    cou(cnt);

}

Measured memory_bytes: 3652
#include <iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

char get(int a,int b,int c){
	if(a==100||b==100||c==100 || a+b>=180 || a+b+c >= 240)return 'A';
	if(a+b+c>=210 || (a+b+c>=150&&(a>=80||b>=80)))return 'B';
	return 'C';
}
int main(){
	int n;
	while(cin >> n , n){
		rep(i,n){
			int a,b,c;
			cin >> a >> b >> c;
			cout << get(a,b,c) << endl;
		}
	}
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

int main() {
  ll H, W;
  cin >> H >> W;

  ll ans = H * W;

  for (ll i = 1; i < H; i++) {
    ll h = H - i;
    if (h > 1) {
      vector<ll> s(3);
      s[0] = i * W;
      s[1] = h / 2 * W;
      s[2] = (h - h / 2) * W;
      sort(all(s));
      ans = min(ans, s[2] - s[0]);
    }
    if (W > 1) {
      vector<ll> s(3);
      s[0] = i * W;
      s[1] = h * (W / 2);
      s[2] = h * (W - W / 2);
      sort(all(s));
      ans = min(ans, s[2] - s[0]);
    }
  }

  for (ll i = 1; i < W; i++) {
    ll w = W - i;
    if (w > 1) {
      vector<ll> s(3);
      s[0] = i * H;
      s[1] = w / 2 * H;
      s[2] = (w - w / 2) * H;
      sort(all(s));
      ans = min(ans, s[2] - s[0]);
    }
    if (H > 1) {
      vector<ll> s(3);
      s[0] = i * H;
      s[1] = w * (H / 2);
      s[2] = w * (H - H / 2);
      sort(all(s));
      ans = min(ans, s[2] - s[0]);
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R;


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

	cin >> N;
	vector<pair<long long int, int>>p(N);
	for (int i = 0; i < N; i++) {
		cin >> p[i].first;
		p[i].second = i;
	}
	sort(p.begin(), p.end());
	set<long long int>st;
	set<long long int>rev_st;
	st.insert(N);
	rev_st.insert(1);
	long long int ans = 0;
	for (int i = 0; i < N; i++) {
		auto it = st.upper_bound(p[i].second);
		auto itt = rev_st.upper_bound(-p[i].second);
		//cout << *it << " " << *itt << endl;
		ans += ((*it) - p[i].second)*((*itt) + p[i].second)*p[i].first;
		st.insert(p[i].second);
		rev_st.insert(-p[i].second);
	}
	cout << ans << endl;
	return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0)
#define mapmax(v) v.rbegin()->first
#define mapmin(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const int mod=1000000007;
const int mod2=998244353;

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

template<class T>
inline bool chmax(T& a, T b){if(a<b){a=b;return true;} return false;}

template<class T>
inline bool chmin(T& a, T b){if(a>b){a=b;return true;} return false;}

void YES(bool b) {cout << (b?"YES\n":"NO\n");}
void Yes(bool b) {cout << (b?"Yes\n":"No\n");}
void yes(bool b) {cout << (b?"yes\n":"no\n");}
void Yay(bool b) {cout << (b?"Yay!\n":":(\n");}

long long powmod(long long a,long long b){
    long long c=1;
    while(b>0){
        if(b&1) c=a*c%mod;
        a=a*a%mod;
        b>>=1;
    }
    return c;
}

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	string s,t="",pre="";
	ll ans=0;
	cin >> s;
	rep(i,SIZE(s)){
		t+=s[i];
		if(t!=pre){
			ans++;
			pre=t;
			t="";
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))


INF = float("inf")
MOD = 10**9 + 7


def main():
    a = INT()
    print(a + a**2 + a**3)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9200
N, M = map(int, input().split())
Mat = [[0 for i in range(N)] for i in range(M)]
for i in range(M):
  sw = list(map(int, input().split()))
  for j in range(1, sw[0]+1):
    Mat[i][sw[j]-1] = 1
p = list(map(int, input().split()))
pat = 2**N
cnt = 0
for i in range(pat):
  A = []
  for j in range(N):
    A.append(i%2)
    i //= 2
  B = [sum(A[i]*Mat[j][i] for i in range(N)) % 2 for j in range(M)]
  if B == p:
    cnt += 1
print(cnt)

Measured memory_bytes: 3188
#include<iostream>
#include<cmath>

using namespace std;
typedef unsigned long long ULL;
bool check(int h, int w, char map[50][51]);
int main(){
	int h,w;
	int i;
	bool flag;
	char map[50][51];
	cin >> h >> w;
	for(i=0;i<h;i++){
		cin >> map[i];
	}
	flag = check(h,w,map);
	if(flag == true){
		cout << "Yes" ;
	}else{
		cout << "No";
	}
	return 0;
}
bool check(int h, int w, char map[50][51]){
	int i,j;
	bool flag;
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			flag = false;
			if( map[i][j] == '.' ){
				continue;
			}
			if( i > 0 && map[i-1][j] == '#'){
				flag = true;
			}
			if( i+1 < h && map[i+1][j] == '#'){
				flag = true;
			}
			if( j>0 && map[i][j-1] == '#'){
				flag = true;
			}
			if( j+1<w && map[i][j+1] == '#'){
				flag = true;
			}
			if( flag == false){
				return false;
			}
		}
	}
	
	return true;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    
using namespace std;
typedef long long ll;
    
int main()
{
    string S;
    cin >> S;

    int count = 0;
    for (int i = 0; i < S.length(); i++) {
        if (S[i] == 'o') {
            count += 1;
        }
    }
    cout << 700 + (count * 100);
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define pf push_front
#define in insert
#define ff first
#define ss second
#define mp make_pair
#define int long long
#define uint unsigned long long
#define rep(i,x,m) for(int i=x;i<m;i++)
#define repr(i,x,m) for(int i=x;i>=m;i--)
#define MOD 1000000007
#define endl "\n"
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define vi vector<int>
#define vs vector<string>
#define print(v) for(int i=0;i<v.size();i++) cout<<v[i]<<" ";cout<<endl
using namespace std;
#define noob ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int fac[2000005]={0};
void factorial(){ fac[0]=1; fac[1]=1; for(int i=2;i<200005;i++) fac[i]=((i%MOD)*(fac[i-1]%MOD))%MOD;}
int power(int n,int m)
{int p=1;if(m==0)return 1;p=(power(n,m/2)%MOD);p=(p%MOD*p%MOD)%MOD;
return(m&1?((p%MOD*n%MOD)%MOD):(p%MOD));}
int ncr(int n,int r){return ((fac[n]*power(fac[r],MOD-2))%MOD*power(fac[n-r],MOD-2))%MOD;}

void ram5564()
{
    string s;
    cin>>s;
    for(auto x:s)
    {
    	if(x=='7')
    	{
    		cout<<"Yes";return;
    	}
    }
    cout<<"No";
}

signed main()
{
		noob
		// #ifndef ONLINE_JUDGE
  //    	freopen("input.txt","r",stdin);
  //    	freopen("output.txt","w",stdout);
  //    	#endif   
        
        int t=1;
        //cin>>t;
        while(t--)
        ram5564();
        return 0;
}

Measured memory_bytes: 3652
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define ll long long
#define REP(a,b,c) for(int a=b;a<=c;a++)
#define re register
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
typedef pair<int,int> pii;
#define mp make_pair
inline int gi()
{
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
const int N=100010,Inf=1e9+10;
int n,A[N];
int Solve(int b)
{
	int s=0,mn=Inf;
	for(int i=1;i<=n;i++)s+=A[i]&1,mn=min(mn,A[i]);
	if((n-s)&1)return b;if(s>1||mn==1)return b^1;
	int d=0;
	for(int i=1;i<=n;i++){if(A[i]&1)A[i]--;d=__gcd(A[i],d);}
	for(int i=1;i<=n;i++)A[i]/=d;
	return Solve(b^1);
}
int main()
{
	n=gi();
	for(int i=1;i<=n;i++)A[i]=gi();
	puts(Solve(1)?"First":"Second");
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>
#include <string>
#include <set>
#include <map>

using namespace std;

typedef long long ll;

int main()
{
    //freopen("/Users/qianjay/Documents/apac/in", "r", stdin);
    char s1[1024],s2[1024];
    scanf("%s%s",s1,s2);
    int l1=(int)strlen(s1);
    int l2=(int)strlen(s2);
    if(l1!=l2)
    {
        if(l1<l2) cout<<"LESS"<<endl;
        else cout<<"GREATER"<<endl;
        return 0;
    }
    if(strcmp(s1, s2)<0)
    {
        cout<<"LESS"<<endl;
    }
    else if(strcmp(s1, s2)==0)cout<<"EQUAL"<<endl;
    else cout<<"GREATER"<<endl;
    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
liners = {i: [] for i in range(1, n+1)}

for _ in range(m):
    a, b = map(int, input().split())
    liners[a].append(b)
    liners[b].append(a)

for l in liners[1]:
    if n in liners[l]:
        print('POSSIBLE')
        break
else:
    print('IMPOSSIBLE')


Measured memory_bytes: 55396
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  string a,b;cin >> a >> b;
  a += b;
  int c = atoi(a.c_str());
  YesNo(c == (int)sqrt(c) * sqrt(c));
  return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
def preorder(here, conn, chain):
    if here == -1:
        return
    chain.append(here)
    if conn[here]:
        preorder(conn[here][0], conn, chain)
        preorder(conn[here][1], conn, chain)

def inorder(here, conn, chain):
    if here == -1:
        return
    if conn[here]:
        inorder(conn[here][0], conn, chain)
        chain.append(here)
        inorder(conn[here][1], conn, chain)

def postorder(here, conn, chain):
    if here == -1:
        return
    if conn[here]:
        postorder(conn[here][0], conn, chain)
        postorder(conn[here][1], conn, chain)
    chain.append(here)

query = int(input())
connect = defaultdict(list)
in_v = [0 for n in range(query + 1)]
for _ in range(query):
    here, left, right = (int(n) for n in input().split(" "))
    connect[here] = [left, right]
    in_v[left] += 1
    in_v[right] += 1
for i in range(query):
    if not in_v[i]:
        root = i
        break
preo = []
ino = []
posto = []
preorder(root, connect, preo)
inorder(root, connect, ino)
postorder(root, connect, posto)

print("Preorder")
print("", end = " ")
print(*preo)
print("Inorder")
print("", end = " ")
print(*ino)
print("Postorder")
print("", end = " ")
print(*posto)

Measured memory_bytes: 8108