akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
constexpr long long MOD = 1000000007;
using ll = long long;
void solve(){
    ll n,m;
    cin >> n >> m;
    vector<vector<ll>> adj(n);
    for(ll i=0;i<m;i++){
        ll a,b;
        cin >> a >> b;
        a--;
        b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    for (ll i = 0; i < n;i++){
        cout << adj[i].size() << endl;
    }
    }
int main(){
    solve();
}


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

using namespace std;

int main(){
  int size[3];
  while(~scanf("%d %d %d", &size[0], &size[1], &size[2]) && size[0] && size[1] && size[2]){
      sort(size, size + 3);
      double can = sqrt(size[0] * size[0] + size[1] * size[1]);
      int n;
      scanf("%d", &n);
      while(n--){
        int r;
        scanf("%d", &r);
        printf("%s\n", can < r * 2 ? "OK" : "NA");
      }
  }
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int a[10001];
int cont=0;
void print(int n)
{
	for(int i=0;i<n;i++)
	{
		cout<<a[i];
		if(i!=n-1)
		cout<<' ';
		else
		cout<<endl;
	}
		
}
void BubbleSort(int n)
{
	for(int i=0;i<n;i++)
	  for(int j=i;j>=0;j--)
	  {
	  	if(a[j]<a[j-1])
	  	{
	  		cont++;
	  		swap(a[j],a[j-1]);
	  		
	  	}
	  }
	  print(n);
	  cout<<cont<<endl;
}
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	cin>>a[i];
	BubbleSort(n);
}


Measured memory_bytes: 3084
#include<stdio.h>

int main(void){
    int n, k, x, y;
    scanf("%d%d%d%d",&n, &k, &x, &y);
    int cost;
    if(n<=k) cost = n*x;
    else cost = k*x+(n-k)*y;
    printf("%d\n",cost);
    return 0;
}


Measured memory_bytes: 128
N, K, Q = map(int,input().split())
L = [K-Q for _ in range(N)]

for j in range(Q):
    a = int(input())
    L[a-1] += 1

for k in range(N):
    if L[k] > 0 :
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 7880
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)

	X := make(map[string]int, n)
	for i := 0; i < n; i++ {
		var x string
		fmt.Scan(&x)
		X[x] += 1
	}

	max := 0
	words := make([]string, 1)
	for k, v := range X {
		if max == v {
			words = append(words, k)
			max = v
		} else if max < v {
			words = words[:1]
			words[0] = k
			max = v
		}
	}

	sort.Strings(words)
	for _, v := range words {
		fmt.Println(v)
	}
}


Measured memory_bytes: 33152
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000000000000007;
const int MOD=1000000007;
struct Node{
    int no;
    int par;
    int a;
    int lis;
    vector<Node*> child;
    void build(int i){
        no=i;
        par=i;
        a=0;
        lis=0;
    }
};
struct Tree{
    int n;
    vector<Node> node;
    Tree(int k){
        n=k;
        node.resize(n+1);
        for(int i=1;i<=n;++i){
            node[i].build(i);
            int a;cin>>a;
            node[i].a=a;
        }
    }
    void input(int k){
        for(int i=0;i<k;++i){
            int a,b;cin>>a>>b;
            node[a].child.push_back(&node[b]);
            node[b].child.push_back(&node[a]);
        }
    }
    void BFS(int s){
        queue<Node> que;
        node[s].lis=1;
        que.push(node[s]);
        while(!que.empty()){
            Node buf=que.front();que.pop();
            int num=buf.child.size();
            for(int i=0;i<num;++i){
                if(buf.child[i]->no!=buf.par){
                    buf.child[i]->par=buf.no;
                    que.push(*buf.child[i]);
                }
            }
        }
    }
    void DFS(Node& node,vector<int>& dp){
        if(node.child.size()==1&&node.par==node.no+inf){
            return;
        }
        else{
            int num=node.child.size();
            //vector<int> buf(dp);
            for(int i=0;i<num;++i){
                if(node.child[i]->no!=node.par){
                  auto it=lower_bound(ALL(dp),node.child[i]->a);
                  int rev=*it;
                  *it=min(*it,node.child[i]->a);
                  auto it2=upper_bound(ALL(dp),inf-1);
                  int ind=it2-(dp).begin();
                  node.child[i]->lis=ind;
                  DFS(*node.child[i],dp);
                  *it=rev;
                }
            }
        }
    }
};
signed main(){
  int n;cin>>n;
  Tree tree(n);
  tree.input(n-1);
  tree.BFS(1);
  vector<int> dp(n+1,inf);
  dp[0]=tree.node[1].a;
  tree.DFS(tree.node[1],dp);
  rep1(i,n){
    cout<<tree.node[i].lis<<"\n";
  }
  return 0;
}


Measured memory_bytes: 36896
#include  <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 1000000007
//P pa(114,514);   ,vector<P>vec(N,0);
//vector<vector<int>> vec(縦, vector<int>(横));
#define REP(i,N) for(int i=0;i<N;i++)
int gcd(int a, int b) {
    if(a>b){
        swap(a,b);
        }
    while(b%a!=0){
        b%=a;
        swap(a,b);
    }
    return a;
}
//cout << setprecision(123);
int main(){
  int N,a=0;
  cin>>N;
  vector<int>p(N);
  REP(i,N){
    cin>>p[i];
    if((p[i]-i-1)!=0){
      a++;
    }
  }
  if(a!=0 && a!=2){
    cout<<"NO"<<endl;
  }
  else{
    cout<<"YES"<<endl;
  }
}

Measured memory_bytes: 384
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")

#include <cstdio>
using namespace std;

