akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using str = string;
using ss = stringstream;

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

    str s;cin>>s;

    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='A')s[i]='1';
        else if(s[i]=='T')s[i]='1';
        else if(s[i]=='G')s[i]='1';
        else if(s[i]=='C')s[i]='1';
        else s[i]='0';
    }

    int ans=0;
    int cnt=0;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='1')cnt++;
        else
        {
            ans=max(ans,cnt);
            cnt=0;
        }
    }
    ans=max(ans,cnt);

    cout<<ans<<"\n";

    return 0;
}


Measured memory_bytes: 3592
from collections import deque
from enum import Enum
import sys
import math

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001


V = int(input())

table = [['0']*V for i in range(V)]

for loop in range(V):
    tmp_array = list(map(int,input().split()))
    node_id = tmp_array[0]-1
    for i in range(tmp_array[1]):
        table[node_id][tmp_array[2+i]-1] = '1'

for row in range(V):
    print(' '.join(table[row]))



Measured memory_bytes: 6448
#include <iostream>
#include<string>
#include<algorithm>
using namespace std;
int a[810];
int b[810];
int c[810];
int main() {
	int cnt = 0;
	for(int i=0;i<50;i++){
		cin >> a[i] >> b[i] >> c[i];
		if (a[i] == -1 && b[i] == -1 && c[i] == -1) break;
		cnt++;
	}
	for (int i = 0; i < cnt; i++) {
		if (a[i] == -1 || b[i] == -1) {
			cout << 'F' << endl;
		}
		else if (a[i] + b[i] >= 80) { cout << 'A' << endl; }
		else if (a[i] + b[i] >= 65) { cout << 'B' << endl; }
		else if (a[i] + b[i] >= 50) { cout << 'C' << endl; }
		else if (a[i] + b[i] >= 30 && c[i] >= 50) { cout << 'C' << endl; }
		else if (a[i] + b[i] < 30) { cout << 'F' << endl; }
		else { cout << 'D' << endl; }
	}
}


Measured memory_bytes: 3032
#include <stdio.h>
#include<string.h>
#include <ctype.h>


int main(void){
 
    char t[1000];
    char w[10];
    int i;
    int count=0;
    
    scanf("%s",w);
    for( i=0 ; i < strlen(w) ; i++){
        w[i]=tolower(w[i]);
    }
    while(1){
        scanf("%s",t);
        if(strcmp(t,"END_OF_TEXT")==0){
            break;
        }
        for (i=0; i< strlen(t); i++) {
            t[i]= tolower(t[i]);
        }
        if (strcmp(t,w)==0) {
            count++;
        }
    }
    printf("%d\n",count);
    return 0;
}

Measured memory_bytes: 552
import java.io.*;
import java.math.*;
import java.util.*;
public class Main { 
 
	public static void main(String[] args) { 
		FastScanner I = new FastScanner(); //Input
		OutPut O = new OutPut(); //Output
		int N  = I.nextInt();
		long[] a = new long[N];
		long[] ans = new long[N];
		for (int i = 0; i < N; i++) {
			a[i] = I.nextLong();
		}
		ans[0]=0;
		boolean UPD = false;
		long diff = 0;
		for (int i = 1; i < N; i++) {
			if (i<N-1)ans[i] = a[i-1]*2-ans[i-1];
			else {
				ans[i] = a[i-1]*2-ans[i-1];
				if (ans[N-1]+ans[0]!=2*a[N-1]) {
					diff=2*a[N-1]-ans[N-1]-ans[0];
					UPD=true;
				}
			}
		}
		if (UPD) {
			ans[0]=diff/2;
			for (int i = 1; i < N; i++) {
				if (i%2==0) ans[i]+=ans[0];
				else ans[i]-=ans[0];
			}
		}
		for (int i = 0; i < N; i++) O.p(ans[i]+" ");
	}
	public static long ceil(long num, long den) {long ans = num/den; if (num%den!=0) 
	ans++; return ans;}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return Math.max(a,b);
		return GCD(Math.min(a, b),Math.max(a, b)%Math.min(a, b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());};
	}
	static class OutPut{
		PrintWriter w = new PrintWriter(System.out);
		void pln(int x) {w.println(x);w.flush();}
		void pln(long x) {w.println(x);w.flush();}
		void pln(String x) {w.println(x);w.flush();}
		void pln(char x) {w.println(x);w.flush();}
		void pln(StringBuilder x) {w.println(x);w.flush();}
		void p(int x) {w.print(x);w.flush();}
		void p(long x) {w.print(x);w.flush();}
		void p(String x) {w.print(x);w.flush();}
		void p(char x) {w.print(x);w.flush();}
		void p(StringBuilder x) {w.print(x);w.flush();}
	}
}


Measured memory_bytes: 56684
import math


def main():
    k = int(input())
    ans = 0
    gcd = math.gcd
    for i in range(1, k+1):
        for j in range(1, k+1):
            ij = gcd(i,j)
            for l in range(1, k+1):
                ans += gcd(ij, l)

    print(ans)

main()


Measured memory_bytes: 9188
p,n=map(int,input().split())
l=list(map(int,input().split()))
s=0
l1=[]
for i in range(1,n):
    l1.append(l[i]-l[i-1])
    s+=l1[-1]
l1.append(p-s)
l1.remove(max(l1))
print(sum(l1))

