akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define fr first
#define sc second
#define pb push_back
#define ll long long
#define maxheap priority_queue<int>
#define minheap priority_queue<int,vector<int>,greater<int>>
const  long double eps = 1e-2;
const long double pi = acos(-1.0);
using namespace std;


vector<int> z_function (string s) {
	int n = (int) s.length();
	vector<int> z (n);
	for (int i=1, l=0, r=0; i<n; ++i) {
		if (i <= r)
			z[i] = min (r-i+1, z[i-l]);
		while (i+z[i] < n && s[z[i]] == s[i+z[i]])
			++z[i];
		if (i+z[i]-1 > r)
			l = i,  r = i+z[i]-1;
	}
	return z;
}

vector <bool> get(string s){
    int n = s.length();
    vector <bool> bol(n + 1, false);
    vector <int> z = z_function(s);
        int d = 1e9;
        for (int i = 1; i <= n; i++) {
        for (int j = 2 * i; j <= n; j += i) {
            if (z[i] >= j - i) {
                bol[j] = true;
            }
        }
    }
    return bol;
}

void solve(){
    string s;
    cin >> s;
    bool ok = false;
    for (int i = 0; i < s.length() - 1; i++)
        if (s[i] != s[i + 1])
            ok = true;

    if (!ok){
        cout << s.length() << endl;
        cout << 1 << endl;
        return;
    }
 
    vector <bool> bol1, bol2;
    bol1 = get(s);
    reverse(s.begin(), s.end());
    bol2 = get(s);
    
    if (bol1[s.length()] == false){
    
        cout << 1 << endl;
        cout << 1 << endl;
        return;
    }
    //for (auto x : bol1) cout << x << " ";
   // cout << endl;
   // for (auto x : bol2) cout << x << " ";
    //cout << endl;
    int ans = 0;
    for (int i = 1; i <= s.length() - 1; i++){
            if (!bol1[i] && !bol2[s.length() - i])  
                ans++;
    }
    cout << 2 << endl;
    cout << ans << endl;
}
int main() {
    ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
    cout.setf(ios::fixed), cout.precision(3);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int step;
	step = 1;
    for (int i = 1; i <= step; i++){
         solve();
    }
}


Measured memory_bytes: 6932
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
"""
a,b,c = LS()
if a[-1] == b[0] and b[-1] == c[0]:
    print("YES")
else:
    print("NO")
"""
#B
a,b,c = LI()
x = a
f = [0 for i in range(b)]
while 1:
    if a%b == c:
        print("YES")
        quit()
    if f[a%b]:
        print("NO")
        quit()
    f[a%b] = 1
    a += x
#C
""""
n,T = LI()
ans = 0
t = LI()
for i in range(n-1):
    ans += min(T,t[i+1]-t[i])
ans += T
print(ans)
"""

#D
"""
n,w = LI()
g = LIR(n)
l = [[] for i in range(4)]
for W,v in g:
    l[W-g[0][0]].append(v)
    l[W-g[0][0]].sort(reverse = True)
l0 = len(l[0])
l1 = len(l[1])
l2 = len(l[2])
l3 = len(l[3])
for i in range(l0-1):
    l[0][i+1] += l[0][i]
l[0].insert(0,0)
for i in range(l1-1):
    l[1][i+1] += l[1][i]
l[1].insert(0,0)
for i in range(l2-1):
    l[2][i+1] += l[2][i]
l[2].insert(0,0)
for i in range(l3-1):
    l[3][i+1] += l[3][i]
l[3].insert(0,0)
ans = 0
for i in range(l0+1):
    for j in range(l1+1):
        for k in range(l2+1):
            for m in range(l3+1):
                if i*g[0][0]+j*(g[0][0]+1)+k*(g[0][0]+2)+m*(g[0][0]+3) <= w:
                    ans = max(ans,l[0][i]+l[1][j]+l[2][k]+l[3][m])
print(ans)
"""

#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 38512
#include<iostream>
#include<string>
#include<vector>
#include <algorithm>

#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)

#define INF 1e9
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;


template<class T>T max(T a, T b) { return a > b ? a : b; }
template<class T>T min(T a, T b) { return a < b ? a : b; }
template<class T>bool chmax(T &a, const T &b) {
	if (a < b) { a = b; return 1; }
	return 0;
}
template<class T>bool chmix(T &a, const T &b) {
	if (a > b) { a = b; return 1; }
	return 0;
}

int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };


using namespace std;
int main()
{
	int n;
	cin >> n;

	vector<int> v1,v2;
	REP(i, n) {
		int x;
		cin >> x;
		v1.push_back(x);
		v2.push_back(x);
	}

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

	int cnt = 0;
	REP(i, n) {
		if (v1[i] == v2[i])cnt++;
	}
	if (cnt == n || cnt == n - 2) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int b=a;
		int count=0;
		for(int i=0;i!=8;i++) {
			count+=b%10;
			b/=10;
		}
		if(a%count==0) {
			System.out.println("Yes");
		}
		else {
		System.out.println("No");
		}
		}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h> 