int main() {
    const int m_max = 200000;
    const int q_max = 100000;

    int N, M, Q;
    scanf("%d%d%d", &N, &M, &Q);

    alignas(32) short L[m_max], R[m_max];

    for (int i = 0; i < M; i++) {
        scanf("%hd%hd", &L[i], &R[i]);
    }

    int ans[q_max];
    alignas(32) short p[q_max], q[q_max];

    for (int i = 0; i < Q; i++) {
        ans[i] = 0;
    }

    for (int i = 0; i < Q; i++) {
        scanf("%hd%hd", &p[i], &q[i]);
    }

    const int Q1 = Q / 6 * 6;
  
    for (int i = 0; i < Q1; i += 6) {
        for (int j = 0; j < M; j++) {
            ans[i] += (p[i] <= L[j] & R[j] <= q[i]);
            ans[i + 1] += (p[i + 1] <= L[j] & R[j] <= q[i + 1]);
          	ans[i + 2] += (p[i + 2] <= L[j] & R[j] <= q[i + 2]);
            ans[i + 3] += (p[i + 3] <= L[j] & R[j] <= q[i + 3]);
            ans[i + 4] += (p[i + 4] <= L[j] & R[j] <= q[i + 4]);
            ans[i + 5] += (p[i + 5] <= L[j] & R[j] <= q[i + 5]);
        }
    }
  
    for (int i = Q1; i < Q; i++) {
        for (int j = 0; j < M; j++) {
            ans[i] += (p[i] <= L[j] & R[j] <= q[i]); 
        }
    }

    for (int i = 0; i < Q; i++) {
        printf("%d\n", ans[i]);
    }
}


Measured memory_bytes: 2432
import java.util.Scanner;
public class Main {

    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int a =sc.nextInt();
        int b =sc.nextInt();
        int c =sc.nextInt();
        int temp=0;
        int[] arr={a,b,c};
        temp=arr[1];
        arr[1]=a;
        arr[0]=temp;
        temp=arr[2];
        arr[2]=arr[0];
        arr[0]=c;
        arr[0]=temp;
        for (int i = 0; i <arr.length ; i++) {
            System.out.print(arr[i]+" ");

        }





     }
}


Measured memory_bytes: 38568
#TRE
#pow(m,n)のnが大きい時は繰り返し2乗法を使う

#繰り返し2乗法のアルゴリズム
def modPow (a,n,p):
    if n==1:
        return a % p
    if n%2 == 1:
        return (a * modPow(a,n-1,p)) % p
    else:
        t = modPow(a,n/2,p)
        return t * t


#main
n,a,b = map(int,input().split())
p = 10**9+7
if n == 2 :
    print(0)
else:
#繰り返し2乗法により計算時間を短縮
    ans = modPow(2,n,p)-1#組み合わせのシグマは2のn乗
#組み合わせはn*...*(n-a+1)/(a*...*1)
    child_a = 1
    mother_a = 1
    for i in range(a):
        child_a = (child_a*(n-i))%p
        mother_a = (mother_a*(i+1))%p
    com_a = (child_a * modPow(mother_a,p-2,p)) % p
    child_b = 1
    mother_b = 1
    for i in range(b):
        child_b = (child_b*(n-i))%p
        mother_b = (mother_b*(i+1))%p
    com_b = (child_b * modPow(mother_b,p-2,p)) % p
    ans = (ans -(com_a+com_b))%p
    print(ans%p)

Measured memory_bytes: 3064
houses = [[[0 for r in range(10)] for f in range(3)] for b in range(4)]

n = int(input())

for i in range(n):
    b, f, r, v = map(int, input().split())
    houses[b - 1][f - 1][r - 1] += v

for b in range(4):
    for f in houses[b]:
        print('', *f)
    if b != 3:
        print('#' * 20)



Measured memory_bytes: 5624
#include<stdio.h>
#include<iostream>
#include<cmath>
#include<string>
#include<cassert>
using namespace std;
#define N 4
#define N2 16
#define LIMIT 100

static const int dx[4] = {0, -1, 0, 1};
static const int dy[4] = {1, 0, -1, 0};
static const char dir[4] = {'r', 'u', 'l', 'd'};
int MDT[N2][N2];

struct Puzzle { int f[N2], space, MD; };

Puzzle state;
int limit;
int path[LIMIT];

int getAllMD(Puzzle pz) {
  int sum = 0;
  for ( int i = 0; i < N2; i++ ) {
    if ( pz.f[i] == N2 ) continue;
    sum += MDT[i][pz.f[i] - 1];
  }
  return sum;
}

bool isSolved() {
  for ( int i = 0; i < N2; i++ ) if ( state.f[i] != i + 1 ) return false;
  return true;
}


bool dfs(int depth, int prev) {
  if ( state.MD == 0 ) return true;
  if ( depth + state.MD > limit ) return false;

  int sx = state.space / N;
  int sy = state.space % N;
  Puzzle tmp;

  for ( int r = 0; r < 4; r++ ) {
    int tx = sx + dx[r];
    int ty = sy + dy[r];
    if ( tx < 0 || ty < 0 || tx >= N || ty >= N ) continue;
    if ( max(prev, r)-min(prev, r) == 2 ) continue;
    tmp = state;
    state.MD -= MDT[tx * N + ty][state.f[tx * N + ty] - 1];
    state.MD += MDT[sx * N + sy][state.f[tx * N + ty] - 1];
    swap(state.f[tx * N + ty], state.f[sx * N + sy]);
    state.space = tx * N + ty;
    if ( dfs(depth + 1, r) ) { path[depth] = r; return true; }
    state = tmp;
  }

  return false;
}

string iterative_deepening(Puzzle in) {
  in.MD = getAllMD(in);

  for ( limit = in.MD; limit <= LIMIT; limit++ ) {
    state = in;
    if ( dfs(0, -100) ) {
      string ans = "";
      for ( int i = 0; i < limit; i++ ) ans += dir[path[i]];
      return ans;
    }
  }

  return "unsolvable";
}

int main() {
  for ( int i = 0; i < N2; i++ )
    for ( int j = 0; j < N2; j++ )
      MDT[i][j] = abs(i / N - j / N) + abs(i % N - j % N);

  Puzzle in;

  for ( int i = 0; i < N2; i++ ) {
    cin >> in.f[i];
    if ( in.f[i] == 0 ) {
      in.f[i] = N2;
      in.space = i;
    }
  }
  string ans = iterative_deepening(in);
  cout << ans.size() << endl;

  return 0;
}


Measured memory_bytes: 3200
N = int(input())
A = list(map(int, input().split()))
A.sort()


