akhauriyash/Code-Regression huggingface dataset:
from bisect import bisect_left,bisect
a,b,q = map(int,input().split())
jin = [-10**16]
for i in range(a):
    jin.append(int(input()))
jin.append(10**16)
tera = [-10**20]
for i in range(b):
    tera.append(int(input()))
tera.append(10**20)
for i in range(q):
    x = int(input())
    j = bisect(jin,x)
    t = bisect(tera,x)
    j1 = jin[j]
    j2 = jin[j-1]
    t1 = tera[t]
    t2 = tera[t-1]
    ans = min(abs(x-j1)+abs(j1-t1),abs(x-j1)+abs(j1-t2),abs(x-j2)+abs(j2-t1),abs(x-j2)+abs(j2-t2))
    ans = min(ans,abs(x-t1)+abs(t1-j1),abs(x-t1)+abs(t1-j2),abs(x-t2)+abs(t2-j1),abs(x-t2)+abs(t2-j2))
    print(ans)

Measured memory_bytes: 16916
#include<iostream>
#include<cstdio>
using namespace std;
bool cross(double ax, double ay, double bx, double by, double cx, double cy, double dx, double dy) {
	double ta = (cx - dx) * (ay - cy) + (cy - dy) * (cx - ax);
	double tb = (cx - dx) * (by - cy) + (cy - dy) * (cx - bx);
	double tc = (ax - bx) * (cy - ay) + (ay - by) * (ax - cx);
	double td = (ax - bx) * (dy - ay) + (ay - by) * (ax - dx);
	return tc * td <= 0 && ta * tb <= 0;
}
signed main(){
	double x1,y1,x2,y2,x3,y3,xp,yp;
	while( scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3, &xp, &yp) != EOF ){
		double xc = ( x1 + x2 + x3 )/3;
		double yc = ( y1 + y2 + y3 )/3;
		if (cross(x1, y1, x2, y2, xc, yc, xp ,yp) ||
				cross(x2, y2, x3, y3, xc, yc, xp ,yp) ||
				cross(x3, y3, x1, y1, xc, yc, xp ,yp)){
			cout << "NO" << endl;
		}else cout << "YES" << endl;
	}
	return 0;
}

Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define llinf 1e17
#define nllinf -4e18
#define vll vector<ll>
#define sll set<ll>
#define pll pair<ll,ll> 
#define vpll vector<pair<ll,ll > > 
#define repup(a,b,i) for(i=a;i<=b;i++)
#define repdown(a,b,i) for(i=b; i>=a; i--)
#define repit(v,it) for(it=v.begin(); it!=v.end(); it++)
#define itall(v) v.begin(),v.end()
#define pb push_back
#define pf push_front
#define mp make_pair
#define fr first
#define sc second
#define err(n) cout<<n<<" ";
#define t1 cout<<",";

void err_mask(ll n){
	if(n==0)return;
	while(n){
		cout<<n%2;
		n/=2;
	}
	cout<<" ";
}
ll MOD= 98244353;

void add_self (ll& a, ll b){
	a+= b;
	a%=MOD;
}

void sub_self (ll& a, ll b){
	a-=b;
	a= ((a%MOD)+MOD)%MOD;
}

ll mul(ll a, ll b){
	a*=b;
	a%=MOD;
	return a;
}

void min_self(double& a, double b){
	a= min(a,b);
}


bool conflict(pll a, pll b){
	if(b.fr> a.sc)return 0;
	else return 1;
}


int main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll i,j;

ll n,m,l;cin>>n>>m>>l;
ll g[n+5][n+5];
repup(0,n+4,i){
	repup(0,n+4,j)g[i][j]=0;
}
repup(0,m-1,i){
	ll a,b,c;
	cin>>a>>b>>c;
	if(c<=l){
		g[a][b]=c;
		g[b][a]=c;
	}
}

ll dp[n+5][n+5];
ll dist[n+5][n+5];
repup(0,n+4,i){
	repup(0,n+4,j){
		dp[i][j]=llinf;
		dist[i][j]=llinf;
	}
}
repup(0,n,i){
	repup(0,n,j){
		if(g[i][j]){
			dp[i][j]=1;
			dist[i][j]=g[i][j];
			
		}
		if(i==j){
			dp[i][j]=0;
			dist[i][j]=0;
		}
	}
}
ll k;

repup(1, n,k){
	repup(1,n,i){
		repup(1,n,j){
			
			dist[i][j]= min(dist[i][j], dist[i][k]+ dist[k][j]);
		}
	}
}
repup(0,n,i){
	repup(0,n,j)if(dist[i][j]<=l)dp[i][j]=1;
}
repup(1, n,k){
	repup(1,n,i){
		repup(1,n,j){
			
			dp[i][j]= min(dp[i][j], dp[i][k]+ dp[k][j]);
		}
	}
}



ll q;
cin>>q;
while(q){
	q--;
	ll s,t;cin>>s>>t;
	if(dp[s][t]== llinf)cout<<-1<<'\n';
	else cout<<dp[s][t]-1<<'\n';
}
}
	

Measured memory_bytes: 2688
n=int(input())
f=[0]*(10**5)
for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            cal=x**2+y**2+z**2+x*y+x*z+y*z
            f[cal]+=1
for i in range(1,n+1):
    print(f[i])

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

#define FOR(a,b,c) for (int a=(b);a<(c);++a)
#define REP(i,n) FOR(i,0,n)
#define ll long long
#define pii pair<ll, ll>
#define x first
#define y second
#define pb push_back
#define lf double

using namespace std;

const int MAX = (int)1e6 + 5;

ll n;
pii p[MAX];
vector<ll> v;