Measured memory_bytes: 26444
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int a,b[10000];
  cin>>a;
  for(int i=0;i<a;i++){
    cin>>b[i];
  }
  cin>>a;
  int c,d,e;
  for(int i=0;i<a;i++){
    int q[10000],n=0;
    cin>>c>>d>>e;
    for(int j=d;j<e;j++){
      q[j]=b[j];
    }
    sort(q+d,q+e);
    if(c==0) cout<<q[d]<<"\n";
    if(c==1) cout<<q[e-1]<<"\n";
  }
}



Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
#include <boost/multiprecision/cpp_int.hpp>
using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_temp>
using smaller_queue = priority_queue<Q_temp, vector<Q_temp>, greater<Q_temp>>;

const ll MOD = (ll)(1e9 + 7);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << setiosflags(ios::fixed);
  string s;
  cin >> s;
  stack<int> stk;
  for (auto c : s)
    stk.push((int)(c - '0'));
  ll sum = 0;
  while (!stk.empty())
  {
    int a = stk.top();
    stk.pop();
    if (a >= 6 || (a == 5 && !stk.empty() && stk.top() >= 5))
    {
      sum += 10 - a;
      if (!stk.empty())
        stk.top()++;
      else
        stk.push(1);
    }
    else
    {
      sum += a;
    }
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 5404
#include<iostream>
#include<map>
using namespace std;
map<int,int>m;
int n,c[1<<17],f;
main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int a;cin>>a;
		if(m[a]++==0)c[f++]=a;
	}
	int ans=0;
	for(int i=0;i<f;i++)
	{
		ans+=m[c[i]]>=c[i]?m[c[i]]-c[i]:m[c[i]];
	}
	cout<<ans<<endl;
}

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

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define rep(i,n) for(int i=0; i<(int)(n); i++)
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; }

using ll = long long;
using P = pair<ll, ll>;

//constexpr ll mod = 998244353;
constexpr ll mod = 1e9+7;
constexpr double PI = 3.14159265358979323846;

// Segment Tree for query sum[a, b)
struct {
    int N;
    vector<ll> dat;

    void init(int n) {
      N = 1;
      while(N < n) N *= 2;
      dat.resize(2*N-1, 0);
    }

    void build(vector<ll>& a) {
      int n = a.size();
      init(n);
      for(int i=0; i<n; i++) dat[i+N-1] = a[i];
      for(int i=N-2; i>=0; i--) dat[i] = dat[i*2+1]+dat[i*2+2];
    }

    // update k-th element
    void update(int k, long long a) {
      k += N-1;
      dat[k] = a;
      while(k > 0) {
        k = (k-1)/2;
        dat[k] = dat[k*2+1] + dat[k*2+2];
      }
    }

    // add k-th element by a
    void add(int k, long long a) {
      k += N-1;
      dat[k] += a;
      while(k > 0) {
        k = (k-1)/2;
        dat[k] = dat[k*2+1] + dat[k*2+2];
      }
    }

    // return sum[a, b)
    ll query(int a, int b) {
      return query(a, b, 0, 0, N);
    }
    ll query(int a, int b, int k, int l, int r) {
      if (r <= a || b <= l) return 0;
      if (a <= l && r <= b) return dat[k];
      auto m = (l+r)/2;
      return query(a, b, k*2+1, l, m) + query(a, b, k*2+2, m, r);
    }
} SegTree;

vector<deque<int>> pos(26, deque<int>());

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  string s; cin >> s;
  auto n = s.size();
  rep(i, n) {
    auto c = s[i];
    pos[c-'a'].push_back(i);
  }

  SegTree.init(n);
  set<int> st;
  rep(i, n) st.insert(i);
  ll ans = 0;

  bool flag = true;
  int len = n;
  for(int i=0; i<(n+1)/2; i++) {
    int p = *st.begin();
    st.erase(p);
    char c = s[p];
    int r = pos[c-'a'].back();
    if (p==r && n%2==1 && flag) {
      auto mid = len/2;
      ans += mid;
      pos[c-'a'].pop_back();
      SegTree.add(p, 1);
      flag = false;
      len--;
      continue;
    } else if (p==r) {
      cout << -1 << endl;
      return 0;
    }
    st.erase(r);
    pos[c-'a'].pop_front();
    pos[c-'a'].pop_back();
    auto t = r - SegTree.query(0, r);
    ans += len-1-t;
    SegTree.add(p, 1);
    SegTree.add(r, 1);
    len-=2;
  }
  cout << ans << endl;
}

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

using namespace std;
const int N=2e5+10;

const int MAX=1e9+10;
vector <int> g[N];
int vis[N];
int ans;
typedef long long ll;
int a[N];
map<int,int>mp;
int main()
{
   int n;
   cin>>n;
   for(int i=1;i<=n;i++) cin>>a[i];
   ll ans=0;
   for(int i=1;i<=n;i++){
        ans+=mp[i-a[i]];
        mp[a[i]+i]++;
   }
   cout<<ans<<endl;
}


Measured memory_bytes: 26128
# Enter your code here. Read input from STDIN. Print output to STDOUT
from sys import stdin
ans = 'Yes'
s = set()
a = stdin.readline().strip()
for i in a:
 if i in s:
  s.remove(i)
 else:
  s.add(i)
if len(s):
 ans = 'No'
print ans

Measured memory_bytes: 2568
N,M = map(int,input().split())
list = [list(map(int,input().split())) for x in range(N)]

