akhauriyash/Code-Regression huggingface dataset:
N, S = map(int,input().split())
A = list(map(int,input().split()))
mod = 998244353
dp = [[0 for j in range(S + 1)] for i in range(N + 1)]
dp[0][0] = 1
for i in range(N) : 
    for j in range(S + 1) : 
        dp[i + 1][j] += 2 * dp[i][j]
        dp[i + 1][j] %= mod 
        if j + A[i] <= S : 
            dp[i + 1][j + A[i]] += dp[i][j]
            dp[i + 1][j + A[i]] %= mod
print(dp[N][S])

Measured memory_bytes: 147696
r,c = gets.chomp.split.map(&:to_i)
t = Array.new(r){Array.new(c, 0)}
s = Array.new(c+1, 0)
t.each do |ti|
  ti.replace(gets.chomp.split.map(&:to_i))
  ti.push(ti.inject(:+))
  ti.each_with_index do |item, index| s[index] += item end
end
t.push(s)
t.each do |item| puts item*" " end

Measured memory_bytes: 6200
N,A,B = map(int, input().split())
L = []
b = 0
ans = 0

if A == 0:
  ans = 0
elif N < A:
  ans = N
elif N < A+B:
  ans = A
else:
  x = N // (A+B)
  y = N % (A+B)
  ans = A * x + min(y, A)

print(ans)

Measured memory_bytes: 3060
using System;
using System.Linq;
class Program{
static void Main(string[] args){
  var N = int.Parse(Console.ReadLine());
  //Linqで計算ver
  var a = Console.ReadLine().Split().Select(x => int.Parse(x)).OrderByDescending(x=>x);
  //第二引数はindexとなる
  int alice=a.Where((x, y) => y % 2 == 0).Sum();
  int bob=a.Where((x, y) => y % 2 == 1).Sum();
  Console.WriteLine(alice-bob);
}
}

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

int main() {
  int N, M;
  std::cin >> N >> M;
  std::string A[N], B[M];
  for (int i = 0; i < N; ++i) {
    std::cin >> A[i];
  }
  for (int i = 0; i < M; ++i) {
    std::cin >> B[i];
  }

  bool exist = false;
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      if ( j + M - 1 >= N || i + M - 1 >= N ) continue;
      bool match = true;
      for (int ii = 0; ii < M; ++ii) {
        for (int jj = 0; jj < M; ++jj) {
          if ( A[i + ii][j + jj] != B[ii][jj] ) match = false;
        }
      }
      if ( match ) exist = true;
    }
  }
  if ( exist ) std::cout << "Yes" << std::endl;
  else std::cout << "No" << std::endl;

  return 0;
}


Measured memory_bytes: 256
use std::vec::Vec;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn read_touple<T: std::str::FromStr + Copy>() -> (T, T) {
  let v: Vec<T> = read_vec();
  assert_eq!(v.len(), 2);
  (v[0], v[1])
}

fn main() {
    let (h, n) = read_touple::<usize>();
    let a: Vec<usize> = read_vec();

    let sum: usize = a.iter().fold(0, |acc, &x| x + acc);

    let ans = if sum >= h {
       "Yes"
    } else {
       "No"
    };

    println!("{}", ans);
}


Measured memory_bytes: 6396
/* D-"Median of Medians" */
/*  */
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <map>
#define ll long long
#define N_MAX 100000
using namespace std;

int main(){
    string s;
    cin >> s;
    if(s[0] == s[1] && s[1] == s[2]){
        cout << "No";
    } else
    {
        cout << "Yes";
    }
    

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define TS to_string
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


ll INF = 1e9;
ll NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}     //最小公倍数

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

//-----------------------------------------
string s, t;
const ll L_MAX = 3000+10;

ll dp[L_MAX][L_MAX]; // dp[i][j] = (s[i],t[j]までの最長共通部分列長)

ll q(ll x, ll y){
    if(dp[x][y]!=-1) return dp[x][y];

    if(s[x-1]==t[y-1]) dp[x][y] = q(x-1,y-1) + 1;
    else dp[x][y] = max(q(x-1,y),q(x,y-1));

    return dp[x][y];
}



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

    cin >> s >> t;

    ll n = SZ(s);
    ll m = SZ(t);

    for(ll i=0;i<=n;i++){
        for(ll j=0;j<=m;j++){
            if(i==0 || j==0){
                dp[i][j] = 0;
            }
            else{
                dp[i][j] = -1;
            }
        }
    }

    ll k = q(n,m);

    ll i = n;
    ll j = m;

    string ans = "";

    while(i!=0 && j!=0){
        if(s[i-1]==t[j-1]){
            ans += s[i-1];
            i--;
            j--;
        }
        else{
            if(dp[i-1][j]>=dp[i][j-1]){
                i--;
            }
            else j--;
        }
    }
    reverse(ALL(ans));

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 74408
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


	int H, N;
	cin >> H >> N;
	int goukei = 0;
	rep(i, N) {
		int a;
		cin >> a;
		goukei += a;
	}
	if (goukei >= H) co("Yes");
	else co("No");

	Would you please return 0;
}

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 fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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 (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, A[301010];
int B[301010], C[301010];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	rep(i, 0, N) cin >> A[i];

	map<int, int> cnt;
	rep(i, 0, N) cnt[A[i]]++;

	map<int, int> cnt2;
	fore(p, cnt) cnt2[p.second]++;

	fore(p, cnt) B[p.second] += p.second;
	fore(p, cnt) C[p.second]++;

	rrep(i, 301000, 0) B[i] += B[i + 1];
	rrep(i, 301000, 0) C[i] += C[i + 1];

	rep(k, 1, N + 1) {
		int ans = 0;

		rep(cand, 1, N / k + 1) {
			int rest = N - (B[cand] - C[cand] * cand);
			if (cand * k <= rest) chmax(ans, cand);
		}
		
		printf("%d\n", ans);
	}
}







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

