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

typedef pair<int, int> P;
const int M = 1000000007;

int prim_cost(vector<vector<P>> edge) {
    int n = edge.size();
    vector<int> vis(n, 0);
    int c = 0;
    priority_queue<P, vector<P>, greater<P>> q;
    q.push(P(0, 0));
    while (!q.empty()) {
        P p = q.top();
        q.pop();
        if (vis[p.second]) continue;
        vis[p.second] = 1;
        c += p.first;
        for (auto& e : edge[p.second]) {
            if (!vis[e.second]) {
                q.push(P(e.first, e.second));
            }
        }
    }
    return c;
}


int main() {
    int n;
    cin >> n;
    vector<vector<P>> edge(n);
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            int a;
            cin >> a;
            if (a != -1)
                edge[i].push_back(P(a, j));
        }
    }
    cout << prim_cost(edge) << "\n";
    return 0;
}

Measured memory_bytes: 3232
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let s = read_as_string();

    if (s.matches("N").count() > 0 && s.matches("S").count() == 0) ||
        (s.matches("S").count() > 0 && s.matches("N").count() == 0) ||
        (s.matches("E").count() > 0 && s.matches("W").count() == 0) ||
        (s.matches("W").count() > 0 && s.matches("E").count() == 0){
            println!("No");
        }else{
            println!("Yes");
        }
}


Measured memory_bytes: 4352
from collections import deque

H, W = map(int, input().split())
S = []
for _ in [0]*H:
	S.append(list(input().rstrip()))

visited = []
for _ in [0]*H:
	visited.append([False] * W)

delta = [[1, 0], [0, 1], [-1, 0], [0, -1]]

ans = 0
for x in range(H):
	for y in range(W):
		if visited[x][y]: continue
		b = 0
		w = 0
		queue = deque()
		queue.append([x, y])
		visited[x][y] = True
		while len(queue) is not 0:
			px, py = queue[0]
			queue.popleft()
			if S[px][py] == '#' : b += 1
			else: w += 1
			found = False
			for dx, dy in delta:
				nx = px + dx
				ny = py + dy
				if 0 <= nx < H and 0 <= ny < W and not visited[nx][ny]:
					if S[px][py] != S[nx][ny]:
						found = True
						visited[nx][ny] = True
						queue.append([nx, ny])

		ans += b * w

print(ans)

Measured memory_bytes: 6132
//【ライブラリここから】
// 1. 入力の容易化（https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8）
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
//【ライブラリここまで】

fn main() {
    input! {
        n: i64,
        l: [i32; n]
    }
    let mut lv: Vec<i32> = Vec::<i32>::with_capacity(n as usize);
    for i in 0..n {
        lv.push(l[i as usize]);
    }
    lv.sort();
    let mut counter = 0;
    for i in 0..lv.len() {
        for j in i + 1..lv.len() {
            if lv[i] == lv[j] {
                continue;
            }
            for k in j + 1..lv.len() {
                if lv[j] == lv[k] {
                    continue;
                }
                if (lv[i] + lv[j]) > lv[k] {
                    counter += 1;
                }
            }
        }
    }
    println!("{}", counter);
}


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

const long long inf = 2000000000000000000;

int t;
long long a, b, c, d, e, g, l, r, m;

signed main () {
	scanf("%d", &t);
	while (t--) {
		scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
		if (b > a || b > d || c < a % b)
			printf("No\n");
		else if (c >= b || b == d)
			printf("Yes\n");
		else {
			g = __gcd(b, d);
			l = -inf / g, r = inf / g;
			while (r - l > 1) {
				m = (l + r) / 2;
				if (m * g + (a % g) >= c - b + 1)
					r = m;
				else
					l = m;
			}
			if (l * g + (a % g) >= c - b + 1) 
				e = l;
			else
				e = r;
			if (e >= 0)
				printf("Yes\n");
			else
				printf("No\n");
		}
	}
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int n;
  cin >> n;
  int go[10][10] = {};
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    string s = to_string(i);
    go[s[0] - '0'][s.back() - '0']++;
  }

  for (int i = 0; i < 10; ++i)
    for (int j = 0; j < 10; ++j) ans += go[i][j] * go[j][i];
    
  cout << ans << endl;
  return 0;
}


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