#一列目削除
for i in range(0,N):
    list[i].pop(0)

stock = []

#解答が全リストにあるか探索
for i in range(0,N):
    for j in range(0,len(list[i])):
        cnt = 0
        for k in range(0,N):
            if list[i][j] in list[k]:
                cnt += 1
        if cnt == N:
            stock.append(list[i][j])

if N == 1:
    stock = list[i]

print(len(set(stock)))

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		int maxW = scan.nextInt();
		int[] v = new int[n];
		int[] w = new int[n];
		for(int i = 0; i < n; i++) {
			v[i] = scan.nextInt();
			w[i] = scan.nextInt();
		}
		scan.close();
		
		int[][] dp = new int[n+1][maxW+1];
		for(int i = 0; i < n; i++)
			for(int j = 0; j < maxW+1; j++)
				if(j >= w[i]) {
					dp[i+1][j] = Math.max(dp[i][j], dp[i+1][j-w[i]] + v[i]);
				}else {
					dp[i+1][j] = dp[i][j];
				}

		
		System.out.println(dp[n][maxW]);
	}
}


Measured memory_bytes: 31060
#include <iostream>
using namespace std;
 
int main() {
  int N;
  cin >> N;

  long long L[100];
  L[0] = 2;
  L[1] = 1;
  for(int i = 2; i < N+1; i++) {
    L[i] = L[i-2] + L[i-1];
  }

  cout << L[N] << endl;
  
}

Measured memory_bytes: 3592
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
vector<long long>P;
long long a[1000],b[1000],c[1000],d[1000];
int n;
long long v;
main()
{
	cin>>n>>v;
	for(int i=0;i<n;i++)cin>>a[i];
	for(int j=0;j<n;j++)cin>>b[j];
	for(int i=0;i<n;i++)for(int j=0;j<n;j++)
	{
		if(a[i]+b[j]<v)P.push_back(a[i]+b[j]);
	}
	sort(P.begin(),P.end());
	long long cnt=0;
	for(int i=0;i<n;i++)cin>>c[i];
	for(int i=0;i<n;i++)
	{
		cin>>d[i];
		for(int j=0;j<n;j++)
		{
			if(c[j]+d[i]<v)
			{
				cnt-=distance(upper_bound(P.begin(),P.end(),v-c[j]-d[i]),
				lower_bound(P.begin(),P.end(),v-c[j]-d[i]));
			}
		}
	}
	cout<<cnt<<endl;
}



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

#define N 100010
#define MP make_pair
typedef long long LL;

int n, m;
int d[N], ord[N];
vector<int> E[N], g[N];

int main()
{
	//freopen("in.txt", "r", stdin);
	scanf("%d %d", &n, &m);
	for (int i = 1; i <= n - 1 + m; ++i)
	{
		int x, y;
		scanf("%d %d", &x, &y);
		++d[y];
		E[x].push_back(y);
		g[y].push_back(x);
	}
	queue<int> q;
	for (int i = 1; i <= n; ++i)
		if (!d[i]) q.push(i);
	
	int t = 0;
	while (!q.empty())
	{
		int x = q.front();
		q.pop();
		ord[x] = ++t;
		for (auto y: E[x])
		{
			if (--d[y] == 0)
			   q.push(y);
		}
	}
	for (int i = 1; i <= n; ++i)
	{
		if (g[i].size() == 0) puts("0");
		else
		{
			int fa = g[i][0];
			for (auto y: g[i])
				if (ord[y] > ord[fa])
				   fa = y;
            printf("%d\n", fa);
		}
	}
	
	return 0;	
}

Measured memory_bytes: 12672
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <assert.h>
#include <numeric>
#include <climits>

using namespace std;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
typedef long long ll;

pair<int, int> getmax(map<int, int> o) {
    int cmax = 0;
    int vmax = 0;
    for (auto it = o.begin(); it != o.end(); it++) {
        if (cmax < it->second) {
            cmax = it->second;
            vmax = it->first;
        }
    }
    return make_pair(cmax, vmax);
}

template<typename A, typename B>
std::pair<B,A> flip_pair(const std::pair<A,B> &p)
{
    return std::pair<B,A>(p.second, p.first);
}

template<typename A, typename B>
std::multimap<B,A> flip_map(const std::map<A,B> &src)
{
    std::multimap<B,A> dst;
    std::transform(src.begin(), src.end(), std::inserter(dst, dst.begin()),
                   flip_pair<A,B>);
    return dst;
}