using   namespace std;
typedef long long int ll;
#define fo(i,s,e_ex) for(i=s;i<e_ex;i++)
#define Fo(i,s,e) for(i=s;i<=e;i++)
#define endl '\n'
#define MOD 1000000007//998244353
#define pbb push_back
#define mpp make_pair
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define mset(arr,val) memset(arr,val,sizeof(arr))
ll dfs(ll start,bool* visited,vector<ll>* edges,ll* dp,ll& ans){
	ll i;
	visited[start]=true;
	fo(i,0,edges[start].size()){
		ll adjv = edges[start][i];
		if(!visited[adjv]){
			dp[start]=max(dp[start],1+dfs(adjv,visited,edges,dp,ans));
		}else dp[start] = max(dp[start],1+dp[adjv]);
	}
	ans = max(ans,dp[start]);
	return dp[start];
}
void solve(){
	ll i,j,n,m;
	cin>>n>>m;
	vector<ll>* edges = new vector<ll>[n];
	fo(i,0,m){
		ll u,v;
		cin>>u>>v;
		u--;v--;
		edges[u].pbb(v);
	}
	ll* dp = new ll[n];
	bool* visited = new bool[n]();
	fo(i,0,n) dp[i]=0;
	ll ans=-1;
	fo(i,0,n){
		if(!visited[i]) 
			dfs(i,visited,edges,dp,ans);
	}
	cout<<ans<<endl;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	ll t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 9984
inputs = input().strip().split()
D = int(inputs[0])
G = int(inputs[1])

pi = []
ci = []

for i in range(0, D):
    inputs = input().strip().split()
    pi.append(int(inputs[0]))
    ci.append(int(inputs[1]))

bitArray = []
for i in range(0, pow(2, D)):
    bitArray.append(format(i, 'b').zfill(D))

ans = 1000000
for bit in bitArray:
    num = 0
    score = 0
    for index, value in enumerate(bit):
        if value is "1":
            score += (index + 1) * 100 * pi[index] + ci[index]
            num += pi[index]
        else:
            max_zero_index = index  
    for i in range(0, pi[max_zero_index] - 1):
        if score < G:
            num += 1
            score += (max_zero_index + 1) * 100
    if ans > num and score >= G:
        ans = num

print(ans)

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

int main() {
	int n, num, count = 0;

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> num;
		if (num == 2) {
			count++;
			continue;
		}

		for (int j = 2; j <= sqrt(num); j++)
			if (num % j == 0) {
				count--;
				break;
			}

		count++;
	}
	cout << count << endl;
}

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

using namespace std;

#define REP(i, n)   for(int i = 0; i < (n); i++)
#define REPS(i, n)  for(int i = 1; i <= (n); i++)
#define RREP(i, n)  for(int i = (n)-1; i >= 0; i--)
#define RREPS(i, n) for(int i = (n); i > 0; i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

using ll  = long long;
using pi  = pair<int, int>;
using pl  = pair<ll, ll>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vs  = vector<string>;
using vb  = vector<bool>;
using vvi = vector<vi>;
using vvl = vector<vl>;

const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e9 + 7;
const ll  INFL = 1e18;
const double PI = 3.141592653589793;
const double EPS = 1e-9;

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


signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N; cin >> N;
    vl a(N); REP(i, N) cin >> a[i]; 
    vl sum(N+1); REP(i, N) sum[i+1] += sum[i] + a[i];
    ll ans = INFL;
    for(int i = 1; i < N; i++)
    {
        ll s = sum[i];
        ll t = sum[N] - sum[i];
        chmin(ans, abs(s-t));
    }
    cout << ans << endl;
}