int main(){
	scanf ("%lld",&n);
	REP(i,n) scanf ("%lld%lld",&p[i].x,&p[i].y);
	if (!(n&1)){
		REP(i,n) p[i].x*=2,p[i].y*=2;
	}
	REP(i,n) v.pb(p[i].x);
	sort(v.begin(),v.end());
	ll lo,hi;
	if (n&1){
		lo=v[n/2];
	}
	else{
		lo=((ll)v[n/2-1]+v[n/2])/2;
	}
	v.clear();
	REP(i,n) v.pb(p[i].y);
	sort(v.begin(),v.end());
	if (n&1){
		hi=v[n/2];
	}
	else{
		hi=((ll)v[n/2-1]+v[n/2])/2;
	}
	printf ("%lld\n",hi-lo+1);
	
	return 0;
}


Measured memory_bytes: 8424
/*
 * 17-06-21_ARC076_D.cpp
 *
 *  Created on: 2017/06/24
 *      Author: ryoma
 */
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>

using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

struct UnionFind {
	vector<int> data;
	UnionFind(int size) :
			data(size, -1) {
	}
	bool unionSet(int x, int y) {
		x = root(x);
		y = root(y);
		if (x != y) {
			if (data[y] < data[x])
				swap(x, y);
			data[x] += data[y];
			data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};
typedef int Weight;
struct Edge {
	int src, dst;
	Weight weight;
	Edge(int src, int dst, Weight weight) :
			src(src), dst(dst), weight(weight) {
	}
};
bool operator <(const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
			e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;

pair<Weight, Edges> minimumSpanningForest(const Graph &g) {
	int n = g.size();
	UnionFind uf(n);
	priority_queue<Edge> Q;
	REP(u, n)
		FOR(e, g[u])
			if (u < e->dst)
				Q.push(*e);

	Weight total = 0;
	Edges F;
	while (F.size() < n - 1 && !Q.empty()) {
		Edge e = Q.top();
		Q.pop();
		if (uf.unionSet(e.src, e.dst)) {
			F.push_back(e);
			total += e.weight;
		}
	}
	return pair<Weight, Edges>(total, F);
}

int N;
pair<int,int> x[100010], y[100010];
int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> x[i].first >> y[i].first;
		x[i].second =y[i].second= i;

	}
	Graph g(N);
	sort(x,x+N);
	sort(y,y+N);
	for(int i=0;i<N-1;i++){
		g[x[i].second].push_back(Edge(x[i].second,x[i+1].second,x[i+1].first-x[i].first));
		g[x[i+1].second].push_back(Edge(x[i+1].second,x[i].second,x[i+1].first-x[i].first));
		g[y[i].second].push_back(Edge(y[i].second,y[i+1].second,y[i+1].first-y[i].first));
		g[y[i+1].second].push_back(Edge(y[i+1].second,y[i].second,y[i+1].first-y[i].first));
	}
	pair<Weight, Edges> ans = minimumSpanningForest(g);
	cout << ans.first << endl;
	return 0;
}


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

int main()
{
	string s;
	cin>>s;
	bool flag=true;
	for (int i=0; i<s.length(); i++)
	{
		if ((i+1)%2==0)
		{
			if (s[i]=='R')
			{
				cout<<"No\n";
				return 0;
			}
		}
		else
		{
			if(s[i]=='L')
			{
				cout<<"No\n";
				return 0;
			}
		}
	}
	cout<<"Yes\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
int main(){
  string c1,c2,c3;
  cin >> c1 >> c2 >> c3;
  transform(c1.begin(), c1.end(), c1.begin(), ::toupper);
  transform(c2.begin(), c2.end(), c2.begin(), ::toupper);
  transform(c3.begin(), c3.end(), c3.begin(), ::toupper);
  cout << c1.at(0) << c2.at(0) << c3.at(0) << endl;
}

  


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}

const int INF = 1e9, MOD = 998244353; /// think
const ll LINF = 1e15;

const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }

main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    string s;
    cin >> s;
    int l = 0, r = n;
    while (l < r) {
        int mid = (l + r + 1) >> 1;
        map <string, int> posl, posr;
        for (int i = 0; i + mid - 1 < n; i++) {
            posr[s.substr(i, mid)] = i;
            if (!posl.count(s.substr(i, mid))) {
                posl[s.substr(i, mid)] = i;
            }
        }
        bool ok = false;
        for (auto &i : posl) {
            if (i.y + mid <= posr[i.x]) {
                ok = true;
                break;
            }
        }
        if (ok) l = mid;
        else r = mid - 1;
    }
    cout << r << '\n';
}


Measured memory_bytes: 16216
inp = []
r, c = map(int, input().split())
for i in range(r):
    inp.append(list(map(int, input().split())))
for i in range(r):
    inp[i].append(sum(inp[i]))
last = []
for i in range(c+1):
    s = 0
    for j in range(r):
        s += inp[j][i]
    last.append(s)
inp.append(last)
for l in inp:
    print(' '.join(map(str, l)))


Measured memory_bytes: 5700
#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;
#ifdef TEST
#define getchar_unlocked _getchar_nolock
#endif
#define int long long
#define ins insert
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define pp pop
#define ppb pop_back
#define ppf pop_front
#define eb emplace_back
#define g0(a) get<0>(a)
#define g1(a) get<1>(a)
#define g2(a) get<2>(a)
#define g3(a) get<3>(a)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long double ld;
typedef long long ll;
typedef tree<pair<int, int>, null_type, less<pair<int, int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	set<string> s;
	string str;
	cin >> n;
	while (n--) {
		cin >> str;
		s.insert(str);
	}
	cout << s.size() << '\n';
}

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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

int main()
{
  ll n;
  bool contin = true;

  cin >> n;

  vector <string> shiri(n);
  forll(i, 0, n){
	cin >> shiri[i];
	forll(j, 0, i){
	  if(shiri[i] == shiri[j])
		contin = false;
	}
	if (i!=0){
	  if (shiri[i-1][shiri[i-1].size() - 1] != shiri[i][0])
		contin = false;
	}
	
	if(contin == false)
	  break;
  }
  if (contin == true)
	cout << "Yes" << endl;
  else
	cout << "No" << endl;
}