def find(A):
    if len(A) == 1:
        return A.pop()

    if min(A) <= 1000:
        while 1 < len(A):
            m = min(A)
            s = {m}
            for x in A:
                v = x % m
                if 0 < v:
                    s.add(v)
            A = s
        return A.pop()

    for _ in range(10):
        m = min(A)
        s = {m}
        for x in A:
            v = x % m
            if 0 < v:
                s.add(v)
        A = s
    return find(A)


print(find(A))

Measured memory_bytes: 62704
def cmb(n,r,mod):
    if r<0 or r>n:return 0
    r=min(r,n-r)
    return g1[n]*g2[r]*g2[n-r]%mod


mod=10**9+7
n,k=map(int,input().split())
g1=[1,1]
g2=[1,1]
inverse=[0,1]

for i in range(2,n+2):
    g1.append((g1[-1]*i)%mod)
    inverse.append((-inverse[mod%i]*(mod//i))%mod)
    g2.append((g2[-1]*inverse[-1]%mod))

A=[]
for i in range(k):
    a,b=n-k+1,i+1
    ans=cmb(a,b,mod)*cmb(k-1,i,mod)%mod
    A.append(ans)

for i in A:print(i)

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



int main(){
    int N,x,y;
    x = 0,y = 0;
    int ans = 0;
    cin >> N;
    int v[N],c[N];
    for(int i = 0; i < N;i++){
        cin >> v[i];
    }
    for(int i = 0; i < N;i++){
        cin >> c[i];
    }

    // この品物を買うことで得をするか損をするかのみ考えればよい。
    for(int i = 0;i < N; i++){
        ans += max(0,v[i]-c[i]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
long long modpow(long long a, long long b){
  long long ans = 1;
  while (b > 0){
    if (b % 2 == 1){
      ans *= a;
      ans %= MOD;
    }
    a *= a;
    a %= MOD;
    b /= 2;
  }
  return ans;
}
long long modinv(long long a){
  return modpow(a, MOD - 2);
}
vector<long long> mf = {1};
vector<long long> mfi = {1};
long long modfact(int n){
  if (mf.size() > n){
    return mf[n];
  } else {
    for (int i = mf.size(); i <= n; i++){
      long long next = mf.back() * i % MOD;
      mf.push_back(next);
      mfi.push_back(modinv(next));
    }
    return mf[n];
  }
}
long long modfactinv(int n){
  if (mfi.size() > n){
    return mfi[n];
  } else {
    return modinv(modfact(n));
  }
}
long long modbinom(int n, int k){
  if (n < 0 || k < 0 || k > n){
    return 0;
  } else {
    return modfact(n) * modfactinv(k) % MOD * modfactinv(n - k) % MOD;
  }
}
int main(){
  int N, K;
  cin >> N >> K;
  for (int i = 1; i <= K; i++){
    cout << modbinom(K - 1, i - 1) * modbinom(N - K + 1, i) % MOD << endl;
  }
}

Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int main() {

	int n;
	cin >> n;
	cout << pow(n, 3) << endl;

	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1000000;
#include <map>
#include <math.h>
 
using ll = long long;
using namespace std;

ll n, k;
const ll mod = 1000000007;

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if(a+b>c+d) out("Left");
    else if(a+b<c+d) out("Right");
    else out("Balanced");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n;i++)
using namespace std;
int main(){
    string s;
    cin >> s;
    int len = s.size();
    int cnt = 0;
    rep(i, len / 2){
        if(s[i]!=s[len-i-1]){
            cnt++;
        }
    }
    cout << cnt << endl;
}

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

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<pii> vpii;

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int h, w, k;
    cin >> h >> w >> k;

    vector<string> vs(h);
    rep(i, h) cin >> vs[i];

    vvi ans(h, vi(w, 0));
    int cur = 1;
    rep(y, h) rep(x, w) {
        if (vs[y][x] == '#') {
            ans[y][x] = cur++;
        }
    }

    rep(y, h) {
        for (int x = 1; x < w; x++) {
            if (ans[y][x - 1] > 0 and ans[y][x] == 0) {
                ans[y][x] = ans[y][x - 1];
            }
        }
        for (int x = w - 2; x >= 0; x--) {
            if (ans[y][x + 1] > 0 and ans[y][x] == 0) {
                ans[y][x] = ans[y][x + 1];
            }
        }
    }

    rep(x, w) {
        for (int y = 1; y < h; y++) {
            if (ans[y - 1][x] > 0 and ans[y][x] == 0) {
                ans[y][x] = ans[y - 1][x];
            }
        }
        for (int y = h - 2; y >= 0; y--) {
            if (ans[y + 1][x] > 0 and ans[y][x] == 0) {
                ans[y][x] = ans[y + 1][x];
            }
        }
    }

    rep(y, h) {
        rep(x, w) cout << ans[y][x] << " ";
        cout << endl;
    }

    return 0;
}


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

int main(){
	int N, i;
	cin >> N;
	
	int A[N], B[N], C[N];
	for(i=0; i<N; i++){
		cin >> A[i];
	}
	for(i=0; i<N; i++){
		cin >> B[i];
	}
	for(i=0; i<N-1; i++){
		cin >> C[i];
	}
	
	int ans=0;
	for(i=0; i<N; i++){
		ans+=B[i];
	}
	for(i=0; i<N-1; i++){
		if(A[i]+1==A[i+1])	ans+=C[A[i]-1];
	}
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <cstring>
#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;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

void solve(){
  int N; cin >> N;
  priority_queue<int> pql, pqr; ll ans = 0;
  vector<pair<int, ll>>p, q;
  rep(i, N){
    int k; ll l, r; cin >> k >> l >> r;
    ans+=min(l, r);
    if(l>r) p.push_back({k, l-r});
    else q.push_back({N-k, r-l});
  }
  sort(p.begin(), p.end()); sort(q.begin(), q.end());
  int cnt = 0; 
  for(auto pp: p){
    ll fi = pp.first, se = pp.second; cnt++;
    pql.push(-se); ans+=se;
    if(cnt>fi){
      ans+=pql.top(); pql.pop(); cnt--; //cout << cnt << " " << fi << endl;
    }
  }
  cnt = 0;
  for(auto qq: q){
    ll fi = qq.first, se = qq.second; cnt++;
    pqr.push(-se); ans+=se;
    if(cnt>fi){
      ans+=pqr.top();  pqr.pop(); cnt--; //cout << cnt << " " << fi << " " << endl;
    }
  }
  cout << ans << endl;
}

int main(){
  int T; cin >> T;
  while(T--) solve();
}

Measured memory_bytes: 7816
using System;
class p
{
  static void Main()
  {
    string[] input = Console.ReadLine().Split(' ');
    int N = int.Parse(input[0]);
    int X = int.Parse(input[1]);
    input = Console.ReadLine().Split(' ');
    
    int count = 1, prevD = 0;
    for (int i = 0; i < N; i++) {
      int l = int.Parse(input[i]);
      int d = prevD + l;
      if (X < d) { break; }
      count++;
      prevD = d;
    }
    Console.WriteLine(count);
  }
}

Measured memory_bytes: 13140
#include <stdio.h>

int main()
{
	int height[10];
	unsigned int nazo;
	unsigned char i,j;	
	for(i=0;i<10;i++) scanf("%d",&height[i]);
	for(i=0;i<10;i++){
	for(j=i+1;j<10;j++){
	if(height[i]>height[j]){
	nazo=height[i];
	height[i] = height[j];
	height[j] = nazo; }
	}
}
	for(i=9;i>6;i--)printf("%d\n",height[i]);
	exit(0);
}

Measured memory_bytes: 600
import java.util.Arrays;
import java.util.Scanner;

class Main {
	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int n=scanner.nextInt();
		int h=scanner.nextInt();
		int[] a=new int[n];
		int[] b=new int[n];
		for(int i=0;i<n;i++) {
			a[i]=scanner.nextInt();
			b[i]=scanner.nextInt();
		}
		Arrays.sort(a);
		Arrays.sort(b);
		int l=-1;
		int r=b.length;
		while(r-l>1) {
			int mid=(l+r)/2;
			if(a[n-1]<=b[mid]) {
				r=mid;
			}else {
				l=mid;
			}
		}
		int d=0;
		int cnt=0;
		for(int i=r;i<n;i++) {
			d+=b[n-1-i+r];
			cnt++;
			if(d>=h) {
				System.out.println(cnt);
				return;
			}
		}
		h-=d;
		System.out.println(cnt+(int)Math.ceil((double)h/a[n-1]));
	}
}

Measured memory_bytes: 82796
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<map>
using namespace std;
int main() {
    int N, C, K;
    cin >> N >> C >> K;
    int T[100010];
    for(int i = 0; i < N; i++) cin >> T[i];
    int take = 0;
    int bus = 0;
    int first = 0;
    sort(T,T+N);
    for(int i = 0; i < N;){
        while(take < C && T[i+take] <= T[i]+K){
            take++;//while内のtake +1で出される
        }
        bus++;
        i += take;
        take = 0;
    }
    cout << bus << endl;
    return 0;
}

Measured memory_bytes: 3964
import collections

n =int(input())
X = [list(map(str, ''.join(sorted(input())))) for i in range(n)]
for i in range(n):
    X[i] = ''.join(X[i])
c = collections.Counter(X)
result = 0
for k in c.keys():
    if c[k] >= 2:
        res = 0
        for i in range(c[k]):
            res += i
        result += res
print(result)

Measured memory_bytes: 27540
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String args[])
	{
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		int c=scan.nextInt();
		int ar[]=new int[3];
		ar[0]=a;ar[1]=b;ar[2]=c;
		Arrays.sort(ar);
		int aa=ar[2]-ar[0];
		int two=ar[2]-ar[1];
		
		int min=Math.min(aa, two);
		int max=Math.max(aa, two);
//		aa=Math.min(aa, two);
		ar[0]=aa;
		ar[1]=two;
//		System.out.println(ar[0]+" "+ar[1]);
		if(ar[0]%2==0 && ar[1]%2==0)
		{
			System.out.println(ar[0]/2+ar[1]/2);
		}else if(ar[0]%2==1 && ar[1]%2==1)
		{
			System.out.println((ar[0]/2)+(ar[1]/2)+1);
		}else {
			System.out.println(((ar[0]+1)/2)+((ar[1]+1)/2)+1);
		}
//		System.out.println(operations);
			
	}
}


Measured memory_bytes: 25172
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl

ll par[1000000];
ll Rank[100000];
ll N;
void init(){
  rep(i,N){
    Rank[i]=0;
    par[i]=i;
  }
}
ll root(ll x){
  return par[x]==x ? x : par[x]=root(par[x]);
}
bool same(ll x,ll y){
  return root(x)==root(y);
}

void unite(ll x,ll y){
  x=root(x);y=root(y);
  if(x==y)return;
  if(Rank[x]<Rank[y]){
    par[x]=y;
  }else{
    par[y]=x;
    if(Rank[x]==Rank[y])Rank[x]++;
  }
}

int main(){
  ll ans=0;
  ll M;cin>>N>>M;
  init();
  vector<ll> p(N);
  rep(i,N){
    cin>>p[i];
  }
  ll x,y;
  rep(i,M){
    cin>>x>>y;
    unite((x-1),(y-1));
  }

  vector<set<ll>> v(N);
  rep(i,N){
    v[root(i)].insert(p[i]-1);
  }

  rep(i,N){
    ans+=v[root(i)].count(i);
  }
  cout<<ans<<endl;
    
  return 0;
}

Measured memory_bytes: 11904
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int m, d; cin >> m >> d;

	int c = 0;
	FOR_LE(i, 1, m) {
		FOR_LE(j, 10, d) {
			if (j / 10 <= 1 || j % 10 <= 1) continue;
			if (i == (j / 10) * (j % 10)) {
				c++;
			}
		}
	}
	cout << c << endl;

	return 0;
}

Measured memory_bytes: 256
program name
    use,intrinsic :: iso_fortran_env
    implicit none
    character(3000):: s,t,res
    integer(int32):: sl,tl,si,ti
    integer(int32), allocatable:: dp(:,:)

    read*, s
    read*, t
    sl = len_trim(s)
    tl = len_trim(t)

    allocate(dp(0:sl,0:tl))
    dp(:,:) = 0

    do ti=1,tl
        do si=1,sl
            if (s(si:si) == t(ti:ti)) then
                call chmax(dp(si,ti), dp(si-1,ti-1)+1)
            end if
            call chmax(dp(si,ti), dp(si,ti-1))
            call chmax(dp(si,ti), dp(si-1,ti))
        end do
    end do

    ti=tl
    si=sl
    res=''
    do while(ti>0 .and. si>0)
        ! print*, ti,si
        if (dp(si,ti) == dp(si-1,ti)) then
            si=si-1
        else if (dp(si,ti) == dp(si,ti-1)) then
            ti=ti-1
        else
            res=s(si:si)//trim(res)
            si=si-1
            ti=ti-1
        end if
    end do

    print'(a)', trim(res)

contains
    subroutine chmax(x,y)
        integer(int32):: x,y
        if (x < y) x = y
    end subroutine

end program name

Measured memory_bytes: 35456
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        double[] v = new double[n];
        for (int i = 0; i < n; i++) {
            v[i] = sc.nextDouble();
        }
        Arrays.sort(v);
        for (int i = 1; i < n; i++) {
            v[i] = (v[i-1] + v[i])/2.0;
        }
        System.out.println(v[n-1]);
        sc.close();

    }

}


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