int main() {
    string s;
    cin >> s;
    
    if (s[s.size()-1] == '1') {
        cout << -1 << endl;
        return 0;
    }
    
    if (s[s.size()-2] == '0') {
        cout << -1 << endl;
        return 0;
    }
    
    if (s[0] == '0') {
        cout << -1 << endl;
        return 0;
    }
    
    int N = s.size();
    REP(i, N-1) {
        if (i == 0) continue;
        if (s[i] != s[N-i-2]) {
            cout << -1 << endl;
            return 0;
        }
    }
    
    
    cout << N << " " << N-1 << endl;
    int cur = N-1;
    for (int i = N-2; i >= 1; i--) {
        cout << cur << " " << i << endl;
        if (s[i-1] == '1') {
            cur = i;
        }
    }
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
typedef int sign;
typedef long long ll;
#define For(i,a,b) for(register sign i=(sign)a;i<=(sign)b;++i)
#define Fordown(i,a,b) for(register sign i=(sign)a;i>=(sign)b;--i)
const int N=300+5;
bool cmax(sign &a,sign b){return (a<b)?a=b,1:0;}
bool cmin(sign &a,sign b){return (a>b)?a=b,1:0;}
template<typename T>T read()
{
  T ans=0,f=1;
  char ch=getchar();
  while(!isdigit(ch)&&ch!='-')ch=getchar();
  if(ch=='-')f=-1,ch=getchar();
  while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch-'0'),ch=getchar();
  return ans*f;
}
template<typename T>void write(T x,char y)
{
  if(x==0)
  {
      putchar('0');putchar(y);
      return;
  }
  if(x<0)
  {
      putchar('-');
      x=-x;
  }
  static char wr[20];
  int top=0;
  for(;x;x/=10)wr[++top]=x%10+'0';
  while(top)putchar(wr[top--]);
  putchar(y);
}
void file()
{
  #ifndef ONLINE_JUDGE
      freopen("d.in","r",stdin);
      freopen("d.out","w",stdout);
  #endif
}
char s[N];
int len,k;
void input()
{
	scanf("%s",s+1);
	k=read<int>();
	len=strlen(s+1);
}
int dp[N][N][N];
void work()
{
	if(k>=len/2){write(len,'\n');return;}
	For(i,1,len)For(j,0,k)dp[i][i][j]=1;
	For(i,1,len-1)
	{
		dp[i][i+1][0]=(s[i]==s[i+1]?2:1);
		For(j,1,k)dp[i][i+1][j]=2;
	}
	int j;
	For(l,2,len)For(i,1,len-l)
	{
		j=i+l;
		//cout<<i<<' '<<j<<endl;
		For(v,0,k)
		{
			dp[i][j][v]=max(dp[i+1][j][v],dp[i][j-1][v]);
			if(s[i]==s[j])cmax(dp[i][j][v],dp[i+1][j-1][v]+2);
			if(v)
			{
				cmax(dp[i][j][v],dp[i+1][j-1][v-1]+2);
				cmax(dp[i][j][v],dp[i][j][v-1]);
			}
			//cout<<i<<' '<<j<<' '<<v<<' '<<dp[i][j][v]<<endl;;
		}
	}
	write(dp[1][len][k],'\n');
}
int main()
{
	//file();
	input();
	work();
	return 0;
}

Measured memory_bytes: 110464
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    for(int i=1;;i++){
      int x=sc.nextInt();
      if(x==0) break;
      else System.out.printf("Case %d: %d\n",i,x);
    }
  }
}

Measured memory_bytes: 62596
#include <iostream>
#include <fstream>
#include <math.h>
#include <string>

using namespace std;

int main(){

  long long n;
  cin >> n;

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

  const long long mod = pow(10,9) + 7; //quotient
  long long ans = 0, tmp = 0;

  for(int i=0; i<n-1; i++){
    tmp += a[i];
    tmp = tmp % mod;
    ans += a[i+1] * tmp;
    ans = ans % mod;
  }

  /*
  for(int i=0; i<n-1; i++){
    tmp += a[n-1-i];
    tmp = tmp % mod;
    ans += a[n-2-i] * tmp;
  }

  for(int i=0; i<n; i++){
    ans = ans % mod;
  }
  */


  cout << ans;
}


Measured memory_bytes: 5160
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;

void main() {
    int N, M;
    scan(N, M);
    int ans;
    for (int i = 1; i*i <= M; i++) {
        if (M % i != 0) continue;
        if (M / i >= N) chmax(ans, i);
        if (M / (M / i) >= N) chmax(ans, M / i);
    }
    writeln(ans);
}

void scan(T...)(ref T args) {
    auto line = readln.split; // @suppress(dscanner.suspicious.unmodified)
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args)
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args)
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    return isChanged;
}

