akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int main() {
#ifdef LBT
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif

  int n;
  scanf("%d", &n);
  vector<tuple<int, int, int, int>> block;
  block.reserve(n);
  int m = 0;
  while (n--) {
    int w, s, v;
    scanf("%d%d%d", &w, &s, &v);
    m = max(m, w + s);
    block.emplace_back(w + s, w, s, v);
  }
  sort(block.begin(), block.end());
  vector<ll> dp(m + 1);
  for (const auto& tup : block) {
    int key, w, s, v;
    tie(key, w, s, v) = tup;
    for (int i = s; i >= 0; --i)
      dp[i + w] = max(dp[i + w], dp[i] + v);
  }
  printf("%lld\n", *max_element(dp.begin(), dp.end()));

#ifdef LBT
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e2 + 5;

int a[maxn];
int b[maxn];
int c[maxn];

int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
        scanf("%d", a + i);
    for (int i = 0; i < n; i++)
        scanf("%d", b + i);
    for (int i = 0; i < n - 1; i++)
        scanf("%d", c + i);
    int sum = 0;
    for (int i = 0; i < n; i++) {
        if (i > 0 && (a[i - 1] + 1 == a[i])) {
            sum += b[a[i] - 1];
            sum += c[a[i - 1] - 1];
        } else {
            sum += b[a[i] - 1];
        }
    }
    cout << sum;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int ans = 0;
        boolean error = false;
        int [] num = new int[N];
        for(int i=0;i<N;i++){
            num[i] = -1;
        }

        for(int i=0;i<M;i++){
            int s = sc.nextInt();
            int c = sc.nextInt();
            if(s > N){
                error = true;
                break;
            }
            if(c == num[s-1] || num[s-1] == -1){
                num[s-1] = c;
            } else {
                error = true;
                break;
            }

        }
        if(num[0] == 0){
            if(N != 1){
                error = true;
            }

        } else if (num[0] == -1){
            if(N != 1){
                num[0] = 1;
            } else {
                num[0] = 0;
            }
        }

        for(int i=0;i<N;i++) {
            if (num[i] == -1) {
                num[i] = i == 0 ? 1 : 0;
            }
            ans += num[i] * Math.pow(10, N - 1 - i);
        }

        if(error){
            ans = -1;
        }

        System.out.println(ans);


    }

}








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

using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n); i > 0; i--)
#define print(n) cout << n << endl

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    int r;
    cin >> r;

    print(2*M_PI*r);
    return 0;
}

Measured memory_bytes: 3804
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(){
    int n;
    int t,x,y;
    int _t=0,_x=0,_y=0;
    int dt,dx,dy;
    int dist;

    scanf("%d",&n);

    for(int i=1;i<=n;i++){
        //printf("%d",i);
        scanf("%d%d%d",&t,&x,&y);
        dt=t-_t;
        dx=x-_x;
        dy=y-_y;

        dist=abs(dx)+abs(dy);

        if(dt<dist){
            printf("No");
            return 0;
        }
        if((dist%2)^(dt%2)){
            printf("No");
            return 0;
        }
        
    }
    printf("Yes");


    return 0;
}

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

using namespace std;

int main(){
    int cards[4][14] = {};
    int n;cin >> n;
    vector<char>kind(n);
    vector<int>nkind(n),rank(n);
    for(int i=0;i<n;i++){
        cin >> kind[i] >> rank[i];
        if(kind[i] == 'S'){
            nkind[i] = 0;
        }else if(kind[i] == 'H'){
            nkind[i] = 1;
        }else if(kind[i] == 'C'){
            nkind[i] = 2;
        }else{
            nkind[i] = 3;
        }
        cards[nkind[i]][rank[i]] = 1;
    }
    for(int i=0;i<4;i++){
        for(int j=1;j<14;j++){
            if(cards[i][j]==0){
                if(i==0){
                    cout << "S " << j << endl;
                }else if(i==1){
                    cout << "H " << j << endl;
                }else if(i==2){
                    cout << "C " << j << endl;
                }else{
                    cout << "D " << j << endl;
                }
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3092
function Main(input){
    input = input.split(" ");
    var a = BigInt(input[0]);
    // 小数点を外してx100の状態にして
    var b = BigInt(input[1].split(".").join(""));
    // あとで100割ってnを外す
    console.log(String(a*b/100n).split("n").join(""));
  }
Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());


Measured memory_bytes: 29524
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;
    cin >> N;
    vector<int> A(N),B(N),C(N - 1);
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    for(int i = 0; i < N; i++){
        cin >> B[i];
    }
    for(int i = 0; i < N - 1; i++){
            cin >> C[i];
        }
    int S = B[A[0] - 1];
    
    for(int i = 1; i < N; i++){
        S += B[A[i] - 1];
        if(A[i] == A[i - 1] + 1){
            S += C[A[i - 1] - 1];
        }
        //cout << S << endl;
    }
    cout << S << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int a, b, c;
    cin >> a >> b >> c;
    
    int cnt = 0;
    
    if(a == b and b == c and  a == c) cnt = 1;
    else if(a == b or b == c or a == c ) cnt = 2;
    else cnt = 3;

    cout << cnt << endl;

}


Measured memory_bytes: 3524
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 210000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ

int p[30];
long long dp[23][1100];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<b;i++){
		scanf("%d",p+i);
	}
	init_C(110000);
	dp[0][0]=1;
	for(int i=0;i<b;i++){
		for(int j=0;j<=a;j++){
			if(!dp[i][j])continue;
			for(int k=0;j+k<=a;k++){
				if(k>p[i])continue;
				long long ks=Comb(a-j,k)*Comb(a-k,p[i]-k)%mod;
				dp[i+1][j+k]=(dp[i+1][j+k]+dp[i][j]*ks)%mod;
			}
		}
	}
	printf("%lld\n",dp[b][a]);
}