using namespace std;

class dice {

public:

	int TOP, S, E, W, N, BOTTOM, tmp;

	void rotN () {
		tmp = N;
		N = TOP; TOP = S; S = BOTTOM, BOTTOM = tmp;
	}
	void rotE () {
		tmp = E;
		E = TOP; TOP = W; W = BOTTOM; BOTTOM = tmp;
	}
	void rotW () {
		tmp = W;
		W = TOP; TOP = E; E = BOTTOM; BOTTOM = tmp;
	}
	void rotS () {
		tmp = S;
		S = TOP; TOP = N; N = BOTTOM; BOTTOM = tmp;
	}
	void clockwise () {
		tmp = W;
		W = S; S = E; E = N; N = tmp;
	}
	void antiClockwise () {
		tmp = W;
		W = N; N = E; E = S; S = tmp;
	}
};


// 違うならtrueを返す

bool same_dice(dice dice_1, dice dice_2){

    int j = 0;

    while( (dice_1.TOP != dice_2.TOP || dice_1.BOTTOM != dice_2.BOTTOM) && j != 7){
        dice_1.rotN();
        // cout << "rotN" << endl;
        j++;
        if(j == 4){
            dice_1.rotE();
            // cout << "rotE" << endl;
        }
    }

    if( j == 7){
        return false;
    }

    j = 0;

    while( (dice_1.N != dice_2.N  || dice_1.E != dice_2.E || dice_1.W != dice_2.W || dice_1.S != dice_2.S) && j < 4){
        dice_1.clockwise();
        // cout << "clock : " << j << endl; 
        j++;
    }

    if(j == 4){
        return false;
    }else{
        return true;
    }

}