Measured memory_bytes: 256
package main
import . "fmt"
func main() {
  var n,m,idx,dst,tmp int
  var a,b,c,d []int
  Scan(&n,&m)
  a = make([]int,n)
  b = make([]int,n)
  c = make([]int,m)
  d = make([]int,m)
  for i:=0;i<n;i++ {
    Scan(&a[i],&b[i])
  }
  for i:=0;i<m;i++ {
    Scan(&c[i],&d[i])
  }
  for j:=0;j<n;j++ {
    idx = 0
    dst = 2000000000
    for i:=0;i<m;i++ {
      tmp = abs(c[i]-a[j]) + abs(d[i]-b[j])
      if dst > tmp {
        dst = tmp
        idx = i+1
      }
    }
    Println(idx)
  }
}
func abs(x int) int {
  if x < 0 {
    return -x
  } else {
    return x
  }
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

int MaximumProfit(vector<int> A,int n)
{
	int min = A[0];
	int max = -1000000000;
	for(int i=1;i<n;i++){
		max = std::max(max,A[i]-min);
		min = std::min(A[i],min);
	}
	return max;
}

int main()
{	
	int n;
	cin >> n;
	
	vector<int> A;
	A.resize(n);

	for(int i=0;i<n;i++)cin >> A[i];
	
	cout << MaximumProfit(A,n) << endl;
	
	return 0;
}

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

using namespace std;

struct Node {
    int key;
    Node *parent;
    Node *left;
    Node *right;
};

class BinarySearchTree {
private:
    Node *root = nullptr;
public:
    BinarySearchTree() {}

    BinarySearchTree(int key)
    {
        insert(key);
    }

    void insert(int key)
    {
        /* Nodeの準備 */
        Node *node = new Node;
        node->key = key;
        node->left = nullptr;
        node->right = nullptr;

        /* 根がNULL(木が空)の場合 */
        if (root == nullptr)
        {
            root = node;
            return;
        }

        Node *parent = root;
        while (true)
        {
            if (node->key <= parent->key)
            {
                if (parent->left == nullptr)
                {
                    parent->left = node;
                    node->parent = parent;
                    break;
                } else
                    parent = parent->left;
            } else
            {
                if (parent->right == nullptr)
                {
                    parent->right = node;
                    node->parent = parent;
                    break;
                } else
                    parent = parent->right;
            }
        }
    }

    void inParse(Node *node)
    {
        if (node != nullptr)
        {
            inParse(node->left);
            cout << " " << node->key;
            inParse(node->right);
        }
    }

    void preParse(Node *node)
    {
        if (node != nullptr)
        {
            cout << " " << node->key;
            preParse(node->left);
            preParse(node->right);
        }
    }

    void print()
    {
        inParse(root);
        cout << endl;
        preParse(root);
        cout << endl;
    }
};

int main()
{
    int m;
    cin >> m;
    BinarySearchTree tree;
    string command;
    int key;
    for(int i = 0; i < m; i++)
    {
        cin >> command;
        if(command == "insert")
        {
            cin >> key;
            tree.insert(key);
        }
        else if(command == "print")
            tree.print();
    }
}


Measured memory_bytes: 26608
using System;

public class Hello
{
    public static void Main()
    {
        string line;
        for (; (line = Console.ReadLine()) != null;)
        {
            int ans;
            string[] a = line.Trim().Split('+', '=');
            if ((a[0].StartsWith("X") && a[0].Length >= 2) |
                (a[1].StartsWith("X") && a[1].Length >= 2) |
                (a[2].StartsWith("X") && a[2].Length >= 2)) ans = check(a, 1);
            else ans = check(a, 0);
            Console.WriteLine(ans == -1 ? "NA" : ans.ToString());
        }
    }
    public static int check(string[] a, int ooz)
    {
        for (int i = ooz; i <= 9; i++)
        {
            var a1 = a[0].Replace("X", i.ToString());
            var a2 = a[1].Replace("X", i.ToString());
            var a3 = a[2].Replace("X", i.ToString());
            if (getPlus(a1, a2) == a3) return i;
        }
        return -1;
    }
    public static string getPlus(string a1, string a2)
    {
        var b1 = new int[126]; var b2 = new int[126]; var b3 = new int[126];
        var imax = Math.Max(a1.Length, a2.Length);
        var j = 0; var k = 0;
        for (int i = imax - a1.Length; i < imax; i++) b1[i] = int.Parse(a1[j++].ToString());
        for (int i = imax - a2.Length; i < imax; i++) b2[i] = int.Parse(a2[k++].ToString());
        for (int i = imax-1; i >=1; i--)
        {
            b3[i] += (b1[i] + b2[i]) % 10;
            b2[i - 1] += (b1[i] + b2[i]) / 10;
        }
        b3[0] += b1[0] + b2[0];
        var ret = "";
        for (int i = 0; i < imax; i++)
            ret += b3[i].ToString();
        return ret;
    }
}

Measured memory_bytes: 9996
#include <iostream>
#include <vector>

// template<class S, S (*next)(S), int (*idx)(S)>
// struct doubling {
//     doubling(int _n, long long _max_k) : n(_n) {
//         log = 1;
//         while (1LL << log < _max_k) log++;
//         t = std::vector<std::vector<int>>(log, std::vector<int>(_n));
//         for (int i = 0; i < _n; ++i) t[0][i] = next(i);
//     }

//     void init() {
//         for (int k = 0; k < log - 1; k++) {
//             for (int i = 0; i < n; i++) t[k + 1][i] = t[k][idx(t[k][i])];
//         }
//     }

//     S query(S s, long long k) {
//         S now = s;
//         for (int _k = 0; k > 0; _k++) {
//             if (k & 1) now = t[_k][idx(now)];
//             k >>= 1;
//         }
//         return now;
//     }

//     private:
//         int n, log;
//         std::vector<std::vector<S>> t;
// };


struct doubling {
    doubling(int _n, long long _max_k, std::vector<int> &next) : n(_n) {
        log = 1;
        while (1LL << log < _max_k) log++;
        t = std::vector<std::vector<int>>(log, std::vector<int>(_n));
        t[0] = next;
    }

    void init() {
        for (int k = 0; k < log - 1; k++) {
            for (int i = 0; i < n; i++) t[k + 1][i] = t[k][t[k][i]];
        }
    }

    int query(int s, long long k) {
        int now = s;
        for (int _k = 0; k > 0; _k++) {
            if (k & 1) now = t[_k][now];
            k >>= 1;
        }
        return now;
    }

    private:
        int n, log;
        std::vector<std::vector<int>> t;
};


/**
 * AtCoder ABC167 D-Teleporter
 * url:https://atcoder.jp/contests/abc167/tasks/abc167_d
 */
int main(){
    int N;
    long long K;
    std::cin >> N >> K;

    std::vector<int> A = std::vector<int>(N);
    for (auto &i : A) std::cin >> i, i--;

    doubling d(N, K, A);
    d.init();
    std::cout << d.query(0, K) + 1 << std::endl;
}


Measured memory_bytes: 51668
#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 fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

ll w[111111];
ll d[111111];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	ll n,k; cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		cin>>w[i]>>d[i];
	}
	ll lo = 1; ll hi = ll(4e18);
	ll ans=0;
	while(lo<=hi)
	{
		ll mid=(lo+hi)>>1;
		ll cnt=0;
		for(int i=0;i<n;i++)
		{
			if(w[i]<=mid)
			{
				cnt+=1+(mid-w[i])/d[i];
				cnt=min(cnt,k);
			}
		}
		if(cnt>=k)
		{
			ans=mid;
			hi=mid-1;
		}
		else
		{
			lo=mid+1;
		}
	}
	cout<<ans<<'\n';
}	


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