Measured memory_bytes: 6328
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(void)
{
    int n,k;
    cin >> n;
    vector<int> a(7);
    a[0] = 2;
    for (int i = 1;i < 7;i++)
    {
        a[i] = 2 * a[i - 1]; 
    }

    int ans;
    if (n < 2) ans = 1;
    for (int i = 0;i < 7;i++)
    {
        if (n >= a[i]) ans = a[i];
    }

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


Measured memory_bytes: 3592
def main():
    N, M = map(int, input().split())
    AB = []
    for _ in range(M):
        a, b = map(int, input().split())
        AB.append([a, b])

    A = [0] * (N + 3)

    for a, b in AB:
        # print(':', a, b)
        if a == 1:
            A[b] = 1

    # print(A)

    ans = 'IMPOSSIBLE'
    for a, b in AB:
        # print('::', a, b)
        if b == N:
            if A[a] == 1:
                ans = 'POSSIBLE'


    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 37712
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define ll long long
#define INF 1<<31-1
#define LNF 9223372036854775807
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
//#define MOD 998244353
#define NUM 200010
 
void swap(int* a,int* b){int tmp=*a;*a=*b;*b=tmp;}
int abs(int a){if(a<0)return -a;return a;}
int dup(int a,int d){if(a%d==0)return a/d;else return a/d+1;}
int mod(int a,int m){if(a<0)return a%m+m;else return a%m;}

void swapl(ll* a,ll* b){ll tmp=*a;*a=*b;*b=tmp;}
ll absl(ll a){if(a<0)return -a;return a;}
ll dupl(ll a,ll d){if(a%d==0)return a/d;else return a/d+1;}
ll modl(ll a,ll m){if(a<0)return a%m+m;else return a%m;}

ll GCD(ll a,ll b){ll c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
ll LCM(ll a,ll b){return a*b/GCD(a,b);}

ll factorial(ll n, ll m) {return n < m ? 1 : n*factorial(n-1, m);}

int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

// ll dp[]

int main(){
  char s[200001], t[200001];
  int n, ans =0;

  scanf("%s", s);
  scanf("%s", t);

  for(n=0; ;n++) if(s[n] == '\0') break;

  for (int i = 0; i < n; i++)
  {
    if (s[i] != t[i])
    {
      ans++;
    }
  }

  printf("%d\n", ans);

  return 0;
}

Measured memory_bytes: 2100
n = int(input())
for _ in range(n):
  h, w = map(int, input().split())
  mp = [list(input()) for _ in range(h)]
  range_dic = {}
  keys = []
  for y in range(h):
    for x in range(w):
      c = mp[y][x]
      if c in range_dic:
        x1, x2, y1, y2 = range_dic[c]
        range_dic[c] = (min(x, x1), max(x, x2), min(y, y1), max(y, y2))
      else:
        range_dic[c] = (x, x, y, y)
        keys.append(c)
  
  while keys:
    tmp = keys[:]
    for key in keys:
      break_flag = False
      x1, x2, y1, y2 = range_dic[key]
      for x in range(x1, x2 + 1):
        for y in range(y1, y2 + 1):
          if not mp[y][x] in (key, "#"):
            break_flag = True
            break
        if break_flag:
          break
      else:
        for y in range(y1, y2 + 1):
          mp[y][x1:x2 + 1] = ["#"] * (x2 - x1 + 1)
        keys.remove(key)
    
    if tmp == keys:
      print("SUSPICIOUS")
      break
  
  else:
    print("SAFE")


Measured memory_bytes: 5628
import numpy as np
h,w = map(int,input().split())
n = int(input())
a = list(map(int,input().split()))
mat = np.zeros((h,w),dtype=int)
st = 0
for i in range(len(a)):
    for idx in range(st,st+a[i]):
        mat[idx//w][idx%w]=i+1
    st+=a[i]
for i in range(1,h,2):
    mat[i]=mat[i][::-1]
for i in range(h):
    for j in range(w):
        print(mat[i][j],end=" ")
    print("")



Measured memory_bytes: 14552
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <utility>
#include <typeinfo>
#include <tuple>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define INF_LONG 1e18
#define rep(i, n) for(int i=0; i<n; ++i)
#define rep1(i, n) for(int i=1; i<=n; ++i)
#define rrep(i, m, n) for(int i=m; i<n; ++i)
#define countof(array) (sizeof(array) / sizeof(array[0]))
typedef long long ll;

#define MAX_N 200000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100
#define MAX_Q 100000

int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

string as = {"ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
string ab = {"abcdefghijklmnopqrstuvwxyz"};

ll gcd(ll x, ll y) {
  if(y==0) return x;
  else return gcd(y, x%y);
}

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

void yes() {
  cout << "Yes" << endl;
}

void no() {
  cout << "No" << endl;
}

void print_array(int array[], int len) {

  for(int i=0; i<len; ++i) {
    cout << array[i] << endl;
  }

}

ll absolute(ll x) {
  return (x<0)? (-1)*x : x;
}

//g++ AtCoder.cpp -o AtCoder
//AtCoder

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

int main() {

  string s;
  cin >> s;
  int i;

  if(s=="SUN") i = 7;
  else if(s=="MON") i = 6;
  else if(s=="TUE") i = 5;
  else if(s=="WED") i = 4;
  else if(s=="THU") i = 3;
  else if(s=="FRI") i = 2;
  else if(s=="SAT") i = 1;

  cout << i << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
int s[2200];
int t[2200];
int UF[60];
int FIND(int a){
	if(UF[a]<0)return a;
	return UF[a]=FIND(UF[a]);
}
void UNION(int a,int b){
	a=FIND(a);b=FIND(b);if(a==b)return;UF[a]+=UF[b];UF[b]=a;
}
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<b;i++){
		scanf("%d%d",s+i,t+i);s[i]--;t[i]--;
	}
	int ret=0;
	for(int i=0;i<b;i++){
		for(int j=0;j<a;j++)UF[j]=-1;
		for(int j=0;j<b;j++){
			if(i==j)continue;
			UNION(s[j],t[j]);
		}
		if(UF[FIND(0)]!=-a){
			ret++;
		}
	}
	printf("%d\n",ret);
}

Measured memory_bytes: 128
a, b, c = map(int, input().split())
max_value = max(a, b, c)
l = []
d = [a, b, c]
ans = 0
for i in d:
    if max_value-i != 0:
        l.append(max_value-i)
if len(l) == 0:
    print(ans)
    exit()
if len(l) == 1:
    if l[0] % 2 == 0:
        ans = l[0]//2
        print(ans)
        exit()
    else:
        ans = l[0]//2 + 2
        print(ans)
        exit()
if len(l) == 2:
    if sum(l) % 2 == 0:
        print(sum(l)//2)
        exit()
    if sum(l) % 2 == 1:
        print(sum(l)//2+2)
        exit()


Measured memory_bytes: 3064
#include <map>
#include <algorithm>
#include <cassert>
#include <climits>
#include <complex>
#include <cstdio>
#include <string>
#include <iostream>
#include <queue>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
#define DEBUG(X) cerr<<"  "<<#X<<" = "<<X<<endl;
#define DUMP(A, n) for (auto x=begin(A); x!=begin(A)+n;x++){cout <<*x<< ' ';} cout<<endl;
#define DUMPP(A, n, m) for (auto x=begin(A); x != begin(A)+n;x++) {for (auto y=begin(*x); y != begin(*x)+m;)cout <<*y++<< ' '; cout<<endl;};
#define DUMPM(M) for (auto itr=mp.begin(); itr!=mp.end(); itr++) {cout<<itr->first<<" -> "<<itr->second<<endl;}
#define FOR(i,x,y) for(int i=(x);i<(int)(y);i++)
#define FORP(i,x,y) for(int i=(x);i<=(int)(y);i++)
#define REP(i,y) for(int i=0;i<(int)(y);i++)
#define REPP(i,y) for(int i=1;i<=(int)(y);i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
int a,b;
int main() {
  cin >> a >> b;
  if (a+b>=10) cout << "error";
  else cout << a+b;
  cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
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;
}
void hr() { cerr << "--------------" << endl; }
const int INF = 2e9;
const int MOD = 1e9 + 7;

int main() {
   string s;
   cin >> s;
   int ans = 700;
   rep(i, 0, 3) {
      if (s[i] == 'o') ans += 100;
   }
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define DEBUG
#define PI 3.141592653589793238462643383279
 
#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#define sl(...) show(__VA_ARGS__);cout<<endl;
#else
#define s(...)
#define sl(...)
#endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define REP1(i, n) for(ll i = 1; i <= n; i++)
#define REPR1(i, n) for(ll i = n; i >= 1; i--)
#define FOR1(i, m, n) for(ll i = m; i <= n; i++)
const ll INF = LLONG_MAX;
#define VEC(type,A,N) vector<type> A(N)
#define VECi(type,A,N,i) vector<type> A(N,i)
#define VEC2(type,A,N,M) vector<vector<type>> A(N,vector<type>(M))
#define VEC2i(type,A,N,M,i) vector<vector<type>> A(N,vector<type>(M,i))
#define ALL(v) v.begin(), v.end()
ll frac(ll k){
    int s = 1;
    for (ll i=1; i<=k; ++i)s *= i;
    return s;
}
ll gcd(ll a, ll b){
   if (a%b==0)return(b);
   else return(gcd(b, a%b));
}
ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}
ll antidiv(ll N,ll C,ll D){
    return N-floor(N/C)-floor(N/D)+floor(N/lcm(C,D));
}
vector<ll> yakusuu(ll N){
    vector<ll> ret;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            ret.push_back(i);
            if (i * i != N) ret.push_back(N / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}
int main(){
    ll N,K;
    cin>>N>>K;
    
    VEC(ll,h,N);
    REP(i,N){
        cin>>h[i];
    }
    sort(ALL(h));
    ll m=INF;
    REP(i,N-K+1){
        //s(h[i])
        m=min(m,h[i+K-1]-h[i]);
    }
    cout<<m;
    //cout<<fixed<<setprecision(32)<<m;
    //sort(ALL(C),[](auto& a, auto& b) {return a[2] < b[2];});
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 1024
/* 
			BURN OUT
		*/	  

#include <bits/stdc++.h>
using namespace std;
	     
#define ll long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
	     
#define mp make_pair
#define pb push_back
#define ld long double
#define F first
#define S second
const ll N =(1e6);  
const ll mod = (1e9+7);
	
int main(){
	fast;	
	int h , n;
	cin >> h >> n;
	int x ;
	int sum = 0 ;
	for(int i = 0 ;i < n ; i ++)
	{
		cin >> x;
		sum+=x;
	}

	if(sum >= h )
		cout<<"Yes";
	else
		cout<<"No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define PB push_back
#define ZERO (1e-10)
#define INF (1<<29)
#define CL(A,I) (memset(A,I,sizeof(A)))
#define DEB printf("DEB!\n");
#define D(X) cout<<"  "<<#X": "<<X<<endl;
#define EQ(A,B) (A+ZERO>B&&A-ZERO<B)
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
#define IN(n) int n;scanf("%d",&n);
#define FOR(i, m, n) for (int i(m); i < n; i++)
#define REP(i, n) FOR(i, 0, n)
#define F(n) REP(i, n)
#define FF(n) REP(j, n)
#define FT(m, n) FOR(k, m, n)
#define aa first
#define bb second
void ga(int N,int *A){F(N)scanf("%d",A+i);}
#define MX (1<<19)
int N,M,n,A[MX],I,J,D,u,v;
int main(void){
    scanf("%d%d",&n,&M),N=n*2-1;
    if(M==1||M==N)return puts("No"),0;
    D=N/2,I=M-1,J=M+1,u=D-2,v=D+2;
    A[D]=M,A[D+1]=I--,A[D-1]=J++;
    while(~u){
        if(!I)I=N;
        A[u--]=I--;
    }
    while(v<N){
        if(J>N)J=1;
        A[v++]=J++;
    }
    puts("Yes");
    F(N)printf("%d\n",A[i]);
    return 0;
}


Measured memory_bytes: 2304
#include <stdio.h>
#include <string.h>


int main()
{
	int m[100],temp[100];
	for(int i=0;i<10;i++)
	{
		scanf("%d",&m[i]);
	}
	for(int i=0;i<10;i++)
	{
		if(m[i]<m[i+1])
		{
			temp[i]=m[i+1];
			m[i+1]=m[i];
			m[i]=temp[i];
			i=-1;
		}
		
	}
	printf("%d\n%d\n%d\n",m[0],m[1],m[2]);
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define inf 1000000007
#define double long double
using namespace std;
typedef pair<ll, ll>P;
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
ll lcm(ll x, ll y) {
	return x * y / gcd(x, y);
}
ll mod_pow(ll x, ll n, ll mod) {
	ll bit = 1;
	while (n) {
		if (n & 1)bit = bit * x % mod;
		x = x * x % mod;
		n /= 2;
	}
	return bit;
}
void pyes() { cout << "Yay!" << endl; }
void pno() { cout << ":(" << endl; }
struct edge { ll to, cost; };
ll n;
ll a[224224], b[224224];
signed main() {
	cin >> n;
	rep(i, n)cin >> a[i] >> b[i];
	ll ans = 0;
	rep(i, n)ans += a[i] * b[i];
	ll memo = 0;
	rep(i, n)memo += b[i];
	if (ans % 9 == 0)cout << ans / 9 + memo - 2 << endl;
	else cout << ans / 9 + memo - 1 << endl;
	ggr
}



Measured memory_bytes: 3328
w=int(input())
n=int(input())
A=[int(i+1) for i in range(w)]
for i in range(n):
	x,y=map(int,input().split(','))
	A[x-1],A[y-1]=A[y-1],A[x-1]
for i in range(w):
	print(A[i])

Measured memory_bytes: 7664
<?php
list($n, $y) = explode(' ', fgets(STDIN));
$r10000 = -1;
$r5000 = -1;
$r1000 = -1;
for ($a = 0; $a <= $n; $a++) {
    for ($b = 0; $a + $b <= $n; $b++) {
        $c = $n - $a - $b;
        if (10000 * $a + 5000 * $b + 1000 * $c == $y) {
            $r10000 = $a;
            $r5000 = $b;
            $r1000 = $c;
        }
    }
}
printf('%d %d %d', $r10000, $r5000, $r1000);
?>

Measured memory_bytes: 3704
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()
#define INF 1e6
using namespace std;

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

const int MAX_V = 2*200*200 + 2;

struct edge{ int to, cap, cost, rev; };

int V; 				// 頂点数
vector<edge> G[MAX_V];		// グラフの隣接リスト表現
int dist[MAX_V];			// 最短距離
int prevv[MAX_V], preve[MAX_V]; 	// 直前の頂点と辺

// from から to へ向かう容量 cap の辺をグラフに追加する
void add_edge(int from, int to, int cap, int cost){
	G[from].push_back((edge){to, cap, cost, G[to].size()});
	G[to].push_back((edge){from, 0, -cost, G[from].size() - 1});
}

// s から t への流量 f の最小費用流を求める
// 流せない場合は -1 を返す
int min_cost_flow(int s, int t, int f){
	int res = 0;
	while(f > 0){
		// ベルマンフォード法により、s-t 間の最短路を求める
		fill(dist, dist + V, INF);
		dist[s] = 0;
		bool update = true;
		while(update){
			update = false;
			rep(v, V){
				if (dist[v] == INF) continue;
				rep (i, G[v].size()){
					edge &e = G[v][i];
					if (e.cap > 0 && dist[e.to] > dist[v] + e.cost){
						dist[e.to] = dist[v] + e.cost;
						prevv[e.to] = v;
						preve[e.to] = i;
						update = true;
					} // end if
				} // end rep
			} // end rep
		} // end while
		
		if (dist[t] == INF){
			// これ以上流せない
			return -1;
		} // end if
	
		// s-t 間最短路を使って目一杯流す
		int d = f;
		for (int v = t; v != s; v = prevv[v]){
			d = min(d, G[prevv[v]][preve[v]].cap);
		} // end for
		f -= d;
		res += d*dist[t];
		for (int v = t; v != s; v = prevv[v]){
			edge &e = G[prevv[v]][preve[v]];
			e.cap -= d;
			G[v][e.rev].cap += d;
		} // end for
	} // end whle

	return res;
}

int a[202][202];
int in[202][202];
int out[202][202];

int main(){
	memset(a, 0, sizeof(a));
	memset(in, 0, sizeof(in));
	memset(out, 0, sizeof(out));

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int H, W; cin >> H >> W;
	rep (i, H) rep (j, W) cin >> a[i][j];
	V = 2 * H * W + 2;

	int cnt = 0;	
	for (int i = 0; i < H; ++i){
		for (int j = 0; j < W; ++j){
			in[i][j] = cnt++;
		} // end for
	} // end for
	for (int i = 0; i < H; ++i){
		for (int j = 0; j < W; ++j){
			out[i][j] = cnt++;
		} // end for
	} // end for
	int s = cnt++;
	int t = cnt++;

	for (int i = 0; i < H; ++i){
		for (int j = 0; j < W; ++j){
			add_edge(in[i][j], out[i][j], 1, -a[i][j]);
		} // end for
	} // end for

	add_edge(in[0][0], out[0][0], 1, 0);
	add_edge(in[H-1][W-1], out[H-1][W-1], 1, 0);

	for(int i = 0; i < H; ++i){
		for (int j = 0; j < W; ++j){
			if (i + 1 < H){
				add_edge(out[i][j], in[i+1][j], 1, 0);
			} // end if
			if (j + 1 < W){
				add_edge(out[i][j], in[i][j+1], 1, 0);
			} // end if
		} // end for
	} // end for
	add_edge(s, in[0][0], 2, 0);
	add_edge(out[H-1][W-1], t, 2, 0);

	int res = -min_cost_flow(s, t, 2);

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 9856
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <istream>
#include <sstream>
#include <iomanip>
using namespace std;

typedef ostringstream oss;
typedef istringstream iss;

typedef vector<int> vi;
typedef vector< vi > vvi;

int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};

void dfs(vector< vvi >& gred, int h, int w) {
	for (int i = 0; i < 4; i++) {
		if (!gred[h][w][i]) {
			int deh = h + dy[i];
			int dew = w + dx[i];
			if (gred[deh][dew][4] > gred[h][w][4] + 1 || (gred[deh][dew][4] == 1 && !(deh == 0 && dew == 0))) {
				gred[deh][dew][4] = gred[h][w][4] + 1;
				dfs(gred, deh, dew);
			}
		}
	}
}

int main(void) {
	int W, H;
	while (cin >> W >> H, W) {
		vector< vvi > gred(H, vvi(W, vi(5, 1) ) );

		for (int h = 0; h < H * 2 - 1; h++) {
			int tmp;
			if (!(h % 2)) for(int w = 0; w < W - 1; w++) {	//縦
				cin >> tmp;
				gred[h / 2][w][1] = tmp;
				gred[h / 2][w + 1][3] = tmp;
			}else for(int w = 0; w < W; w++) {		//横
				cin >> tmp;
				gred[h / 2][w][2] = tmp;
				gred[h / 2 + 1][w][0] = tmp;
			}
		}

		dfs(gred, 0, 0);

		int res = gred[H - 1][W - 1][4];
		cout << (res == 1 ? 0 : res) << endl;
	}

	return 0;
}

Measured memory_bytes: 1320
let prk ss ps f =
  let ssl = String.length ss in
  let psl = String.length ps in
  let b = 10007 in
  let rec pow n =
    if n = 0 then 1
    else if n mod 2 = 0 then let x = pow (n / 2) in x * x
    else b * pow (n-1) in
  let bb = pow psl in
  let rh s =
    let h = ref 0 in
    String.iter (fun c -> h := !h * b + (Char.code c)) s; !h
  in
  let ih = rh (String.sub ss 0 psl) in
  let psh = rh ps in
  let rec loop h x =
    if h = psh then f x;
    if x >= ssl - psl then ()
    else
      let nh = h * b + (Char.code ss.[x+psl]) - (Char.code ss.[x]) * bb in
      loop nh (x+1)
  in
  loop ih 0

let () =
  let t = read_line () in
  let p = read_line () in
  let f x = string_of_int x |> print_endline in
  try prk t p f with _ -> ()

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

int main() {
  int A,B;
  cin>>A>>B;
  int count_ana=1,count_ans=0;
  while(count_ana<B){
  count_ana+=A-1;
  count_ans++;  
  }
  cout<<count_ans<<endl;
}


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

int main(){
    map<string, int> str;
    map<char, int> ch;
    int N;
    string STR;
    char c = '*';
    cin >> N;
    int flag = 1;
    while(N--){
    	cin >> STR;
    	if(flag){
    	   if(str[STR]!=0)
		   {
		   	flag = 0;
			   }
		   else {
		   	str[STR]++;
		   }
		   if(c == *STR.begin() || c == '*'){
		   	c = STR.back();
		   }	
		   else flag = 0;
		}
	}
	if(flag)
	cout << "Yes";
	else 
	cout << "No";
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };


int main(){cout<<fixed<<setprecision(10);
		 //最初だけ考える
           //横横は*３　縦横は*2 横縦は*1
           int n;
           cin>>n;
           string s0,s1;
           cin>>s0>>s1;
           ll ans=0;
           int now=1;
           int tate=1;
           if(s0[0]==s1[0])ans=3;
           else {
             ans=6;
             tate=0;
             now++;
           }
           
           while(now<n){
             if(s1[now]==s0[now]){
               if(tate){
                 ans*=2;
               }
               tate=1;
             }
             else{
               if(tate){
                 ans*=2;
               }
               else{
                 ans*=3;
               }
               tate=0;
               now++;
             }
             ans%=inf;
            now++; 
           }
           cout<<ans<<endl;
}

Measured memory_bytes: 3620
// AOJ2013
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
#define e_b emplace_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ipair;
typedef pair<ll,ll> lpair;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v) //vectorの中身を見る
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
void map_p(map<int,int>& d){cout<<"map: ";for(auto a : d){cout<<"{"<<a.first<<":"<<a.second<<"}";}cout<<endl;} //mapの中身を見る
void set_p(set<int>& d){cout<<"set: ";for(int a : d){cout<<a<<" ";}cout<<endl;} //setの中身を見る

struct name{
    tuple<int,int,int> bunkai(string s){
        int a=check(s[0],s[1]),b=check(s[3],s[4]),c=check(s[6],s[7]);
        return forward_as_tuple(a,b,c);
    }
    int check(char a,char b){
        int s;
        if(a=='0'){
            s=b-'0';
        }else{
            s=(a-'0')*10+(b-'0');
        }
        return s;
    }
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);

    int n;
    int max_=25*60*60;
    name me;
    while(cin>>n){
        if(n==0) break;
        vector<int> imos(max_,0);
        rep(i,n){
            string s,t;
            cin>>s>>t;
            int a,b,c;
            tie(a,b,c)=me.bunkai(s);
            imos[a*60*60+b*60+c]++;
            tie(a,b,c)=me.bunkai(t);
            imos[a*60*60+b*60+c]--;
        }
        int ans=imos[0];
        for(int i=1;i<max_;i++){
            imos[i]+=imos[i-1];
            ans=max(ans,imos[i]);
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 3484
import sys
input = sys.stdin.readline

N = int(input())
T = list(map(int, input().split()))
A = list(map(int, input().split()))
maxh = [0] * N
if T[0] > A[0] or T[-1] < A[-1]:
    print(0)
    exit()

maxh[0] = -T[0]
for i in range(1, N):
    if T[i-1] == T[i]:
        maxh[i] = T[i]
    else:
        maxh[i] = -T[i]

maxh[-1] = -A[-1]
for i in range(N-1)[::-1]:
    if maxh[i] > 0:
        if A[i] == A[i+1]:
            maxh[i] = min(maxh[i], A[i])
        else:
            if maxh[i] < A[i]:
                print(0)
                exit()
            else:
                maxh[i] = -A[i]
    else:
        if A[i] == A[i+1]:
            if -maxh[i] > A[i]:
                print(0)
                exit()
        else:
            if -maxh[i] != A[i]:
                print(0)
                exit()

ans = 1
mod = 10**9+7
for i in range(N):
    if maxh[i] > 0:
        ans = ans * maxh[i] % mod
print(ans)


Measured memory_bytes: 73700
let () =
    let main () =
        let s = int_of_string (read_line ()) in
        let i1 = s / 100 in
        let i2 = s mod 100 in
        let f1 = i2 >= 1 && i2 <= 12 in
        let f2 = i1 >= 1 && i1 <= 12 in

        let msg = match f1, f2 with
        | true,  true  -> "AMBIGUOUS"
        | false, false -> "NA"
        | true,  false -> "YYMM"
        | false, true  -> "MMYY"
        in
        print_endline msg
    in
    main ()

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
string getString(char x) 
{ 
    // string class has a constructor 
    // that allows us to specify size of 
    // string as first parameter and character 
    // to be filled in given size as second 
    // parameter. 
    string s(1, x); 
  
    return s;    
} 
int main() {
	// your code goes here
	//set<string> out;
	string s;
	cin>>s;
	string f="";
	vector<string> out;
	for(ll i=0;i<s.size();i++)
	{
		f.append(getString(s[i]));
		if(out.size())
		{
			string t=out.back();
			if(t!=f)
			{
				//cout<<f<<" ";
				out.push_back(f);
				f="";
			}
		}
		else
		{
			//cout<<f<<" ";
			out.push_back(f);
				f="";
		}
		
	}
	cout<<out.size();
	return 0;
}

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

int main() {
	string s;
	cin >> s;
	ll len = s.length();
	ll ans = 0;
	rep(i,len-1) if (s[i] != s[i+1]) ans++;
	cout << ans << endl;
	return 0;
}


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

int main(){
	int n, x[51], y[51], c = 1;
	double pori;
	while(cin >> n, n != 0){
		pori = 0;
		for(int i = 0; i < n; i++){
			cin >> x[i] >> y[i];
		}
		x[n] = x[0];
		y[n] = y[0];
		for(int i = 0; i < n; i++){
			pori += (double)(y[i] + y[i+1]) * (-x[i] + x[i+1]) / 2.0;
		}
		printf("%d %.1f\n", c, pori);
c++;
	}
	return 0;
}

Measured memory_bytes: 1192
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    string s,t;
    cin>>s>>t;
    int a,b;
    cin>>a>>b;
    string u;
    cin>>u;
    if(s==u){
        cout<<a-1<<" "<<b<<endl;
    }else{
    cout<<a<<" "<<b-1<<endl;
        
    }

    return 0;
}


Measured memory_bytes: 888
# https://atcoder.jp/contests/abc081/tasks/abc081_b
N = int(input())
int_list = list(map(int, input().split()))

def check_even(int_list):
    for i in int_list:
        if i % 2 == 1:
            return False
    else:
        return True

def half_list(int_list):
    return [i / 2 for i in int_list]
    
for i in range(50):
    if check_even(int_list):
        int_list = half_list(int_list)
    else:
        print(i)
        break

Measured memory_bytes: 9012
#include <cstdio>
#include <algorithm>
#include <cstring>
#define maxn 200010
using namespace std;
struct node{
	char s[12];
}q[maxn];
char pre[12];
int cmp(node a,node b){
	return strcmp(a.s,b.s)<0;
}
int main(){
	int n,i,cnt=1;
	scanf("%d",&n);
	for(i=1;i<=n;i++)scanf("%s",q[i].s);
	sort(q+1,q+1+n,cmp);
	strcpy(pre,q[1].s);
	for(i=2;i<=n;i++)
		if(strcmp(q[i].s,pre)!=0)strcpy(pre,q[i].s),cnt++;
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 5548
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

int main() {
  int a, b;
  cin >> a >> b;

  int res = b;
  if (b < 10) res += a * 10;
  else if (b < 100) res += a * 100;
  else res += a * 1000;

  int c = sqrt(res);
  cout << (c * c == res ? "Yes" : "No") << endl;


  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#define pb push_back
#define mp make_pair
using namespace std;
const int N=2e5+5;

int n,m;

struct edge{

  int v;
  int w;

  edge() {}

  edge(int _v,int _w)
  {
      v=_v;
      w=_w;
  }

};

vector <edge> nb[N];
bool vis[N];
int d[N];

vector <int> tp;
void DFS_topological(int v)
{
    vis[v]=true;
    for(int i=0;i<nb[v].size();i++)
    {
        if(!vis[nb[v][i].v])
            DFS_topological(nb[v][i].v);
    }

    tp.pb(v);
}

bool ans=true;

void DFS(int v,int cast)
{
    vis[v]=true;
    d[v]=cast;

    for(int i=0;i<nb[v].size();i++)
    {
        if(!vis[nb[v][i].v])
            DFS(nb[v][i].v,d[v]+nb[v][i].w);
        else
        {
            if(d[nb[v][i].v] != d[v] + nb[v][i].w)
                ans=false;
        }
    }
}

int main()
{
    int i;
    int l,r,d;

    scanf("%d%d", &n, &m);
    while(m--)
    {
        scanf("%d%d%d", &l, &r, &d);

        nb[l].pb(edge(r,d));
    }

    for(i=1;i<=n;i++)
    {
       if(!vis[i])
        DFS_topological(i);
    }

    memset(vis,false,sizeof(vis));
    for(i=n-1;i>=0;i--)
    {
        if(!vis[tp[i]])
        {
           DFS(tp[i],0);
        }
    }

    if(ans)
        printf("Yes\n");
    else
        printf("No\n");


    return 0;
}


Measured memory_bytes: 13816
#include<bits/stdc++.h>
using namespace std;
#define ll long long
map<int,int>mp;
int main()
{
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
   ll x,y,a,i,j,b,c,d;
    cin>>x>>y;
    for(i=0; i<=x; i++)
    {
        for(j=0; j<=x; j++)
        {
            ll m=i*10000+j*5000;
            if(m>y){
                    break;
            }
            else if(m==y && i+j==x)
            {
                cout<<i<<" "<<j<<" "<<0<<endl;
                return 0;
            }
            else if((y-m)%1000==0)
            {
                if(i+j+(y-m)/1000==x)
                {
                    cout<<i<<" "<<j<<" "<<(y-m)/1000<<endl;
                    return 0;
                }
            }

        }
    }
    cout<<-1<<" "<<-1<<" "<<-1<<endl;
    return 0;
}


Measured memory_bytes: 256
#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 UB upper_bound
#define LB lower_bound
#define PQ priority_queue

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

template<typename T> bool setmin(T & a, T b) { if(a <= b) { return false; } else { a = b; return true; } }
template<typename T> bool setmax(T & a, T b) { if(b <= a) { return false; } else { a = b; return true; } }
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; }

template<typename T> ostream & operator<<(ostream & os, const vector<T> & v) {
	os << "[";
	FOR(it, v) {
		if(it != v.begin()) { os << ", "; }
		os << *it;
	}
	os << "]";
	return os;
}
template<typename F, typename S> ostream & operator<<(ostream & os, const pair<F, S> & p) {
	os << "<" << p.FI << ", " << p.SE << ">";
	return os;
}

// ---- ----

int n, m, l[300000], r[300000];
vector<int> dd[100002];
set<int> s;
int ans[100002];

int main() {
	cin >> n >> m;
	inc(i, n) { cin >> l[i] >> r[i]; }
	
	inc1(d, m) {
		int i = d;
		while(i <= m) {
			dd[i].PB(d);
			i += d;
		}
	}
	
	inc(i, n) {
		if((l[i] - 1) * 2 <= r[i]) {
			ans[1]++;
			ans[ r[i] + 1]--;
		} else {
			if(r[i] - l[i] < 30) {
				s.clear();
				incII(j, l[i], r[i]) {
				inc(k, dd[j].size()) {
					s.insert(dd[j][k]);
				}
				}
				FOR(it, s) {
					ans[*it]++;
					ans[(*it) + 1]--;
				}
				continue;
			}
			int llim = (r[i] + 1) - l[i] + 1;
			int rlim = m + 2;
			ans[1]++;
			ans[llim]--;
			inc1(d, m) {
				bool flag = false;
				int nl = (l[i] + (d - 1)) / d;
				int nr = (r[i] + 1 + (d - 1)) / d;
				if(nl <= llim) { flag = true; }
				setmax(nl, llim);
				setmin(nr, rlim);
				ans[nl]++;
				ans[nr]--;
				rlim = nl;
				if(flag) { break; }
			}
		}
	}
	
	inc1(i, m) {
		ans[i] += ans[i - 1];
		cout << ans[i] << "\n";
	}
	
	return 0;
}


Measured memory_bytes: 14080
import sys

def point(sushi, n, k):
  sushi = sorted(sushi, key=lambda x:-x[1])
  
  ate_t = set()
  dpoint = 0
  dup = []
  for s in sushi[:k]:
    t = s[0]
    d = s[1]
    if t in ate_t:
      dup.append(d)
    ate_t.add(t)
    dpoint += d
  
  ans = len(ate_t)**2 + dpoint
  
  for s in sushi[k:]:
    t = s[0]
    d = s[1]
    if len(dup) <= 0:
      break
    if t in ate_t:
      continue
    ate_t.add(t)
    rm = dup.pop()
    dpoint = dpoint - rm + d
    res = len(ate_t)**2 + dpoint
    ans = max(ans, res)
  
  return ans

def main():
  input = sys.stdin.readline
  n, k = map(int, input().split())
  sushi = []
  for _ in range(n):
    t, d = map(int, input().split())
    sushi.append([t,d])
  print(point(sushi, n, k))


if __name__ == '__main__':
  main()

Measured memory_bytes: 25332
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;

int64_t gcd(int64_t a, int64_t b) {return b?gcd(b, a%b):a;}
int64_t lcm(int64_t a, int64_t b) {return a/gcd(a,b)*b;}
int64_t extgcd(int64_t a, int64_t b, int64_t &x, int64_t &y) { // ax+by=gcd(a, b)の解を与える
    int64_t d = a;
    if(b) {
        d = extgcd(b, a%b, y, x);
        y -= (a/b)*x;
    } else {
        x = 1; y = 0;
    }
    return d;
}

ll saiki(ll n, ll x) {
    if(n-x < x) x = n-x;
    if(x == 1) {
        return 3LL * (n-1);
    }
    return saiki(x + n%x, x) + (n/x-1) * x * 3LL;
} 

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

    ll ans = 1LL;
    ans *= gcd(n, x);
    n /= ans;
    x /= ans;

    cout << saiki(n, x) * ans << endl;
}

Measured memory_bytes: 256
h, w = gets.chomp.split(' ').map(&:to_i)
field = readlines.map(&:chomp).map{|row| row.split('')}

field.each_with_index do |row, column|
    row.each_with_index do |value, index|
        if value == '.'
            field[column][index] = 0
        end
    end
end

field.each_with_index do |row, i_h|
    row.each_with_index do |value, i_w|
        next if value != '#'
        l = ( i_w == 0 ? 0 : -1 )
        r = ( i_w == w - 1 ? 0 : 1 )
        u = ( i_h == 0 ? 0 : -1 )
        d = ( i_h == h - 1 ? 0 : 1 )
        for tate in u..d do 
            for yoko in l..r do 
                next if tate == 0 && yoko == 0
                next if field[i_h+tate][i_w+yoko] =='#'
                field[i_h+tate][i_w+yoko] += 1
            end
        end
    end
end


field.each do |row|
    print("#{row.join}\n")
end

Measured memory_bytes: 2172
import sys
from fractions import gcd

input = sys.stdin.readline


def main():
    N, X = map(int, input().split())
    x = list(map(int, input().split()))

    x.append(X)
    x.sort()
    ans = x[1] - x[0]
    for i in range(1, N):
        ans = gcd(ans, x[i + 1] - x[i])

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 16280
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include <functional>
#include <queue>
#include <regex>

using namespace std;

constexpr int MOD = 1000000007;
constexpr int INF = 1050000000;

#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl

#define Tof(x) (x) ? Yes : No
#define TOF(x) (x) ? YES : NO
#define tof(x) (x) ? yes : no

using ll = long long;


/*vectorの要素を全部確認するやつだよ。


for (vector<int>::iterator itr = ans.begin(); itr != ans.end(); ++itr) {
	cout << *itr << " ";
}


*/


/*for文でx,yを上下左右確認するやつだよ。

int dy[] = { 0, 1, 0, -1 };
int dx[] = { 1, 0, -1, 0 };


for (int i = 0; i < 4; i++) {
	int ny = y + dy[i];
	int nx = x + dx[i];
}
*/

/*繰り返し二乗法だよ。modもとってくれるよ。n^kをmodで割った余りでやってくれるよ。

ll POW_MOD(ll n, ll k, ll mod) {
	ll r = 1;

	for (; k > 0; k >>= 1) {
		if (k & 1) {
			r = (r * n) % mod;
		}
		n = (n * n) % mod;
	}
	return r;
}


*/

/*2重for文書くのめんどくなった時用だよ。

for (int i = 0; i < h; i++) {
	for (int j = 0; j < w; j++) {

	}
}

*/

int p[100005];

int main(void) {
	int n; cin >> n;

	for (int i = 1; i <= n; i++) {
		cin >> p[i];
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (p[i] == i) {
			int tmp = p[i];
			p[i] = p[i + 1];
			p[i + 1] = tmp;
			ans++;
		}
	}


	cout << ans << endl;







}

Measured memory_bytes: 640