void yes(bool ok, string y = "Yes", string n = "No") {
    return writeln(ok ? y : n);
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <functional>
#include <cassert>

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

using namespace std;
typedef unsigned long ul;
typedef pair<ul, ul> P;

int main() {
    string s;
    getline(cin, s);
    const char *cstr = s.c_str();
    int a = -1;
    int b = -1;

    if (cstr[0]==cstr[1]){
        a = 1;
        b = 2;
    } else {
        REP(i,strlen(cstr)-2){
            if (cstr[i]==cstr[i+1]){
                a = i+1;
                b = i+2;
                break;
            }
            if (cstr[i+1]==cstr[i+2]){
                a = i+2;
                b = i+3;
                break;
            }
            if (cstr[i]==cstr[i+2]){
                a = i+1;
                b = i+3;
                break;
            }
        }
    }

    printf("%d %d\n", a, b);
}


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

#define vd vector<double>
 
typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define vc vector<char>
#define vcc vector< vector<char> >
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define X first
#define Y second
#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,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
// #define mp make_pair
//#define endl '\n'
 
int main() {
    int n;
    cin >> n;
    int ans = 0;
    int c1 = 0; // 先頭がB、末尾がAである数
    int c2 = 0; // 先頭がB、末尾がAでない数
    int c3 = 0; // 先頭がBでなく、末尾がAである数
    rep(i,n){
        string s;
        cin >> s;
        int s_size = int(s.length());
        rep(j, s_size){
            if(s[j] == 'A' && s[j+1] == 'B'){
                ans++;
            }
        }
        if(s[0] == 'B' && s[s_size - 1] == 'A') c1++;
        else if(s[0] == 'B' && s[s_size - 1] != 'A') c2++;
        else if(s[0] != 'B' && s[s_size - 1] == 'A') c3++;
    }
    if(c1 == 0){
        ans += min(c2, c3);
    }
    else{
        if((c2 + c3) == 0) ans += (c1 - 1);
        else ans+= (c1 + min(c2, c3));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mst(a,b) memset((a),(b),sizeof(a))
#define pi acos(-1)
#define pii pair<int,int>
const int INF = 0x3f3f3f3f;
const double eps = 1e-6;
const int MAXN = 1e5 + 10;
const int MAXM = 2e6 + 10;
const ll mod = 1e9 + 7;



int main() {
#ifdef local
    freopen("data.txt","r",stdin);
//    freopen("data.txt","w",stdout);
#endif
    int n,a,b;
    scanf("%d%d%d",&n,&a,&b);
    int ans = 0;
    while(1) {
        if(ans % 2 == 0) {
            if(a < b) {
                if(a + 1 < b) a++;
                else if(a + 1 == b) {
                    if(a - 1 >= 1) a--;
                    else {
                        puts("Borys");
                        return 0;
                    }
                }
            }
            else {
                if(a - 1 > b) a--;
                else if(a - 1 == b) {
                    if(a + 1 <= n) a++;
                    else {
                        puts("Borys");
                        return 0;
                    }
                }
            }
        }
        else {
            if(b < a) {
                if(b + 1 < a) b++;
                else if(b + 1 == a) {
                    if(b - 1 >= 1) b--;
                    else {
                        puts("Alice");
                        return 0;
                    }
                }
            }
            else {
                if(b - 1 > a) b--;
                else if(b - 1 == a) {
                    if(b + 1 <= n) b++;
                    else {
                        puts("Alice");
                        return 0;
                    }
                }
            }
        }
        ans++;
    }
    return 0;
}


Measured memory_bytes: 256
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a); i<(b);++i)
#define rep(i, n) FOR(i, 0, n)

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

// solve

int main(int argc, char const* argv[])
{
  string s;
  ll k;
  cin >> s >> k;
  string res = "";
  rep(i, s.size()){
    if(s[i] == 'a'){
      res += "a";
      continue;
    }
    int tmp = int('z' - s[i]) + 1;
    if(tmp <= k){
      res += 'a';
      k -= tmp;
    }else{
      res += s[i];
    }
  }
  if(k > 0){
    k = k % 26;
    res[res.size() - 1] = char((int(res[res.size() - 1] - 'a') + k) % 26 + 'a');
  }
  cout << res << endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long int N;
  cin>>N;
  if(N%2==0){
    vector<long long int> as(N/2, 0);
    for(int i=0;i<N;i++){
      long long int a;
      cin>>a;
      as.at(a/2)++;;
    }
    for(int i=0;i<as.size();i++){
      if(as.at(i)!=2){cout<<0<<endl;return 0;}
    }
    long long int ans=1;
    for(int i=1;i<=N/2;i++){
      ans*=2;
      ans=ans%1000000007;
    }
    cout<<ans%1000000007<<endl;
  }else{
    vector<long long int> as((N+1)/2, 0);
    for(int i=0;i<N;i++){
      long long int a;
      cin>>a;
      as.at(a/2)++;
    }
    if(as.at(0)!=1){cout<<0<<endl;return 0;}
    for(int i=1;i<as.size();i++){
      if(as.at(i)!=2){cout<<0<<endl;return 0;}
    }
    long long int ans=1;
    for(int i=1;i<=(N-1)/2;i++){
      ans*=2;
      ans=ans%1000000007;
    }
    cout<<ans%1000000007<<endl;
  }
}

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

int main() {
    string s; cin >> s;
    vector<int> l(26);
    for (int i = 0; i < s.size(); i++) {
        l[s[i] - 'a']++;
    }

    for (int i = 0; i < 26; i++) {
        if (l[i] > 1) { 
            puts("no");
            return 0;
        }
    }
    puts("yes");
}

Measured memory_bytes: 256
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

class UF(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]

    def find(self, x):
        '''
        x が属するグループを探索
        '''
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        '''
        x と y のグループを結合
        '''
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]

    def is_same(self, x, y):
        '''
        x と y が同じグループか否か
        '''
        return self.find(x) == self.find(y)

    def get_size(self, x):
        '''
        x が属するグループの要素数
        '''
        x = self.find(x)
        return self.size[x]

N,M = II()
a,b = Line(M)

ans = 0
for i in range(M):
    uf = UF(N)
    for j in range(M):
        if j==i:
            continue
        else:
            uf.union(a[j]-1,b[j]-1)
    flag = False
    for k in range(N):
        for l in range(k+1,N):
            if not uf.is_same(k,l):
                flag = True
                break
        else:
            continue
        break
    if flag:
        ans += 1

print(ans)

