akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int n, k; cin >> n >> k;
	vector<int> a(n + 1); for(int i = 0; i < n; ++i) cin >> a[i];
	for(int q = 0; q < k; ++q) {
		bool end = true;
		for(int i = 0; i < n; ++i) {
			if(a[i] < n) end = false;
		}
		if(end) {
			break;
		}
		vector<int> imos(n + 1);
		for(int i = 0; i < n; ++i) {
			++imos[max(0, i - a[i])];
			--imos[min(n, i + a[i] + 1)];
		}
		for(int i = 1; i <= n; ++i) {
			imos[i] += imos[i - 1];
		}
		a = imos;
	}
	for(int i = 0; i < n; ++i) {
		cout << a[i] << (i == n - 1 ? "\n" : " ");
	}
	return 0;
}

Measured memory_bytes: 4840
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5;
int par[N], rnk[N], sz[N];
int findroot(int node) {
	if (par[node] == node)
		return node;
	else {
		par[node] = findroot(par[node]);
		return par[node];
	}
}
void dounion(int x, int y) {
	if (rnk[x] > rnk[y]) {
		par[y] = x;
		sz[x] += sz[y];
	}
	else if (rnk[x] < rnk[y]) {
		par[x] = y;
		sz[y] += sz[x];
	}
	else {
		par[x] = y;
		sz[y] += sz[x];
		rnk[y]++;
	}
}
int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		sz[i] = 1;
		par[i] = i;
	}
	vector<pair<int, int> > edg(m);
	for (int i = 0; i < m; i++) {
		cin >> edg[i].first >> edg[i].second;
		edg[i].first--;
		edg[i].second--;
	}
	long long ans[m], cnt = (n - 1LL) * n / 2;
	for (int i = m - 1; i >= 0; i--) {
		ans[i] = cnt;
		int x = findroot(edg[i].first);
		int y = findroot(edg[i].second);
		if (x != y) {
			cnt -= (long long) sz[x] * sz[y];
			dounion(x, y);
		}
	}
	for (int i = 0; i < m; i++) {
		cout << ans[i] << ' ';
	}
	return 0;
}


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