Measured memory_bytes: 9344
# -*- coding: utf-8 -*-
n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))
ri = 0
for i in range(0,n):
    a  = v[i] - c[i] 
    if a>0:
        ri += a
    else:
        pass
print(ri)

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

//square1??¨square2?????????
//sq1>sq2?????¨???1???sq<sq2?????¨???-1???sq1=sq2?????¨???0
int sqcmp(int h1,int w1,int h2,int w2){
    double l1=h1*h1+w1*w1, l2=h2*h2+w2*w2;
    if(l1!=l2){
        if(l1>l2) return 1;
        else if(l1<l2) return -1;
        else return 0;
    }else{
        if(h1>h2) return 1;
        else if(h1<h2) return -1;
        else return 0;
    }
}

int main(void){
    int i,j,h,w,ah,aw;
    for(;;){
        ah=200; aw=200;
        scanf("%d %d", &h, &w);
        if(h==0 && w==0) break;
        for(i=1;i<=150;i++){
            for(j=i+1;j<=150;j++){
                // printf("%d\n", sqcmp(ah,aw,i,j));
                if(sqcmp(i,j,h,w)==1){ //(i,j) > (h,w)
                    if(sqcmp(ah,aw,i,j)==1){ //(ah,aw) > (i,j)
                        //?§£??????????£??????´??°
                        ah=i;
                        aw=j;
                    }
                    break;
                }
            }
        }
        printf("%d %d\n", ah, aw);
        // printf("sqcmp(1,3,1,2): %d\n", sqcmp(1,3,1,2));
        // printf("sqcmp(200,200,1,3): %d\n", sqcmp(200,200,1,3));
        // printf("--------\n");
    }
    return 0;
}