Measured memory_bytes: 45168
#include <cstdio>
#include <vector>
#include <cstring>
#include <functional>
#include <algorithm>
#include <math.h>
#include <bitset>
#include <set>
#include <queue>
#include <assert.h>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <complex>
#include <numeric>
#include <map>
#include <time.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<int,ull> piu;
typedef pair<ull,ull> puu;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;
typedef pair<pii,ll> ppl;
typedef pair<ll,pii> plp;
typedef pair<ll,pll> plP;
typedef pair<int,pii> pip;
typedef pair<pii,int> ppi;
typedef pair<pii,pii> ppp;
typedef pair<double,int> pdi;
typedef pair<int,double> pid;
typedef pair<double,pii> pdp;
typedef pair<double,double> pdd;
typedef pair<pdd,double> pd3;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i,n) for (int (i) = 0; (i) < (n); (i)++)
#define repn(i,a,n) for (int (i) = (a); (i) < (n); (i)++)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define SORT(x) sort((x).begin(),(x).end())
#define SORTN(x,n) sort((x),(x)+(n))
#define ERASE(x) (x).erase(unique((x).begin(),(x).end()),(x).end())
#define COUNT(x,c) count((x).begin(),(x).end(),(c))
#define REMOVE(x,c) (x).erase(remove((x).begin(),(x).end(),(c)),(x).end())
#define REVERSE(x) reverse((x).begin(),(x).end())
#define FORIT(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))-(x).begin()
#define lb(x,a) lower_bound((x).begin(),(x).end(),(a))
#define LBN(x,a,n) lower_bound((x),(x)+(n),(a))-(x)
#define lbN(x,a,n) lower_bound((x),(x)+(n),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))-(x).begin()
#define ub(x,a) upper_bound((x).begin(),(x).end(),(a))
#define BS(x,a) binary_search((x).begin(),(x).end(),(a))
#define BS2(x,n,a) binary_search((x),(x)+(n),(a))
#define NB(x) (((x)&~((x)+((x)&-(x))))/((x)&-(x))>>1)|((x)+((x)&-(x)))
#define NP(x) next_permutation((x).begin(),(x).end())
#define MM(x,p) memset((x),(p),sizeof(x))
#define SQ(x) (x)*(x)
#define SC(c1,c2) strcmp(c1,c2)==0
#define mp make_pair
#define INF (1<<29)
#define INFL (1LL<<61)
#define fi first
#define se second
#define EPS 1e-9
#define MOD 1000000007
#define MIN(x,a) x=min(x,a)
#define MAX(x,a) x=max(x,a)
#define madd(x,a) x=(x+a)%MOD
#define msub(x,a) x=(x+MOD-a)%MOD
#define OUTPUT(x) rep(__,x.size())printf("%d%c",x[__],__+1==x.size()?'\n':' ')

int N;
int A[300000];
ll res;
ll s1[300000];
ll s2[300000];

int main()
{
	scanf("%d",&N);
	rep(i,N*3)scanf("%d",&A[i]);
	priority_queue<int,vector<int>,greater<int> > f;
	rep(i,N)s1[N]+=A[i],f.push(A[i]);
	repn(i,N+1,N+N+1)
	{
		f.push(A[i-1]);
		s1[i]=s1[i-1]+A[i-1]-f.top();
		f.pop();
	}
	priority_queue<int> e;
	rep(i,N)s2[N+N]-=A[i+N+N],e.push(A[i+N+N]);
	for(int i=N+N-1;i>=N;i--)
	{
		e.push(A[i]);
		s2[i]=s2[i+1]-A[i]+e.top();
		e.pop();
	}
	ll res=-1LL<<61;
	repn(i,N,N+N+1)MAX(res,s1[i]+s2[i]);
	printf("%lld\n",res);
}

Measured memory_bytes: 5112
#include<iostream>

using namespace std;