int main(){
    string S,T;
    cin >> S;
    cin >> T;
    string t = T.substr(0,S.length());
    if(S == t){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
   
#define ll long long
#define F first
#define S second
#define pb push_back
using namespace std;
   
void data() {
    #ifdef NURS
        freopen("main.in", "r", stdin);
        freopen("main.out", "w", stdout);
    #endif
} 
const int N = 1e6 + 200;
int main ()
{
    data();
    char c;
    cin >> c;
    if (c >= 'a' && c <= 'z')
    {
    	cout << 'a';
    }
    else {
    	cout << "A";
    }
                            
}

Measured memory_bytes: 3648
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <vector>
#define INF 0x3f3f3f3f
using namespace std;
typedef long long  ll;
const int MAXN=1e5+10;
char ch[MAXN];
char buf[5]={'M','A','R','C','H'};
ll ans[5];
ll dfs(int dep,int x)
{
    if(dep>1)
    {
        if(x>0)return dfs(dep-1, x-1)*ans[x]+dfs(dep, x-1);
        return 0;
    }
    else
    {
        if(x>0)return ans[x]+dfs(dep, x-1);
        return ans[x];
    }
}
int main()
{
    int n;
    while (scanf("%d",&n)!=EOF) {
        for(int i=0;i<=4;i++)
            ans[i]=0;
        for(int i=1;i<=n;i++)
        {
            scanf("%s",ch);
            for(int j=0;j<=4;j++)
                if(ch[0]==buf[j])
                    ans[j]++;
        }
        cout<<dfs(3, 4)<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
using namespace std;
// namespace boost::multiprecision;
// using Bint = cpp_int;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a), i##_len = (b); i < i##_len; ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define _repr(i, n) repri(i, n, 0)
#define repri(i, a, b) for(int i = int(a), i##_len = (b); i >= i##_len; --i)
/* 閉区間で定義しているので注意！repr(i,n,m)でn〜mまで */
#define repr(...) _overload3(__VA_ARGS__, repri, _repr, )(__VA_ARGS__)
/* 逆回しのループ。両閉区間であることに注意 */
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << ": " << (x) << '\n'
typedef long long lint;
#define int lint
const int INF = (int)1145141919;
int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const lint LINF = (lint)1e18;
typedef vector<int> vint;
typedef pair<int, int> pint;
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(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T, class U>
std::ostream &operator<<(std::ostream &os, const std::pair<T, U> p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    os << p.first << " " << p.second;
    return os;
}

template <typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    for(int i = 0; i < (int)v.size(); i++) {
        os << v[i] << (i + 1 != v.size() ? ", " : "");
    }
    os << "]";
    return os;
}

template <typename T> istream &operator>>(istream &is, vector<T> &v) {
    for(T &in : v)
        is >> in;
    return is;
}

template <typename T = lint> vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) {
    t = v;
}

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) {
    for(auto &e : t)
        fill_v(e, v);
}

/* templates */ /* templates */ /* templates */ /* templates */ /* templates */
/* make directory: atcoder-tools gen コンテスト略称(ex.agc033) */
/* テストコード：atcoder-tools test */
/* 提出：atcoder-tools submit -u */

signed main() {
#ifdef LOCAL
    ifstream in("in_1.txt");
    cin.rdbuf(in.rdbuf());
#else
    cin.tie(0);
    ios::sync_with_stdio(false);
#endif

    /* input part */
    long long X;
    cin >> X;
    long long Y;
    cin >> Y;

    /* write your code!*/
    cout << X + Y / 2 << endl;
}


Measured memory_bytes: 256
from collections import defaultdict
import bisect
s = input()
t = input()
ns = len(s)
nt = len(t)
word = defaultdict(int)
wordnum = defaultdict(int)
for i in range(ns):
  if word[s[i]] != 0:
    word[s[i]].append(i+1)
  else:
    word[s[i]] = [i+1]
  wordnum[s[i]] += 1
cnt = 0
pnt = 0
for i in range(nt):
  x = t[i]
  if word[x] != 0:
    pos = bisect.bisect_right(word[x],pnt)
    if pos == wordnum[x] or pnt>word[x][pos]:
      cnt += 1
    if pos == wordnum[x]:
      pnt = word[x][0]
    else:
      pnt = word[x][pos]
  else:
    print(-1)
    exit()
print(cnt*ns+pnt)

Measured memory_bytes: 9920
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  ll a,b,q;cin>>a>>b>>q;
  vl s(a),t(b),x(q);
  rep(i,a)cin>>s[i];
  rep(i,b)cin>>t[i];
  rep(i,q)cin>>x[i];
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  rep(i,q){
    ll idx_lowers=a;
    ll idx_lowert=b;
    if(s[a-1]>=x[i]){
      idx_lowers= distance(s.begin(),lower_bound(s.begin(), s.end(), x[i]) );
    }
    if(t[b-1]>=x[i]){
      idx_lowert= distance(t.begin(),lower_bound(t.begin(),t.end(),x[i]) );
    }
    vl ans;
    //cout<<idx_lowers<<" "<<idx_lowert;
    //cout<<endl;
    if(idx_lowers!=a&&idx_lowert!=b)ans.push_back(max(s[idx_lowers]-x[i],t[idx_lowert]-x[i]));
    if(idx_lowers>=1&&idx_lowert>=1)ans.push_back(max(x[i]-s[idx_lowers-1],x[i]-t[idx_lowert-1]));
    if(idx_lowers>=1&&idx_lowert!=b)ans.push_back(min(x[i]-s[idx_lowers-1]+(t[idx_lowert]-x[i])*2,(x[i]-s[idx_lowers-1])*2+t[idx_lowert]-x[i]));
    if(idx_lowers!=a&&idx_lowert>=1)ans.push_back(min(x[i]-t[idx_lowert-1]+(s[idx_lowers]-x[i])*2,(x[i]-t[idx_lowert-1])*2+s[idx_lowers]-x[i]));
    sort(ans.begin(),ans.end());
    //rep(j,ans.size())cout<<ans[j]<<" ";
    //cout<<endl;
    cout<<ans[0]<<endl;
  }
}
  

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
const int N=200005;
char s[N];
long long ans,a[N],p[N];
int main()
{
	scanf("%s",s+1);
	int n=strlen(s+1),t=0;
	a[t]++;
	p[n+1]=1;
	for(int i=n;i>=1;i--)
	{
		int x=s[i]-'0';
		p[i]=p[i+1]*10%2019;
		t=(t+x*p[i])%2019;
		a[t]++;
	}
	for(int i=0;i<2019;i++)
		ans+=a[i]*(a[i]-1)/2;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5424
n, m, = map(int, input().split())

arr = []
for i in range(m):
    c = input().split()
    arr.append([(int)(c[0]), c[1]])
#print("{}".format(arr))

penalty_log = {}    # まだACでないWAはここに溜める
success_log = set([])    # 一度でも成功したACはここに溜める

for elem in arr:
    if elem[1] == 'WA':
        if elem[0] not in success_log:
            if elem[0] not in penalty_log:
                penalty_log[elem[0]] = 1
            else:
                penalty_log[elem[0]] += 1

    elif elem[1] == 'AC':
        if elem[0] not in success_log:
            success_log.add(elem[0])

#print("success_log = {}".format(success_log))
#print("penalty_log = {}".format(penalty_log))

success = len(success_log) # ACの個数
penalty = 0 # WAの個数
for k, v in penalty_log.items():
    if k in success_log:
        penalty += v
print("{} {}".format(success, penalty))

Measured memory_bytes: 28176
#include<bits/stdc++.h>
#include<cstdio>
#define ll long long int

using namespace std;

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

    int min=x-k+1;
    int max=x+k-1;

    int i;

    for(i=min;i<=max;i++){
        printf("%d ",i);
    }

    puts("");
}

Measured memory_bytes: 256
n = int(input())
l = (1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51)
print(l[n-1])

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#define P 1000000007LL
#define ll long long
using namespace std;
ll fac[200001],n,k,inv[200001],a,b,c,d;
ll power(ll x, ll y) {   
 
 	
    ll ret = 1;
    while (y > 0) {
        if (y % 2) {
            ret *= x;
            ret %= P;
        }
        x *= x;
        x %= P;
        y /= 2;
    }
    return ret;
}
ll sol(ll n,ll k)
{
	if(k==0)
	return 1;
    ll sum = (fac[n] * inv[n - k]) % P;
	sum = (sum*inv[k]) % P;
	
	return sum;
}
int main() {
    fac[1] = 1;
    for (int i = 2; i <= 200000; i++)
        fac[i] = (fac[i - 1] * i) % P;           
    inv[200000] = power(fac[200000], P - 2);   
    for (int i = 200000 - 1; i > 0; i--) 
        inv[i] = (inv[i + 1] * (i + 1)) % P;    
    
    cin >> a >> b >> c >> d;
    
    ll i=a-c+1,j=d;
    ll tot=sol(a+b-2,min(a-1,b-1));
	while(i<=a&&j>=0)
	{
		tot=((tot-sol(i+j-2,min(i-1,j-1))*sol(a-i+b-j,min(a-i,b-j)))+P*P)%P;
		i++,j--;
	}
    cout << tot << "\n";
    return 0;
}

Measured memory_bytes: 3328
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_2_B&lang=jp
#???????????????
#?????????????????????????????¨????§???????????????????????¢????????????°????????????
#?¨???????????????°??¢??°???????¢????????????????

def selection_sort(target_list):
    list_length = len(target_list)
    change_count = 0
    for i in range(list_length):
        min_index = i
        for j in range(i, list_length):
            if target_list[j] < target_list[min_index]:
                min_index = j
        else:
            if not i == min_index:
                tmp = target_list[i]
                target_list[i] = target_list[min_index]
                target_list[min_index] = tmp
                change_count += 1
                
    return change_count
def main():
    
    n_list = int(input())
    target_list = [int(n) for n in input().split()]
    cc = selection_sort(target_list)
    print(*target_list)
    print(cc)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 7768
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    ll k;
    string s;
    cin >> s >> k;
    int p;
    REP(i,s.length()){
        if(s[i] != '1'){
            p = i;
            break;
        }
    }
    if(p==s.length()){
        cout << 1 << endl;
        return 0;
    }
    if(k > p){
        cout << s[p] << endl;
    }
    else{
        cout << 1 << endl;
    }
    return 0;
}

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