#define ran 10011

int h, n;
int a[ran], b[ran];
int f[ran];

void upd(int &a, int b) {
	if(a<0 || a>b) a=b;
}

int main() {
	scanf("%d%d", &h, &n);
	for(int i=0;i<n;i++) 
		scanf("%d%d", &a[i], &b[i]);
	
	memset(f, -1, sizeof f);
	f[0] = 0;
	for(int i=0;i<n;i++) {
		for(int j=0;j<h;j++)
			if(f[j]>=0) upd(f[min(h, j+a[i])], f[j]+b[i]);
	}
	printf("%d\n", f[h]);
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, k;
    cin >> n >> k;
    double p;
    vector<long long> v;
    double ans = 0;
    for (int i = 1; i <= n; i++)
    {
        int x = i;
        p = 1.0;
        while (x < k)
        {
            x *= 2;
            p *= 0.500000;
        }
        ans += p / n;
    }
    cout << setprecision(10) << ans << endl;
}


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

int main(){
  ll n;
  cin >> n;
  string s;
  while(n>0){
    int r = n%26;
    char c;
    if(r>0) c = 'a' + r - 1;
    else c = 'z';
    s += c;
    n /= 26;
    if(r==0) n--;
  }
  reverse(s.begin(),s.end());
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define MOD ((int)(1e9+7))
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define float long double

int32_t main()
{
	IOS
	int r,g,b,n,ans=0;cin>>r>>g>>b>>n;
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=n;j++)
		{
			int k=(n-(i*r+j*g))/b;
			if(i*r+j*g+k*b==n && k>=0)ans++;
		}
	}
	cout<<ans<<endl;
}
	
			
	
	
	
	
	

	

	

	
		


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

int64_t a[200001];

int main()
{
    int i,n;
    scanf("%d",&n);
    int b[n];
    for(i=0;i<n;i++)
        {
            scanf("%d",&b[i]);
            a[b[i]]++;
        }
    int64_t s=0;
    for(i=1;i<=200000;i++)
        if(a[i])
    {
        s+=a[i]*(a[i]-1)/2;

    }
    for(i=0;i<n;i++)
        printf("%lld\n",s-a[b[i]]+1);

   return 0;
}


Measured memory_bytes: 3968
H, W = gets.split.map(&:to_i)
M = Array.new(H+2){ Array.new(W+2, 0) }
(1 .. H).each do |y|
  row = gets.chomp
  (1 .. W).each do |x|
    M[y][x] = 1 if row[x-1] == '#'
  end
end
ans = (1 .. H).all? do |y| 
  (1 .. W).all? do |x|
    M[y][x] == 0 || [M[y + 1][x], M[y - 1][x], M[y][x + 1], M[y][x - 1]].any?{|v| v > 0}
  end
end
puts ans ? 'Yes' : 'No'



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

int main(void)
{
    int N;
    cin >> N;
    int A[N+1], B[N];
    for (int i = 0; i < N+1; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> B[i];
    }

    long long killcount = 0;
    for (int i = 0; i < N; i++) {
        if (B[i] <= A[i]) {
            killcount += B[i];
        }
        else {
            killcount += A[i];
            if (A[i+1] >= B[i]-A[i]) {
                killcount += B[i]-A[i];
                A[i+1] -= B[i]-A[i];
            }
            else {
                killcount += A[i+1];
                A[i+1] = 0;
            }
        }
    }

    cout << killcount << endl;
}


Measured memory_bytes: 4384
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>
using namespace std;

#define sz(x) (int)(x.size())
#define rep(i,a,b) for(int i=a;i<b;++i)
#define pb push_back
#define mp make_pair
typedef pair<int, int> pii;
//////////////////////////

int const INF = 1e6 + 41;

void solve(){
	int n, k;
	cin >> n >> k;
	vector<int> b;
	rep(i, 0, k){
		int d;
		cin >> d;
		b.pb(d);
	}
	
	rep(i, n, INF){
		bool ok = true;
		int v = i;
		while(v){
			if(find(b.begin(), b.end(), v % 10) != b.end()) ok = false;
			v /= 10;
		}
		if(ok){
			cout << i << endl;
			return;
		}
	}
}