int main(){

    int i, j; 
    int n;

    cin >> n;

    int dices_nums[n][6];

    for(i=0;i<n;i++){
        for(j=0;j<6;j++){
            cin >> dices_nums[i][j];
        }
    }

    for(i=0;i<n-1;i++){
        for(j=i+1;j<n;j++){
            dice dice_1 = {dices_nums[i][0], dices_nums[i][1], dices_nums[i][2], dices_nums[i][3], dices_nums[i][4], dices_nums[i][5]};
            dice dice_2 = {dices_nums[j][0], dices_nums[j][1], dices_nums[j][2], dices_nums[j][3], dices_nums[j][4], dices_nums[j][5]};
            if ( same_dice(dice_1, dice_2) ){
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;

    return 0;

}

// https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_ITP1_11_A_1


Measured memory_bytes: 3100
using Atcoder;
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var firstLine = Console.ReadLine().Split(' ').Select(int.Parse).OrderBy(x => x).ToArray();
            Console.WriteLine(firstLine[0] + firstLine[1]);
        }

    }

    //var N = int.Parse(Console.ReadLine());
    //var S = Console.ReadLine();
    //var K = Console.ReadLine().Split(' ');
    //var N = int.Parse((K[0]));
    //var M = int.Parse((K[1]));
    //var firstLine = Console.ReadLine().Split(' ').Select(int.Parse);
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n+1); ++i)
const double PI  =3.141592653589793238463;
using namespace std;
using ll = long long;
const ll INF = +10010010000;
typedef pair<int,int> P;
const int mod = 1e9+7;

struct mint{
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint& operator+=(const mint a){
        (x+=a.x)%=mod;
        return *this;
    }
    mint& operator-=(const mint a){
        (x-=mod-a.x)%=mod;
        return *this;
    }
    mint& operator*=(const mint a){
        (x *= a.x)%= mod;
        return *this;
    }
    mint operator+(const mint a)const{
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a)const{
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a)const{
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
      if(!t)return 1;
      mint a = pow(t>>1);
      a*=a;
      if(t%1)a*=*this;
      return a;
    }

    // for prime mod
    mint inv() const {
      return pow(mod-2);
    }
    mint& operator/=(const mint a){
      return (*this) *= a.inv();
    }
    mint operator/(const mint a)const{
      mint res(*this);
      return res/=a;
    }
};

struct combination{
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1){
    fact[0] = 1;
    for(int i = 1; i<n;++i)fact[i] = fact[i-1] * i;
    ifact[n] = fact[n].inv();
    for(int i = n; i>=1;--i) ifact[i-1] = ifact[i] * i;
  }
  mint operator()(int n, int k){
    if(k<0 || k>n)return 0;
    return fact[n] * ifact[k] + ifact[n-k]; 
  }
};

int main(){
    int x, n;
    cin >> x >> n;
    set<int> p;
    rep(i,n){
        int pp;
        cin >> pp;
        p.insert(pp);
    }
    int mini = 1000;
    int v_min = 150;
    rep(i,150){
        if(p.count(i)>0)continue;
        else if(mini >abs(i-x)){
            mini = abs(i-x);
            v_min = i;
        }
    }
    cout << v_min << endl;
    return 0;
}

Measured memory_bytes: 3596
#include<stdio.h>