int main() {
	int N, dir = 0;
	string S;
	cin >> N;
	cin >> S;
	stack<char> A;
	
	
	//Parte 1
	for(int i=0; i<N; i++) {
		
		if(S[i] == ')') {
		
			if(dir)
				dir--;
			else
				cout << '(';
		}else{
			dir++;
		}
		
		A.push(S[i]);
	}
	
	
	
	cout << S;
	dir = 0;
	
	
	//Parte 2
	while(!A.empty()) {
		
		if(A.top() == '(') {
			
			if(dir)
				dir--;
			else
				cout << ')';
				
		}else{
			dir++;
		}
		
		A.pop();
	}
	
	return 0;
}

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

int main() {
    int h, w;
    cin >> h >> w;
    string s[h];
    for (int i = 0; i < h; i++)
        cin >> s[i];
    
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (s[i][j] == '#')
                continue;

            int num = 0;
            for (int x = -1; x <= 1; x++) {
                for (int y = -1; y <= 1; y++) {
                    int ni = i + y;
                    int nj = j + x;
                    if (ni < 0 or ni >= h) continue;
                    if (nj < 0 or nj >= w) continue;
                    if (s[ni][nj] == '#') num++;
                }
            }
            s[i][j] = char(num + '0');

        }
    }
    for (int i = 0; i < h; i++)
        cout << s[i] << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int W[] = new int[N];
		for(int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
		}
		int ans = 1000;
		for(int i = 0; i < N; i ++) {
			int g1 = 0;
			int g2 = 0;
			for(int j = 0; j < N; j++) {
				if(j > i) {
					g1 += W[j];
				} else {
					g2 += W[j];
				}
			}
			ans = Math.min(ans, Math.abs(g1 - g2));
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
/*Read the problem carefully before starting to work on it*/
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#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;

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

#define pb push_back
#define eb emplace_back
#define mp(x,y) make_pair(x,y)
#define mod 1000000007

double PI=3.1415926535897932384626;

//template<typename T> T power(T x,T y,ll m=mod){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ost;

#define fi first
#define se second

#define SSIZE 3005

ll dp[SSIZE][SSIZE];

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin>>n;
	string s;
	cin>>s;
	dp[1][1]=1;
	for(ll len=2;len<=n;len++)
	{
		for(ll i=1;i<=(len-1);i++)
		{
			dp[len-1][i]+=dp[len-1][i-1];
			dp[len-1][i]%=mod;
		}
		for(ll b=1;b<=len;b++)
		{
			ll L,R;
			if(s[len-2]=='<')
			{
				L=1;
				R=b-1;
			}
			else
			{
				L=b;
				R=len-1;
			}
			if(L<=R)
			{
				dp[len][b]+=( (dp[len-1][R]-dp[len-1][L-1]+mod)%mod );
				dp[len][b]%=mod;
			}
		}
	}
	ll ans=0;
	for(ll i=1;i<=n;i++)
	{
		ans+=dp[n][i];
		ans%=mod;
	}
	cout<<ans;
    return 0;
}