Measured memory_bytes: 600
def resolve():
    '''
    code here
    '''
    N = int(input())
    s = input()
    t = input()

    cnt = 0
    for i in range(N):
        if i == 0:
            if s[-1] == t[0]:
                cnt = 1
        else:
            if s[-1* (i+1):] == t[:(i+1)]:
                cnt = i + 1
    
    print(2*N - cnt)

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 3064
#include<stdio.h>
int main()
{
int a,b,c,r,i;
scanf("%d",&r);
if(r<=1000)
{
for(i=1;i<=r;i++)
{
scanf("\n%d %d %d",&a,&b,&c);
if(a>=1&&a<=1000&&b>=1&&b<=1000&&c>=1&&c<=1000)
  {
    if(((a*a)==(b*b)+(c*c))||((b*b)==(c*c)+(a*a))||((c*c)==(b*b)+(a*a)))
        printf("YES\n");
    else
        printf("NO\n");

  }
}
}
    return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
#define F first
#define S second
#define pb push_back
mt19937 rnd;


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    int n, k, s;
    cin >> n >> k >> s;
    if (s < (int) 1e9) {
        for (int i=1; i<=k; i++) {
            cout << s << " ";
        }
        for (int i=k+1; i<=n; i++) {
            cout << s + 1 << " ";
        }
    }
    else {
        for (int i=1; i<=k; i++) {
            cout << s << " ";
        }
        for (int i=k+1; i<=n; i++) {
            cout << "1 ";
        }
    }
    cout << "\n";

#ifdef LOCAL
    cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
   return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <set>
#include <list>

using namespace std;


int main() {
    int n, flag{1}, count{0}, min_i;
    cin >> n;
    string A[n], tmp_A[n];
    int occ;
    bool stable;

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

    for (int i = 0; i < n; i++) {
        A[i] = tmp_A[i];
    }

    // bubble
    while (flag) {
        flag = 0;
        for (int i = n - 1; i > 0; i--) {
            if (A[i][1] < A[i - 1][1]) {
                swap(A[i], A[i - 1]);
                flag = 1;
                count++;
            }
        }
    }

    for (int i = 0; i < n; i++) {
        cout << A[i];
        if (i == n - 1) cout << endl;
        else cout << " ";
    }
    int cnt, A_idx, tmpA_idx;
    stable = true;
    for (int i = 1; i < 9; i++) {
        occ=0;
        for(int j=0;j<n;j++){
            if(A[j][1]-'0'==i) occ++;
        }
        for(int j=1; j<=occ;j++){
            cnt = 0;
            for(int k=0; k<n; k++){
                if (A[k][1]-'0' ==  i) {cnt++;A_idx=k;}
                if (occ == cnt)break;
            }
            cnt = 0;
            for(int k=0; k<n; k++){

                if (tmp_A[k][1]-'0' == i) {cnt++;tmpA_idx=k;}
                if (occ == cnt)break;
            }
            if(A[A_idx][0]!=tmp_A[tmpA_idx][0])stable=false;
        }
    }
    if(stable) cout << "Stable" << endl;
    else cout << "Not stable" << endl;

    //selection
    for (int i = 0; i < n; i++) {
        A[i] = tmp_A[i];
    }

    for (int i = 0; i < n; i++) {
        min_i = i;
        for (int j = i; j < n; j++)
            if (A[j][1] < A[min_i][1]) min_i = j;

        if (A[i] != A[min_i])count++;
        swap(A[i], A[min_i]);

    }

    for (int i = 0; i < n; i++) {
        cout << A[i];
        if (i == n - 1) cout << endl;
        else cout << " ";
    }
    stable = true;
    for (int i = 1; i < 9; i++) {
        occ=0;
        for(int j=0;j<n;j++){
            if(A[j][1]-'0'==i) occ++;
        }
        for(int j=1; j<=occ;j++){
            cnt = 0;
            for(int k=0; k<n; k++){
                if (A[k][1]-'0' ==  i) {cnt++;A_idx=k;}
                if (occ == cnt)break;
            }
            cnt = 0;
            for(int k=0; k<n; k++){

                if (tmp_A[k][1]-'0' == i) {cnt++;tmpA_idx=k;}
                if (occ == cnt)break;
            }
            if(A[A_idx][0]!=tmp_A[tmpA_idx][0])stable=false;
        }
    }
    if(stable) cout << "Stable" << endl;
    else cout << "Not stable" << endl;
//    cout << count << endl;
}


Measured memory_bytes: 3176
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 1e-5
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL
#define MOD 998244353LL
#define seg_size 262144*4
#define REP(a,b) for(long long a = 0;a < b;++a)
#define int long long
string s;
int n;
vector<int> vertexs[3000];
long long cnt[3000];
pair<long long,long long> dfs(long long now, long long back) {
	vector<pair<int,int>> inputs;
	pair<int, int> ans = make_pair(0, 0);
	REP(i, vertexs[now].size()) {
		int going = vertexs[now][i];
		if (going == back) continue;
		pair<int, int> next = dfs(going, now);
		next.second += cnt[going];
		cnt[now] += cnt[going];
		swap(next.first, next.second);
		inputs.push_back(next);
	}
	if (s[now] == '1') cnt[now]++;
	if (inputs.size() != 0) {
		sort(inputs.begin(), inputs.end());
		reverse(inputs.begin(), inputs.end());
		long long total = 0;
		REP(q, inputs.size()) {
			total += inputs[q].first;
		}
		long long can_fill = 0;
		for (int q = 1; q < inputs.size(); ++q) {
			can_fill += inputs[q].second;
			ans.first += inputs[q].second;
		}
		ans.first += inputs[0].second;
		can_fill /= 2;
		can_fill *= 2;
		can_fill += total - inputs[0].first;
		if (can_fill >= inputs[0].first) {
			ans.first += total;
		}
		else {
			int summing = 0;
			for (int q = 1; q < inputs.size(); ++q) {
				summing += inputs[q].first;
			}
			ans.first += summing * 2;
			inputs[0].first -= summing;
			int cnt = 0;
			for (int q = 1; q < inputs.size(); ++q) {
				cnt += inputs[q].second;
			}
			cnt /= 2;
			cnt *= 2;
			ans.first += cnt;
			ans.second = inputs[0].first - cnt;
		}
	}
	return ans;
}
#undef int
int main() {
	iostream::sync_with_stdio(false);
#define int long long
	cin >> n;
	cin >> s;
	REP(i, n - 1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		vertexs[a].push_back(b);
		vertexs[b].push_back(a);
	}
	long long ans = LONG_INF;
	for (int i = 0; i < n; ++i) {
		REP(q, 3000) {
			cnt[q] = 0;
		}
		pair<long long,long long> geko = dfs(i, -1);
		if (geko.second == 0&&geko.first % 2 == 0) {
			ans = min(ans, geko.first / 2);
		}
	}
	if (ans == LONG_INF) ans = -1;
	cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define INF LLONG_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(int i=0; i<n; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  int N; string A, B, C;
  cin >> N >> A >> B >> C;
  int ans = 0;
  rep(i,N) {
    if(A[i] == B[i] && B[i] == C[i]) continue;
    else if(A[i] == B[i]) ans += 1;
    else if(A[i] == C[i]) ans += 1;
    else if(B[i] == C[i]) ans += 1;
    else ans += 2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll N, D, A;
    cin >> N >> D >> A;
    vector<P> p(N);
    REP(i, N) {
        cin >> p[i].first >> p[i].second;
    }
    VSORT(p);
    vll x(N), h(N);
    REP(i, N) {
        x[i] = p[i].first, h[i] = p[i].second;
    }
    ll res = 0;
    vll mem(N + 1); // mem[i] : i に既に入った爆破回数
    REP(i, N) {
        mem[i + 1] += mem[i];
        // 体力を削りきっていたら continue
        h[i] -= mem[i] * A;
        if (h[i] <= 0) continue;
        ll b = (h[i] - 1) / A + 1; // ここで必要な爆破回数
        res += b;
        mem[i + 1] += b;
        ll ub = upper_bound(ALL(x), x[i] + 2 * D) - x.begin();
        mem[ub] -= b;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 8064
X, N = map(int, input().split())
p = set(map(int, input().split()))

num_set = set(range(-201, 201))

ans_list = list(num_set - p)
min_diff = None
min_ans = None
for ans in reversed(ans_list):
    diff = abs(ans - X)
    if min_diff is None or diff <= min_diff:
        min_diff = diff
        min_ans = ans

print(min_ans)


Measured memory_bytes: 9236
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;

#define N 1000

int main(){
	long int n, i, j, k, cnt = 0;
	cin >> n;
	k = n;

	for (i = 1; i <= n / 2; i++) {
		for (j = k - 1; j > n / 2; j--) {
			if (n == i + j) {
				cnt++;
				k--;
				break;
			}
		}
	}

	cout << cnt << endl;


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<int, int, int> T;

int N;

int main(void){
    
    scanf("%d", &N);
    for(int i = 0; i < N; ++i){
        char a; scanf("%c", &a);
        if(a == 'Y'){ printf("Four\n"); return 0; }
    }
    printf("Three\n");
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void){
	int k;
	long long int ans=0;
	int min=200;
	scanf("%d",&k);

	for(int i=1; i<=k; i++){
		for(int j=1; j<=k; j++){
			for(int l=1; l<=k; l++){
				min=fmin(i,j);
				min=fmin(min,l);
				for(int m=min; m>0; m--){
					if(i%m==0 && j%m==0 && l%m==0){
						ans+=m;
						break;
					}
				}
			}
		}
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 2152
n, k = gets.to_s.split.map{|t|t.to_i}

snuke = [true] * n

k.times do
  
  d = gets.to_s.to_i
  a = gets.to_s.split.map{|t|t.to_i-1}
  
  a.each{|i| snuke[i] = false }
  
end

puts snuke.count(true)

Measured memory_bytes: 14328
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
int n;
bool flg[60000];

int main() {
	memset(flg, 1, sizeof(flg));
	flg[1] = 0;
	for(int i = 2; i <= 55555; i++) {
		for(int j = 2; j <= sqrt(i); j++) {
			if(i % j == 0) {
				flg[i] = 0;
				break;
			}
		}
	}
	flg[2] = 0;
	//for(int i = 1; i <= 100; i++) if(flg[i]) printf("%d ", i);
	scanf("%d", &n);
	for(int i = 1; i <= 55555; i++) {
		if(n == 0) break;
		if(flg[i] && i % 10 == 3) {
			printf("%d ", i);
			n--;
		}
	}
	printf("\n");
}

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

int main()
{
  int n,m;
  int a[1000];
  std::vector<int> ans;
  int max;
  while(std::cin){
    std::cin>>n>>m;
    if(n==0&&m==0){
      break;
    }
    for(int i=0;i<n;i++){
      std::cin>>a[i];
    }
    max=0;
    for(int i=0;i<n-1;i++){
      for(int j=i+1;j<n;j++){
	if((a[i]+a[j])>=max&&(a[i]+a[j])<=m){
	  max=a[i]+a[j];
	}
      }
    }
    ans.push_back(max);
  }
  for(int i=0;i<ans.size();i++){
    if(ans[i]>0){
      std::cout<<ans[i];
    }
    else{
      std::cout<<"NONE";
    }
    std::cout<<"\n";
  }
}


Measured memory_bytes: 3120
N, M = map(int,input().split())

if M == 0:
  if N == 1:
    print(0)
  if N == 2:
    print(10)
  if N == 3:
    print(100)
  exit(0)

List = []
for i in range(M):
  s, c = input().split()
  s = int(s)
  s -= 1
  List.append([s, c])

ans = -1
for v in range(1000):
  t = str(v)
  ok = True
  for i in range(M):
    s = List[i][0]
    c = List[i][1]
    if s > len(t) or N != len(t):
      ok = False
      continue

    if t[s] != c:
      ok = False

  if ok and ans == -1:
    ans = v

print(ans)

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

using namespace std;

int main(void){
    int s = 0;
    long long ans = 0;
    int N;
    cin >> N;
    vector<long long> A(N);
    for(int i = 0; i < N; i++){
        cin >> A[i];
        ans += abs(A[i]);
        if(A[i] < 0) s++;
        A[i] = abs(A[i]);
    }

    if(s % 2 == 1) ans -= 2 * (*min_element(A.begin(), A.end()));
    cout << ans << endl;



    return 0;
}

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

int main() {
	int a, b;
	cin >> a >> b;
	if (a * b % 2 == 0) {
		cout << "Even" << endl;
	}
	else {
		cout << "Odd" << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define vll vector<int>
#define pii pair<int,int>
#define pb push_back
#define sz(v) (int)(v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(int i=a;i<b;++i)
using namespace std;

#define M 100010


int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   	
   	int n;cin>>n;
   	int a[n],b[n];
   	rep(i,0,n)cin>>a[i];
   	rep(i,0,n)cin>>b[i];
   	int i=0,j=0;
   	while(i<n){
   		if(a[i]==b[i]){
   			int k=n;
   			while((a[i]==b[j] or a[j]==b[i]) and k--)j=(j+1)%n;
   			swap(b[i],b[j]);
   			if(a[i]==b[i]){
   				cout<<"No";
   				return 0;
   			}
   		}++i;
   	}
   	cout<<"Yes\n";
   	rep(i,0,n)cout<<b[i]<<" ";
   	
   	
    return 0;
}

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

using namespace std;

#define llong long long int
#define ldouble long double
#define ternary(condition, x, y) ((condition) ? x : y) 
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) x.begin(), x.end()
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)

const static llong MOD = 1000000000 + 7;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    llong n, a, b;
    cin >> n >> a >> b;
    llong h_max = -1, h_min = 10000000000;
    vector<llong> h(n);
    rep(i, n) {
        cin >> h[i];
        h_max = max(h_max, h[i]);
        h_min = min(h_min, h[i]);
    }

    llong left = 0, right = h_max / b + 1, t;
    while (left + 1 < right) {
        t = (left + right) / 2;
        llong cnt = 0;
        rep(i, n) {
            if (h[i] > b * t) cnt += ceil((double)(h[i] - b * t) / (a - b));
        }
        if (cnt <= t) right = t;
        else left = t;
    }

    cout << right << endl;

    return 0;
}

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

using namespace std;
#define ll long long
#define ld long double

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
    string s;
    cin >> s;
    deque<char> dq(s.begin(), s.end());
    bool remain = true;
    int q, t, f;
    char c;
    cin >> q;
    while(q--) {
        cin >> t;
        if(t == 1) remain = !remain;
        else {
            cin >> f >> c;
            remain ^ (f - 1) ? dq.push_front(c) : dq.push_back(c);
        }
    }
    while(!dq.empty()) {
        cout << (remain ? dq.front() : dq.back());
        remain ? dq.pop_front() : dq.pop_back();
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 976
#include<stdio.h>
int main(void){
	
  int s1,s2,s3;
  int N;
  int ct;
  scanf("%d",&N);
  s3=(N%10);
  s2=((N-s3)/10)%10;
  s1=(N-10*s2-s3)/100;
  
  if(s1==1)ct++;
  if(s2==1)ct++;
  if(s3==1)ct++;
  
  printf("%d\n",ct);
  
  return 0;
}

Measured memory_bytes: 1700
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * 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;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 整数の入力
            int X = Integer.parseInt(in.next());
            int ans = X;
            boolean rt = true;

            while (rt) {
                rt = isPrime(ans);
                ans++;
            }
            // 出力
            out.println(ans - 1);

        }

        public static boolean isPrime(int num) {
            if (num < 2) return true;
            else if (num == 2) return false;
            else if (num % 2 == 0) return true; // 偶数はあらかじめ除く

            double sqrtNum = Math.sqrt(num);
            for (int i = 3; i <= sqrtNum; i += 2) {
                if (num % i == 0) {
                    // 素数ではない
                    return true;
                }
            }

            // 素数である
            return false;
        }

    }
}



Measured memory_bytes: 23892
#include <stdio.h>

int main(){

  int a,b,c,m;
  scanf("%d%d%d",&a,&b,&c);
    if(a>b){
      m=b;
      b=a;
      a=m;
    }if(b>c){
      m=c;
      c=b;
      b=m;
    }if(a>b){
      m=b;
      b=a;
      a=m;
    }
  printf("%d %d %d\n",a,b,c);
  return 0;
}
    

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

int main()
{
    int n;
    cin >> n;
    vector<int> l(n);
    rep(i,n) cin >> l[i];
    sort(l.begin(), l.end());
    int ans = 0;
    rep(i, n) {
        for (int j = i + 1; j < n; j++) {
            for (int k = j + 1; k < n; k++) {
                if (l[i] != l[j] && l[i] != l[k] && l[j] != l[k])
                    if (abs(l[i] - l[j]) < l[k] && l[k] < l[i] + l[j])
                        ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

long long modpow(long long a,long long n,long long mod){
    
    long long res = 1;
    while(n > 0){
        //if(n&1)
        res = res*a%mod;
        //a = a * a % mod;
        n -= 1;
    }
    return res;
}

int main(){
    int N;
    cin >> N;
    int D[N];
    long long mod = 998244353;
    map<long long,int> d;
    for(int i = 0; i < N;i++){
        cin >> D[i];
        d[D[i]]++;
    }
    long long ans = 1;
    bool flag = false;
    for(int i = N -1; i >= 1;i--){
        if(d[i]!=0)flag = true;
        if(flag&&d[i]==0){
            cout << 0 << endl;
            return 0;
        }
    }
    if(d[0]!=1){
        cout << 0 << endl;
        return 0;
    }
    if(D[0]!= 0){
        cout << 0 << endl;
        return 0;
    }
    for(int i = 1; i <N;i++){
        ans *= modpow(d[i-1],d[i],mod);
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define ll long long
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<long long>;
using vvll = vector<vll>;

//snippets:tmp,cl,cvl,cs,co,coy,con,cov,setp

int main(){
    ll h1;
    cin >> h1;
    ll m1;
    cin >> m1;
    ll h2;
    cin >> h2;
    ll m2;
    cin >> m2;
    ll k;
    cin >> k;
    h2-=h1;
    m1=h2*60-m1+m2;
    cout << m1-k << endl;
}

Measured memory_bytes: 3596
import sys
import collections

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def check_path(mp, is_archive, wi, hi):
	w = len(mp[0])
	h = len(mp)
	nb = 0
	nw = 0
	qq=collections.deque()
	st_color = mp[hi][wi]
	nb+=1
	qq.append((wi, hi, st_color))
	is_archive[hi][wi] = 1
	while qq:
		pw, ph, pc = qq.popleft()
		for dw, dh in ((1,0), (-1,0), (0,1),(0,-1)):
			if pw+dw<0 or pw+dw>=w or ph+dh < 0 or ph+dh >= h:
				continue
			if is_archive[ph+dh][pw+dw]>0:
				continue
			if mp[ph+dh][pw+dw]==pc:
				continue
			nc = mp[ph+dh][pw+dw]
			if nc == st_color:
				nb += 1
			else:
				nw += 1
			
			qq.append((pw+dw, ph+dh, nc))
			is_archive[ph+dh][pw+dw]=1
	
	return nb*nw

def main():
	#a = int(input())
	h, w = tin()
	#s = input()
	mp = [input() for _ in range(h)]
	is_archive = [[-1]*w for _ in range(h)]
	ret = 0
	for wi in range(w):
		for hi in range(h):
			if is_archive[hi][wi] != -1:
				continue
			nn = check_path(mp, is_archive, wi, hi)
			ret += nn
	print(ret)
			
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

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

int main(){
  int n,k;
string s;
  cin>>n>>s>>k;
  --k;
  for(int i=0; i<n; ++i){
    if(s[i] != s[k]){
      s[i]='*';
    }
  }
  cout<<s<<endl;
}

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

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds; 
 
typedef long long int ll;
typedef long int li;

const ll mod = 1000000007;
const ll inf = 1000000000000000000;

typedef vector<int> vi;
typedef vector<li> vli;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef vector<vli> vvli;
typedef vector<vll> vvll;
typedef vector<vs> vvs;
typedef map<ll, ll> mll;
typedef map<ll, string> mls;
typedef map<string, ll> msl;
typedef pair<ll, ll> pll;

// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#pragma GCC optimize ("-O3")
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define all(v) v.begin(), v.end()
#define mini(a) *min_element(all(a))
#define maxi(a) *max_element(all(a))
#define tol(s) transform(s.begin(), s.end(), s.begin(), ::tolower);
#define tou(s) transform(s.begin(), s.end(), s.begin(), ::toupper);
#define FOR(i, j, k, in) for(li i=j; i<k; i+=in)
#define RFOR(i, j, k, de) for(li i=j; i>=k; i-=de)
#define rep(i,j,k) FOR(i, j, k, 1)
#define rrep(i,j,k) RFOR(i, j, k, 1)
#define repc(v) for(auto it=v.begin(); it!=v.end(); it++)
#define rrepc(v) for(auto it=v.rbegin(); it!=v.rend(); it--)
#define T ll t; cin>>t; while(t--)

ll gen(){
    ll temp;
    cin>>temp;
    return temp;
}

ll power(ll a, ll b, ll m){    
    ll res=1;
    while(b>0){
        if(b&1){
            res=(res*a)%m;
            b--;
        }
        a=(a*a)%m;
        b=b>>1;
    }
    return res;
}

ll gcd(ll a, ll b){if(a==0)return b; else return gcd(b%a, a);}
ll lcm(ll a, ll b){return (a*b)/gcd(a,b);}

#define inpt(v) generate(all(v),gen)
#define sum(v) accumulate(all(v),0LL)
#define vpll vector<pll>
#define umap unordered_map
#define uset unordered_set
#define print(v) rep(i,0,n) cout<<v[i]<<" ";

int32_t main(){
  FAST

    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout); 

	
    ll x,k,d;
    cin>>x>>k>>d;
    
    ll xto0 = (ll)abs(x)/d;

    if(xto0 >= k){
      if(x >= 0)
      x = x - k * d;
      else
      x = x + k * d;
      cout<<(ll)abs(x);
    }
        
    else{
      k = k - xto0;
      if(x >= 0)
      x = x - xto0 * d;
      else 
      x = x + xto0 * d;

      if(k&1){
        if(x >= 0)
        x -= d;
        else
        x += d;        
      }

     cout<<(ll)abs(x);
    }
  
  return 0;
}










Measured memory_bytes: 3588
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    string s; cin >> s;
    cout << "2018" << s.substr(4) << endl;
    return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  if(a>b) cout << "safe" << endl;
  else cout << "unsafe" << endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
int SIZE(string s){return (int)s.size();}
const long long INF = 1LL << 60;

int main(){
    cout << fixed << setprecision(20);
    int n; cin >> n;
    vc<ll> a(n), sum(n+1);
    rep(i,n){
        cin >> a[i];
        sum[i+1] = sum[i]+a[i];
    }
    
    ll ans = INF;
    rng(i,1,n){
        chmin(ans, abs( (sum[i]-sum[0]) - (sum[n]-sum[i]) ) );
    }
    cout << ans << endl;
    return 0;
    
}

Measured memory_bytes: 3328
#include<stdio.h>
int main(void){
    int n,m,t[100001],s[100001],i,j,ans=0,from,to;
    from=0;
    scanf("%d%d",&n,&m);
    n--;
    for(i=0; i<n; i++){
        scanf("%d",&s[i]);
        t[i]=0;
    }
    for(i=0; i<m; i++){
        scanf("%d",&to);
        to+=from;
        if(to>from){
            for(j=from; j<to; j++){
                t[j]++;
            }
        }else{
            for(j=to; j<from; j++){
                t[j]++;
            }
        }
        from = to;
    }
    for(i=0; i<n; i++){
        ans+=s[i]*t[i];
        ans%=100000;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1804
///At Coder  : Frog 2
///Approach  : Recursive DP
///Complexity: O(n*k)

#include<bits/stdc++.h>
using namespace std;

int k;
int dp[100005];
int arr[100005];

int frog(int pos, int n){

    if(pos==n)return 0;
    if(dp[pos]!=-1)return dp[pos];

    int a=abs(arr[pos]-arr[pos+1])+frog(pos+1,n);
    int b=INT_MAX;
    for(int i=2; i<=k; i++){
        if(pos+i<=n){
           b=abs(arr[pos]-arr[pos+i])+frog(pos+i,n);
           a=min(a,b);
        }
        else
            break;
    }
    return dp[pos]=a;

}

int main(){

    ios_base::sync_with_stdio(false);cout.tie(false);cin.tie(false);

    int n,i;
    cin>>n>>k;
    for(i=1; i<=n; i++){
        cin>>arr[i];
        dp[i]=-1;
    }
    cout<<frog(1,n)<<endl;


    return 0;
}



Measured memory_bytes: 7296
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int num = Integer.parseInt(br.readLine());
		int point[] = {0,0};
		for(int i = 0 ; i < num ; i++){
			String str[] = br.readLine().split(" ");
			if(str[0].compareToIgnoreCase(str[1])>0){
				point[0]+=3;
			}
			else if(str[0].compareToIgnoreCase(str[1])<0){
				point[1]+=3;
			}
			else if(str[0].compareToIgnoreCase(str[1])==0){
				point[0]++;
				point[1]++;
			}
		}
		System.out.println(point[0]+" "+point[1]);

	}

}

Measured memory_bytes: 25808
#include <bits/stdc++.h>
#include <chrono>
#include <math.h>
using namespace std;
using ll = long long;
using ld = long double;
using namespace std::chrono; 
#define fo(i,z,n) for(int i = z;i<n;i++)
#define Fo(i,z,n) for(ll i = z;i<n;i++)
#define INT_BITS 32
#define mod 1000000007
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> > 
#define pb push_back
#define f first
// #define s second
#define int long long
#define float long double
#define all(c) (c).begin(), (c).end()
#define endl '\n'
#define pi 3.14159265358979323846

ll pow(ll a,ll p,ll m=mod)
{ll res=1;while(p>0){if(p&1)res=(res*a)%m;a=(a*a)%m;p>>=1;}
return res;}


int32_t main()
{
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     cout.tie(0);
   	
 //    int t;
 //     cin >> t;

 //     while(t--){


 // }

     string s;
     cin >> s;
     if(s == "ABC")cout << "ARC" << endl;
     else cout << "ABC" << endl;


return 0;
	
	}




Measured memory_bytes: 3532
import java.util.*;

public class Main {

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();
        int p = Integer.valueOf(a + b);
        String res = "No";
        for(int i = 1; i * i <= p; i++) {
            if(i * i == p) {
                res = "Yes";
                break;
            }
        }
        System.out.println(res);
    }

}


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

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;

#define rep(idx, N) for (u64 idx = 0; idx < N; idx++)


int main() {
    char a;
    cin >> a;
    if (a >= 'a') cout << 'a' << endl;
    else cout << 'A' << endl;

  return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<vector<int>> A(2,vector<int>(N));

  for(int i = 0;i < 2;i++){
    for(int j = 0;j < N;j++){
      cin >> A[i][j];
    }
  }

  //A(1,1)で2段目に移る場合
  int counter = A[0][0];
  for(int i = 0;i < N;i++){
    counter += A[1][i];
  }

  int diff = counter;

  //差分が大きい（プラスでたすものが一番大きい）箇所を探す
  for(int i = 1;i < N;i++){
    int y = A[0][i] - A[1][i - 1];
    diff += y;
    counter = max(diff,counter);
  }

  cout << counter << endl;
}


Measured memory_bytes: 256
cum, i = [0], 0
while cum.last < 100000
    cum << 3 ** i
    i += 1
end
1.upto(cum.length - 1){|i| cum[i] += cum[i - 1]}

w, str, h = gets.to_i, "", {0=>'0', 1=>'+', 2=>'-'}
cum.each_with_index{|offset, i|
    break if offset >= w
    x, r = (w + cum[i]).divmod 3
    i.times{x, r = x.divmod 3}
    str = h[r] + str
}
puts str


Measured memory_bytes: 8896
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <limits.h>
using namespace std;

#define INF LLONG_MAX/3
#define inf INT_MAX/3
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
typedef pair<int, int> P;
typedef long long ll;

int gcd(int a, int b) {
	if (b == 0)return a;
	return gcd(b, a%b);
}
int lcm(int a, int b) {
	return a / gcd(a, b)*b;
}
int modpow(int a, int b) {
	if (b == 0)return 1;
	if (b == 1)return a % MOD;
	if (b % 2)return modpow(a, b - 1)*a%MOD;
	else return modpow(a, b / 2)*modpow(a, b / 2) % MOD;
}
int comb(int a, int b) {
	if (b == 0 || a == b)return 1;
	if (b == 1)return a % MOD;
	return (comb(a - 1, b - 1) + comb(a - 1, b)) % MOD;
}

int n, q, a, b;

int main() {
	cin >> n >> q;
	rep(i, q) {
		cin >> a >> b;
		if (n == 1)cout << min(a, b) << endl;
		else {
			while (a != b) {
				if (a < b)b = (n + b - 2) / n;
				else a = (n + a - 2) / n;
			}
			cout << a << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1280
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from collections import defaultdict

n = int(readline())
xy = [tuple(map(int, readline().split())) for _ in range(n)]
dict = defaultdict(int)
dict[0] = 0
for i, check in enumerate(xy):
    for dxy in xy[i + 1:]:
        y, x = check[0], check[1]
        dy, dx = dxy[0], dxy[1]
        dict[(y - dy, x - dx)] += 1
        dict[(dy - y, dx - x)] += 1
print(n - max(dict.values()))


Measured memory_bytes: 3828
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N, x;
    cin >> N >> x;
    vector<ll> a(N);
    for (ll i = 0; i < N; i++) {
        cin >> a[i];
    }

    vector<ll> reach_min(N, LONG_MAX);

    ll ans = LLONG_MAX;
    //魔法をi回使うと決め打ち
    for (ll i = 0; i < N; i++) {
        ll curr_ans = i * x;
        for (ll j = 0; j < N; j++) {
            reach_min[j] = min(reach_min[j], a[(j - i + N) % N]);
            curr_ans += reach_min[j];
        }

        ans = min(ans, curr_ans);
    }

    cout << ans << endl;
}


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

// ??????????????????????????????????????°??????????????¨????????????
int bubleSort(int A[], int N) {
  int excount = 0;
  bool flag = true;

  while ( flag) {
    flag = false;
    for ( int i = N - 1; i > 0; i-- ) {
      if ( A[i] < A[i - 1] ) {
        int tmp = A[i];
        A[i] = A[i - 1];
        A[i - 1] = tmp;
        excount++;
        flag = true;
      }
    }
  }
  return excount;
}

int main() {
  int A[100], N, excount;

  cin >> N;
  for ( int i = 0; i < N; i++ ) cin >> A[i];

  excount = bubleSort(A, N);
  
  cout << A[0];
  for ( int i = 1; i < N; i++ ) cout << " " << A[i];
  cout << endl << excount << endl;

  return 0;
}

Measured memory_bytes: 1160
# include<iostream>
# include <cstdio>
# include <algorithm>
# include <cstring>
# include <set>
using namespace std;

int A[10];
int mi[10],vis[10];
long long N;
long long solve(){
    long long anss = 0;
    for (int i=1;i<=N;i++) vis[i] = 1;
    for (int i=1;i<=N;i++){
        vis[A[i]] = 0;
        int temp = 0;
        for (int j=1;j<=A[i];j++) temp+=vis[j];
        anss+=temp*mi[N-i];
    }
    anss++;
    return anss;
}

int main(void){
    // freopen("aaa.in","r",stdin);
    scanf("%lld",&N);
    mi[0] = 1;
    for (int i=1;i<=9;i++) mi[i] = mi[i-1]*i;
    long long ans1=0,ans2=0;
    for (int i=1;i<=N;i++) scanf("%d",&A[i]);
    ans1 = solve();
    for (int i=1;i<=N;i++) scanf("%d",&A[i]);
    ans2 = solve();
    cout<<abs(ans1-ans2)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	long long int i,N,sum=0;
	scanf("%lld",&N);
	for(i=1;i<=N;i++){
		if(i%3==0 || i%5==0 || (i%3==0 && i%5==0)){
			continue;
		}
		else{
			sum=sum+i;
		}
	}
	printf("%lld\n",sum);
	return 0;
}


Measured memory_bytes: 1732
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log

mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

h,w=mii()

mat=[list(ss()) for _ in range(h)]

chk=[[0]*w for _ in range(h)]

for i in range(h):
    for j in range(w):
        if i==0:
            if j==0:
                if mat[i][j]=="#":
                    chk[i][j]+=1
            else:
                if mat[i][j]!=mat[i][j-1] and mat[i][j]=="#":
                    chk[i][j]=chk[i][j-1]+1
                else:
                    chk[i][j]=chk[i][j-1]
        
        else:
            if j==0:
                if mat[i][j]!=mat[i-1][j] and mat[i][j]=="#":
                    chk[i][j]=chk[i-1][j]+1
                else:
                    chk[i][j]=chk[i-1][j]
            
            else:
                if mat[i][j]==mat[i-1][j] and mat[i][j]==mat[i][j-1]:
                    chk[i][j]=min(chk[i-1][j],chk[i][j-1])
                    
                elif mat[i][j]!=mat[i-1][j] and mat[i][j]==mat[i][j-1] and mat[i][j]=="#":
                    chk[i][j]=min(chk[i-1][j]+1,chk[i][j-1])
                elif mat[i][j]!=mat[i][j-1] and mat[i][j]==mat[i-1][j] and mat[i][j]=="#":
                    chk[i][j]=min(chk[i-1][j],1+chk[i][j-1])
                elif mat[i][j]=="#":
                    chk[i][j]=min(chk[i-1][j]+1,1+chk[i][j-1])
                else:
                    chk[i][j]=min(chk[i-1][j],chk[i][j-1])

                    
print(chk[-1][-1])
#print(chk)

Measured memory_bytes: 44656