int main(void)
{
	int n, c, i, x, z;
	scanf( "%d", &n );
	int a[n];
	for( i = 0; i < n; i++ ){
		scanf( "%d", &a[i] );
	}
	
	c = 0;
	x = 1;
	
	while( x == 1 ){
		x = 0;
		for( i = n-1; i > 0; i-- ){
			if( a[i] < a[i-1] ){
				z = a[i];
				a[i] = a[i-1];
				a[i-1] = z;
				x = 1;
				c++;
			}
		}
	}
	
	printf( "%d", a[0] );
	for( i = 1; i < n; i++ ){
		printf( " %d", a[i] );
	}
	
	printf( "\n%d\n", c );
	
	return 0;
}


Measured memory_bytes: 2040
#include "bits/stdc++.h"
using namespace std;

int H, W, INF = 1000000000;
static int Dis[1000][1000] = {}, dx[4] = { 1, -1, 0, 0 }, dy[4] = { 0, 0, 1, -1 };
string S[1000];

void BFS() {
	queue<pair<int, int> > Q;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (S[i][j] == '#') {
				Dis[i][j] = 0;
				Q.push(pair<int, int>(i, j));
			}
			else Dis[i][j] = INF;
		}
	}
	while (Q.size()) {
		pair<int, int> p;
		p = Q.front();
		Q.pop();
		for (int i = 0; i < 4; i++) {
			int nx = p.first + dx[i], ny = p.second + dy[i];
			if (nx != -1 && nx != H && ny != -1 && ny != W) {
				if (Dis[nx][ny] == INF && S[nx][ny] == '.') {
					Q.push(pair<int, int>(nx, ny));
					Dis[nx][ny] = Dis[p.first][p.second] + 1;
				}
			}
		}
	}
}

int main() {
	int ans = 0;
	cin >> H >> W;
	for (int i = 0; i < H; i++) {
		cin >> S[i];
	}
	BFS();
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			ans = max(ans, Dis[i][j]);
		}
	}
	cout << ans;
}

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

using namespace std;

#define DBG cerr << '!' << endl;
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define PI 3.14159265359

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

int main()
{
	int n;cin >> n;
	vector<int> v(n+2);
	v[0] = v[n+1] = 0;
	REP(i,n)cin >> v[i+1];
	int sum = 0;
	
	REP(i,n+1){
		sum += abs(v[i] - v[i+1]);
	}
	
	
	REP(i,n){
		int tmp = abs(v[i] - v[i+2]) - (abs(v[i] - v[i+1]) + abs(v[i+1] - v[i+2]));
		cout << sum + tmp << endl;
	}

	return 0;
}


Measured memory_bytes: 1664
N,M=map(int,input().split())
*H,=map(int,input().split())

graph = [[] for _ in range(N)]
    