//252908XL

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

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



int main(){
    const long long INF = 0;


    long long N;
    cin >> N;

    vector<int> a(N);
    vector<int> b(N);
    vector<int> c(N);

    for(int i = 0; i < N; i++){
        cin >> a.at(i) >> b.at(i) >> c.at(i);
    }

    // DP テーブル
    long long dp[N + 10][3];

    // DP テーブル全体を初期化
    for (int i = 0; i < N + 10; ++i){
        for(int j = 0; j < 3; ++j){
            dp[i][j] = INF;
        }
    }

    for(int i = 1; i < N+1; i++){

        chmax(dp[i][0],dp[i-1][1] + a[i-1]);
        chmax(dp[i][1],dp[i-1][0] + b[i-1]);
        chmax(dp[i][2],dp[i-1][0] + c[i-1]);
        chmax(dp[i][0],dp[i-1][2] + a[i-1]);
        chmax(dp[i][1],dp[i-1][2] + b[i-1]);
        chmax(dp[i][2],dp[i-1][1] + c[i-1]);


    }

    cout << max(dp[N][0],max(dp[N][1],dp[N][2])) << endl;

}


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

using namespace std;

const int MAXN = 100010;

map<int, int>mp;
map<int, int>fa;

int a[MAXN];
int b[MAXN];

inline int find(int x) {
    return fa[x] == x ? x : fa[x] = find(fa[x]);
}

inline int Merge(int x, int y) {
    int fx = find(x), fy = find(y);
    if(fx == fy) return 0;
    fa[fx] = fy;
    return 1;
}

