akhauriyash/Code-Regression huggingface dataset:
# coding: utf-8
N, P = map(int, input().split())
S = input()
ans = 0
if P == 2:
    for i in range(N):
        if int(S[i]) % 2 == 0:
            ans += i+1
elif P == 5:
    for i in range(N):
        if int(S[i]) == 0 or int(S[i]) == 5:
            ans += i+1
else:
    cnt = [0 for _ in range(P)]
    cnt[0] = 1
    bai = 1
    v = 0
    for i in range(N)[::-1]:
        v = (v + int(S[i]) * bai) % P
        bai *= 10
        bai %= P
        cnt[v] += 1
    for i in range(P):
        ans += ((cnt[i] - 1 ) * cnt[i]) // 2
print(ans)

Measured memory_bytes: 3500
#include<iostream>
using namespace std;
long long arr[1000000];
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);   
    string s;
    cin>>s;
    if (s[0]=='7' ||s[1]=='7' ||s[2]=='7'  )
    {
    	cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 3656
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
	long long int n, m, r, R[9], d[210][210] = {}, a, b, c, i, j, k, I = 1e9, s;
	cin >> n >> m >> r;
	for (i = 0; i < r; i++)cin >> R[i];
	for (i = 1; i <= n; i++)for (j = i + 1; j <= n; j++)d[i][j] = d[j][i] = I;
	for (i = 0; i < m; i++) {
		cin >> a >> b >> c;
		if (d[a][b] > c)d[a][b] = d[b][a] = c;
	}
	for (k = 1; k <= n; k++)for (i = 1; i <= n; i++)for (j = 1; j <= n; j++)d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
	sort(R, R + r);
	do {
		s = 0;
		for (i = 0; i < r - 1; i++)s += d[R[i]][R[i + 1]];
		I = min(I, s);
	} while (next_permutation(R, R + r));
	cout << I << endl;
	return 0;
}


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