int main(int argc, char const *argv[])
{	
	vector<int> bell(3);
	for (int i = 0; i < 3; ++i)	cin >> bell.at(i);
	sort(bell.begin(), bell.end());
	cout << bell.at(0) + bell.at(1) << endl;
	return 0;	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<cctype>
#include<cmath>
#include<queue>
#include<stack> 
#include<vector>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
//const int MAX_V=105;
const long double pi = 3.14159265;
const long long mod =1e9+7;


int main(){
    int A, B,i,count=0;
    string S;
    cin >> A >> B >> S;
    for(i=0;i<S.size();i++){
        if(S[i] == '-'){
            count++;
        }
    }

    if(count == 1){
        if(S[A] == '-'){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }else{
        cout << "No" << endl;
    }


    return 0;
}
 

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

class Node {
private:
	int id;
	Node *parent;
	Node *child_l;
	Node *child_r;
public:
	Node(int id){ this->id = id; parent = NULL; child_l = NULL; child_r = NULL;}
	void setChildl(Node *nl);
	void setChildr(Node *nr);
	void setParent(Node *np){ parent = np; }
	int getId(){ return id; }
	Node *getParent(){ return parent; }
	Node *getChildl(){ return child_l; }
	Node *getChildr(){ return child_r; }
};

void Node::setChildl(Node *nl)
{
	child_l = nl;
	if (child_l != NULL) child_l->setParent(this);
}

void Node::setChildr(Node *nr)
{
	child_r = nr;
	if (child_r != NULL) child_r->setParent(this);
}

class BinaryTree {
private:
	Node *root;
	void walkPreorder(Node *node);
	void walkInorder(Node *node);
public:
	BinaryTree(){ root = NULL; }
	void insert(int id);
	void find(int id);
	void walkPreorder();
	void walkInorder();
};

void BinaryTree::insert(int id)
{
	if (root == NULL) {
		root = new Node(id);
		return;
	}

	Node *node = root;
	while (1) {
		if (id < node->getId()) {
			if (node->getChildl() == NULL) {
				node->setChildl(new Node(id));
				break;
			}
			else {
				node = node->getChildl();
			}
		}
		else if (id > node->getId()) {
			if (node->getChildr() == NULL) {
				node->setChildr(new Node(id));
				break;
			}
			else {
				node = node->getChildr();
			}
		}
	}
}

void BinaryTree::find(int id)
{
	Node *node = root;
	while (node != NULL) {
		if (id == node->getId()) {
			cout << "yes" << endl;
			return;
		}
		else if (id < node->getId()) {
			node = node->getChildl();
		}
		else {
			node = node->getChildr();
		}
	}
	cout << "no" <<endl;
}

void BinaryTree::walkPreorder()
{
	walkPreorder(root);
	cout << endl;
}

void BinaryTree::walkPreorder(Node *node)
{
	if (node == NULL) return;
	cout << " " << node->getId();
	walkPreorder(node->getChildl());
	walkPreorder(node->getChildr());
}

void BinaryTree::walkInorder()
{
	walkInorder(root);
	cout << endl;
}

void BinaryTree::walkInorder(Node *node)
{
	if (node == NULL) return;
	walkInorder(node->getChildl());
	cout << " " << node->getId();
	walkInorder(node->getChildr());
}

int main(void)
{
	BinaryTree bt;

	int m;
	cin >> m;
	for (int i = 0; i < m; i++) {
		char command[7] = "\0";
		cin >> command;
		if (command[0] == 'i') {			
			int id;
			cin >> id;
			bt.insert(id);
		}
		else if (command[0] == 'f') {
			int id;
			cin >> id;
			bt.find(id);
		}
		else {
			bt.walkInorder();
			bt.walkPreorder();
		}
	}
		
	return 0;
}

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

int A,B;
bool tmp[4];

int main(){
	memset(tmp,false,sizeof(tmp));
	scanf("%d%d",&A,&B);
  	tmp[A]=tmp[B]=true;
	if(!tmp[1]) puts("1");
	if(!tmp[2]) puts("2");
	if(!tmp[3]) puts("3");
	return 0;
}

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

int X[100002];

int main()
{
	int N; cin >> N;
	for (int i = 0; i < N; i++) {
		int a; cin >> a; a++;
		X[a]++;
		X[a + 1]++;
		X[a - 1]++;
	}

	int cnt = 0;
	for (int i = 0; i < 100002; i++) {
		cnt = max(cnt, X[i]);
	}

	cout << cnt << endl;

    return 0;
}



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

signed main() {
#ifdef LOCAL
  assert(freopen("b.in", "r", stdin));
#endif
  int n;
  cin >> n;
  if (n == 3) {
    cout << "2 5 63\n";
    return 0;
  }
  set<int> s{2, 3, 4, 9};
  const int C = 30000;
  vector<int> s2, s3, s6;
  for (int i = 1; i <= C; ++i) {
    if (s.count(i)) {
      continue;
    }
    if (i % 6 == 0) {
      s6.push_back(i);
    } else if (i % 2 == 0) {
      s2.push_back(i);
    } else if (i % 3 == 0) {
      s3.push_back(i);
    } else {
    }
  }
  while (!s2.empty()) {
    ll sum = s2.back();
    int i = s2.size() - 1;
    while (i > 0 && sum % 6 != 0) {
      sum += s2[--i];
    }
    assert(sum % 6 == 0);
    if ((int) s.size() + (int) s2.size() - i > n) {
      break;
    }
    for (int j = i; j < (int) s2.size(); ++j) {
      s.insert(s2[j]);
    }
    s2.resize(i);
  }
  while (s3.size() >= 2 && (int) s.size() + 2 <= n) {
    for (int iter = 0; iter < 2; ++iter) {
      s.insert(s3.back());
      s3.pop_back();
    }
  }
  while (!s6.empty() && (int) s.size() < n) {
    s.insert(s6.back());
    s6.pop_back();
  }
  ll sum = 0;
  for (int x : s) {
    sum += x;
  }
  assert(sum % 6 == 0);
  assert((int) s.size() == n);
  for (int x : s) {
    cout << x << ' ';
  }
  cout << '\n';
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define lsh(i) (1 << (i))
#define lshll(i) (1LL << (i))
#define rep(i, n) for (int (i) = 0; (i) < n; (i)++)
#define until(x) while (!x)
#define fail(s) assert(!s)
#define ULL unsigned long long
const int INF = 0x3f3f3f3f;
const int EPS = 1e-6;
int n, W;
const int MAXN = 100000;
LL dp[MAXN + 10];
int w[110], v[110];
int main()
{
	cin >> n >> W;
	memset(dp, 0, sizeof(dp));
	for (int i = 1; i <= n; i++)cin >> w[i] >> v[i];
	dp[0] = 0;
	for (int i = 1; i <= n; i++) 
		for (int j = W; j >= w[i]; j--)
			dp[j] = max(dp[j], dp[j - w[i]] + v[i]); 
	cout << dp[W] << endl;
	return 0;
}


Measured memory_bytes: 1152
#include <stdio.h>

int main() {
  int number_n, number_m, i, j = 0;
  scanf("%d %d", &number_n, &number_m);
  long long int stage[number_n+1];
  int broken_stage[number_m];
  for(i = 0; i < number_m; i++) scanf("%d", &broken_stage[i]);
  stage[0] = 1;
  stage[1] = (broken_stage[0] == 1)? 0 : 1;
  for(i = 2; i <= number_n; i++) {
    stage[i] = stage[i-1] + stage[i-2];
    for(; j < number_m; j++) {
      if(broken_stage[j] == i) {
        stage[i] = 0;
        break;
      } else if(broken_stage[j] > i) {
        break;
      }
    }
    if(stage[i] > 1000000007) stage[i] -= 1000000007;
  }
  printf("%lld\n", stage[number_n]);
  return 0;
}


Measured memory_bytes: 1280
# coding:utf-8

INF = float('inf')


def inpl(): return list(map(int, input().split()))


N, M, X, Y = inpl()
x = inpl()
y = inpl()
x.append(X)
y.append(Y)

x.sort()
y.sort()


if y[0] - x[-1] >= 1:
    print('No War')
else:
    print('War')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
    
int main(){
    int n;
    cin >> n;
    std::set<unsigned long int> s;
    for(int i=0; i<n; i++) {
        unsigned long int a;
        cin >> a;
        if( s.find(a) != s.end() )
        {
            // 紙に数字が存在するとき
            s.erase(a);
        } else {
            s.insert(a);
        }
    }
    std::cout << s.size() << std::endl;
    return 0;
}

Measured memory_bytes: 4864
#include<bits/stdc++.h>
#define llong long long
#define mkpr make_pair
#define riterator reverse_iterator
using namespace std;

inline int read()
{
	int x = 0,f = 1; char ch = getchar();
	for(;!isdigit(ch);ch=getchar()) {if(ch=='-') f = -1;}
	for(; isdigit(ch);ch=getchar()) {x = x*10+ch-48;}
	return x*f;
}

const int N = 185;
int fx[N+3][N+3],fy[N+3][N+3];
int gx[N+3][N+3][N+3],gy[N+3][N+3][N+3];
int hx[N+3][N+3][N+3],hy[N+3][N+3][N+3];
char a[N+3][N+3];
int n,m;

void updmax(int &x,int y) {x = max(x,y);}

void dp()
{
	for(int lx=1; lx<=n; lx++) for(int ly=1; ly<=m; ly++) for(int rx=lx; rx<=n; rx++)
	{
		gx[lx][ly][rx] += gx[lx][ly+gx[lx][ly][rx]][rx];
		if(gx[lx][ly][rx]>0) {updmax(hy[lx][ly][ly+gx[lx][ly][rx]-1],rx-lx+1);}
	}
	for(int lx=1; lx<=n; lx++) for(int ly=1; ly<=m; ly++) for(int ry=ly; ry<=m; ry++)
	{
		gy[lx][ly][ry] += gy[lx+gy[lx][ly][ry]][ly][ry];
		if(gy[lx][ly][ry]>0) {updmax(hx[lx][ly][lx+gy[lx][ly][ry]-1],ry-ly+1);}
	}
	for(int lx=1; lx<=n; lx++) for(int ly=1; ly<=m; ly++) for(int rx=n; rx>=lx; rx--)
	{
		if(rx<n) updmax(hx[lx][ly][rx],hx[lx][ly][rx+1]);
		updmax(gx[lx][ly][rx],hx[lx][ly][rx]);
	}
	for(int lx=1; lx<=n; lx++) for(int ly=1; ly<=m; ly++) for(int ry=m; ry>=ly; ry--)
	{
		if(ry<m) updmax(hy[lx][ly][ry],hy[lx][ly][ry+1]);
		updmax(gy[lx][ly][ry],hy[lx][ly][ry]);
	}
}

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1; i<=n; i++) scanf("%s",a[i]+1);
	for(int i=1; i<=n; i++) for(int j=m; j>=1; j--)
	{
		fx[i][j] = a[i][j]==a[i][j+1]?fx[i][j+1]+1:1;
	}
	for(int j=1; j<=m; j++) for(int i=n; i>=1; i--)
	{
		fy[i][j] = a[i][j]==a[i+1][j]?fy[i+1][j]+1:1;
	}
	for(int lx=n; lx>=1; lx--) for(int ly=1; ly<=m; ly++)
	{
		int z = gx[lx][ly][lx] = fx[lx][ly];
		if(a[lx][ly]==a[lx+1][ly])
		{
			for(int rx=lx+1; rx<=n; rx++)
			{
				gx[lx][ly][rx] = min(z,gx[lx+1][ly][rx]);
			}
		}
	}
	for(int ly=m; ly>=1; ly--) for(int lx=1; lx<=n; lx++)
	{
		int z = gy[lx][ly][ly] = fy[lx][ly];
		if(a[lx][ly]==a[lx][ly+1])
		{
			for(int ry=ly+1; ry<=m; ry++)
			{
				gy[lx][ly][ry] = min(z,gy[lx][ly+1][ry]);
			}
		}
	}
	int ans = 0;
	while(gx[1][1][n]<m)
	{
		ans++;
		dp();
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 104064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  int n,q; string s; 
  cin >> n;
  cin >> s;
  cin >> q; 
  vector<set<int>> sets(26);
  rep(i, n) {
    sets[s[i]- 'a'].insert(i);
  }
  rep(_,q) {
    int a; cin >> a;
    if (a==1) {
      int i; char c; cin >> i >> c; --i;
      sets[s[i] - 'a'].erase(i);
      s[i] = c;
      sets[s[i]-'a'].insert(i);
    }
    else {
      int l, r; cin >> l >> r;
      --l; --r;
      int num = 0;
      rep(i,26) {
        auto it = sets[i].lower_bound(l);
        if (it != sets[i].end() && *it <= r) ++num;
      }
      cout << num << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 24196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=924844033,MAX=2003,INF=1<<30;
ll dp[MAX][MAX][2];
ll bik[MAX];

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N,K;cin>>N>>K;
    dp[0][0][0]=1;
    int pre=0;
    
    for(int mo=1;mo<=min(N,2*K);mo++){
        for(int i=0;i<N;i++){
            dp[i][mo][0]+=dp[i][pre][0]+dp[i][pre][1];
            if(mo-K>=1) dp[i+1][mo][0]+=dp[i][pre][0]+dp[i][pre][1];
            if(mo+K<=N) dp[i+1][mo][1]+=dp[i][pre][0]+dp[i][pre][1];
            
            dp[i][mo][0]%=mod;
            dp[i+1][mo][0]%=mod;
            dp[i+1][mo][1]%=mod;
        }
        pre=mo;
        
        for(int j=1;mo+j*2*K<=N;j++){
            for(int i=0;i<N;i++){
                dp[i][mo+j*2*K][0]+=dp[i][mo+(j-1)*2*K][0]+dp[i][mo+(j-1)*2*K][1];
                if(mo+j*2*K-K>=1) dp[i+1][mo+j*2*K][0]+=dp[i][mo+(j-1)*2*K][0];
                if(mo+j*2*K+K<=N) dp[i+1][mo+j*2*K][1]+=dp[i][mo+(j-1)*2*K][0]+dp[i][mo+(j-1)*2*K][1];
                
                dp[i][mo+j*2*K][0]%=mod;
                dp[i+1][mo+j*2*K][0]%=mod;
                dp[i+1][mo+j*2*K][1]%=mod;
            }
            
            pre=mo+j*2*K;
        }
    }
    
    bik[0]=1;
    for(ll i=1;i<=N;i++){
        bik[i]=bik[i-1]*i%mod;
    }
    
    ll ans=0;
    
    for(int i=N;i>=0;i--){
        if(i%2==1) ans+=mod-(dp[i][pre][0]+dp[i][pre][1])%mod*bik[N-i]%mod;
        else ans+=(dp[i][pre][0]+dp[i][pre][1])%mod*bik[N-i]%mod;
        
        ans%=mod;
        
        //cout<<ans<<endl;
    }
    
    cout<<ans<<endl;
    
    //if(N<=K+K) return 1;
    
}




Measured memory_bytes: 62848
h, w, k = map(int, input().split())
s = []
for i in range(h):
    s.append(list(input()))
strawberry = []
for i in range(h):
    strawberry.append(s[i].count("#"))
m = 1
fuck = []
ans = []
for i in range(h):
    ans.append([0 for j in range(w)])
for i in range(h):
    if strawberry[i] != 0:
        cnt = 0
        flag = 0
        j = 0
        while True:
            while s[i][j] == ".":
                ans[i][j] = m
                j += 1
                if j == w:
                    flag = 1
                    break
            if flag == 0:
                cnt += 1
                ans[i][j] = m
                if cnt == strawberry[i] and j < w-1:
                    j += 1
                elif j < w-1:
                    j += 1
                    m += 1
                else:
                    flag = 1
            if flag:
                m += 1
                break
        fuck.append(1)
    else:
        fuck.append(0)
i = 0
while i < h:
    shusei = []
    while fuck[i] == 0:
        shusei.append(i)
        i += 1
        if i == h:
            break
    if not(h-1 in shusei):
        for p in shusei:
            for q in range(w):
                ans[p][q] = ans[i][q]
    else:
        i_up = min(shusei) - 1
        for p in shusei:
            for q in range(w):
                ans[p][q] = ans[i_up][q]
    i += 1



for i in range(h):
    for j in range(w):
        if j != w-1:
            print(ans[i][j], end=" ")
        else:
            print(ans[i][j])


Measured memory_bytes: 54488
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/tag_and_trait.hpp>
#include <ext/pb_ds/trie_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) begin(x),end(x)
#define Fixed fixed << setprecision(12)
#define int int_fast64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7;
constexpr int mod2 = 998244353;

template <class Func>
class FixPoint : Func {
public:
    explicit constexpr FixPoint(Func&& f) noexcept : Func(forward<Func>(f)) {}

    template <class... Args>
    constexpr decltype(auto) operator()(Args&&... args) const {
        return Func::operator()(*this, std::forward<Args>(args)...);
    }
};

template <class Func>
static inline constexpr decltype(auto) makeFixPoint(Func&& f) noexcept {
    return FixPoint<Func>{forward<Func>(f)};
}

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
template <class T> using Set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class K, class V> using Umap = gp_hash_table<K, V>;
using Trie = trie<string, null_type, trie_string_access_traits<>, pat_trie_tag, trie_prefix_search_node_update>;

inline int square(int a){ return a * a;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }

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


signed main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout.setf(ios_base::fixed);
    cout.precision(10);

    int n;
    string s;
    
    cin >> n >> s;

    s = " "s + s;

    vector<int> r(n+1), g(n+1), b(n+1);

    reps(i,n){
        r[i] = r[i-1] + (s[i] == 'R');
        g[i] = g[i-1] + (s[i] == 'G');
        b[i] = b[i-1] + (s[i] == 'B');
    }

    int res = 0;

    for(int i = 1; i <= n; ++i){
        for(int j = i + 1; j <= n; ++j){
            if(s[i] == s[j]) continue;
            if(s[i] != 'R' && s[j] != 'R'){
                res += r[n] - r[j];
                if(j + j - i <= n && s[j + j - i] == 'R') --res;
            }else if(s[i] != 'G' && s[j] != 'G'){
                res += g[n] - g[j];
                if(j + j - i <= n && s[j + j - i] == 'G') --res;
            }else if(s[i] != 'B' && s[j] != 'B'){
                res += b[n] - b[j];
                if(j + j - i <= n && s[j + j - i] == 'B') --res;
            } 
        }
    }

    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 3708
# include <iostream>
# include <cmath>
# include <vector>
# include <algorithm>
# include <string>
# include <set>
# include <map>
# include <bitset>
# include <queue>
# include <iomanip>
# include <string>

# define FILE
# define x first
# define y second
using namespace std;



int main()
{
    # ifdef FILEs
        freopen( "travel.in", "r", stdin );
        freopen( "travel.out", "w", stdout );
    # endif // FILE

    # ifdef FILEs
        freopen( "input.txt", "r", stdin );
        freopen( "output.txt", "w", stdout );
    # endif // FILE
    ios_base::sync_with_stdio( false );
    int n, d[100];
    long long sum = 0;
    cin >> n;
    for( int i = 1 ; i<= n; i++ ){
        cin >> d[i];
    }
    for( int i = 1; i <= n; i ++ ){
        for( int j = i+1; j <= n; j ++ ){
            sum += d[i] * d[j];
        }
    }
    cout << sum;






    # ifdef FILEs
        cout << endl << "------------------------";
        cout << endl << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s. |";
        cout << endl << "------------------------";
    # endif
    return 0;
}




Measured memory_bytes: 256
fn get_input() -> String {
    let mut word = String::new();
    std::io::stdin().read_line(&mut word).unwrap();
    word.trim().to_owned()
}

fn main() {
    let (l, r) = {
        let line = get_input();
        let mut split = line.split_whitespace();
        let l: i64 = split.next().unwrap().parse().unwrap();
        let r: i64 = split.next().unwrap().parse().unwrap();
        (l, r)
    };

    let mut ans = 2019;
    if r - l > ans {
        ans = 0;
    } else {
        for i in l..r {
            for j in i+1..r+1 {
                ans = std::cmp::min(ans, i * j % 2019);
                if j - i == 0 || ans == 0 {
                    break;
                }
            }
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
typedef long long ll;
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

vector<vector<int> > G(300030);
vector<int> dist(300030,-1),visited(300030,0);
int main(){
    ll N,M,S,T; cin >> N >> M;
    for (int i = 0; i < M; i++){
        int u,v; cin >> u >> v;
        u--; v--;
        G[3*u].push_back(3*v+1);
        G[3*u+1].push_back(3*v+2);
        G[3*u+2].push_back(3*v);
    }
    cin >> S >> T;
    S--; T--;
    queue<ll> que;
    que.push(3*S); dist[3*S] = 0; visited[3*S] = true;
    while (que.size()){
        int u = que.front();
        que.pop();
        for (auto s : G[u]){
            if (!visited[s]){
                dist[s] = dist[u]+1;
                visited[s] = true;
                que.push(s);
            }
        }
    }
    if (dist[3*T] == -1) cout << -1 << endl;
    else cout << dist[3*T]/3 << endl;
}


Measured memory_bytes: 18944
n,k = map(int,input().split())
l = list(map(int,input().split()))

# xは求める長さ
def C(x):
    num = 0
    for i in range(n):
        # (a[i]-1)//x 回切る必要がある
        num += (l[i]-1)//x
    # k回以内に収まるか
    return num <= k

lb,ub = 0,max(l)
for i in range(100):
    mid = (lb + ub) / 2
    # 条件を満たすならxを小さくしていく
    if C(mid):
        ub = mid
    else:
        lb = mid
    # print(lb,ub)

import math
ans = math.ceil(ub)
print(ans)

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

#define ll long long
#define mod 1000000007

int main()
{
  int n;
  cin>>n;
  if(n>=30){
  	cout<<"Yes"<<endl;
  }else{
  	cout<<"No"<<endl;
  }

return 0;
}



Measured memory_bytes: 3648
unittest
{
	assert( [ "3 2" ].parse.expand.solve == 9 );
	assert( [ "5 3" ].parse.expand.solve == 1 );
	assert( [ "31415 9265" ].parse.expand.solve == 27 );
	assert( [ "35897 932" ].parse.expand.solve == 114191 );
}



import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nk = input.front.split.to!( long[] );
	return tuple( nk[ 0 ], nk[ 1 ] );
}

auto solve( long n, long k )
{
	if( k % 2 == 1 )
	{
		auto p = n / k;						// kの倍数の数
		return p * p * p;
	}
	else
	{
		auto pa = n / k;					// kの倍数の数
		auto pb = n / ( k / 2 ) - pa;		// 上以外のk/2の倍数の数（kの倍数とは組み合わせられないので別計算にする）
		return pa * pa * pa + pb * pb * pb;
	}
}


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

#define show(x) cerr << #x << " = " << x << endl

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "sz:" << v.size() << "\n[";
    for (const auto& p : v) {
        os << p << ",";
    }
    os << "]\n";
    return os;
}

template <typename S, typename T>
ostream& operator<<(ostream& os, const pair<S, T>& p)
{
    os << "(" << p.first << "," << p.second
       << ")";
    return os;
}


constexpr ll MOD = (ll)1e9 + 7LL;

template <typename T>
constexpr T INF = numeric_limits<T>::max() / 100;

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

    string s;
    cin >> s;
    for (int i = 0; i < s.size() - 1; i++) {
        if (s[i] == 'A' and s[i + 1] == 'C') {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define input freopen("input.txt", "r", stdin);
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);



#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n, cnt=0;
    cin>>n;
    int a[n];
    for(int i=0; i<n; i++) cin>>a[i];
    sort(a, a+n);
    for(int i=0; i<n-2; i++){
        for(int j=i+1; j<n-1; j++){
            for(int k=j+1; k<n; k++){
                if(a[i]!=a[j] && a[j]!=a[k]){
                    if(a[i]+a[j]>a[k]) cnt++;
                }
            }
        }
    }
    cout<<cnt;
}


Measured memory_bytes: 3640
/*
ID: Aman Raj
LANG: C++
TASK: prefix
*/
//#include<iostream>
#include <stdio.h>
//#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#include<math.h>
typedef  long long int ll;
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
using namespace __gnu_pbds;

#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
//#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
//#define mod 7
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
//#define flush fflush(stdout)
#define primeDEN 727999983
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#include <fstream>
// find_by_order()  // order_of_key
typedef tree<
	int,
	null_type,
	less<int>,
	rb_tree_tag,
	tree_order_statistics_node_update>
	ordered_set;

	 ll n;vector<pair<ll,ll> > v;
   bool comp(pair<ll,ll> p1, pair<ll,ll> p2)
   {
    if(p1.first!=p2.first)return p1.first < p2.first;
     else return p1.second < p2.second;
   }
   ll aman(ll i)
   {  while(v[i+1].first==v[i].first){i++;if(i==n-1)return n-1;}
      return i;

   }
   vector<ll> dpfact;
   ll fact(ll a)
   { return dpfact[a];

   }
   ll mo=26;
   ll power1(ll a, ll b)//a raised to power b
   {  if(b<=0) return 1; if(b==1) return a;
       ll c=power1(a,b/2);
        c*=c;c%=mo;if(b%2==1) c*=a;c%=mo;
        return c;
   }
   ll mi(ll a,ll m)
   { ll c= power1(a,m-2);

     return c;
   }
   int main()
{    ofstream fout("tcase.txt");
     ll m,d;cin>>m>>d;
     ll ans=0;
      for(ll i=2;i<10;i++)
      {
          for(ll j=2;j<=9;j++)
          {
              ll a=10*i+j;
               ll b=i*j;
               if(a<=d&&b<=m)ans++;
          }
      }
      cout<<ans;

    return 0;
 }


Measured memory_bytes: 256
//
//  main.swift
//  AtCoderSwift
//
//  Created by burita083 on 2020/08/25.
//  Copyright © 2020 burita083. All rights reserved.
//

import Foundation
func readInt() -> Int {
    return Int(readLine()!)!
}
 
func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}
 
func readTwoInts() -> (a: Int, b: Int) {
    let ints = readLine()!.split(separator: " ").map { Int($0)! }
    return (a: ints[0], b: ints[1])
}


func abc080_b() {
    let N = readLine()!
    let sum = N.map { Int(String($0))! }.reduce(0, +)
    print(Int(N)! % sum == 0 ? "Yes" : "No")
}

abc080_b()


Measured memory_bytes: 12984
#include<stdio.h>

int main() {
	int f = 0, w, work, ans=0, mini=10;
	int p[5];

	for (int i = 0;i < 5;i++) {
		scanf("%d",&work);
		
		w = work % 10;
		
		if (w == 0) {
			ans += work;
		}
		else {
			ans += work + (10-w);
		}


		if (w < mini && w >= 1) {
			mini = w;
		}
	}

	ans = ans - (10 - mini);

	printf("%d",ans);

	return 0;
}

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

int a[1010];
int b[1010];

int main(){
	int n;
	scanf("%d", &n);
	for(int i = 0; i < n; i++)
		scanf("%d", &a[i]);
	int q;
	scanf("%d", &q);
	for(int i = 0; i < q; i++)
		scanf("%d", &b[i]);
	for(int i = 0; i < min(n, q); i++) {
		if(a[i] == b[i]) continue;
		else if(a[i] < b[i]) {
			printf("%d\n", 1);
			return 0;
		}else{
			printf("%d\n", 0);
			return 0;
		}
	}
	if(max(n, q) == n)
		printf("%d\n", 0);
	else
		printf("%d\n", 1);
}



Measured memory_bytes: 3216
#include<bits/stdc++.h>
using namespace std;
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    int x, y;
    cin>>x>>y;
    if((4*x-y)>=0 && !(y&1) && !((4*x-y)&1) && y>=2*x) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}

Measured memory_bytes: 3648
import itertools

n = int(input())
a = []
xy = [0] * n
for i in range(n):
    tmp = int(input())
    a.append(tmp)
    xy[i] = [list(map(int, input().split())) for j in range(tmp)]

comb = itertools.product([0, 1], repeat=n)
ans = 0
for c in comb:
    list_c = list(c)
    flag = True
    for i in range(len(xy)):
        if list_c[i] == 1:
            for j in range(len(xy[i])):
                if xy[i][j][1] == 1:
                    if list_c[xy[i][j][0]-1] != 1:
                        flag = False
                        break
                else:
                    if list_c[xy[i][j][0]-1] != 0:
                        flag = False
                        break
    if flag:
        ans = max(ans, list_c.count(1))
print(ans)


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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)        //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++)   //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)      //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define RANGE(i,v) for(auto &(i):v)                  //repeat range
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size

using LL = long long;

template<typename T> using V = vector< T >;
using Vi = V<int>;
using Vll = V<LL>;
using Vs = V<string>;

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

    Vi v(n),c(n);
    REP(i,n) cin>>v[i];
    REP(i,n) cin>>c[i];

    int ans = 0;
    REP(i,n){
        if(v[i]-c[i]>0) ans += v[i]-c[i];
    }

    cout<<ans<<endl;

    return 0;
}

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

#define ll long long
#define ull unsigned long long

#define pii pair < int, int >
#define pll pair < ll, ll >
#define pci pair < char, int >
#define psi pair < string, int >

#define vi vector < int >
#define vll vector < ll >
#define vs vector < string >
#define vc vector < char >
#define vpi vector < pii >
#define vpll vector < pll >

#define pb push_back

#define pi acos(-1)

#define fast ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

using namespace std;

const int maxn = 1e4 + 5;
const int mod = 1e9 + 7;

int main()
{
    fast;

    int x;

    cin >> x;

    if(x >= 400 && x <= 599) cout << 8 << endl;
    else if(x >= 600 && x <= 799) cout << 7 << endl;
    else if(x >= 800 && x <= 999) cout << 6 << endl;
    else if(x >= 1000 && x <= 1199) cout << 5 << endl;
    else if(x >= 1200 && x <= 1399) cout << 4 << endl;
    else if(x >= 1400 && x <= 1599) cout << 3 << endl;
    else if(x >= 1600 && x <= 1799) cout << 2 << endl;
    else cout << 1 << endl;

    return 0;
}




Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
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; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main() {
  int n,a;
  cin >> n >> a;
  cout << n*n-a << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int tam = 1e6;
vector< list< int > > G(tam);
long long v[tam];
bool used[tam];

void DFS(int idx, long long sum = 0) {
    used[idx] = true;
    v[idx] += sum;
    for( int i: G[idx] ) {
        if( !used[i] ) {
            DFS(i, v[idx]);
        }
    }
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    memset( v, 0, sizeof v );
    memset( used, 0, sizeof used );
    int n, q, a, b;
    cin >> n >> q;
    for( int i = 0; i < n-1; i++ ) {
        cin >> a >> b; a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    while( q-- ) {
        cin >> a >> b; a--;
        v[a] += b;
    }
    //cout << "Hello\n";
    DFS(0);
    for( int i = 0; i < n; i++ ) {
        cout << v[i] << ((n == i+1)? '\n' : ' ');
    }
    return 0;
}

Measured memory_bytes: 45568
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
void Main(){
    ll n;cin>>n;
    vector<int> alphabet(26,0);
    vector<string> s(n);
    For(i,0,n) cin >> s[i];
    For(j,0,s[0].size()) alphabet[s[0][j]-'a'] ++;
    For(i,0,n){
        vector<int> alphabeti(26,0);
        For(j,0,s[i].size()) alphabeti[s[i][j]-'a'] ++;
        For(j,0,26) alphabet[j] = min(alphabet[j],alphabeti[j]);
    }
    string t="";
    For(i,0,26){
        For(j,0,alphabet[i]) t.push_back(i+'a');
    }
    cout << t << endl;
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

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

#define ll long long
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define x first
#define y second
const ll INF=1e18;
const ll INF2=1e19;

ll a[100001];
ll res=1;

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

	int n;
	cin>>n;
	for (int i=0; i<n; i++)
		cin>>a[i];
	sort(a,a+n);
	if (a[0]==0){
		cout<<0<<endl;
		return 0;
	}
	for (int i=0; i<n; i++){
		double num=INF/res;
		//ll t=ceil(num);
		if (a[i]>num){
			cout<<-1<<endl;
			return 0;
		}
		res*=a[i];
	}
	if (res>INF)
		cout<<-1<<endl;
	else cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 4392
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var a, b string
	fmt.Scan(&a, &b)
	s, _ := strconv.Atoi(a + b)
	ok := false
	for i := 1; i <= 1000; i++ {
		if i*i == s {
			ok = true
			break
		}
	}
	if ok {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

bool check(int n){
	bool flag = true;
	for(int i = 2;i * i <= n;i++){
		if(n % i == 0){
			flag = false;
			break;
		}
		if((n+1) / 2 % i == 0){
			flag = false;
			break;
		}
	}
	return flag;
}

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

	vector<int> sum(100001,0);
	sum[1] = 0;
	for(int i = 3;i <= 99999;i++){
		if(check(i))sum[i] = 1;
	}

	for(int i = 2;i <= 100000;i++)sum[i] = sum[i] + sum[i-1];

	vector<int> ans(q);

	for(int i = 0;i < q;i++){
		int l,r;
		cin >> l >> r;
		ans[i] = sum[r] - sum[l-1];
	}

	for(int a:ans)cout << a << endl;
}


Measured memory_bytes: 1408
#include<iostream>
#include<stdlib.h>
using namespace std;
int main(){
	int a,b,c,d,e,k;
	cin >> a >> b >> c;
	if(a+b>=c){
		k=b+c;
	}
	else{//a+b<c
		k=a+b+b;
		if(c+b>k)
            k++;
	}
	cout << k << endl;
}


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

vector<int> hurui(int n){
  vector<int> d(n+1,-1);
  d[1]=1;
  int curr_d;
  for(int i=2;i<=n;i++){
    if(d[i]==-1){
      curr_d=i;
      for(int j=1;j<n/curr_d+1;j++){
        if(d[curr_d*j]==-1){
          d[curr_d*j]=curr_d;
        }
      }
    }
  }
  return d;
}


bool gozyohou1(vector<int> a){
  sort(a.begin(),a.end());
  vector<int> d=hurui(a.at((int)a.size()-1));
  set<int> primes;
  int p;
  int dp;
  for(int i=0;i<(int)a.size();i++){
    p=a.at(i);
    while(d[p]!=p){
      if(primes.count(d[p])){
        return false;
      }
      primes.insert(d[p]);
      dp=d[p];
      while(p%dp==0){
        p/=dp;
      }
    }
    if(primes.count(d[p])){
      return false;
    }
    if(p!=1){
      primes.insert(d[p]);
    }
  }
  return true;
}
bool gozyohou2(vector<int> a){
  sort(a.begin(),a.end());
  while(a.at(0)>1){
    for(int i=1;i<(int)a.size();i++){
      a.at(i)%=a.at(0);
    }
    a.erase(remove_if(a.begin(),a.end(),[](int x){return x==0;}),a.end());
    if((int)a.size()==1){
      return false;
    }
    sort(a.begin(),a.end());
  }
  return true;
}

int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a.at(i);
  }
  if(gozyohou1(a)){
    cout<<"pairwise coprime"<<endl;
    return 0;
  }
  if(gozyohou2(a)){
    cout<<"setwise coprime"<<endl;
    return 0;
  }
  cout<<"not coprime"<<endl;
}
  
  

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

int main(void) {
  ll N;
  cin >> N;
  vector<vector<ll>> C(N, vector<ll>(N));
  REP(i, 0, N) REP(j, 0, N) cin >> C[i][j];

  ll ans = 0;
  REP(i, 0, N) REP(j, i + 1, N) ans += min(C[i][j], C[j][i]);
  cout << ans << endl;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)
const ll MAX_N = 100005; 

vector<pll> infos[MAX_N];
vector<ll> place(MAX_N);
vector<bool> visited(MAX_N);

bool dfs(int now){
	visited[now] = true;
	REP(i, infos[now].size()){
		int next = infos[now][i].first;
		if (visited[next]){
			if(place[next] != place[now] + infos[now][i].second){
				return false;
			}
		}else{
			place[next] = place[now] + infos[now][i].second;
			if (!dfs(next)) return false;
		}
	}
	return true;
}

int main(){
	ll N, M;
	cin >> N >> M;
	REP(i, M){
		ll l, r, d;
		cin >> l >> r >> d;
		l--;r--;
		infos[l].push_back(make_pair(r, d));
		infos[r].push_back(make_pair(l, -d));
	}
	REP(i, N) place[i] = -1;
	REP(i, N) visited[i] = false;

	bool flag = true;
	REP(i, N){
		if(visited[i]==true) continue;
		visited[i] = 0;
		if(!dfs(i)) flag = false;
	}
	cout << (flag ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 16512
#include <iostream>//cout<<right で右揃え
#include <iomanip>//cout<<setw(数字) で空白による桁揃え
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <cstdlib>//abs()で整数絶対値
#include <cmath>//abs()かfabs()で少数絶対値

using namespace std;
using ll = long long int;

int main(void){
    int X,Y,Z;
    cin>>X>>Y>>Z;
    cout << Z << " " << X << " " << Y << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
long long a[100100],b[100100]={0},c[100100]={0},d[100010]={0};
using namespace std;
int main()
{
    long long  n,m=0,k=0,i,x=1E10,sum=0,y,j;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sum=a[0];
    for(i=0;i<n;i++)
    {
        sum=__gcd(sum,a[i]);
        b[i]=sum;
    }
    sum=a[n-1];
    for(i=n-1;i>=0;i--)
    {
        sum=__gcd(sum,a[i]);
        c[i]=sum;
    }
    if(n==2)
        cout<<max(a[0],a[1])<<endl;
    if(n>2)
    {
        d[0]=c[1];
        d[n-1]=b[n-2];
        for(i=1;i<n-1;i++)
        {
            d[i]=__gcd(b[i-1],c[i+1]);
        }
        sort(d,d+n);
       cout<<d[n-1]<<endl;

    }

    return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
#include<iostream>
#include<stdio.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fr(i,j,n)   for(long long i=j;i<(n);++i)
#define bk(i,j,n)   for(long long i=j;i>=n;--i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define endl "\n"
#define MOD 1000000007
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define srt(x) sort(x.begin(),x.end());
#define run ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ordered_set tree<ll , null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>

typedef long long ll;
ll modpower(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b>>=1;
	}
	return res;
}

ll n,m,x;
ll a[15][15],c[15];
ll ans=INT_MAX;
void fun(ll ind,ll pai,ll cur[])
{

    if(ind>=n)
        return ;

    ll f=0;
    ll b[15];
    fr(i,0,15)
    {
        b[i]=cur[i];
    }
    fun(ind+1,pai,b);
    fr(i,0,m)
    {
        cur[i]+=a[ind][i];
        if(cur[i]<x)
            f=1;
    }
    if(f)
    {
        fun(ind+1,pai+c[ind],cur);
    }
    else
    {
        ans=min(ans,pai+c[ind]);

    }




}

int main()
{
    run;

    cin>>n>>m>>x;
   // ll a[n][m],c[n];
    //memset(dp,-1ll,sizeof dp);

    fr(i,0,n)
    {
        cin>>c[i];
        fr(j,0,m)
        {
            cin>>a[i][j];
        }
    }
    ll b[15]={0};
    fun(0,0,b);
    if(ans==INT_MAX)
    {
        ans=-1;
    }
    cout<<ans<<endl;






}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <numeric>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;

void ReplaceString(string& io_source, const string& i_from, const string& i_to) {
    string::size_type pos(io_source.find(i_from));

    while(pos != string::npos) {
        io_source.replace(pos, i_from.length(), i_to);
        pos = io_source.find(i_from, pos + i_to.length());
    }
}

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

    string s; cin >> s;
    ll nD = 0, res = 0;

    ReplaceString(s, "BC", "D");
    
    rrep(i, s.size()-1, 0) {
        if (s[i] == 'D') ++nD;
        else if (s[i] == 'A') res += nD;
        else nD = 0;
    }

    cout << res << endl;
}

Measured memory_bytes: 720
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<iostream>
using namespace std;
#define ll long long
#define N 200005
int n;
ll k;
ll a[N],f[N],b[N];
bool check(ll x)
{
	ll js=0;
	for(int i=1;i<=n;i++)
		b[i]=x/f[i];
	for(int i=1;i<=n;i++)
		if(a[i]-b[i]>0)js+=a[i]-b[i];
	return js<=k;
}
bool cmp(ll x,ll y)
{
	return x>y;
}
int main()
{
	scanf("%d%lld",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
		scanf("%d",&f[i]);
	sort(a+1,a+n+1);
	sort(f+1,f+n+1,cmp);
	ll l=0,r=(ll)1e12;
	while(l<r)
	{
		//printf("%lld %lld\n",l,r);
		ll mid=(l+r)>>1;
		if(check(mid))r=mid;
		else l=mid+1;
	}
	printf("%lld",r);
}

Measured memory_bytes: 4992