int main() {
    ios::sync_with_stdio(false);
    int n, Xor = 0, flag = 0;
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> a[i], mp[a[i]]++, Xor ^= a[i];
    a[n + 1] = Xor, mp[Xor]++;
    for(int i = 1; i <= n; i++) {
        int &x = b[i];
        cin >> x;
        if(!mp[x]) return puts("-1"), 0;
        mp[x]--;
    }
    for(int i = 1; i <= n; i++) {
        if(a[i] != b[i]) {
            fa[a[i]] = a[i];
            fa[b[i]] = b[i];
        }
    } fa[Xor] = Xor;
    int res = fa.size();
    for(int i = 1; i <= n; i++) {
        if(a[i] != b[i])
            res -= Merge(a[i], b[i]), ++res;
    } res--;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 12928
fn main() {
  let (n, m): (usize, usize) = read_tuple();
  let xys: Vec<(usize, usize)> = read_tuples(m);
  
  let mut vec = vec![(false, 1); n+1];
  vec[1] = (true, 1);
  for (x,y) in xys {
    let (r1, w1) = vec[x];
    let (r2, w2) = vec[y];
    match (r1, w1) {
      (true, w) if w > 1  => {vec[x] = (true,  w1-1); vec[y] = (true, w2+1)},
      (true, w) if w == 1 => {vec[x] = (false, 0);    vec[y] = (true, w2+1)},
      (false, _)          => {vec[x] = (false, w1-1); vec[y] = (r2, w2+1)},
      _ => unreachable!()
    }
  }
  
  let ans = vec.iter().filter(|&p| p.0).count();
  println!("{}", ans);
}

fn read_tuple<T1: std::str::FromStr, T2: std::str::FromStr>() -> (T1, T2) {
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).ok();
  let mut it = buf.trim().split_whitespace();
  let x = it.next().unwrap().parse::<T1>().ok().unwrap();
  let y = it.next().unwrap().parse::<T2>().ok().unwrap();
  (x, y)
}

fn read_tuples<T1: std::str::FromStr, T2: std::str::FromStr>(n: usize) -> Vec<(T1, T2)> {
  let mut vec: Vec<(T1, T2)> = vec![];
  for _ in 0 .. n {
    vec.push(read_tuple());
  }
  vec
}

Measured memory_bytes: 6396
#include<stdio.h>
int main(void){
	int h, w, i, j;
	do{
		scanf("%d %d", &h, &w);
		if(h == 0 && w == 0){
			break;
		}
		for(i = 1; i <= h; i++){
			if(i == 1 || i == h){
					for(j = 1; j <= w; j++){
						printf("#");
					}
			}else{
				for(j = 1; j <= w; j++){
					if(j == 1 || j == w){
						printf("#");
					}else{
						printf(".");
					}
				}
			}
			printf("\n");
		}
		printf("\n");
	}while(1);
	
	return 0;
}



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