for _ in range(M):
    a,b=map(int,input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

print(sum(all(H[j]<H[i]  for j in graph[i]) for i in range(N)))

Measured memory_bytes: 29256
import math
import numpy as np
A, B = map(int, input().split())


def count(i):
    n = 1
    c = 0
    while n < i:
        c += 1
        n *=2
    return c

def check(i):
    lst = [0] * count(i)
    for j in range(len(lst)):
        if i%(2 ** (j+1)) == i%(2 ** j):
            tmp = (i//(2 ** (j+1)) * (2 ** j))
        else:
            tmp = (i//(2 ** (j+1)) * (2 ** j)) + i%(2 ** j)
        lst[j] = tmp
    return lst

lstA = check(A)
lstB = check(B+1)
# print ('A', lstA)
# print ('B', lstB)
for k in range(len(lstA)):
    lstB[k] -= lstA[k]

# print (lstB)
ans = 0
for l in range(len(lstB)):
    ans += (2 ** l) * (lstB[l]%2)

print (ans)

# for i in range(1,9):
#     print (i, check(i+1))

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

static const int INF = 1001001001;
static const int MAX = 2005;
ll dp[MAX][MAX];

int main(){
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    rep(i, n+1) rep(j, n+1) dp[i][j] = -INF;
    dp[0][0] = 0;
    vector<P> p;
    rep(i,n) p.emplace_back(a[i],i);
    sort(p.rbegin(), p.rend());
    rep(i,n){
        int pi = p[i].second;
        rep(l,i+1) {
            int r = i - l;
            dp[i+1][l+1] = max(dp[i+1][l+1] , dp[i][l]+ll(pi-l)*a[pi]);
            dp[i+1][l] = max(dp[i+1][l], dp[i][l]+ll((n-r-1)-pi)*a[pi]); 
        }
    }
    ll ans = 0;
    rep(i,n+1) ans = max(ans, dp[n][i]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 34924
n = int(input())
a = [1]*10000001 
b = [1]*10000001
c = [0]*(n+1)
answer = 0
for i in range(1000001):
  a[i+1] = (a[i]*9)%1000000007
for j in range(1000001):
  b[j+1] = (b[j]*8)%1000000007
if(n==1):
  print(0)
else:
  for k in range(2,n+1):
    c[k] = 2*a[k-1]-2*b[k-1]+10*c[k-1]
    c[k] = c[k]%1000000007
  print(c[n])

Measured memory_bytes: 268164
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

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

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int r, g, b, n;
	cin >> r >> g >> b >> n;
	int ans = 0;
	REP(i, n / r+1) {
		REP(j, n / g+1) {
			
			if (n>=i*r+j*g&&(n - i * r - j * g) % b == 0)ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

void	ft_swap(int *x, int *y)
{
	int temp;

	temp = *x;
	*x = *y;
	*y = temp;
}

int		euclid(int small, int big)
{
	int amari = 0;

	if(small > big)
		ft_swap(&small, &big);
	while (1)
	{
		if((amari = big % small) == 0)
			return small;
		big = small;
		small = amari;
	}
	return (0);
}

int		main(void)
{
	int a = 0;
	int b;
	int c;
	int K;
	int ans = 0;
	int buff;

	scanf("%d", &K);
	while (++a <= K)
	{
		b = 0;
		while (++b <= K)
		{
			c= 0;
			while (++c <= K)
			{
				buff = euclid(a, b);
				ans = ans + euclid(buff, c);
			}
		}
	}
	printf("%d\n", ans);
	return (0);
}


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

int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector <int> a(n);
	long long sum = 0;
	map <int, int> m;
	for (int &i : a)  { cin >> i; sum += i; ++m[i];}
	int q;
	cin >> q;
	int b, c;
	while (q--) {
		cin >> b >> c;
		sum += (m[b] * (c - b));
		m[c] += m[b];
		m[b] = 0;
		cout << sum << '\n';
	}
}


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

typedef long long ll;
typedef unsigned long long ull;

bool pair_comp(pair<ll, ll> &a, pair<ll, ll> &b) {
  return a.second > b.second;
}

int main() {
  vector<ll> v(5);
  for (ll i = 0; i < 5; ++i) {
    cin >> v[i];
  }

  ll ans = 0;
  vector<pair<ll, ll>> vt;
  for (ll i = 0; i < 5; ++i) {
    if (v[i] % 10 == 0) {
      ans += v[i];
    } else {
      ll tmp = v[i] - ((v[i] / 10) * 10);
      vt.push_back(pair<ll, ll>(i, tmp));
    }
  }

  if (vt.size() > 0) {
    sort(vt.begin(), vt.end(), pair_comp);

    for (ll i = 0; i < vt.size()-1; ++i) {
      ans += v[vt[i].first] - vt[i].second + 10;
    }
    ans += v[vt[vt.size()-1].first];
  }

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

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
typedef long long int ll;
int main(){
ll n;
cin >> n;
int a[n];
int b[n];
for(int i=0;i<n;i++){
  cin >> a[i];
  if(i==0) b[i]=n-1;
  else{
  if(n%2==1){
  if(i<=n/2)  b[i]=b[i-1]-2;
  else b[i]=b[i-1]+2;
  }
  else{
    if(i<n/2) b[i]=b[i-1]-2;
    else if(i==n/2) b[i]=b[i-1];
    else b[i]=b[i-1]+2;
  }
 }
}
sort(a,a+n);
sort(b,b+n);
for(int i=0;i<n;i++){
  if(a[i]!=b[i]){
    cout <<0<<endl;
    return 0;
  }
}
  ll ans=1;
for(int i=0;i<n/2;i++){
    ans*=2;
    ans%=(1000000007);
}
cout <<ans<<endl;
}


Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<utility>
#include<queue>
#include<stdbool.h>
#include<math.h>
#include<sstream>
typedef long long ll;
#define N (1000000000+7)
#define INF (-1000000)
using namespace std;
typedef pair<int, int> P;

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

int d[55][55];

char board[55][55];
int h, w;

int bfs() {
	queue<P>q;
	for (int i = 1;i <= h;i++) {
		for (int j = 1;j <= w;j++) {
			d[i][j] = INF;
		}
	}
	q.push(P(1, 1));
	d[1][1] = 0;
	while (!q.empty()) {
		P p = q.front();q.pop();
		if ((p.first == h) && (p.second == w))break;
		for (int i = 0;i < 4;i++) {
			int nx = p.first + dx[i];
			int ny = p.second + dy[i];
			if ((1 <= nx) && (nx <= h) && (1 <= ny) && (ny <= w) && (board[nx][ny] != '#') && (d[nx][ny] == INF)) {
				q.push(P(nx, ny));
				d[nx][ny] = d[p.first][p.second] + 1;
			}
		}
	}
	return d[h][w];
}

int t[100010], x[100010], y[100010];

int main(void) {
	string a, b, c;
	cin >> a >> b;
	c = a + b;
	int x = stoi(c);
	for (int i = 0;i < 400;i++) {
		if (i*i == x) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
//BY: YASH JAIN, CF: yashjain0333
#include <bits/stdc++.h>
using namespace std;
#define May_the_fork_be_with_you ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define MOD 1000000007
#define ll long long
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define endl "\n"
// #define N 100

void solve(){
    string s; cin>>s;
    int sum = 0;
    for(int i=0;i<s.length();i++){
        sum += (s[i]-'0');
    }
    if(sum%9) cout<<"No";
    else cout<<"Yes";
}

int32_t main(){
    May_the_fork_be_with_you
    int t = 1; 
    // cin>>t;
    while (t--)
        solve();
}


Measured memory_bytes: 3740
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001



int main (){
    int N, M, C; cin >> N >> M >> C;
    vector<int> B(M);
    vector<vector<int>> A(N, vector<int>(M));
    for(int &b:B)
        cin >> b;
    for(vector<int> &v:A)
        for(int &a:v)
            cin >> a;
    
    
    int ret = 0;
    for(int i=0; i<N; i++){
        ll sum = C;
        for(int j=0; j<M; j++){
            sum += A[i][j]*B[j];
        }
        if(sum > 0) ret++;
    }
    
    cout << ret << endl;
    return 0;
}



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

#define  SZ(items) (int)items.size()
#define  CLR(a)  memset(a,0,sizeof(a))
#define  SET(a)  memset(a,-1,sizeof(a))

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

template <class T> inline T gcd(T a, T b) { while (b) { a = a%b; swap(a, b); } return a; }


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int H, W, h, w;
	cin >> H >> W >> h >> w;

	int painted = h*W+(H-h)*w;

	cout << H*W- painted << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define ALL(a) a, a+sizeof(a)/sizeof(a[0])
#define all(a) a.begin(),a.end()
using namespace std;
ll gcd(ll n, ll m) {
	if (m == 0) return n;
	return gcd(m, n % m);
}
ll lcm(ll n, ll m) {
	return m / gcd(n, m) * n;
}
//各桁の和を求める
ll dig_sum(ll num) {
	int dig, sum = 0;
	while (num) {
		dig = num % 10;
		sum = sum + dig;
		num = num / 10;
	}
	return sum;
}
int alpha[26];

int main(void) {
	int n;
	string s,t;
	cin >> n >> s >> t;
	alpha[s[0] - 'a'] = 1;
	for (int i = 1; i < n - 1; i++) {
		alpha[s[i] - 'a'] += alpha[t[i] - 'a'];
		alpha[s[i] - 'a'] %= 1000000007;
	}
	cout << alpha[t[n - 1] - 'a']<<endl;
	return 0;
}


Measured memory_bytes: 3332
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>
#include <complex>
 
 
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 pb push_back
#define mp make_pair
#define fi first
#define se second
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
 
 
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
 
const int MOD =  1e9 + 7; 
 
 
 
ll power(ll a, ll b){
	if(b == 0) return 1;
	else {
		ll x = power(a,b/2);
		x = (x*x)%MOD;
		if(b&1) return (x*a)%MOD;
		else return x;
	}
}
 
 
ll& Mod(ll& a) {
    if (a >= MOD) {
        return Mod(a -= MOD);
    } else if (a < 0) {
        return Mod(a += MOD);
    } else {
        return a;
    }
}
 
ll gcd(ll a, ll b) { 
	// b < a
    if (b == 0) 
        return a; 
    return gcd(b, a % b); 
} 
 



int main() {
	fast_cin();	
	
	set<int> s;
	int n; cin >> n;
	for(int i = 0; i < n; i++){
		int a; cin >> a; s.insert(a);
	}
	
	if(s.size() == n){
		cout << "YES" << '\n';
	}
	else{
		cout << "NO" << '\n';
	}
	
	
	
	
	
		
}


Measured memory_bytes: 9600
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		char []c = sc.next().toCharArray();
		
		int n = c.length;
		
		boolean jdg = true;
		for(int i = 0 ; i < (n-1)/2 ; i++) {
			if(c[i] != c[(n+2)/2 + i]) {
				jdg = false;
			}
		}
		if(jdg) {
			System.out.println("Yes");
		} 
		else {
			System.out.println("No");
		}

	}

}


Measured memory_bytes: 23124
X, K, D = map(int, input().split())
p = (abs(X)+D-1)//D
if p >= K:
    print(abs(abs(X)-K*D))
    exit()
K -= p
if X > 0:
    X = X-p*D
else:
    X = X+p*D
plus, minus = 0, 0
if X > 0:
    plus = K//2
    minus = (K+1)//2
else:
    plus = (K+1)//2
    minus = K//2
# print(X, plus, minus)
print(abs(X+plus*D-minus*D))


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

using namespace std;
#define BUF (2005)
#define ll long long 

int n;
int A[BUF];
int dp[BUF*BUF];

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

	if(sum%2==1) sum++;

	bitset<BUF*BUF> bs(1);
	
	for(int i=1;i<=n;i++) bs = bs|(bs<<A[i]);


	int cnt = sum/2;
	while(bs[cnt]==0)cnt++;
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 2176
#include <cstdio>
#include <algorithm>

const int MN = 200005, MM = 18;

int N, V, A[MN], v[MM], M;
int L[MM + 1][MN], R[MM + 1][MN];
int fl[1 << MM], fr[1 << MM];
int val[MN];

int main() {
	scanf("%d%d", &N, &V);
	for (int i = 1; i <= N; ++i) scanf("%d", &A[i]);
	for (int x = V; x; ) v[M++] = x /= 2;
	for (int j = 0; j <= M; ++j) {
		int nv = j ? v[j - 1] : V;
		L[j][0] = L[j][1] = 1, R[j][N + 1] = R[j][N] = N;
		for (int i = 2; i <= N; ++i) L[j][i] = A[i] - A[i - 1] > nv ? i : L[j][i - 1];
		for (int i = N - 1; i >= 1; --i) R[j][i] = A[i + 1] - A[i] > nv ? i : R[j][i + 1];
	}
	fl[0] = 0, fr[0] = N + 1;
	for (int S = 1; S < 1 << M; ++S) {
		fl[S] = 0, fr[S] = N + 1;
		for (int j = 0; j < M; ++j) if (S >> j & 1)
			fl[S] = std::max(fl[S], R[j + 1][fl[S ^ 1 << j] + 1]),
			fr[S] = std::min(fr[S], L[j + 1][fr[S ^ 1 << j] - 1]);
	}
	for (int i = 0; i <= N; ++i) val[i] = N + 2;
	for (int S = 0; S < 1 << M; ++S)
		val[fl[S]] = std::min(val[fl[S]], fr[((1 << M) - 1) ^ S]);
	for (int i = N - 1; i >= 0; --i) val[i] = std::min(val[i], val[i + 1]);
	for (int i = 1; i <= N; ++i) puts(val[L[0][i] - 1] <= R[0][i] + 1 ? "Possible" : "Impossible");
	return 0;
}

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

int main(void){
    int n;
    std::cin >> n;
    std::vector<int> b(n-1);
    for(int i = 0; i < n-1; i++){
        std::cin >> b[i];
    }
    int ans = 0;
    ans += b[0];
    for(int i = 0; i < n-2; i++){
        ans += std::min(b[i], b[i+1]);
    }
    ans += b[n-2];
    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
int N, ans = 0;
string str;
map<string, int> mp;

int main(){
    cin >> N;
    for(int i=0;i<N;i++){ cin >> str; mp[str] = 1;}
    for(auto i = mp.begin(); i != mp.end(); ++i) ans += i->second;
    cout << ans << endl;
    return 0;  
}

Measured memory_bytes: 19156
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const ll mod = 1e9+7;

int n,l;
vector<string> s;

int main()
{
    cin >> n >> l;
    s.resize(n); rep(i,n) cin >> s[i];
    sort(all(s));
    rep(i,n) rep(j,l) cout << s[i][j];
    cout << endl;
}



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

using namespace std;

int main(void) {
  int n, h;
  cin >> n >> h;
  vector<int> a(n), b(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
  }

  int max = a[0];
  int max_itr = 0;
  for (int i = 0; i < n; i++) {
    if (max < a[i]) {
      max = a[i];
      max_itr = i;
    }
  }

  int count = 0;
  sort(b.rbegin(), b.rend());
  for (int i = 0; i < n; i++) {
    if (b[i] > max) {
      count++;
      h -= b[i];
      if (h <= 0) {
        cout << count << endl;
        return 0;
      }
    } else {
      break;
    }
  }

  count += h / max;
  if (h % max != 0) {
    count++;
  }

  cout << count << endl;
}

Measured memory_bytes: 1024