int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	solve();


	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int i,n,debt = 100000;
	scanf("%d",&n);
	for(i = 0;i < n;i++){
		debt = (((int)(debt * 1.05) - 1) / 1000 + 1) * 1000;
	}
	printf("%d\n",debt);
}

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

int main(){
  int a;
  double n;
  cin >> n;
  a=(n+1)/2;
  n=a/n;
  printf("%.9lf\n",n);
}

Measured memory_bytes: 384
use std::io::*; //Not mine.
use std::str::FromStr;
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
fn main() {
    let n: i64 = read();
    let mut a: Vec<i64> = (0..n + 1).map(|_| read()).collect();
    let mut b: Vec<i64> = (0..n).map(|_| read()).collect();
    let mut ans:i64 = 0;
    for k in 0..n {
        let i = k as usize;
        if a[i] <= b[i] {
            b[i] -= a[i];
            ans += a[i];
            a[i] = 0;
        } else if b[i] < a[i] {
            a[i] -= b[i];
            ans += b[i];
            b[i] = 0;
        }
        if b[i] >= a[i + 1] {
            ans += a[i + 1];
            a[i + 1] = 0;
        } else if b[i] < a[i + 1] {
            ans += b[i];
            a[i + 1] -= b[i];
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        std::cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
    }
} fast;

/* define */
#define FOR(I, X, Y) for (long long(I) = (X); (I) < (Y); (I)++)
#define REP(I, X, Y) for (long long(I) = (Y)-1; (I) >= (X); (I)--)
#define ALL(X) (X).begin(), (X).end()
#define pb push_back
#define COUNT(V, X)                           \
    (upper_bound((V).begin(), (V).end(), X) - \
     lower_bound((V).begin(), (V).end(), X))
#define debug(x) cerr << #x << ':' << x << endl;
#define DEBUG(v)                             \
    {                                        \
        cerr << #v << ':';                   \
        for (auto xv : v) cerr << xv << ' '; \
        cerr << endl;                        \
    }
#define Yes(X) cout << (X ? "Yes" : "No") << endl;
#define YES(X) cout << (X ? "YES" : "NO") << endl;
#define ctoi(C) (C - '0')
#define pow2(x) ((long long)((long long)1 << x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int, int>;
using pl = pair<long long, long long>;
template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1, 0, -1, 0};
const long long dy[] = {0, 1, 0, -1};
const long long dx8[] = {1, 1, 0, -1, -1, -1, 0, 1};
const long long dy8[] = {0, 1, 1, 1, 0, -1, -1, -1};
const long long dx9[] = {1, 1, 0, -1, -1, -1, 0, 1, 0};
const long long dy9[] = {0, 1, 1, 1, 0, -1, -1, -1, 0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T1, typename T2>
inline bool chmin(T1 &a, const T2 &b) {
    if (a > b) a = b;
    return a > b;
}
template <typename T1, typename T2>
inline bool chmax(T1 &a, const T2 &b) {
    if (a < b) a = b;
    return a < b;
}
long long max(long long x, int y) {
    return max(x, (long long)y);
}
long long max(int x, long long y) {
    return max((long long)x, y);
}
long long min(long long x, int y) {
    return min(x, (long long)y);
}
long long min(int x, long long y) {
    return min((long long)x, y);
}

/* library */

/* main */

signed main() {
    ll N;
    cin >> N;
    FOR(i, 1, 10) {
        FOR(j, 1, 10) {
            if (i * j == N) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include<string>
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<math.h>
#include<unordered_set>
#include<string.h>
#include<unordered_map>
using namespace std;

typedef long long ll;

#define FOR(i,N) for(int i=0;i<N;i++)

ll mod=1e9+7;


int n;
map<int,vector<int> >tree;
map<int,int>depth;
vector<int>visited;

int dfs(int node,int d,int last){
    int de=0;
    for(auto a:tree[node]){
        if(a!=last){
            de=de^(dfs(a,d+1,node)+1);
        }
    }
    return depth[node]=de;
}

int main() {
    cin>>n;
    for(int i=0;i<n-1;i++){
        int x,y;
        cin>>x>>y;
        tree[x].push_back(y);
        tree[y].push_back(x);
    }
    ;
  
    if(dfs(1,0,-1)>0){
        cout<<"Alice"<<endl;
    } else {
        cout<<"Bob"<<endl;
    }
}


Measured memory_bytes: 25216
#include <iostream>

int s(long long i)
{
    int a = i % 10;
    while(i >= 10) {
        i /= 10;
        a += (i%10);
    };

    return a;
}

int main()
{
    long long N;
    std::cin >> N;

    if (N%s(N)==0) {
        std::cout << "Yes" << std::endl;
    }
    else {
        std::cout << "No" << std::endl;
    }

    return 0;
}

Measured memory_bytes: 764
def main():
    import sys
    def input(): return sys.stdin.readline()[:-1]
    pl = lambda x: print(*x, sep='\n')

    A, B, K = map(int, input().split())

    for val in range(A, B+1):
        if val<=A+K-1 or B-K+1<=val:
            print(val)

if __name__ == '__main__':
    main()

Measured memory_bytes: 38512
'''
研究室PCでの解答
'''
import math
#import numpy as np
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7
dir = [(-1,0),(1,0),(0,-1),(0,1)]
alp = "abcdefghijklmnopqrstuvwxyz"


def main():
    m,k = map(int,ipt().split())
    if m == 1:
        if k == 0:
            print("0 1 1 0")
        else:
            print(-1)
        exit()
    if k <= 2**m-1:
        a = []
        b = []
        for i in range(m):
            if (k>>i)&1:
                a.append(2**i)
        sa = set(a)
        for i in range(2**m):
            if not i in sa:
                b.append(i)
        print(" ".join(map(str,a+b+a[::-1]+b[::-1])))
    else:
        print(-1)

    return None

if __name__ == '__main__':
    main()


Measured memory_bytes: 119268
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include<cmath>
using namespace std;
int dist1[200009], dist2[200009], n, a, b; vector<int>x[200009];
void dfs1(int pos, int depth) {
	if (dist1[pos] != -1)return;
	dist1[pos] = depth;
	for (int i = 0; i < x[pos].size(); i++) {
		dfs1(x[pos][i], depth + 1);
	}
}
void dfs2(int pos, int depth) {
	if (dist2[pos] != -1)return;
	dist2[pos] = depth;
	for (int i = 0; i < x[pos].size(); i++) {
		dfs2(x[pos][i], depth + 1);
	}
}
int main() {
	cin >> n;
	for (int i = 0; i < n - 1; i++) {
		cin >> a >> b; x[a].push_back(b); x[b].push_back(a);
	}
	for (int i = 0; i < 200009; i++) { dist1[i] = -1; dist2[i] = -1; }
	dfs1(1, 0); dfs2(n, 0);
	int cnt1 = 0, cnt2 = 0;
	for (int i = 1; i <= n; i++) { if (dist1[i] <= dist2[i])cnt1++; else cnt2++; }
	if (cnt1 > cnt2)cout << "Fennec" << endl;
	else cout << "Snuke" << endl;
	return 0;
}

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

#define ran 111

int n;
char s[ran], t[ran];

int main() {
	scanf("%d%s%s", &n, s, t);
	for(int i=0;i<n;i++) {
		putchar(s[i]);
		putchar(t[i]);
	}
	puts("");
	
	return 0;
}

Measured memory_bytes: 256
import fractions
from functools import reduce

n = int(input())
a = list(map(int, input().split()))

m1 = [0] * (n + 1)
m2 = [0] * (n + 1)
for i in range(1, n + 1):
  m1[i] = fractions.gcd(m1[i - 1], a[i - 1])
  m2[n - i] = fractions.gcd(m2[n - i + 1], a[n - i])

m = [0] * n
for i in range(n):
  m[i] = fractions.gcd(m1[i], m2[i + 1])

print(max(m))

Measured memory_bytes: 16084
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

int main(void) {
    string S;
    cin >> S;

    int ans = 700;
    for (auto c : S) {
        if (c == 'o') {
            ans += 100;
        }
    }

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


Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>

using namespace std;

int gcd(int n, int m) {
    if (n == 0) return m;
    return gcd(m % n, n);
}

int main() {
    uint64_t r, D, x;
    cin >> r >> D >> x;

    for (int i = 1; i <= 10; ++i) {
        x = r * x - D;
        cout << x << endl;
    }
}


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

int n;
int x[10], y[10];

double calc(int i, int j){
    double dx = x[i]-x[j];
    double dy = y[i]-y[j];
    return sqrt(dx*dx + dy*dy);
    //return pow(dx*dx + dy*dy, 0.5);
}

int main(){ 
    cin >> n;
    for(int i=1;i<=n;i++) cin >> x[i] >> y[i];
    vector<int> v(n);
    double sum=0.0;
    for(int i=0;i<n;i++) v[i]=i+1;
    
    do{
        for(int i=0;i<n-1;i++) sum += calc(v[i], v[i+1]);
    }while(next_permutation(v.begin(), v.end()));
    
    int count=1;
    for(int i=2;i<=n;i++) count*=i;
    cout << fixed << setprecision(10) << sum/count << endl;

    return 0;
} 

Measured memory_bytes: 256
// 深さ優先探索
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func genid(a, b int) int {
	if b < a {
		a, b = b, a
	}
	return a*100000 + b
}

func main() {
	N := readInt()

	ab := make([][2]int, N-1)
	edges := make([][]int, N)
	for i := 0; i < N-1; i++ {
		a := readInt() - 1
		b := readInt() - 1
		ab[i][0], ab[i][1] = a, b
		edges[a] = append(edges[a], b)
		edges[b] = append(edges[b], a)
	}

	colors := make(map[int]int)
	q := make([][3]int, 0)
	q = append(q, [3]int{0, -1, -1})
	for len(q) != 0 {
		currentNode, usedColor, parentNode := q[0][0], q[0][1], q[0][2]
		q = q[1:]
		color := 1
		for _, childNode := range edges[currentNode] {
			if childNode == parentNode {
				continue
			}
			if color == usedColor {
				color++
			}
			colors[genid(currentNode, childNode)] = color
			q = append(q, [3]int{childNode, color, currentNode})
			color++
		}
	}

	K := -1
	for i := 0; i < N; i++ {
		t := len(edges[i])
		if t > K {
			K = t
		}
	}
	fmt.Println(K)

	for i := 0; i < N-1; i++ {
		fmt.Println(colors[genid(ab[i][0], ab[i][1])])
	}
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}


Measured memory_bytes: 22528
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kamol Paul
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define long long long
typedef pair < long , long > pii;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
class EDivisibleSubstring {
public:
	void solve(std::istream& in, std::ostream& out) {
	    long n,p;
	    in>>n>>p;
	    string data;
	    map<long,long> fre;
	    in>>data;
        if(p==2 || p == 5){
            long ans =0;
            for(int i=0;i<n;i++){
                int x = data[i]-'0';
                if(x%p == 0){
                    ans += (i+1);
                }
            }
            out<<ans<<endl;
            return;
        }
	    reverse(data.begin(),data.end());
	    vector<long> mul(n);
	    mul[0]=1;

	    for(int i=1;i<n;i++){
	        mul[i] =( mul[i-1]*10LL) % p;
	    }
	    long ans =0;
	    for(int i=0;i<n;i++){
	        ans = (ans + mul[i]*(data[i]-'0'))%p;
	        fre[ans]++;
	    }
	    long A =0;
	    for(auto t : fre){
	        long x = t.second;
	        if(t.first==0){
	            A += x*(x+1)/2;
	        }
	        else{
	            long k = x -1;
	            x--;
	            A += x*(x+1)/2;

	        }
	    }
        out<<A<<endl;
	}
};


int main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL);
	EDivisibleSubstring solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 2580
import os
import sys
from io import BytesIO, IOBase


def main():
    A, B = map(int, input().rstrip().split())
    print(A*B)

#.........................................FAST INPUT OUTPUT.......................................
BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

#....................................END OF FAST I/O............................................

if __name__ == "__main__":
    main()

Measured memory_bytes: 62532
using System;

class Program
{
    //Level k の時のpの数を格納
    static readonly long[] dp = new long[51];
    static readonly long[] lengthDp = new long[51];

    static void SetDP(int n, int i)
    {
        dp[i] = dp[i - 1] * 2 + 1;
        lengthDp[i] = lengthDp[i - 1] * 2 + 3;
        i++;
        if (i <= n) SetDP(n, i);
    }
    
    //B/set[n-1]/P/set[n-1]/終端のB
    static long GetRightPCount(int n, long x, int originalN)
    {
        long count = 0;
        
        //B
        if (x <= 1) return count;
        x--;

        if (n == 0) return count;
        n--;//これ以降index = i - 1

        //set[i-1]
        if (x < lengthDp[n])
            return count + GetRightPCount(n, x, originalN);
        count += dp[n];
        x -= lengthDp[n];
        if (x == 0) return count;

        //P
        count++;
        x--;

        //set[i-1]
        if (x < lengthDp[n])
            return count + GetRightPCount(n, x, originalN);
        count += dp[n];
        x -= lengthDp[n];
        return count;
    }

    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int n = int.Parse(input[0]);
        long x = long.Parse(input[1]);

        dp[0] = 1;
        lengthDp[0] = 1;
        SetDP(n, 1);
        
        Console.WriteLine(GetRightPCount(n, x, n));
    }
}

Measured memory_bytes: 11092
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }
}

#endif

// main.cpp

int main() {
  i64 N;
  std::cin >> N;
  std::vector<i64> A;
  tools::read(A, N);

  i64 sum = std::abs(A.front()) + std::abs(A.back());
  for (i64 i = 1; i < N; ++i) {
    sum += std::abs(A[i] - A[i - 1]);
  }

  std::cout << sum + std::abs(A[1]) - std::abs(A[0]) - std::abs(A[1] - A[0]) << std::endl;
  for (i64 i = 1; i < N - 1; ++i) {
    std::cout << sum + std::abs(A[i + 1] - A[i - 1]) - std::abs(A[i] - A[i - 1]) - std::abs(A[i + 1] - A[i]) << std::endl;
  }
  std::cout << sum + std::abs(A[N - 2]) - std::abs(A[N - 1] - A[N - 2]) - std::abs(A[N - 1]) << std::endl;
  return 0;
}

Measured memory_bytes: 2048
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main() {

    int N;
    cin >> N;

    int p;
    vector<int> ps;
    for (int i = 0; i < N; ++i) {
        cin >> p;
        ps.push_back(p);
    }

    int cnt = 0;
    for (int i = 1; i <= N; ++i) {
        if (ps[i - 1] != i) {
            cnt += 1;
        }
    }

    if (cnt == 2 || cnt == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n1=0, n0=0;
  string S;
  cin >> S;
  for (int i=0;i<S.size();i++) {
    if (S.at(i) == '0') n0++;
    else n1++;
  }
  cout << min(n1,n0)*2 << endl;
}

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

using namespace std;
using int64 = unsigned long long;

int main() {
    long double a, b;
    cin >> a >> b;
    a /= 10000;
    b /= 10000;
    long double ans = a * b;
    cout << (int64)(ans*100000000) << endl;
}


Measured memory_bytes: 3188
import java.util.Scanner;
import java.util.Arrays;
public class Main {
	//static int n,k,u[],min[count],max;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int min[]=new int[50000];
		int count=-1;
		while(true){
			count++;
			int n = sc.nextInt();
			if(n==0){
				break;
			}
			int data[]=new int[n];
			for(int i=0;i<n;i++){
				data[i]=sc.nextInt();
			}
			Arrays.sort(data);
			min[count]=data[0]-data[1];
			if(min[count]<0){
				min[count]=min[count]*-1;
			}
			for(int i=1;i<n;i++){
				int hoge=data[i-1]-data[i];
				if(hoge<0){
					hoge=hoge*-1;
				}
				if(min[count]>hoge){
					min[count]=hoge;
				}
			}
		}
		for(int i=0;i<count;i++){
			System.out.println(min[i]);
		}
		
	}
}

Measured memory_bytes: 48144
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >>N;
  vector<int> A(N,0),B(N,0);
  for(int i=0; i<N; i++){
    int x;
    cin >>x;
    A[i]=x;
  }
  B=A;
  sort(A.begin(), A.end());
  int h=A[N/2], l=A[N/2-1];
  for(int i=0; i<N; i++){
    if(B[i]>=h) cout<<l<<endl;
    else cout<<h<<endl;
  }
}