int main(){
  int n,m;
  cin >> n >> m;
  int a[m];
  int sum = 0;
  rep(i,0,m){
    cin >> a[i];
    sum += a[i];
  }
  int ans = n-sum;
  if(ans<0) ans = -1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3672
# https://atcoder.jp/contests/abc077/tasks/arc084_a
from bisect import bisect_left, bisect_right
n = int(input())

a = list(map(int, input().split()))
a.sort()
b = list(map(int, input().split()))
b.sort()
c = list(map(int, input().split()))
c.sort()

ans = 0
for j in b:
    A = bisect_left(a, j)
    C = bisect_right(c, j)
    ans += A * (n - C)
print(ans)

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

int main() {
    int n,d;
    cin >> n >> d;
    vector<vector<int>> data(n, vector<int>(d));
    for (int i=0;i<n;i++){
        for (int j=0;j<d;j++){
            cin >> data.at(i).at(j);
        }
    }
    int num_square = 0;
    for (int i=0;i<n;i++){
        for (int j=i+1;j<n; j++){
            int kyori = 0;
            for (int k=0;k<d;k++){
                kyori += pow((data.at(i).at(k) - data.at(j).at(k)),2);
            }
            for (int p=1;p<161;p++){
                if (kyori == p*p){
                    num_square += 1;
                }
            }
        }
    }
    cout << num_square;
}

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

int main() {
    string a, b;
    cin >> a >> b;
    int c = atoi((a + b).c_str());
    bool ans = false;
    
    for (int i = 1; i <= 1000; i++) {
        if ((i * i) == c) {
            ans = true;
        }
    }
    
    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
# cook your dish here
s=list(input())
k = 0
if s.count('a') == 0:
    s += 'a'
elif s.count('b') == 0:
    s += 'b'
elif s.count('c') == 0:
    s += 'c'
elif s.count('d') == 0:
    s += 'd'
elif s.count('e') == 0:
    s += 'e'
elif s.count('f') == 0:
    s += 'f'
elif s.count('g') == 0:
    s += 'g'
elif s.count('h') == 0:
    s += 'h'
elif s.count('i') == 0:
    s += 'i'
elif s.count('j') == 0:
    s += 'j'
elif s.count('k') == 0:
    s += 'k'
elif s.count('l') == 0:
    s += 'l'
elif s.count('m') == 0:
    s += 'm'
elif s.count('n') == 0:
    s += 'n'
elif s.count('o') == 0:
    s += 'o'
elif s.count('p') == 0:
    s += 'p'
elif s.count('q') == 0:
    s += 'q'
elif s.count('r') == 0:
    s += 'r'
elif s.count('s') == 0:
    s += 's'
elif s.count('t') == 0:
    s += 't'
elif s.count('u') == 0:
    s += 'u'
elif s.count('v') == 0:
    s += 'v'
elif s.count('w') == 0:
    s += 'w'
elif s.count('x') == 0:
    s += 'x'
elif s.count('y') == 0:
    s += 'y'
elif s.count('z') == 0:
    s += 'z'
else:
    for i in range(25):
        if s[25-i] > s[25-i-1]:
            r = s[25-i]
            for j in range(i+1):
                if s[25-i+j] > s[25-i-1]:
                    r = s[25-i+j]
            s = s[:25-i-1:] + list(r)
            break
        else:
            k += 1
if k == 25:
    print(-1)
else:
    ass = ''
    for i in range(len(s)):
        ass += s[i]
    print(ass)

Measured memory_bytes: 3192
#include<stdio.h>

int main (void){

    int n;

    scanf("%d",&n);

    if(10<=n<100){
        n%=10;
    }

    if(n==3){
        printf("bon");
    }else if(n==0||n==1||n==6||n==8){
        printf("pon");
    }else{
        printf("hon");
    }


    return 0;
}

Measured memory_bytes: 1736
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdlib>

using namespace std;

#define ALL(c) c.begin(),c.end()
#define RALL(c) c.rbegin(),c.rend()
#define REP(i,x,y) for(int i=(x);i<(y);++i)
#define MP(a,b) make_pair((a),(b))
#define F_ first
#define S_ second
#define endl '\n'

typedef long long int lli;
typedef pair<int,int> Pi;

const int INF=100000000;
const long long int INF_=100000000000000000;

void Transform(string &str,char ch){
	string::size_type pos=str.find(ch);
	while(pos!=string::npos){
		str.erase(pos);
		pos=str.find(ch);
	}
}

int main(){
	//std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    vector<string> str;
	string tmp;
    while(cin >> tmp) str.push_back(tmp);
	vector<string> ans;
    REP(i,0,str.size()){
		Transform(str[i],'.');
		Transform(str[i],',');
		if(3<=str[i].length()&&str[i].length()<=6) ans.push_back(str[i]);
	}
	REP(i,0,ans.size()){
		cout << ans[i] << (i==ans.size()-1?'\n':' ');
	}
	return 0;
}

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

int main(){
  string a,b;
  cin >> a >> b;
  
  int Ab=0;
  int lena = a.length(), lenb = b.length();
  if(lena > lenb) Ab = 1;
  else if(lenb > lena) Ab = -1;
  else{
    rep(i,lena){
      if(a[i] > b[i]){
        Ab = 1;
        break;
      }else if(b[i] > a[i]){
        Ab = -1;
        break;
      }
    }
  }
  
  if(Ab==1) cout << "GREATER" << endl;
  else if(Ab==-1) cout << "LESS" << endl;
  else cout << "EQUAL" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip	;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int dp[21][21][1030];
int main(){
	int n,m;
	while(cin>>m>>n,n+m){
		vector<string>in(n);
		rep(i,n)cin>>in[i];
		int co=0;
		rep(i,n)rep(j,m)if(in[i][j]=='*'){
			in[i][j]=(char)('0'+co);
			co++;
		}
		int N=1<<co;
		rep(i,21)rep(j,21)rep(k,1030)
			dp[i][j][k]=inf;
		queue<pair<pii,pii> >q;
		rep(i,n)rep(j,m)if(in[i][j]=='o')
			q.push(pair<pii,pii>(pii(i,j),pii(0,0)));
		int dx[]={0,0,1,-1};
		int dy[]={1,-1,0,0};
		while(!q.empty()){
			pii a=q.front().first;
			pii b=q.front().second;
			q.pop();
			if(dp[a.first][a.second][b.first]<b.second)continue;
//			cout<<a.first<<" "<<a.second<<" "<<b.first<<" "<<b.second<<endl;
			rep(i,4){
				int nx=a.first+dx[i];
				int ny=a.second+dy[i];
				int past=b.first;
				int cost=b.second+1;
				if(nx<0||ny<0||nx>=n||ny>=m)continue;
				if(in[nx][ny]=='x')continue;
				if(isdigit(in[nx][ny]))past|=1<<(in[nx][ny]-'0');
				if(dp[nx][ny][past]>cost){
					dp[nx][ny][past]=cost;
					q.push(pair<pii,pii>(pii(nx,ny),pii(past,cost)));
				}
			}
		}
		int out=inf;
		rep(i,n)rep(j,m)out=min(out,dp[i][j][N-1]);
		if(out==inf)out=-1;
		cout<<out<<endl;
	}
}

Measured memory_bytes: 3128
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;

#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define ALLOC(size,type) ((type*)calloc((size),sizeof(type)))

void run (void) {
  i32 n, k;
  scanf ("%" SCNi32 "%" SCNi32, &n, &k);
  i32 *h = ALLOC (n, i32);
  for (i32 i = 0; i < n; ++i) {
    scanf ("%" SCNi32, h + i);
  }
  i32 *dp = ALLOC (n, i32);
  const i32 inf = 1000000000 + 1;
  for (i32 i = 1; i < n; ++i) {
    dp[i] = inf;
  }
  for (i32 i = 0; i < n - 1; ++i) {
    for (i32 j = i + 1; j <= i + k && j < n; ++j) {
      i32 x = dp[i] + ABS (h[j] - h[i]);
      dp[j] = MIN (dp[j], x);
    }
  }
  printf ("%" PRIi32 "\n", dp[n - 1]);
}

int main (void) {
  run();
  return 0;
}


Measured memory_bytes: 896
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
l = []
ans = 0
m = 0
if sum(a) < sum(b):
    print(-1)
    exit()
for i in range(n):
    if a[i] < b[i]:
        ans += 1
        m += b[i] - a[i]
    else:
        l.append(a[i] - b[i])
l = list(reversed(sorted(l)))
for i in l:
    if m > 0:
        m -= i
        ans += 1
print(ans)


Measured memory_bytes: 19068
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstring>
#include<stack>
#include<functional>
using namespace std;

int main(){
	int N,d[100][100]; fill_n((int*)d,100*100,INT_MAX/2);
	cin>>N;
	for(int i=0;i<N;i++){
		int R,K;
		cin>>R>>K; R--;
		for(int j=0;j<K;j++){
			int T;
			cin>>T; T--;
			d[R][T] = 1;
		}
	}
	
	for(int k=0;k<N;k++)for(int i=0;i<N;i++)for(int j=0;j<N;j++)
		d[i][j] = min(d[i][j],d[i][k]+d[k][j]);

	int P; cin>>P;
	for(int i=0;i<P;i++){
		int S,D,V;
		cin>>S>>D>>V; S--; D--;
		if(V<d[S][D]+1) puts("NA");
		else printf("%d\n",d[S][D]+1);
	}
	return 0;
}

Measured memory_bytes: 1188