int main() {
	string str;
	string::iterator b;
	string::iterator e;
	
	cin >> str;
	
	b= str.begin();
	e = str.end();
	--e;

	cout << *b << str.length() - 2 << *e << endl;

	return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
import collections
c = collections.Counter(a)

q=int(input())
query=[list(map(int, input().split())) for _ in range(q)]

suma=sum(a)

for [bk,nx] in query:
    #bkをnxにする
    #つまりbk*
    suma=suma-bk*c[bk]+nx*c[bk]
    print(suma)
    c[nx]+=c[bk]
    c[bk]=0
    #print(c)



Measured memory_bytes: 104900
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, m = map(int, input().split())
    A, C = [], []
    for _ in range(m):
        a, b = map(int, input().split())
        A.append(a)
        key = 0
        for c in map(int, input().split()):
            key |= 1 << (c - 1)
        C.append(key)

    dp = [f_inf] * (1 << n)
    dp[0] = 0
    for S in range(1 << n):
        for i in range(m):
            key, cost = C[i], A[i]
            dp[S | key] = min(dp[S | key], dp[S] + cost)
    print(dp[-1] if dp[-1] != f_inf else -1)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9320
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

#define max(x, y) ((x)>(y)?(x):(y))
#define min(x, y) ((x)<(y)?(x):(y))

vector<int> before[108000];
Int dp[108000];
Int n, m, x, y;
Int solve(Int x){
  Int &res = dp[x];
  if(res != -1)return res;
  res = 0;
  for(int i = 0;i < before[x].size();i++){
    int b = before[x][i];
    res = max(res, solve(b) + 1);
  }
  return res;
}

int main(){
  fill(dp, dp+108000, -1);
  cin >> n >> m;
  for(int i = 0;i < m;i++){
    cin >> x >> y;
    before[y].push_back(x);
  }
  Int res = 0;
  for(int i = 1;i <= n;i++)res = max(res, solve(i));
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 12800
//API???????????????
import java.util.Scanner;
import java.io.IOException;
class Main {
  	public static void main(String[] args) throws IOException{
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();

		Nodes nodes = new Nodes();
		Node[] node = new Node[n];
		nodes.nodes = node;
		for(int i = 0;i < n;i++){
			node[i] = new Node(i);
		}
		
		for(int i = 0;i < n; i++){
			int id = scan.nextInt();
			int left = scan.nextInt();
			int right = scan.nextInt();
			if(left != -1){
				node[id].left = left;
				node[left].parent = id;
			}
			if(right != -1) {
				node[id].right = right;
				node[right].parent = id;
			}
		}
		
		int root = 0;
		
		while(node[root].parent != -1){
			root = node[root].parent;
		}
		
		System.out.println("Preorder");
		nodes.Preorder(root);
		System.out.println("\r\nInorder");
		nodes.Inorder(root);
		System.out.println("\r\nPostorder");
		nodes.Postorder(root);
		System.out.println();
	}
}

class Node{
	int id;
	int parent = -1;
	int left = -1;
	int right = -1;
	public Node(int id) {
		this.id = id;
	}
}

class Nodes{
	/*
	List<Node> nodes;
	/*/
	Node[] nodes;
	/**/
	
	public void Preorder(int id){
		
		if(id == -1){
			return;
		}
		System.out.print(" " + id);
		Preorder(nodes[id].left);
		Preorder(nodes[id].right);
	}
	
	public void Inorder(int id){
		if(id == -1){
			return;
		}
		Inorder(nodes[id].left);
		System.out.print(" " + id);
		Inorder(nodes[id].right);
	}

	public void Postorder(int id){
		if(id == -1){
			return;
		}
		Postorder(nodes[id].left);
		Postorder(nodes[id].right);
		System.out.print(" " + id);
	}
}

Measured memory_bytes: 26344
#include<iostream>
#include<vector>

int main(){
	int n, m, c;
	std::vector<std::vector<int>> aList;
	std::vector<int> bList;
	std::cin>>n>>m>>c;

	aList.resize(n);
	for(int i=0; i<n; i++)
		aList[i].resize(m);

	bList.resize(m);

	for(int i=0; i<m; i++)
		std::cin>>bList[i];

	for(int i=0; i<n; i++)
		for(int j=0; j< m; j++)
			std::cin>>aList[i][j];

	int ans=0;

	for(int i=0; i<n; i++){
		long long sum=0;

		for(int j=0; j< m; j++)
			sum+= aList[i][j]*bList[j];

		if(sum+c >0)
			ans++;
	}

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

	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
A = set(int(input()) for _ in range(M))
mod = 10 ** 9 + 7

dp = [0] * (N+1)
dp[0] = 1
for i in range(1, N+1):
    if i in A:
        continue
    if i == 1:
        dp[i] = 1
        continue
    dp[i] = dp[i-1] + dp[i-2]
    dp[i] %= mod

print(dp[N] % mod)

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

string ans(string A,string B){
  int a=A.size(),b=B.size();
  if(a>b){
    return "GREATER";
  }
  if(a<b){
    return "LESS";
  }
  if(a==b){
    if(A>B){
      return "GREATER";
    }
    if(A<B){
      return "LESS";
    }
    if(A==B){
      return "EQUAL";
    }
  }
}

int main(){
  string a,b;
  cin>>a>>b;
  cout<<ans(a,b)<<endl;
}

Measured memory_bytes: 256
//1974
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int  a[4];
	
	 cin>>a[0]>>a[1]>>a[2]>>a[3];
	 sort(a,a+4);
	 //1 4 7 9
	 if(a[0]==1&&a[1]==4&&a[2]==7&&a[3]==9)
	 cout<<"YES";
	 else cout<<"NO";
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    long n,sum=0,i;
    scanf("%ld",&n);
    i=n;
    while (n!=0){
        sum+=n%10;
        n/=10;
    }
    if(i%sum==0) printf("Yes\n");
    else if(i%sum!=0) printf("No\n");
    return 0;
}

Measured memory_bytes: 128
N=int(input())
if N==1:
    print(0)
    exit()

def primeryNum(n):
    border=int(n**0.5)+1
    ary=list(range(int(n**0.5)+2))
    ary[1]=0
    for a in ary:
        if a>border: break
        elif a==0: continue
        for i in range(a*2,int(n**0.5)+2,a):
            ary[i]=0           
    return ary

primeryNumL=primeryNum(N)
# print(primeryNumL)
ans=0
N_=N
for x in primeryNumL:
    if x==0 or N%x!=0:
        continue
    n=N
    cnt=0
    while n%x==0:
        cnt+=1
        n/=x
    N_//=x**cnt
    buf=cnt-1
    res=1
    # print(x,cnt)
    for i in range(2,cnt+1):
        if buf<i:
            break
        buf-=i
        res+=1
    ans+=res
if N_>1:
    ans+=1
print(ans)


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

struct unionFind {
  vector<int> d;  // 根： 木のサイズ x -1, それ以外： 親のID
  unionFind(int n = 0) : d(n, -1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    // root化しておく
    x = find(x);
    y = find(y);
    if (x == y) return false;

    // x を y に unite
    // d[x] のほうが多きい（=サイズが小さい）場合はswap
    if (d[x] > d[y]) swap(x, y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return -d[find(x)]; }
};

ll combi(ll n) { return n * (n - 1) / 2; }

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> x(m), y(m);
  rep(i, m) {
    cin >> x[i] >> y[i];
    x[i]--;
    y[i]--;
  }

  vector<ll> ans(m);
  unionFind uf = unionFind(n);
  ll sum = combi(n);
  for (int i = m - 1; i >= 0; i--) {
    // rep(j, m) if (uf.d[j] < 0) sum -= combi(uf.size(j));
    ans[i] = sum;
    ll bx = combi(uf.size(x[i]));
    ll by = combi(uf.size(y[i]));
    if (uf.unite(x[i], y[i])) sum -= combi(uf.size(x[i])) - bx - by;
  }
  rep(i, m) cout << ans[i] << endl;
  return 0;
}

Measured memory_bytes: 3328
n,k=map(int,input().split())
ans=0
tmp=2**17
eps=10**(-10)
for i in range(1,n+1):
  if i>=k:
    ans+=1*tmp
  else:
    for j in range(1,18):
      if i*(2**j)>=k:
        ans+=tmp/(2**j)
        break
ans=ans/(n*tmp)
print(ans-eps)

Measured memory_bytes: 3064
n = gets.to_i
b = gets.split.map(&:to_i)
ans = []
n.times do |i|
    (n-i-1).downto(0) do |j|
        if b[j] == j+1
            ans << j+1
            b.delete_at(j)
            break
        elsif b[j] > j+1
            puts "-1"
            exit
        end
    end
end
puts ans.reverse

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

//http://abc067.contest.atcoder.jp/tasks/abc067_a

using namespace std;


typedef long long LL;
typedef pair<LL,LL> pp;


int main()
{
	int N, K;
	cin >> N;
	vector<int> v(N);
	cin >> K;

	for (int i = 0; i < N; i++) {
		cin >> v[i];
	}
	sort(v.begin(), v.end());
	cout << accumulate(v.begin()+(N-K), v.end(), 0);
	exit(0);
}



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

int main() {
    int N, A[MAX], FA, SA;

    FA = SA = 0;

    cin >> N;

    for (int i=0; i<N; i++) {
        cin >> A[i];
        if (A[i] > FA) {
            SA = FA;
            FA = A[i];
        } else if (A[i] > SA) SA = A[i];
    }

    for (int i=0; i<N; i++) {
        if (A[i] < FA) cout << FA << endl;
        else cout << SA << endl;
    }

    return 0;
}

Measured memory_bytes: 2432
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

S = list(input())
S.sort()
if S[0]==S[1] and S[1]!=S[2] and S[2]==S[3]:
    print('Yes')
else:
    print('No')

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

using namespace std;

typedef long long ll;
const int MAX=1e9+7;

int main()
{
    int a,b,x;
    cin>>a>>b>>x;
    if(a+b>=x && a<=x) printf("YES\n");
    else
        printf("NO\n");

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define lpin(a,i,n) for(int i=0;i<n;i++){cin>>a[i];}
int main(){
  int m,f,b;
  cin>>m>>f>>b;
  if(m>=b) cout<<"0"<<endl;
  else if(m+f<b) cout<<"NA"<<endl;
  else cout<<b-m<<endl;
    
  return 0;
}



Measured memory_bytes: 3076
''' ===============================
    -- @uthor : Kaleab Asfaw
    -- Handle : kaleabasfaw2010
    -- Bio    : High-School Student
    ==============================='''

# Fast IO
import sys
import os
from io import BytesIO, IOBase
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")
# Others
# from math import floor, ceil, gcd
# from decimal import Decimal as d
mod = 10**9+7
def lcm(x, y): return (x * y) / (gcd(x, y))
def fact(x, mod=mod):
    ans = 1
    for i in range(1, x+1): ans = (ans * i) % mod
    return ans
def arr2D(n, m, default=0):
    lst = []
    for i in range(n): temp = [default] * m; lst.append(temp)
    return lst
def sortDictV(x): return {k: v for k, v in sorted(x.items(), key = lambda item : item[1])}

def solve(n, lst):
    for i in range(n-2):
        if lst[i][0] == lst[i][1] and lst[i+1][0] == lst[i+1][1] and lst[i+2][0] == lst[i+2][1]:
            return "Yes"
    return "No"

n = int(input())
lst = []
for i in range(n):
    a, b = list(map(int, input().split()))
    lst.append([a, b])
print(solve(n, lst))

Measured memory_bytes: 63100
import math
x = int(input())

def is_prime(x):
    if x < 2: return False # 2未満に素数はない
    if x == 2 or x == 3 or x == 5: return True # 2,3,5は素数
    if x % 2 == 0 or x % 3 == 0 or x % 5 == 0: return False # 2,3,5の倍数は合成数

    # ためし割り: 疑似素数(2でも3でも5でも割り切れない数字)で次々に割っていく
    prime = 7
    step = 4
    while prime <= math.sqrt(x):
        if x % prime == 0: return False

        prime += step
        step = 6 - step

    return True

while True:
    if is_prime(x):
        print(x)
        break
    x += 1


Measured memory_bytes: 9192
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 1
#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR
#endif


//改造
typedef long long int ll;
using namespace std;


//ここから編集する
ll mod = 1000000007;


int main() {
    //入力
    int h, w;
    cin >> h >> w;
    vector<vector<char> > v(h, vector<char>(w));
    int cnt = 0;
    REP(i, 0, h) {
        REP(j, 0, w) {
            char inp;
            cin >> inp;
            v[i][j] = inp;
            if (inp == '#') {
//                v[i][j] = 1;
                cnt++;
            }
//            } else {
//                v[i][j] = 0;
//            }

        }
    }
    //#の数がH+W-1でなければだめ
    int x, y;
    x = y = 0;
    if (cnt != h + w - 1) {
        cout << "Impossible" << endl;
        return 0;
    }
    while (true) {
        //右か下に#があるかを調べる
        //両方に#があればだめ
        if ((x + 1 < h && v[x + 1][y] == '#') && (y + 1 < w && v[x][y + 1] == '#')) {
            cout << "Impossible" << endl;
            return 0;
        }
        //#が右か下になければだめ
        if ((x + 1 < h && v[x + 1][y] != '#') && (y + 1 < w && v[x][y + 1] != '#')) {
            cout << "Impossible" << endl;
            return 0;
        }
        //#がある方に進む
        if ((x + 1 < h && v[x + 1][y] == '#') && !(y + 1 < w && v[x][y + 1] == '#')) {
            x++;
//            y++;
        } else if (!(x + 1 < h && v[x + 1][y] == '#') && (y + 1 < w && v[x][y + 1] == '#')) {
            y++;
//            x++;
        }
        //今いる地点が右下ならゴール
        if (x == h - 1 && y == w - 1) {
            cout << "Possible" << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define pf push_front
#define fr first
#define sc second
#define r_0 return 0
#define ld long double

using namespace std;

    const ll N = 1e3 + 7;
    const ll mod = 1e9 + 7;
    const ld eps = 1e-9;



void solve(){
    ll n , k;
    cin >> n >> k;
    vector < ll > a(n + 1);
    for(ll i = 1; i <= n; ++ i){
        cin >> a[i];
    }
    for(ll i = k + 1; i <= n; ++ i){
        if(a[i] > a[i - k]){
                cout << "Yes\n";
        }
        else{
                cout << "No\n";
        }
    }
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int tt = 1;
    //cin >> tt;
    while(tt --){
            solve();
    }
}

/**

**/


Measured memory_bytes: 4776
#include <stdio.h>
#include <iostream>
#include <string>

using namespace std;

class Dice
{
public:
	int label[6];
	void N();
	void S();
	void W();
	void E();
};

void Dice::N()
{
	int newlabel[6];
	newlabel[0] = label[1];
	newlabel[1] = label[5];
	newlabel[2] = label[2];
	newlabel[3] = label[3];
	newlabel[4] = label[0];
	newlabel[5] = label[4];
	for(int i = 0; i < 6; i++) {
		label[i] = newlabel[i];
	}
}

void Dice::S()
{
	int newlabel[6];
	newlabel[0] = label[4];
	newlabel[1] = label[0];
	newlabel[2] = label[2];
	newlabel[3] = label[3];
	newlabel[4] = label[5];
	newlabel[5] = label[1];
	for(int i = 0; i < 6; i++) {
		label[i] = newlabel[i];
	}
}

void Dice::W()
{
	int newlabel[6];
	newlabel[0] = label[2];
	newlabel[1] = label[1];
	newlabel[2] = label[5];
	newlabel[3] = label[0];
	newlabel[4] = label[4];
	newlabel[5] = label[3];
	for(int i = 0; i < 6; i++) {
		label[i] = newlabel[i];
	}
}

void Dice::E()
{
	int newlabel[6];
	newlabel[0] = label[3];
	newlabel[1] = label[1];
	newlabel[2] = label[0];
	newlabel[3] = label[5];
	newlabel[4] = label[4];
	newlabel[5] = label[2];
	for(int i = 0; i < 6; i++) {
		label[i] = newlabel[i];
	}
}

int main() {
	Dice d;
	scanf("%d %d %d %d %d %d", &d.label[0], &d.label[1], &d.label[2], &d.label[3], &d.label[4], &d.label[5]);
	string cmd;
	cin >> cmd;
	for(int i = 0; i < cmd.size(); i++) {
		if(cmd[i] == 'N') d.N();
		else if(cmd[i] == 'S') d.S();
		else if(cmd[i] == 'W') d.W();
		else if(cmd[i] == 'E') d.E();
	}
	printf("%d\n", d.label[0]);
	return 0;
}

Measured memory_bytes: 3312
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b;
	if(b>=10 && b<100)
	a=a*100+b;
	else if(b<10)
	a=a*10+b;
	else
	a=a*1000+b;
	c=sqrt(a);
	if(c*c==a)
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
	return 0;
}

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


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);

    int x;
    cin>>x;
    int k=1,now=x;
    while(true){
        if(now%360==0) break;
        now+=x;
        k++;
    }
    cout<<k<<endl;
    return 0;
}

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

using namespace std;

int main(){

  long long int n;
  cin>>n;
  long long int power=1;
  long long MOD=1000000007;

  for(int i=1; i<=n; i++){
    power=(power*i)%MOD;
  }

  cout<<power<<endl;
}


Measured memory_bytes: 3556
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf = 1e9 + 7;

int main() {
	int n, cnt = 0, ma = 0;
	vector<string>s;

	string a;
	cin >> n;
	rep(i, n) {
		cin >> a;
		s.push_back(a);
	}
	sort(s.begin(), s.end());
	rep(i, n - 1) {


		if (s[i + 1] == s[i]) {
			cnt = cnt + 1;
			ma = max(cnt, ma);
		}
		else {
			cnt = 0;
		}

	}
	cnt = 0;
	if (ma == 0)rep(i, n)cout << s[i] << endl;
	else 
	rep(i, n - 1) {
		if (s[i + 1] == s[i]) {
			cnt = cnt + 1;
			if (cnt == ma) {
				cout << s[i + 1] << endl;
				cnt = 0;
			}
		}
		else {
			if (cnt == ma)cout << s[i + 1] << endl;
			cnt = 0;
		}

	}
}

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

int main(){
    int X,Y,Z;
    cin >> X >> Y >> Z;
    //X:横幅
    //Y:人の幅
    //Z:必要な間隔
    int person=0;
    X -= Z;
    while(X >= Y+Z){
        X -= Y;
        X -= Z;
        person++;
    }
    cout << person << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

int main() {
    int k, x;
    cin >> k >> x;
    cout << (500 * k >= x ? "Yes" : "No") << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int no_of_cards;
    scanf("%d", &no_of_cards);

    vector <int> card(no_of_cards);
    for(int i = 0; i < no_of_cards; i++)
        scanf("%d", &card[i]);

    vector <long long> sum_till(no_of_cards);
    sum_till[0] = card[0];
    for(int i = 1; i < no_of_cards; i++)
        sum_till[i] = card[i] + sum_till[i - 1];

    vector <long long> sum_from(no_of_cards);
    sum_from[no_of_cards - 1] = card[no_of_cards - 1];
    for(int i = no_of_cards - 2; i >= 0; i--)
        sum_from[i] = card[i] + sum_from[i + 1];

    long long minimum_difference = 1e15;
    for(int i = 0; i < no_of_cards - 1; i++)
        minimum_difference = min(minimum_difference, abs(sum_till[i] - sum_from[i + 1]));

    printf("%lld\n", minimum_difference);
    return 0;
}


Measured memory_bytes: 4096
#include <iostream>
#include <cstdio>

using namespace std;

#define MAX_N 100


int main(){
    int a[MAX_N];
    int N;
    int min;
    int buf;

    cin >> N;

    for(int i;i<N;i++){
        scanf("%d",&a[i]);
    }

    for(int i=-100;i<=100;i++){
        buf = 0;
        for(int j=0;j<N;j++){
            buf += (a[j]-i)*(a[j]-i);
        }
        if(i==-100)
            min = buf;

        if(min>buf)
            min = buf;
    }

    cout << min << "\n";

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
const long long MAX = 1000000007;

int main(){
  long long n,m;
  cin >> n >> m;
  long long allspace[n+1];
  long long a[n];
  long long x;
  for(long long i=0;i<n;i++){
    a[i]= 0;
  }
  for(long long i=0;i<m;i++){
    cin >> x;
    a[x-1]++;
  }
  allspace[0] = 1;
  allspace[1] = 1;
  for(long long i=2;i<=n;i++){
    allspace[i] = (allspace[i-1] + allspace[i-2]) % MAX;
  }
  long long last=1;
  long long mul=1;
  for(long long i=0;i<n;i++){
    //cout << mul << endl;;
    if(!a[i]){
      //cout << 'a' << a[i] << endl;
      last++;
    }else{
      //cout << 'b' << a[i] << endl;
      if(last){
        mul*=allspace[last-1];
        mul%=MAX;
        last=0;
      }else{
        mul=0;
        break;
      }
    }
  }
  mul*= allspace[last-1];
  mul %= MAX;
  cout << mul;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,a,b;
    cin>>n>>a>>b;
    if(n>1&&b>=a||n==1&&a==b)
        cout<<(n-2)*(b-a)+1<<endl; 
    else
        cout<<0<<endl; 
} 

Measured memory_bytes: 256
void main() {
	(48 - ri).writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 256
function Main(input) {
    const lines = input.split("\n");
    const counts = {};
    let max = 0;

    lines.shift();
    lines.forEach(s => {
        counts[s] = (counts[s] || 0) + 1;
        if (max < counts[s]) max = counts[s];
    });
    const keys = Object.keys(counts).sort();

    console.log(keys.filter(k => counts[k] === max).join('\n'));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 114008
#include<stdio.h>
int main(){
  int n,i,k=0,c;
  double a,b;
  scanf("%d\n",&n);
  for(i=1;i<=n;i++){
    a=i;
    b=a*1.08;
    c=b;
    if(c==n){
      k++;
      printf("%d\n",i);
      break;
    }
  }
  if(k==0){
    printf(":(\n");
  }
  return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <cctype>
#include <complex>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::priority_queue;

using std::min;
using std::max;
using std::sort;
using std::abs;

const int MOD = 1e9 + 7;

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


    long p = 1;
    for(int i = 1; i <= n; i++){
        p *= i;
        p %= MOD;
    }

    cout << p << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int s,w;
  string res;
  
  cin >> s >> w;
  
  if (s > w){
    res = "safe";
  }else{
  	res = "unsafe";
  }
 
  cout << res << endl;
 }

Measured memory_bytes: 3624
#include <stdio.h>
#include <vector>
#include <bitset>
using namespace std;
constexpr int kN = int(1E2 + 10);
struct BPM {
	// from l to r
	// x[r] = l => match(l, r)
	int l, r, x[kN];
	vector<int> graph[kN];
	bitset<kN> went;
	void init(int n, int m) {
		l = n, r = m;
		for (int i = 1; i <= n; i++) graph[i].clear();
	}
	void addedge(int u, int v) {graph[u].push_back(v);}

	bool dfs(int pos) {
		went[pos] = true;
		for (int i : graph[pos]) if (!x[i]) {
			x[i] = pos;
			return true;
		}
		for (int i : graph[pos]) if (!went[x[i]] && dfs(x[i])) {
			x[i] = pos;
			return true;
		}
		return false;
	}

	int match() {
		int ans = 0;
		for (int i = 1; i <= r; i++) x[i] = 0;
		for (int i = 1; i <= l; i++) {
			went.reset();
			if (dfs(i)) ans++;
		}
		return ans;
	}
};

BPM bpm;

int main() {
	int x, y, e, l, r;
	scanf("%d%d%d", &x, &y, &e);
	bpm.init(x, y);
	for (int i = 1; i <= e; i++) {
		scanf("%d%d", &l, &r);
		bpm.addedge(l + 1, r + 1);
	}
	printf("%d\n", bpm.match());
}



Measured memory_bytes: 2828
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = new int[n];
            a[0] = -1;
            for (int i = 1; i < n; ++i) {
                a[i] = in.nextInt() - 1;
            }
            int[] firstChild = new int[n];
            int[] nextSibling = new int[n];
            Arrays.fill(firstChild, -1);
            for (int i = 1; i < n; ++i) {
                nextSibling[i] = firstChild[a[i]];
                firstChild[a[i]] = i;
            }
            out.println(doit(0, firstChild, nextSibling));
        }

        private int doit(int root, int[] firstChild, int[] nextSibling) {
            int numChildren = 0;
            int t = firstChild[root];
            while (t >= 0) {
                ++numChildren;
                t = nextSibling[t];
            }
            int[] children = new int[numChildren];
            numChildren = 0;
            t = firstChild[root];
            while (t >= 0) {
                children[numChildren++] = doit(t, firstChild, nextSibling);
                t = nextSibling[t];
            }
            Arrays.sort(children);
            int res = 0;
            for (int i = 0; i < children.length; ++i) {
                res = Math.max(res, children[i] + children.length - i);
            }
            return res;
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

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

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



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

#define long long long int
using namespace std;


#ifdef JUDGE
std::ifstream cin("input.txt");
std::ofstream cout("output.txt");
#else
using std::cin;
using std::cout;
#endif

using namespace std;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.precision(6);


    int s, w;
    cin >> s >> w;
    cout << (s <= w ? "unsafe" : "safe");
    return 0;


}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

using namespace std;

int main() {
   int a,b,c;
   cin >> a >> b >> c; 
   cout << max({a,b,c}) - min({a,b,c}) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

//import jdk.internal.org.jline.utils.InputStreamReader;

//import java.io.*;

public class Main{
        public static void main(final String[] args){
            Scanner scanner = new Scanner(System.in);
            while(true){
                int n = scanner.nextInt();
                int x = scanner.nextInt();
                if(n + x == 0){
                    break;
                }
                int flag = 0;
                for(int i = 1; i <= n; i++){
                    
                    for(int j = i+1; j <= n; j++){
                        //System.out.println(i +" "+ j);
                        for(int k = j+1; k <= n; k++){
                            int answer = i + j + k;
                            //System.out.println(answer);
                            if(answer == x){
                                flag++;
                            }
                            //System.out.printf("%d %d %d\n", i, j, k);
                            
                        }
                    }
                    
                }
                System.out.println(flag);
            }
            scanner.close();
        }
         

}


Measured memory_bytes: 26920
using System;
using System.Linq;
using System.Collections.Generic;
public class Hello{
    public static void Main(){
        var input = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        var n = input[0];
        var k = input[1];
        var a = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        var dp = new long[n];
        
        for(var i = 1;i < n;i++){
            dp[i] = long.MaxValue;
            for(var j = 1;j <= k;j++){
                if(i - j >= 0){
                    dp[i] = Math.Min(dp[i],dp[i - j] + Math.Abs(a[i] - a[i - j]));
                }
            }
        }
        Console.WriteLine(dp[n - 1]);
    }
}


Measured memory_bytes: 21728
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define vec vector
#define rep(i,n) for (int i=0; i<(n); i++)
#define reps(i,s,n) for (int i=(s); i<(n); i++)
#define rep1(i,n) for (int i=1; i<=(n); i++)
#define repr(i,s,n) for (int i=(s)-1; i>=(n); i--)
#define print(a) cout << a << endl
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()


int main() {
  ll N;
  cin >> N;
  vec<ll> a(N);
  ll sum = 0;
  rep(i,N) {
    cin >> a[i];
    sum += a[i];
  }
  sum -= N*(N-1);
  sum = max(sum,(ll)0);
  ll ans = sum;
  rep(i,N) a[i] += sum;
  rep(i,N) {
    ll t = a[i]/(N+1);
    t = min(t,sum);
    a[i] -= t*(N+1);
    sum -= t;
  }
  while (1) {
    ll cnt = 0;
    rep(i,N) {
      cnt += a[i]/N;
    }
    if (cnt == 0)
      break;
    ans += cnt;
    rep(i,N) {
      if (a[i]<N)
        a[i] += cnt;
      else {
        ll t = a[i]/N;
        a[i] -= t*(N+1);
        a[i] += cnt;
      }
    }
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>


using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll, ll> pll;
int dx[4] = { 1,0,0,-1 };
int dy[4] = { 0,1,-1,0 };

#define ARRAY_MAX 100005 

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;

int dp[ARRAY_MAX];
int wmin[ARRAY_MAX];

int main() {

	int n;
	cin >> n;
	vector<string> s(n);

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

	memset(dp, INF, sizeof(dp));
	memset(wmin, INF, sizeof(wmin));

	dp[0] = 0;

	for (int i = 0; i < n; i++)
	{
		dp[i + 1] = min(dp[i] + 1,wmin[s[i][0]-'a']);
		wmin[s[i][0]-'a'] = dp[i + 1];
	}
	cout << dp[n] << endl;

}


Measured memory_bytes: 10004
#include <bits/stdc++.h>
 
using namespace std;
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
#define lp(i, a, b) for (int i=a; i<(b); i++)
#define lpd(i,a,b) for (int i = (b)-1; i >= a; i--)
	
#define sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
 
bool cmp(pi &a, pi &b){
    return (a.first < b.first);
}
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
 
    int n, a, b;
    ll m;
    cin>>n>>m;
 
    vector<pi> v(n);
    lp(i, 0, n){
        cin>>a>>b;
        v[i] = mp(a, b);
    }
    sort(all(v), cmp);
 
    ll sum = 0, price = 0;
    lp (i, 0, n){
        if (sum == m) break;
        ll b = min(m-sum, (ll)v[i].second);
        sum += b;
        price += ((ll)b*(ll)v[i].first);
    }
    cout<<price<<endl;
 
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans=0;
    rep(i,0,s.size()){
        string t = s.substr(0,i);
        string t_2 = s.substr(i);
        set<char> t_count;
        rep(j,0,t.size()){
            t_count.insert(t[j]);
        }
        int match = 0;
        rep(j,0,t_2.size()){
            if(t_count.count(t_2[j])){
                match ++;
                t_count.erase(t_2[j]);
            }
        }
        ans = max(ans,match);
    }
    cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3624
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++)
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

LL n,a[100010],b[100010],suma=0,sumb=0,les=0,ans=0;
vector <LL> mr;

int main()
{
	cin>>n;
	rep(i,n)
	{
		scanf("%I64d",&a[i]);
		suma+=a[i];
	}
	rep(i,n)
	{
		scanf("%I64d",&b[i]);
		sumb+=b[i];
	}
	if(suma<sumb) puts("-1"),exit(0);
	rep(i,n)
	{
		if(a[i]<b[i]) les+=b[i]-a[i],ans++;
		if(b[i]<a[i]) mr.pb(a[i]-b[i]);
	}
	sort(mr.begin(),mr.end());
	for(int i=mr.size()-1;i>=0;i--)
	{
		if(les<=0) break;
		les-=mr[i];
		ans++;
	}
	cout<<ans<<endl;
	rt0;
}

Measured memory_bytes: 2428
A,B,C,X = [int(input()) for x in range(4)]

count = 0
for a in range(0, A+1):
    Xa = X - 500 * a
    if Xa < 0:
        break
    for b in range(0, B+1):
        Xab = Xa - 100 * b
        if Xab < 0:
            break
        for c in range(0, C+1):
            if Xab - 50 * c == 0:
                count += 1;
print(count)

Measured memory_bytes: 3060
N = int(input())
S = input()

lW = 0
rE = S[1:N].count("E")
mi = lW + rE
for i in range(1, N):
    if S[i - 1] == "W":
        lW += 1
    if S[i] == "E":
        rE -= 1
    if lW + rE < mi:
        mi = lW + rE

print(mi)


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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    def sum_of_floor(N,M,A,B):
        """
        return sum_{i=0}^{N-1} (A*i+B)//M
        """
        S = 0
        while N:
            q,A = divmod(A,M)
            S += N * (N-1) // 2 * q
            q,B = divmod(B,M)
            S += N * q
            if not A:
                return S
            y = (A * N + B) // M
            x = M * y - B
            S += (N - (x+A-1)//A) * y
            N,M,A,B = y,A,M,(-x)%A
        return S
    
    T=I()
    for _ in range(T):
        n,m,a,b=MI()
        print(sum_of_floor(n,m,a,b))



main()


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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
bool chmin(T &a,T b){if(a>b){a=b;return true;}else return false;}
template<typename T>
bool chmax(T &a,T b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
ostream &operator<<(ostream &os, pair<ll, ll>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n;cin>>n;
  vector<ll>x(n);
  rep(i,0,n)cin>>x[i];
  res=INF;
  rep(i,1,101){
    ll now=0;
    rep(j,0,n){
      ll tmp=abs(x[j]-i);
      now+=tmp*tmp;
    }
    chmin(res,now);
  }
  cout<<res<<endl;
  return 0;
}

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

int main() {
  int k;
  cin >> k;
  string s;
  cin >> s;

  if (s.size() <= k) {
    cout << s << endl;
  } else {
    string sb = s.substr(0, k);
    sb += "...";
    cout << sb << endl;
  }
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int N;
      int c1, c2, c3, c4;

      cin >> N;
      
      c1 = N / 1000;
      c2 = N / 100 % 10;
      c3 = N / 10 % 10;
      c4 = N % 10;
      
      if (c1 == c2 && c1 == c3)
      {
        cout << "Yes" << endl;
      }
      else if (c2 == c3 && c2 == c4)
      {
        cout << "Yes" << endl;
      }
      else
      {
        cout << "No" << endl;
      }
    }

Measured memory_bytes: 256
//In the name of God
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<int , int> pii;

string s;
int p , g;

int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        cin >> s;
        for(auto c : s)
                (c == 'g'? g++ : p++);
        cout << (g - p) / 2;
        return 0;
}    

Measured memory_bytes: 512
#include<cstdio>
#include<iostream>

using namespace std;

void trace(int a[],int n){
    for (int i = 0; i < n; ++i) {
        cout << a[i];
        if (i != n-1)
            cout << " ";
    }
    cout << "\n";
}

void insertion_sort(int a[], int n){

    int cursor,temp;

    for (int i = 1; i < n; ++i) {
        cursor = i-1;
        temp = a[i];
        while (cursor >= 0 && a[cursor] > temp){
            a[cursor+1] = a[cursor];
            cursor--;
        }
        cursor++;
        a[cursor] = temp;

        trace(a,n);
    }

}

int main(){

    int a[100],n;

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


    trace(a,n);

    insertion_sort(a,n);


    return 0;
}

Measured memory_bytes: 3036
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
void solve(int x)
{
 cout<<fixed<<setprecision(20)<<M_PI*2*x<<"\n";
}
int main()
{
 int r;
 cin>>r;
 solve(r);
 return 0;
}

Measured memory_bytes: 3792
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int p[30] = {};
    for (int i = 0; i < n; i++) {
        int k;
        cin >> k;
        for (int j = 0; j < k; j++) {
            int a;
            cin >> a;
            a--;

            p[a]++;
        }
    }

    int r = 0;
    for (int a = 0; a < m; a++) {
        if (p[a] == n) r++;
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 256
N,Ma,Mb = map(int,input().split())

INF = 10000

dp = [[[INF for b in range(401)] for a in range(401)] for i in range(N+1)]

dp[0][0][0] = 0

for i in range(1,N+1):
    ai,bi,ci = map(int,input().split())
    for a in range(401):
        for b in range(401):
            if a-ai >= 0 and b-bi >= 0:
                dp[i][a][b] = min(dp[i-1][a][b],dp[i-1][a-ai][b-bi]+ci)
            else:
                dp[i][a][b] = dp[i-1][a][b]

ans = INF
for j in range(1,401):
    if Ma*j >= 400 or Mb*j >= 400:
        break
    ans = min(ans,dp[N][Ma*j][Mb*j])
print(ans if ans != INF else -1)



Measured memory_bytes: 98780