int main(){
    int H,W;cin>>H>>W;
    char info[H][W];
    int ans[H][W];
    queue<pair<int,int>> point;
    rep(i,H)rep(j,W){
        cin>>info[i][j];
        if(info[i][j]=='#'){
            point.push(make_pair(i,j));
            ans[i][j]=0;
        }
        else ans[i][j]=INF;
    }
    const int dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
    while(point.size()){
        int p=point.front().first,q=point.front().second;
        point.pop();
        rep(i,4){
            if(0<=p+dy[i] and p+dy[i]<H and 0<=q+dx[i] and q+dx[i]<W){
                if(ans[p+dy[i]][q+dx[i]]==INF){
                    point.push(make_pair(p+dy[i],q+dx[i]));
                    ans[p+dy[i]][q+dx[i]]=min(ans[p+dy[i]][q+dx[i]],ans[p][q]+1);
                }
            }
        }
    }
    int count=0;
    rep(i,H)rep(j,W)count=max(count,ans[i][j]);
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 13328
#include <iostream>
#include <stdio.h>
#include <set>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
using namespace std;


int main(void)
{
	char X, Y; cin >> X >> Y;

	if (X - Y > 0)cout << ">" << endl;
	else if (X == Y)cout << "=" << endl;
	else cout << "<" << endl;

	return 0;
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int MOD = 1000000009;
const long long INF = 1LL << 60;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> s(M);
    vector<char> c(M);
    for (int i = 0; i < M; ++i) {
        cin >> s[i] >> c[i];
        --s[i];
    }
    int res = -1;
    for (int i = 0; i < 1000; ++i) {
        string num = to_string(i);
        if (num.length() != N) continue;
        bool check = true;
        for (int j = 0; j < M; ++j) {
            if (num[s[j]] != c[j]) check = false;
        }
        if (check) {
            res = i;
            break;
        }
    }
    cout << res << endl;
    return 0;
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }

int main() {
	int k;
	cin >> k;
	
	cout << fl(k, 2) * ce(k, 2) << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<P ,ll> P3;
typedef pair<P ,P> PP;
const ll MOD = 998244353;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-6;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

int main() {
    int n, v[25], c[25], sum = 0;
    cin >> n;
    REP(i,n){
        cin >> v[i];
    }
    REP(i,n){
        cin >> c[i];
    }
    REP(i,n){
        if(v[i]-c[i] > 0){
            sum += v[i]-c[i];
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	var N, min, max, r int
	fmt.Scan(&N)
	a := make([]int, N)
	min = math.MaxInt64
	r = math.MaxInt64
	for i := 0; i < N; i++ {
		fmt.Scan(&a[i])
		min = Min(min, a[i])
		max = Max(max, a[i])
	}
	for n := min; n <= max; n++ {
		w := 0
		for i := 0; i < N; i++ {
			if n == a[i] {
				continue
			}
			w += Pow(a[i]-n, 2)
		}
		r = Min(r, w)
	}
	fmt.Println(r)
}

func Min(a, b int) int {
	if b < a {
		return b
	}
	return a
}

func Max(a, b int) int {
	if b > a {
		return b
	}
	return a
}

func Pow(a int, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}


Measured memory_bytes: 512
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=1005;
const int mod=1e9+7;
int n,m,C[N][N],f[25][N];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=C[0][0]=1;i<=n;++i)
		for(int j=C[i][0]=1;j<=i;++j)
			C[i][j]=(C[i-1][j]+C[i-1][j-1])%mod;
	f[0][0]=1;
	for(int i=1,a;i<=m;++i){
		scanf("%d",&a);
		for(int j=0;j<=n;++j)
			for(int k=0;k<=j&&k<=a;++k)
				f[i][j]=(f[i][j]+1ll*f[i-1][j-k]*C[j][k]%mod*C[n-k][a-k])%mod;
	}
	printf("%d\n",f[m][n]);
	return 0;
}

Measured memory_bytes: 4224
"use strict";

const getGcd = (input) => {
  let len, a, b;
	len = input.length;
	a = input[ 0 ];
	for (let i=1; i<len; i++) {
		b = input[i];
		a = gcdTwoNumbers(a, b);
	}
	return a;
}

const gcdTwoNumbers = (x, y) => {
  x = Math.abs(x);
  y = Math.abs(y);
  while(y) {
    let t = y;
    y = x % y;
    x = t;
  }
  return x;
}

const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const X = parseInt(arg[0].split(" ")[1]);
    const numbers = arg[1].split(" ").map(n=>parseInt(n));
    
    const evenOdd = numbers.filter(n=>n % 2 === 0).length;
    
    if(N === 1) {
        console.log(Math.abs(numbers[0] - X));
        return;
    }

    let list = [];
    
    for(let i=0; i<N; i++) {
        let temp = Math.abs(numbers[i] - X);
        list.push(temp);
    }
    
    console.log(getGcd(list));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 28244
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define eb 			emplace_back
#define mp 			make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          first
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define checkbit(n, b) ((n >> b) & 1)
#define mod        1000000007
#define puts(n)		cout<<n;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define setbits(x) __builtin_popcount(x)
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;
vi v1,v2;
string ks(string a, string b){
ll dp[a.size()+1][b.size()+1]={};
	string s="";
	rep(i,1,a.size()+1){
		rep(j,1,b.size()+1)
	if(a[i-1]==b[j-1]){
		//s+=a[i-1];
		dp[i][j]=1+dp[i-1][j-1];
	}
	else{
	 dp[i][j]=max(dp[i][j],max(dp[i-1][j],dp[i][j-1]));
	}
}//cout<<dp[a.size()][b.size()]<<" ";
ll i=a.size();
ll j=b.size();ll u=0;
while(i!=0 && j!=0){
if(dp[i][j]==dp[i-1][j-1]+1 && a[i-1]==b[j-1])	
{
s+=a[i-1];
u++;
i--;
j--;}
else if(dp[i][j]==dp[i][j-1])
j--;
else i--;
}
for(int i=s.size()-1;i>=0;i--)
cout<<s[i];
return s; 
}

int main(){
	ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
      string s1,s2;
      
      cin>>s1>>s2;
      string h=ks(s1,s2);
      //cout<<h;
        return 0;}

Measured memory_bytes: 70656
#include<bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }
int sub(int a, int b) { return (a -= b) < 0 ? a + mod : a; }

const int maxn = 2e5 + 5;
int a[maxn], n;
int res[maxn];
vi g[maxn];
int seg[4 * maxn];

void upd(int t, int val, int l = 0, int r = n - 1, int ind = 1) {
  if(l > t || r < t) return;
  //cout << l << " " << r << " " << ind << endl;
  if(l == r && l == t) {
    seg[ind] = val;
    return;
  }
  int mid = (l + r) / 2;
  upd(t, val, l, mid, ind * 2);
  upd(t, val, mid + 1, r, ind * 2 + 1);
  seg[ind] = max(seg[ind * 2], seg[ind * 2 + 1]);
}

int qry(int tl, int tr, int l = 0, int r = n - 1, int ind = 1) {
  if(l > tr || r < tl) return 0;
  if(l >= tl && r <= tr) {
    return seg[ind];
  }
  int mid = (l + r) / 2;
  int x = qry(tl, tr, l, mid, ind * 2);
  int y = qry(tl, tr, mid + 1, r, ind * 2 + 1);
  return seg[ind] = max(x, y);
}

void dfs(int u, int p = -1) {
  int q = qry(a[u], a[u]);
  int c = qry(0, a[u] - 1);
  upd(a[u], c + 1);
  //cout << u << " -> " << c << " , " << a[u] << " ; " << q << endl;
  res[u] = qry(0, n - 1);
  for(int v : g[u]) {
    if(p != v) {
      dfs(v, u);
    }
  }
  upd(a[u], q);
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  #ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif

  cin >> n;
  vi vec;
  for(int i = 0; i < n; i++) {
    cin >> a[i];
    vec.push_back(a[i]);
  }
  sort(all(vec));
  vec.erase(unique(all(vec)), vec.end());
  for(int i = 0; i < n; i++) {
    a[i] = lower_bound(all(vec), a[i]) - vec.begin();
  }
  for(int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    u--; v--;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  dfs(0);
  for(int i = 0; i < n; i++) {
    cout << res[i] << "\n";
  }
}

Measured memory_bytes: 30852
//  main.cpp
//  ABC168D

#include <iostream>
#include <vector>
#include <queue>
using namespace std;
const int INF=1001001001;
int main(int argc, const char * argv[]) {
    int n,m;
    cin >> n >> m;
    vector<int> r[100005];
    for (int i=0; i<m; i++) {
        int a,b;
        cin>>a>>b;
        r[a].push_back(b);
        r[b].push_back(a);
    }
    queue <int>q;
    vector<int>dist(n+1,INF); // 入り口からの距離
    dist.at(1)=0; // 入り口の洞窟
    q.push(1);
    vector<int>pre(n+1,-1); // 直前の洞窟番号
    while(!q.empty()){
        int v=q.front(); // 先頭の洞窟番号
        q.pop();
        for(int u:r[v]){
            if(dist[u]==INF){
                dist[u]=dist[v]+1;
                pre[u]=v;
                q.push(u);
            }
        }
    }
    cout<<"Yes"<<endl;
    for (int i=2; i<=n; i++) {
        cout <<pre.at(i)<<endl;
    }
    
    
    
    return 0;
}


Measured memory_bytes: 10184
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)
import Data.List

main = do
  n <- readLn :: IO Int
  t <- getIntListBC
  m <- readLn :: IO Int
  px <- getInt2DListBC
  let ans = map (drink t) px
  putStr . unlines . map show $ ans

bsToInt :: BC.ByteString -> Int
bsToInt = fst . fromJust . BC.readInt

getIntBC :: IO Int
getIntBC = bsToInt <$> BC.getLine

getIntListBC :: IO [Int]
getIntListBC = map bsToInt . BC.words <$> BC.getLine

getInt2DListBC :: IO [[Int]]
getInt2DListBC = map (map bsToInt . BC.words) . BC.lines <$> BC.getContents

drink :: [Int] -> [Int] -> Int
drink t [p, x] = sum $ take (p-1) t ++ [x] ++ drop p t


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

int main() {
  string s; cin >> s;
  ll ans = 0;
  rep(x, 1<<(s.size()-1)){
    ll num = 0;
    rep(i,s.size()){
      num *= 10;
      num += s[i] - '0';
      if(x&(1<<i)){
        ans += num;
        num = 0;
      }
    }
    ans += num;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

// int inf = 1 << 28;
int inf = 100000000;

int dijk(int n,int s, int **g) {
	int sum = 0;
	bool *used = new bool[n];
	int *d = new int[n];

	// std::cout << "n = " << n << " " << "s = " << s << std::endl;

/*
	for(int j=0;j<n;j++){
		for(int i=0;i<n;i++){
			std::cout << g[j][i] << ",";
		}
		std::cout << std::endl;
	}
*/

	for(int i = 0; i < n; i++){
		d[i] = inf;
		used[i]=false;
	}
	d[s] = 0;

	while(true) {
		int u = -1;
		for(int v = 0; v < n; v++)
			if(!used[v] && (u == -1 || d[v] < d[u]))
				u = v;

		// std::cout << "u = " << u << std::endl;

		if(u == -1) break;
		used[u] = true;

		for(int v = 0; v < n; v++)
			if(d[v] > d[u] + g[u][v])
				d[v] = d[u] + g[u][v];
	}

	for(int i = 0; i < n; i++) {
		sum += d[i];
	}

	// for(int i = 0; i < n; i++) {
	// std::cout << d[i] << std::endl;
	// }

	return sum;
}

int main() {
	do {
		int **g; // adjacency matrix, ?
		int *d;
		int *a, *b, *c;
		int edge = 0, min = 0, max = 0;
		int tmp = 0;

		std::cin >> edge;
		if(!edge) break;

		a = new int[edge];
		b = new int[edge];
		c = new int[edge];

		for(int i = 0;i < edge;i++) {
			std::cin >> a[i];
			std::cin >> b[i];
			std::cin >> c[i];
		}

		for(int i = 0; i < edge; i++) {
			if(max < a[i])
				max = a[i];
		}
		for(int i = 0; i < edge; i++) {
			if(max < b[i])
				max = b[i];
		}
		max++;

		g = new int*[max];
		d = new int[max];

		for(int i = 0; i < max; i++) {
			g[i] = new int[max];
		}

		for(int i = 0; i < max; i++)
			for(int j = 0; j < max; j++)
				g[i][j] = inf;

		for(int i = 0; i < edge; i++)
			g[b[i]][a[i]] = g[a[i]][b[i]] = c[i];

/*
		for(int i=0;i<max;i++){
			g[i][i]=0;
		}

		for(int k=0;k<max;k++){
			for(int j=0;j<max;j++){
				for(int i=0;i<max;i++){
					if(g[i][k]+g[k][j]<g[i][j]){
						g[i][j]=g[i][k]+g[k][j];
					}
				}
			}
		}
*/

		for(int i = 0; i < max; i++)
			d[i] = dijk(max, i, g);

/*
		for(int i = 0; i < max; i++){
			d[i]=0;
			for(int j=0;j<max;j++){
				d[i] += g[i][j];
			}
		}
*/

		min = d[0];
		for(int i = 1; i < max; i++) {
			if(min > d[i]) {
				min = d[i];
				tmp = i;
			}
		}

		std::cout << tmp << " " << min << std::endl;
		for(int i = 0; i < max; i++)
			delete[] g[i];
		delete[] g;
		delete[] a;
		delete[] b;
		delete[] c;
		delete[] d;

	}while(true);
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;
#define ll long long
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define clr(x,y) memset(x,y,sizeof(x))
#define in(a) a=read()
#define out(a) printf("%d\n",a)
inline ll read(){
    char c=getchar();ll f=1,x=0;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9')x=x*10+(c-'0'),c=getchar();
    return x*f;
}
#define mod 1000000007
void MOD(int &x){if(x>=mod)x-=mod;}
#define maxn 100010
#define inf (1<<30)
int a[100][100],b[100];
int main(){
	int n,m,c;
	in(n);in(m);in(c);
	FOR(i,1,m)in(b[i]);
	int k=0;
	FOR(i,1,n){
		int ans=0;
		FOR(j,1,m){
			ans+=read()*b[j];
		}
		if(ans+c>0)k++;
	}
	out(k);	
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

void solve() {
  while (true) {
    string x;
    cin >> x;
    if (x == "0") return;
    ll ans = 0;
    rep (i, x.size()) ans += x[i] - '0';
    cout << ans << endl;
  }
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  cout << fixed;
  solve();
  return 0;
}



Measured memory_bytes: 3232
using System;
 
public class A
{
  public static void Main()
  {
    string[] input = Console.ReadLine().Split();
    if(int.Parse(input[0]) * int.Parse(input[1]) % 2 == 0)
    {
      Console.WriteLine("Even");
    }
    else
    {
      Console.WriteLine("Odd");
    }
  }
}

Measured memory_bytes: 13140
#include<iostream>
#include<set>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repe(i, n) for(int i = 0; i <= (int)(n); i++)
#define rep1(i, n) for(int i = 1; i < (int)(n); i++)

#include <algorithm>
using namespace std;
#include <cmath>
#include <string>
#define elif else if
typedef long long ll;

int main(){
  int K,S;
  int ans =0;
  cin>>K>>S;
  repe(i,K){
    repe(j,K){
      int Z = S -i-j;
      if(0<=Z && Z<=K )ans++;
      
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<math.h>
#include<cmath>
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<stdio.h>
#include<queue>
using namespace std;
int main()
{
  int a,b;
  cin>>a>>b;
  if(b==100)
    a=1000*a+100;
  else if(b<10)
    a=10*a+b;
  else
    a=100*a+b;
  for(int i=1;i*i<=a;i++)
  {
    if(i*i==a)
    {
      cout<<"Yes\n";
      system("pause");
      return 0;
    }
  }
    cout<<"No\n";
  system("pause");
  return 0;
}

Measured memory_bytes: 504
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string S;
            S = Console.ReadLine();

            for(int i = 0; i < S.Length; i++)
            {
                Console.Write("x");
            }

            Console.WriteLine();

        }
    }
}


Measured memory_bytes: 11092
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <string>
#include <map>

using std::cin;
using std::cout;
using std::endl;
using std::terminate;
using std::string;
using std::map;
using std::make_pair;

void solve() {
    int n, m; cin >> n >> m;

    map<int, char> dic;
    for (int a = 1; a <= m; ++a) {
        int s; cin >> s; s--;
        char c; cin >> c;

        map<int, char>::iterator it = dic.find(s);
        if (it != dic.end()) {
            if (it->second != c) {
                cout << -1 << endl;
                return ;
            }
        } else {
            dic.insert(make_pair(s, c));
        }
    }

    // for (decltype(dic)::iterator it = dic.begin(); it != dic.end(); ++it) {
    //     cout << it->first << " " << it->second << endl;
    // }

    if (dic.find(0) == dic.end()) {
        if (n == 1) {
            dic.insert(make_pair(0, '0'));
        } else {
            dic.insert(make_pair(0, '1'));
        }
    } else {
        if (n != 1 && dic.find(0)->second == '0') {
            cout << -1 << endl;
            return ;
        }
    }

    string str;
    str.append(n, '0');
    for (decltype(dic)::iterator it = dic.begin(); it != dic.end(); ++it) {
        str[it->first] = it->second;
    }
    cout << str << endl;

}

int main() {

#ifdef DEV
    std::ifstream in("input");
    cin.rdbuf(in.rdbuf());

    int t; cin >> t;
    for (int x = 1; x <= t; ++x) {
        solve();
    }
#else
    solve();
#endif

    return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <algorithm>
#include <climits>

using namespace std;

int dp[2][1 << 22];

int main(void){
	while(1){
		int n, m; cin >> n >> m;
		if(!n && !m) break;

		int b[505][505]={0};
		for(int i=1; i<=n; i++){
			for(int j=0; j<m; j++){
				char c; cin >> c;
				b[i][j] = c - '0';
			}
		}

		int ans = 0;
		if(n <= 22){
			int S = 1 << n;
			for(int i=0; i<S; i++){
				int cnt = 0;
				int ingredient[501]={0};//材料
				for(int j=1; j<=n; j++){
					if((i & (1<<(j-1))) == 0) continue;
					cnt++;
					for(int k=0; k<m; k++) ingredient[k] ^= b[j][k];
				}
				bool flag = true;
				for(int j=0; j<m; j++){
					if(ingredient[j] == 1){
						flag = false;
						break;
					}
				}
				if(flag) ans = max(ans, cnt);
			}
		}else{
			int B[501]={0};
			for(int i=1; i<=n; i++){
				for(int j=0; j<m; j++){
					B[i] |= (b[i][j] << j);
				}
			}

			int S = 1 << m;
			fill(dp[0], dp[2], INT_MIN);
			//for(int i=0; i<S; i++) dp[0][i] = dp[1][i] = INT_MIN;
			dp[0][0] = 0;
			for(int i=0; i<n; i++){
				for(int j=0; j<S; j++){
					dp[(i+1)%2][j^B[i+1]] = max(dp[(i+1)%2][j^B[i+1]], dp[i%2][j] + 1);
					dp[(i+1)%2][j] = max(dp[(i+1)%2][j], dp[i%2][j]);
				}
			}
			ans = dp[n%2][0];
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 36864
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S,T;
  cin >> S >> T;
  int count=0;
  for(int i=0;i<S.size();i++){
    if(S.at(i)!=T.at(i)){
      T.at(i)=S.at(i);
      count++;
    }
  }
  cout<<count<<endl;
}

Measured memory_bytes: 3816
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

int main(void){
  int i,n;
  int a[30];
  char s[100001];

  scanf("%s",s);

  n = strlen(s);

  sort(s,s+n);

  for(i=0;i<26;i++)
    a[i]=0;

  for(i=0;i<n;i++){
    a[s[i]-'a']++;
  }

  for(i=0;i<26;i++){
    if(a[i]==0) break;
  }
  if(i==26)
    printf("None\n");
  else
    printf("%c\n",i+'a');

  return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	if (x + r > W || x -r < 0 || y + r > H || y - r <0)
	{
		printf("No\n");
		/* code */
	}else
	{
		printf("Yes\n");
	}
	/* code */
	return 0;
}

Measured memory_bytes: 580
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)

using namespace std;
#define ll long long

int D;
ll G;
int P[10];
ll C[10];
int ans = 1000;

void select_problem(int t, int i=0, int n=0, ll tmp=0LL) {
  // cout << t << ' ' << i << ' ' << n << ' ' << tmp << endl;
  if(i == D) {
    // cout << ceil(max((G - tmp), 0LL) / 100.0*(t+1)) << endl;
    if(tmp + 100*(t+1)*P[t] >= G && n + ceil(max((G - tmp), 0LL) / (100.0*(t+1))) < ans) {
      ans = n + ceil(max((G - tmp), 0LL) / (100.0*(t+1)));
    }
    return;
  } else {
    if(i != t)
      select_problem(t, i+1, n+P[i], tmp+100*(i+1)*P[i]+C[i]);
    select_problem(t, i+1, n, tmp);
  }
}

int main(){
  cin >> D >> G;
  for(int i=0; i<D; i++)
    cin >> P[i] >> C[i];
  for(int i=0; i<D; i++)
    select_problem(i);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
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; }

// 入力
int N;
long long a[100010][3]; // a[i], b[i], c[i] をそれぞれまとめて a[i][0], a[i][1], a[i][2] にしてしまう

// DP テーブル
long long dp[100010][3];

int main() {
    int N; cin >> N;
    for (int i = 0; i < N; ++i) for (int j = 0; j < 3; ++j) cin >> a[i][j];

    // 初期化は既に 0 に初期化される
    // 初期条件も既に 0 で OK

    // ループ
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) {
                if (j == k) continue;
                chmax(dp[i + 1][k], dp[i][j] + a[i][k]);
            }
        }
    }

    // 答え
    long long res = 0;
    for (int j = 0; j < 3; ++j) chmax(res, dp[N][j]);
    cout << res << endl;
}

Measured memory_bytes: 8276
//#include <bits/stdc++.h>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <limits>
#include <map>
#include <vector>
#include <queue> 
#define LL long long
#define ft first
#define sd second
#define mp(x,y) make_pair(x,y)
//#define int LL
#define db double
using namespace std;
//const int N   = ;
//const int mod = ;
const int INF =numeric_limits<int >::max();
#define For(n) for (int i=1;i<=n;++i)
#define rep(i,x,y) for (int i=x;i<=y;++i)
void read(int &x)
{
	x=0;
	char ch=getchar();
	int f=1;
	while (!isdigit(ch)) (ch=='-'?f=-1:0),ch=getchar();
	while ( isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	x*=f;
}

int A,B,C,n,m,k;

signed main()
{
	read(A);read(B);read(C);read(n);read(m);k=min(n,m);
	if (A+B>2*C)
	{
		int ans=k*2*C+(n-k)*A+(m-k)*B,R=max(n,m);
		rep(i,k+1,R) ans=min(ans,i*2*C+max(n-i,0)*A+max(m-i,0)*B);
		printf("%d",ans);
	} //printf("%d",k*2*C+(n-k)*A+(m-k)*B);
	else printf("%d",n*A+m*B);
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;

import static java.util.Arrays.binarySearch;
import static java.util.Arrays.copyOfRange;
import static java.util.Arrays.sort;

public class Main {

    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;

        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }
}

class Task {

    private static int mod = 998244353;

    public void solve(int testNumber, InputReader in, PrintWriter out) {
        String s = in.next();
        String t = in.next();
        out.println(s.length() + 1 == t.length() && s.equals(t.substring(0, t.length() - 1)) ? "Yes" : "No");
   }

}

class InputReader {

    private final BufferedReader reader;
    private StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public String nextLine() {
        try {
            return reader.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(nextLine());
        }
        return tokenizer.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }

}


Measured memory_bytes: 32640
def main(n, A):
    if A[0] != 0:
        return -1

    A.append(0)
    A = A[::-1]

    res = 0
    for x, y in zip(A[:-1], A[1:]):
        if x <= y:
            res += y
        elif x - 1 == y:
            pass
        else:
            return -1

    return res


if __name__ == "__main__":
    n = int(input())
    a = [int(input()) for _ in range(n)]
    ans = main(n, a)
    print(ans)


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

typedef long long ll;
#define fori(n) for(int i=0;i<n;i++)
#define pb push_back


ll power(ll base,ll e)
{
    ll answer=1;
    //ll e=1000000005;
    while(e)
    {
        if(e%2==1)
        {
            answer*=base;
        }
        base*=base;
       // base%=mod;
        e/=2;
       // answer%=mod;
    }
    return answer;
}


void sieveprimes(ll n)
{
    bool prime[n+1];
    memset(prime,true,sizeof(prime));

    for(ll i=2;i*i<=n;i++)
    {
        if(prime[i]==true)
        {
            for(ll j=i*i;j<=n;j+=i)
            {
                prime[j]=false;
            }

        }

    }

    /*for (int p=2; p<=n; p++)
       if (prime[p])
          cout << p << " ";*/
    /*for(ll i=2;i<=n;i++)
    {
        if(prime[i])    ans.insert(i*i);
    }*/
}


int main()
{
    string s;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5])    cout<<"Yes"<<"\n";
    else    cout<<"No"<<"\n";

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>

using namespace std;
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;

int MOD = 1000000007;

std::vector<ll> enum_div(ll n)//nの約数を列挙
{
    std::vector<ll> ret;
    for(ll i=1LL ; i*i<=n ; ++i)
    {
        if(n%i == 0LL)
        {
            ret.push_back(i);
            if(i!=1LL && i*i!=n)
            {
                ret.push_back(n/i);
            }
        }
    }
    return ret;
}

int main(){
    std::ios_base::sync_with_stdio(false);

    ll n; cin >> n;
    ll ans = 0LL;

    if(n==1){
        cout << 0 << endl;
        return 0;
    }

    std::vector<ll> divs = enum_div(n);

    rep(i,divs.size()){
        ll x = divs[i];
        if(x==0) continue;


        ll m = n/x-1;

        if(n/m == n%m){
            ans+=m;
        }
    }

    cout << ans << endl;
    
    

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
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(){
    ll h,w; cin>>h>>w;
    ll white=0;
    vector<string> masu(h);
    rep(i,h) cin>>masu[i];
    rep(i,h){
        rep(j,w){
            if(masu[i][j]=='.') white++;
        }
    }
    vector<ll> dx={0,1,0,-1}, dy={1,0,-1,0};

    queue<pair<ll,ll>> que;
    vector<vector<bool>> used(h, vector<bool>(w, false));
    vector<vector<ll>> dis(h, vector<ll>(w, -1));
    used[0][0]=true;
    dis[0][0]=1;
    que.push({0,0});
    while(!que.empty()){
        pair<ll,ll> p=que.front();
        que.pop();
        ll x=p.first, y=p.second;
        rep(i,4){
            if(x+dx[i]<0 || x+dx[i]>=h || y+dy[i]<0 || y+dy[i]>=w) continue;
            if(masu[x+dx[i]][y+dy[i]]=='#') continue;
            if(used[x+dx[i]][y+dy[i]]) continue;
            used[x+dx[i]][y+dy[i]]=true;
            que.push({x+dx[i], y+dy[i]});
            dis[x+dx[i]][y+dy[i]]=dis[x][y]+1;
        }
    }
    if(dis[h-1][w-1]==-1) cout<<-1<<endl;
    else cout<<white-dis[h-1][w-1]<<endl;
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;

int main(){
 double x1, y1, x2, y2;
 cin >> x1 >> y1 >> x2 >> y2;
 double square = (x2-x1)*(x2-x1)+(y2-y1)*(y2-y1);
 double dis = sqrt( square );
 printf("%f\n", dis);
}
 


Measured memory_bytes: 3176
#define D(x) cout << #x " = " << x << endl
#define DD(x, y) cout << "(" #x ", " #y ") = (" << x << ", " << y << ")" << endl
#define DDD(x, y, z) cout << "(" #x ", " #y ", " #z ") = (" << x << ", " << y << ", " << z << ")" << endl
#define DV(v) for (auto __macro_vi : v){ cout << __macro_vi << " ";} cout << endl;
#define DA(a, n) for (int __macro_i = 0; __macro_i < n; ++__macro_i) { cout << a[__macro_i] << " "; } cout << endl;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(v) (v).begin(), (v).end()
#include<iostream>
#include<vector>
#include<cassert>
#include<cmath>
#include<algorithm>

using namespace std;
int t[3];
int n;
int main()
{
    cin >> n;
    for(int i = 0; i < n; ++i) {
        for(int k = 0; k < 3; ++k) {
            cin >> t[k];
        }
        sort(t, t + 3);
        cout << ((t[2] * t[2] == t[0] * t[0] + t[1] * t[1]) ? "YES" : "NO") << endl;
    }
}



Measured memory_bytes: 3036
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize, q: usize,
        s: chars,
        lr: [(usize1, usize1); q],
    }
    let mut acc = vec![0; n];
    for i in 0..n - 1 {
        let d = if s[i] == 'A' && s[i + 1] == 'C' {
            1
        } else {
            0
        };
        acc[i + 1] = acc[i] + d;
    }
    for &(l, r) in &lr {
        puts!("{}\n", acc[r] - acc[l]);
    }
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 11132
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, char> Pc;
typedef pair<int, string> Ps;

const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};
const int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
const string dir8[8] = {"U", "RU", "R", "RD", "D", "LD", "L", "LU"};

// Self settings
// clang-format off
#define MAX_N 100000
#define MAX 100000
#define INFTY (1<<30)
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1000100011;
class Point { public: double x, y; Point(double x = 0, double y = 0) : x(x), y(y) {} Point operator+(Point p) { return Point(x + p.x, y + p.y); } Point operator-(Point p) { return Point(x - p.x, y - p.y); } Point operator*(double a) { return Point(a * x, a * y); } Point operator/(double a) { return Point(x / a, y / a); } double abs() { return sqrt(norm()); } double norm() { return x * x + y * y; } bool operator<(const Point& p) const { return x != p.x ? x < p.x : y < p.y; } bool operator==(const Point& p) const { return fabs(x - p.y) < EPS && fabs(y - p.y) < EPS; } };
typedef Point Vector;
double norm(Vector a) { return a.x * a.x + a.y * a.y; }
double abs(Vector a) { return sqrt(norm(a));}
double dot(Vector a, Vector b) { return a.x * b.x + a.y * b.y; }
double cross(Vector a, Vector b) { return a.x * b.y - a.y * b.x; }
struct Segment { Point p1, p2; };
typedef Segment Line;
struct Node { int data; Node *left, *right; Node(int data) : data(data), left(NULL), right(NULL) {} };
// clang-format on

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  int turn = 0;
  while (A > 0 && C > 0) {
    if (turn % 2 == 0) {
      C -= B;
    } else {
      A -= D;
    }
    turn++;
  }

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

  return 0;
}


Measured memory_bytes: 3128
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ARoundOne solver = new ARoundOne();
        solver.solve(1, in, out);
        out.close();
    }

    static class ARoundOne {
        public void solve(int testNumber, FastReader s, PrintWriter out) {
            int a = s.nextInt();
            int b = s.nextInt();
            out.println(6 - (a + b));
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 21460
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ii=pair<ll,ll>;
using vi=vector<ll>;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (ll)1e18
#define all(x) (x).begin(),(x).end()
#define print(a); for(auto x:a)cout<<x*2<<" "; cout<<"\n";
#define mset(a); memset(a,0,sizeof(a));

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
    ll n,k;cin>>n>>k;
    map<ll,ll>m;
    for(int i=0;i<n;i++){
        ll a,b;cin>>a>>b;
        m[a]+=b;
    }
    for(auto x:m){
        k-=x.se;
        if(k<=0){
            cout<<x.fi<<"\n";break;
        }
    }
}


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

vector<vector<pair<int, int>>> G;
vector<int> A;

void dfs(int now, int pre, int clr) {
  A.at(now) = clr;
  for (auto g : G.at(now))
    if (g.first != pre) dfs(g.first, now, clr^(g.second & 1));
}

int main() {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  G.resize(N + 1), A.resize(N + 1);
  for (int i = 1, u, v, w; i < N && cin >> u >> v >> w; i++)
    G.at(u).emplace_back(v, w), G.at(v).emplace_back(u, w);

  dfs(1, 0, 0);

  for (int i = 1; i <= N; i++) cout << A.at(i) << "\n";
}

Measured memory_bytes: 8192
#include<iostream>
#include <iostream>
#include<math.h>
#include<algorithm>
typedef long long int ll;
using namespace std;
int main(){
    ll x,n,m,tmp,a,b,r;
    bool flag=true;
    string s,t;
    cin>>n>>m;
    cin>>s>>t;
    x=n*m;
    a=n;
    b=m;  
    if(n==m)r=n;  
    if(n<m){
    tmp = n;
    n = m;
    m = tmp;
 
  }
  /* ユークリッドの互除法 */
  r=n%m;
  while(r!=0){
    n=m;
    m=r;
    r=n%m;
  }

  x=x/m;

for(int i=0;i<m;i++){
    if(s[i*a/m]!=t[i*b/m])flag=false;
}

    if(flag)cout<<x<<endl;
    else cout<<-1<<endl;

}

Measured memory_bytes: 512
#include<cstdio>
#include<cmath>
#include<climits>
#include<algorithm>
#include<sstream>
#include<iostream>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<list>
#include<map>
#include<vector>

using namespace std;


#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define ll long long

#define IMIN INT_MIN;
#define IMAX INT_MAX;


int main(){
	int N;
	cin >> N;
	vector<int> H(N);
	rep(i, N) cin >> H[i];


	int cnt = 1;
	int st = H[0];

	rept(i, 1, N) {
		if (st <= H[i]) {
			cnt++;
			st = H[i];
		}
		else continue;
	}

	cout << cnt << endl;




	return 0;
}



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

typedef long long ll;
const int MaxN = 212345;
const ll mod = 1000000007;

ll add(ll a, ll b) {
	return (a + b) % mod;
}

void solve_case() {
	int n, m;
	cin >> n >> m;
	vector<string> mat(n);
	for (int i = 0; i < n; i++) {
		cin >> mat[i];
	}
	ll dp[n][m];
	memset(dp, 0, sizeof(dp));
	dp[0][0] = 1;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			//cout << "hdhdh";
			if(j - 1 >= 0 && mat[i][j - 1] != '#') {
				dp[i][j] = add(dp[i][j], dp[i][j-1]);
			}
			if(i - 1 >= 0 && mat[i - 1][j] != '#') {
				dp[i][j] = add(dp[i][j], dp[i - 1][j]);
			}
		}
	}
	
	
	cout << dp[n - 1][m - 1] << "\n";
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    ll t=1;
    //cin >> t;
    while(t--) solve_case();
}


Measured memory_bytes: 12424
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ios ios_base::sync_with_stdio(false);cout.tie(0);cin.tie(0);

int main()
{
    ll x;
    cin>>x;
    for(ll i=0;i<=1000000;i++)
    {
        for(ll j=0;j<=1000000;j++)
        {
            ll p=i*i*i*i*i;
            ll q=j*j*j*j*j;
            if(p-q==x)
            {
                cout<<i<<" "<<j;
                return 0;
            }
            j=-j;
            p=i*i*i*i*i;
            q=j*j*j*j*j;
            if(p-q==x)
            {
                cout<<i<<" "<<j;
                return 0;
            }
            i=-i;
            p=i*i*i*i*i;
            q=j*j*j*j*j;
            if(p-q==x)
            {
                cout<<i<<" "<<j;
                return 0;
            }
            j=-j;
            p=i*i*i*i*i;
            q=j*j*j*j*j;
            if(p-q==x)
            {
                cout<<i<<" "<<j;
                return 0;
            }
            i=-i;
        }
    }
    return 0;
}


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

#整数値龍力　複数の入力
def input_multiple_number():
    return map(int, input().split())

S = input()
K = int(input())


if len(S) >= 1:
	flagtail = 0
	old_s = ""
	cnt = 0
	for s_ in S:
		if s_ == old_s:
			cnt +=1
			old_s = ""
		else:
			old_s = s_
	ans = cnt

	cnt1 = cnt
	old_s = ""

	if(K > 1 and K %2 == 0):
		S = S*2
		cnt1 = cnt
		cnt = 0
		old_s = ""
		for s_ in S:
			if s_ == old_s:
				cnt +=1
				old_s = ""
			else:
				old_s = s_

		ans = cnt1 + (cnt-cnt1)*(K-1)

	if(K > 1 and K %2 != 0):
		S = S*3
		cnt1 = cnt
		cnt = 0
		old_s = ""
		for s_ in S:
			if s_ == old_s:
				cnt +=1
				old_s = ""
			else:
				old_s = s_

		ans = cnt1 + (cnt-cnt1)*(K-1)//2
	print(ans)
else:
	print(K//2)

Measured memory_bytes: 3444
S = input()
K = input()
if len(K) > 100:
    K = 110
else:
    K = int(K)


def main():
    if S[0] != '1':
        print(S[0])
        return

    for i in range(len(S)):
        if S[i] != '1':
            break

    if i == len(S) - 1:
        print('1')
        return

    if K <= i:
        print('1')
        return

    print(S[i])


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
N,M = map(int,input().split())
X = list(map(int,input().split()))

if N >= M:
  print(0)
  exit()

X.sort()
L = []
for i in range(M-1):
  L.append(X[i+1]-X[i])
L.sort()
#print(L)
print(sum(L[:M-N]))


Measured memory_bytes: 56744
#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(void) {
	int N, K;
	scanf("%d %d" , &N, &K);
	int A[200100];
	for (int i = 0; i < N; i++) {
		scanf("%d", &A[i]);
	}
	// int hyoten[200100];
	// // for (int i = K - 1; i < N; i++) {
	// 	hyoten[i] = 1;
	// 	for (int j = i - K + 1; j <= i; j++) {
	// 		// cout << "(i,j)" << " " << i << " " << j << " " << A[j] << "\n";
	// 		hyoten[i] *= A[j];
	// 	}
	// 	// cout << hyoten[i] << "\n";
	// }
	for (int i = K; i < N; i++) {
		// if (hyoten[i] > hyoten[i - 1]) printf("Yes\n");
		// else printf("No\n");
		if (A[i] > A[i - K]) printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 4464