int main() {
    int x;
    cin >> x;
    bool flag = false;

    for(int i = 1; i <= 9; i++){
        if(x % i == 0){
            if(x / i < 10){
                flag = true;
            }
        }
    }

    if(flag){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

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

typedef long long ll;
const int MAX_N = 100000;

int main() {
  ll x, ans = 0;
  std::cin >> x;

  ans += x / 11 * 2;
  x %= 11;
  if(x > 0 and x <= 6) ans += 1;
  if(x > 6) ans += 2;

  std::cout << ans << std::endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int k,a,b,c,ans=0,i;
    scanf("%d",&k);
    scanf("%d %d",&a,&b);

    c = a/k;

    for(i=c;i*k<=b;i++){
        if((a <= k*i) && (k*i <= b)){
            ans = 1; 
            break;
        } 
    }

    if(ans == 1){
        printf("OK\n");
    }else{
        printf("NG\n");
    }

    return 0;
}

Measured memory_bytes: 1608
import itertools

N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
np = [i for i in range(1, N+1)]
all_list = list(itertools.permutations(np))
P_num = 0
Q_num = 0

for index, line in enumerate(all_list):
    if list(line) == P:
        P_num = index
    if list(line) == Q:
        Q_num = index

print(abs(P_num - Q_num))

Measured memory_bytes: 8180
#include <stdio.h>

int main(void){
  int i, sum;
  char num[1001];

  for (;;) {
    scanf("%s", num);
    if (num[0] == '0')
      break;

    sum = 0;
    for (i = 0; num[i] != '\0'; i++)
      sum += num[i] - '0';
    printf("%d\n", sum);
  }
  return 0;
}

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

using namespace std;
using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const ll inf = 1e9+7;
const ll mod = 1e9+7;

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

    cout<<min(b/a,c)<<endl;
}


Measured memory_bytes: 256
using System;

public class Program
{

    public void Solve()
    {
        var sc = new Scanner();
        int N = sc.NextInt();
        Console.WriteLine(N*N*N);
    }

    public static void Main(string[] args)
    {
        new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = Console.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FOR(i,s,n) for(int i=s;i<n;i++)
typedef long long ll;
int main(){
	FASTIO
	ll n,x,t;
	cin>>n>>x>>t;
	ll a=ceil((double)n/x);
	cout<<a*t<<"\n";
	return 0;
}


Measured memory_bytes: 3708
//  SMOKE SHISHA PLAY FIFA  // 
#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef long double ld;

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pll pair<ll,ll>
#define MP make_pair
#define ff first
#define ss second
#define PB push_back
#define mod 1000000007
#define lp(i,start,end) for(ll i=start;i<=end;i++) 
#define deb1(a) cout<<#a<<" = "<<(a)<<endl;
#define deb2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define deb3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;


ll modu(ll a, ll b)
{
	ll ans =1;
	while(b>0)
	{
		if(b&1)
		ans = (ans*a)%mod;
		b/=2;
		a = (a*a)%mod;
	}
	return ans;
}

int main()
{
	fastio
	ll t=1;
	//cin >> t;
	while(t--)
	{
		ll x,n,mi=200,curr,ans;
		cin>>x>>n;
		ll a[n];
		bool vis[105]={0};
		lp(i,0,n-1){
			cin>>a[i];
			vis[a[i]]=1;
		}
		lp(i,0,101){
			if(!vis[i]){
				curr=abs(x-i);
				if(curr<mi){
					mi=curr;
					ans=i;
				}
			}
		}
		cout<<ans<<endl;

	}
	return 0;	
}


Measured memory_bytes: 3636
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = println(solve(new Scanner(System.in)))

  def solve(in: String): String = solve(new Scanner(in))

  def solve(sc: Scanner): String = {
    val S = sc.next
    val K = sc.nextLong

    var i = 0
    while (i < S.length && S(i) == '1') {
      i += 1
    }
    if (K <= i) {
      "1"
    } else {
      S(i).toString
    }
  }
}


Measured memory_bytes: 27304
#include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

int main()
{
    int N, X;
    cin >> N >> X;
    vector<int> costs(N);
    for (int i = 0; i < N; ++i) cin >> costs[i];

    X -= accumulate(costs.begin(), costs.end(), 0);
    int minCost = *min_element(costs.begin(), costs.end());
    cout << N + X / minCost << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LL long long 
#define LLU long long unsigned
#define rarr(arr, n) for(int aab = 0; aab < n; aab++){cin >> arr[aab];}
#define parr(arr, n) for(int aab = 0; aab < n; aab++){cout << arr[aab] << " ";}
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << " = " << x << "\n";

#define freopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout);ios_base::sync_with_stdio(0);cin.tie(0);

int main(){   
    int n, ac = 0, wa = 0, tle = 0, re = 0;
    cin >> n;
    for(int i = 0; i < n; i++){
    	char str[50];
    	cin >> str;
    	if(str[0] == 'A') ac++;
    	else if(str[0] == 'W') wa++;
    	else if(str[0] == 'T') tle++;
    	else if(str[0] == 'R') re++;
    }

    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;

}

Measured memory_bytes: 3672
dp = Array.new(10){Array.new(1001){0}}
dp[0][0] = 1

0.upto(100){|i|
  1000.downto(i){|j|
    9.downto(1){|k|
      dp[k][j] += dp[k-1][j-i] 
    }
  }
}

readlines.each{|line|
  n, s = line.split.map(&:to_i)
  break if n == 0 && s == 0
  puts dp[n][s]
}

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

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

  int ans = 0, end_with_a = 0, begin_with_b = 0,
      begin_with_a_and_end_with_b = 0;
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    for (int j = 0; j < s.size() - 1; ++j) {
      if (s[j] == 'A' && s[j + 1] == 'B')
        ++ans;
    }
    if (s.back() == 'A' && s.front() == 'B')
      ++begin_with_a_and_end_with_b;
    else if (s.back() == 'A')
      ++end_with_a;
    else if (s.front() == 'B')
      ++begin_with_b;
  }

  ans += min(end_with_a, begin_with_b);
  ans += begin_with_a_and_end_with_b;
  if (end_with_a + begin_with_b == 0 && begin_with_a_and_end_with_b > 0)
    ans -= 1;
  cout << ans << endl;
}

Measured memory_bytes: 384
n = int(input())
def divisor(n): 
    i = 1
    a = 0
    b = 0
    out = float('inf')
    while i * i <= n:
        if n%i == 0:
            a = i
            b = n//i
        if a+b < out:
          out = a+b
        i += 1
    return out
print(divisor(n)-2)

Measured memory_bytes: 9064
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <math.h>
#include <map>
#include <stack>
using namespace std;
static const int INF = 1e9+7;
// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, a, b) for (int i =a; i < b; i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define PI 3.14159265359

int main(){
    string a, b; cin >> a >> b;
    string c = a + b;
    int d = stoi(c);
    rep(i, d/2){
        if(i*i == d){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;


    return 0;
}


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int n, x;cin >> n >> x;
    int sum = 0;
    int mmin = 100000;
    inc(i, 0, n){
        int m;cin >> m;
        sum += m;
        mmin = min(mmin, m);
    }
    cout << n + (x-sum)/mmin << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n; cin >> n;
    vint a(n),s(n+1,0);
    map<int,int> map;
    rep(i,n){
        cin >> a[i];
        s[i+1]=s[i]+a[i];
    }
    rep(i,n+1) map[s[i]]++;
    
    int res=0;
    for(auto t:map){
        res+=t.S*(t.S-1)/2;
    }
    cout<<res<<endl;
    //rep(i,n+1) cout<<s[i];
}

Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
long long a[100004];
int main(){
    ios_base::sync_with_stdio(0);
    int n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    long long sum=0, add;
    for(int i=1;i<n;i++){
        if(a[i]+a[i-1]>k){
            sum+=a[i]+a[i-1]-k;
            add=a[i]+a[i-1]-k;
            if(a[i] < add)
                a[i]=0;
            else
                a[i]=k-a[i-1];
        }
    }
    cout<<sum<<endl;
    return 0;

}


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

#define mod 1000000007
#define INF 1000000000

#define eb emplace_back
#define len(x) ((int)(x).size())
#define log(x) cout << (x) << endl;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define loop(i,a,b) for(int i = (int)(a); i < (int)(b); ++i)

using ll = long long;
using vi = vector<int>;


int main() {
	int n;
	cin >> n;
	vi a(n);
	rep (i,n) cin >> a[i];

	list<int> l;
	l.push_front(a[0]);

	int p = len(a)&1;
	loop(i, 1, n) {
		if (p) l.push_back(a[i]), p^=1;
		else l.push_front(a[i]), p^=1;
	}

	for (auto i: l) printf("%d ", i);

	return 0;
}



Measured memory_bytes: 9216
from math import sqrt, factorial


def solve():
    N = int(input())
    xy_l = [[0, 0] for _ in range(N)]
    for i in range(N):
        xy_l[i] = list(map(int, input().split()))
    distance_l = []

    for i in range(N-1):
        for j in range(i+1, N):
            distance_l.append(sqrt((xy_l[i][0]-xy_l[j][0])**2 + (xy_l[i][1]-xy_l[j][1])**2))
    print(sum(distance_l)*2*factorial(N-1)/factorial(N))


if __name__ == '__main__':
    solve()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll  long long
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define pb push_back
#define Max(x,y,z) max(x,max(y,z))
#define f first
#define s second
#define lbd lower_bound
#define sz(x)       (ll)x.size()
#define pi 3.1415926536
#define mod 1000000007
using namespace std;
void solve()
{
    ll n,m,k,res=0,l=0,r=0,cnt=0,sum=0,z,sum1=0,cnt1=0,h,res1,t,c,x,y;
    cin>>n;
    ll ar[n];
    rep(i,0,n)
    cin>>ar[i];
    ll dp[n]={0};
    dp[1]=abs(ar[0]-ar[1]);
    rep(i,2,n)
        dp[i]=min(dp[i-1]+abs(ar[i]-ar[i-1]),dp[i-2]+abs(ar[i]-ar[i-2]));
    cout<<dp[n-1];
}
int main()
{   speed_up
    ll t;
    //cin>>t;
    t=1;
    while(t--)
        solve();
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define lor(a,b,c) for(register int a=b;a<=c;++a)
#define ror(a,b,c) for(register int a=c;a>=b;--a)

const int N=505;

int n,x[N],y[N*N],z,cnt[N]; bool vis[N];
struct data {int pos,id;};
inline bool operator < (data a,data b) {return a.pos>b.pos;}
priority_queue <data> line;

int main(){
	scanf("%d",&n); lor(i,1,n) scanf("%d",&x[i]);
	lor(i,1,n) y[x[i]]=i; lor(i,1,n) lor(j,1,i-1) line.push((data){x[i],i});
	lor(i,1,n*n){
		z=i;
		if(y[i]){
			if(cnt[y[i]]!=y[i]-1) {return puts("No"),0;}
			else vis[y[i]]=true;
		}
		else if(!line.empty()){
			data tmp=line.top(); line.pop(); y[i]=tmp.id; cnt[tmp.id]++;
		}
		else {--z; break;}
	}
	lor(i,1,n) cnt[i]=n-i;
	lor(i,z+1,n*n){
		if(y[i]) vis[y[i]]=true;
		else{
			int ch=0;
			lor(j,1,n) if(cnt[j]&&vis[j]) {ch=j; cnt[ch]--; y[i]=ch; break;}
			if(!ch) return puts("No"),0;
		}
	}
	puts("Yes");
	lor(i,1,n*n) printf("%d ",y[i]); puts("");

	return 0;
}


Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>

using namespace std;
typedef long long ll;

int main(){

  string s;
  cin >> s;
  int m;
  m = stoi(s.substr(5, 2));
  if (m <= 4){
    cout << "Heisei" << endl;
  }
  else{
    cout << "TBD" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9+7;
string s;
long long dp1[100002], dp2[100002];

int main(){
    cin >> s;
    dp1[0] = 1;
    dp2[0] = 2;
    for(int i = 1;i < s.length();++i){
        if(s[i] == '1'){
            dp1[i] = (dp1[i-1] * 3 + dp2[i-1]) % MOD;
            dp2[i] = (dp2[i-1] * 2) % MOD;
        }else if(s[i] == '0'){
            dp1[i] = (dp1[i-1] * 3) % MOD;
            dp2[i] = dp2[i-1];
        }
    }
    cout << (dp1[s.length()-1] + dp2[s.length()-1]) % MOD << endl;
    return 0;
}

Measured memory_bytes: 2048