Measured memory_bytes: 3712
#include<iostream>

using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    int *s = new int[m];
    int *c = new int[m];
    int *isAssign = new int[n];
    for (int i = 0; i < m; i++) {
        cin >> s[i] >> c[i];
    }
    for (int i = 0; i < n; i++) {
        isAssign[i] = -1;
    }
    
    for (int i = 0; i < m; i++) {
        if (isAssign[s[i] - 1] == -1) {
            isAssign[s[i] - 1] = c[i];
        } else if (isAssign[s[i] - 1] != -1 && isAssign[s[i] - 1] != c[i]) {
            cout << "-1" << endl;
            return 0;
        }
    }
    if ((isAssign[0] == -1 && n == 1) || (isAssign[0] == 0 && n == 1)) {
        cout << "0" << endl;
        return 0;
    }
    if (isAssign[0] == 0) {
        cout << "-1" << endl;
        return 0;
    } else if (isAssign[0] == -1) {
        isAssign[0] = 1;
    }
    for (int i = 1; i < n; i++) {
        if (isAssign[i] == -1) {
            isAssign[i] = 0;
        }
    }
    for (int i = 0; i < n; i++) {
        cout << isAssign[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <chrono>
#include <climits>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

template <class T1, class T2>
ostream& operator << (ostream& out, const pair <T1, T2> p)
{
	out << '(' << p.first << ',' << p.second << ')';
	return out;
}

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

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

template <class T>
ostream& operator << (ostream& out, const vector<vector<T>> &v)
{
	for (const vector<T> &x : v)
		out << x << '\n';
	return out;
}

template <class T>
ostream& operator << (ostream& out, const vector<T> &v)
{
	for (const T &x : v)
		out << x << ' ';
	return out;
}

long long gcd (long long a, long long b)
{
	if (b > a)
		swap(a, b);
	return (b ? gcd(b, a % b) : a);
}

using ll   = long long;
using pii  = pair<int, int>;
using pll  = pair<long long, long long>;
using tiii = pair<pair<int, int>, int>;
using vi   = vector<int>;
using vl   = vector<long long>;
using vvi  = vector<vector<int>>;
using vvl  = vector<vector<long long>>;

#define F          first
#define S          second
#define First      first.first
#define Second     first.second
#define Third      second
#define mp         make_pair
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define per(i,b,a) for (int i = (b); i > (a); i--)
#define all(x)     x.begin(), x.end()
#define ret(x)     return cout << x, 0;
#define throwex    throw runtime_error ("Found the error.");

const int h = 1000000007;

signed main()
{
	ios::sync_with_stdio(false);
	#ifdef ONLINE_JUDGE
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.setstate(ios::failbit);
	#endif

	int n;
	cin >> n;
	vl a(n), b(n);
	rep(i,0,n)
		cin >> a[i] >> b[i];
	sort(all(a));
	sort(all(b));
	if(n & 1)
		ret(b[n/2] - a[n/2] + 1)
	else
		ret((b[n/2] + b[n/2-1]) - (a[n/2] + a[n/2-1]) + 1);
}


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

/*............................*/

#define uint uint64_t
#define mx 100001
#define ll long long int
#define ull unsigned long long int
#define pii pair<int, int>
#define pll pair<long long int, long long int>
#define mp make_pair
#define pb push_back
#define inf INT_MAX
#define pi acos(-1)
#define eps 1e-8
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b) / __gcd(a, b)
#define input(ara, n)          \
   for (int i = 0; i < n; i++) \
   scanf("%d", &ara[i])
#define inputl(ara, n)                   \
   for (long long int i = 0; i < n; i++) \
   scanf("%lld", &ara[i])
#define pf(a) printf("%d\n", a);
#define pfl(a) printf("%lld\n", a);
#define pfi(a) printf("%d ", a);
#define pfll(a) printf("%lld ", a);
#define sc(a) scanf("%d", &a)
#define scc(a, b) scanf("%d %d", &a, &b)
#define sccdbl(a, b) scanf("%lf %lf", &a, &b)
#define sccc(a, b, c) scanf("%d %d %d", &a, &b, &c)
#define scccdbl(a, b, c) scanf("%lf %lf %lf", &a, &b, &c)
#define scl(a) scanf("%lld", &a)
#define sccl(a, b) scanf("%lld %lld", &a, &b)
#define scccl(a, b, c) scanf("%lld %lld %lld", &a, &b, &c)
using namespace std;
int main()
{
   // int t;
   // sc(t);
   // while (t--)
   // {

   // }
   double w,h,x,y;
   cin>>w>>h>>x>>y;
   if(x+x==w && y+y==h){
      printf("%lf 1\n",(w*h)/2.0);
   }
   else{
      printf("%lf 0\n",(w*h)/2.0);
   }
   return 0;
}


Measured memory_bytes: 3804
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

int main(void){
    string s;

    cin >> s;

    if(s == "Sunny"){
        cout << "Cloudy" << endl;
    } else if(s == "Cloudy"){
        cout << "Rainy" << endl;
    } else {
        cout << "Sunny" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main() {
  
  int a,t,c=0;
  cin >> a;
  t=a;
  while(t>0){
    c += t%10;
    t /= 10;
  }
  if(a%c==0)cout << "Yes" << endl;
  else cout << "No" << endl;
      
}


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

int main()
{
    int n;
    cin >> n;
    int a[102];
    for(int i = 0; i < n; i++) cin >> a[i];
    int s = 1, r = 1;
    for(int i = 0; i < n; i++){
        s *= 3;
        if(a[i] % 2 == 0) r *= 2;
    }
    cout << s - r << endl;
}

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

int min(int x, int y){
    return x < y ? x : y;
}

int main(){
    int n; cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ll sum=0;
    ll cost=0;
    for (int i = 0; i < n; ++i) {
        sum += a[i];
        if(i%2==0){
            if(sum <= 0){
                cost += -sum+1;
                sum = 1;
            }
        }else{
            if(sum >= 0){
                cost += sum + 1;
                sum = -1;
            }
        }
    }
    ll sum2=0;
    ll cost2 = 0;
    for (int i = 0; i < n; ++i) {
        sum2 += a[i];
        if(i%2==0){
            if(sum2 >= 0){
                cost2 += sum2 + 1;
                sum2 = -1;
            }
        }else{
            if(sum2 <= 0){
                cost2 += -sum2+1;
                sum2 = 1;
            }
        }
    }
    ll ans = min(cost, cost2);
    cout << ans << endl;

}


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

#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)
#define pb push_back
#define INF 1000000007LL
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)

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

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

int N, W;
map<ll, vector<ll> > wv;
int main(){
    ios::sync_with_stdio(false);
    cin >> N >> W;
    ll first_w = -1;
    REP(i, N) {
        ll w, v;
        cin >> w >> v;
        if (first_w == -1) {
            first_w = w;
        }
        wv[w].pb(v);
    }
    
    for(auto x: wv) {
        ll key = x.first;
        sort(wv[key].begin(), wv[key].end(), greater<ll>());
    }
    
    ll ans = 0;
    REP(i, wv[first_w].size()+1) REP(j, wv[first_w+1].size()+1) {
        REP(k, wv[first_w+2].size()+1) REP(l, wv[first_w+3].size()+1) {
            ll wei = i * (first_w) + j * (first_w + 1) + k * (first_w + 2) + l * (first_w + 3);
            if (wei <= W) {
                ll val = 0;
                REP(m, i) val += wv[first_w ][m];
                REP(m, j) val += wv[first_w + 1][m];
                REP(m, k) val += wv[first_w + 2][m];
                REP(m, l) val += wv[first_w + 3][m];
                ans = max(ans, val);
            }
        }
    }
    cout << ans << endl;
    
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int a, b, s, i, flag = 0;
    
    scanf("%d %d", &a, &b);
    if(9>=b){
        s = a * 10 + b;
    } else if(10<=b && 100>b){
        s = a * 100 + b;
    } else if(100 == b){
        s = a * 1000 + b;
    }
    for(i = 0; i <= 1000; i++){
        if(i * i == s){
            flag = 1;
            //printf("Yes\n");
        }
    }
    if(flag == 1){
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    
}


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

int main(){
    string a,b;
    cin >> a >> b;
    string ans;
    if(a.size()>b.size())
    puts("GREATER");
    else if(a.size()<b.size())
    puts("LESS");
    else{
        for(int i=0;i<a.size();i++){
            if(a.at(i)>b.at(i)){
                ans="GREATER";
                break;
            }
            else if(a.at(i)<b.at(i)){
                ans="LESS";
                break;
            }
            else
            ans="EQUAL";
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	vector<string> p(3);
	rep(snip_i, 3) cin >> p.at(snip_i);
	int pa = 0;
	vector<int> te(3, 0);
	while(1){
		if(te.at(pa) == (int)p.at(pa).size()) break;
		char c = p.at(pa)[te.at(pa)];
		te.at(pa)++;
		int nx_pa = c - 'a';
		pa = nx_pa;
	}
	cout << (char)(pa + 'A') << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define allR(v) v.rbegin(), v.rend()
#define PRINT(v) for (auto x : (v)) cout <<x <<" " ; cout <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
typedef pair<int,int> Pi;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
const int inf = 1001001001;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }

template<class T> struct edge { int to; T cost;};


int main() {
  int n; cin >>n;
  n %= 10;
  if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9){
    cout <<"hon" <<endl;
  }else if (n == 0 || n == 1 || n == 6 || n == 8){
    cout <<"pon" <<endl;
  }else if (n == 3){
    cout <<"bon" <<endl;
  }
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <climits> 
#include <time.h>

std::vector <long> A;
std::vector<long> B;

void Prime(long s)
{
    long max = std::sqrt(s);
    if(max*max<s){
        max+=1;
    }
    for(long i=2;i<=max; i++){
        long count=0;
        if(s%i==0){
            A.push_back(i);
            count=0;
        }
        bool flag=0;
        while(s%i==0){
            count++;
            s=s/i;
            flag=1;
        }
        if(flag){
        B.push_back(count);
        }
    }
    if(s!=1){
        A.push_back(s);
        B.push_back(1);
    }
}

int main(void){
    long N;
    std::cin >> N;
    Prime(N);
    long result=0;
    for(long i=0; i<A.size(); i++){
        long border=1;
        while(B[i]>=border){
            result++;
            B[i]-=border;
            border++;
        }
    }
    std::cout << result << std::endl;
    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);
#define ADD +
#define SUBTRACT -
#define MULTIPLY *
#define DIVIDE /
#define MOD %
#define INCREMENT(x) ++x
#define DECREMENT(x) --x
#define in(a,b) cin>>a>>b;
#define out(a,b) cout<<a<<endl<<b<<endl;
#define scan(a) scanf("%d",&a);
#define print(a) printf("%d\n",a);
#define scanii(a,b) scanf("%d %d",&a,&b);
#define printii(a,b) printf("%d\n%d\n",a,b);
#define scaniii(a,b,c) scanf("%d %d %d",&a,&b,&c);
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define ll long long
#define ull unsigned long long
#define sll signed long long
#define pi acos(-1)
#define mod 1000000007
#define TRUE 1
#define FALSE 0
#define ZERO 0
#define MP make_pair
#define F first
#define S second
#define f1(i,a) for(int i=0;i<a;++i)
#define f2(i,a) for(int i=a-1;i>=0;--i)
#define en puts("");
#define elif else if
typedef ll int lli;
typedef sll int slli;
typedef ull int ulli;
const int sz=10000;
using namespace std;

int clue();
int result();
void show();
bool check();


bool cmp(pair<int,int>p,pair<int,int>q) {
    // return p.first>q.first;//descending by first
    // return p.first<q.first;//ascending by first
    // return p.second>q.second;//descending by second
    return p.second<q.second;//ascending by second
}

// bool cmp(int p,int q) {
    // return p>q;//descending
    // return p<q;//ascending
// }

int main() {

    int t;
    // cin>>t;
    t=1;
    while(t-->0) {
        clue();
    }

    return 0;
}
int clue() {

    int n,m;
    lli count;
    cin>>n>>m;

    count=n*(n-1)/2;
    count+=m*(m-1)/2;
    
    cout<<count<<endl;

    // (det)?cout<<"Yes"<<endl:cout<<"No"<<endl;
    
    return 0;
}

Measured memory_bytes: 3652
a, b , c, d = map(int, input().split())
if b<=c or d <= a :
    print(0)
elif c<=b:
    if c <= a and b<=d:
        print(b-a)
    elif a<= c and b<=d:
        print(b-c)
    elif a<=c and d<=b:
        print(d-c)
    elif c<=a and d<=b:
        print(d-a)

Measured memory_bytes: 3060