akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>

void insertionsort(int *,int,int);
void shellsort(int *,int);

int cnt=0;

int main(){

    int i,n;
    int *a;

    scanf("%d",&n);

    a=(int *)malloc(sizeof(int)*n);
    if(a==NULL) exit(8);

    for(i=0;i<n;i++) scanf("%d",&a[i]);

    shellsort(a,n);

    free(a);
    return 0;
}

void insertionsort(int *a,int n,int g){

    int i,j,v;

    for(i=g;i<n;i++){

        v=a[i];

        j=i-g;

        while(j>=0&&a[j]>v){

            a[j+g]=a[j];

            j=j-g;

            cnt++;

        }a[j+g]=v;

    }return;

}

void shellsort(int *a,int n){

    int i,m,x=1,*g;

    for(m=1;m<100;m++){

        if(n<3*x+1) break;

        x=3*x+1;

    }g=(int *)malloc(sizeof(int)*m);

    for(i=0,x=1;i<m;i++){

        g[i]=x;
        
        x=x*3+1;

    }

    for(i=m-1;i>=0;i--) insertionsort(a,n,g[i]);

    printf("%d\n",m);

    for(i=m-1;i>=0;i--){

        if(i==m-1) printf("%d",g[i]);

        else printf(" %d",g[i]);

    }printf("\n");

    printf("%d\n",cnt);

    for(i=0;i<n;i++) printf("%d\n",a[i]);

    free(g);

    return;
}


Measured memory_bytes: 5448
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
    int n; cin >> n;
    int s[n];
    int sum = 0;
    for (int i = 0; i < n; ++i) {
        cin >> s[i];
        sum += s[i];
    }
    if (sum % 10 != 0) {
        cout << sum << endl;
        return 0;
    }
    sort(s, s + n);
    int i = 0;
    //
    while (1) {
        if ((sum - s[i]) % 10 != 0) {
            cout << sum - s[i] << endl;
            return 0;
        }
        i++;
        if (i == n) {
            break;
        }
    }
    cout << 0 << endl;
    return 0;
}



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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

int n,m,c,s,g;
int d[22][111][111];
int cost[22][22222];
int dc[111][111];

int main(){
	//cin.sync_with_stdio(false);
	while(1){
		scanf("%d%d%d%d%d",&n,&m,&c,&s,&g);
		if(n==0)break;
		s--; g--;
		rep(i,22)rep(j,111)rep(k,111)d[i][j][k]=(j==k?0:INF);
		rep(i,m){
			int x,y,dd,cmp;
			scanf("%d%d%d%d",&x,&y,&dd,&cmp);
			x--; y--; cmp--;
			d[cmp][x][y]=d[cmp][y][x]=min(dd,d[cmp][x][y]);
		}
		int p[22];
		rep(i,c){
			scanf("%d",p+i);
			//dbg(p[i]);
		}
		rep(i,c){
			int q[55],r[55];
			rep(j,p[i]-1)scanf("%d",q+j);
			rep(j,p[i])scanf("%d",r+j);
			int nq=0;
			cost[i][0]=0;
			rep(dd,20010){
				if(nq<p[i]-1&&dd==q[nq])nq++;
				cost[i][dd+1]=cost[i][dd]+r[nq];
				//if(dd<10)dbg(cost[i][dd]);
			}
		}
		rep(cmp,c)rep(k,n)rep(i,n)rep(j,n)minch(d[cmp][i][j],d[cmp][i][k]+d[cmp][k][j]);
		rep(i,n)rep(j,n)dc[i][j]=(i==j?0:INF);
		rep(i,c)rep(j,n)rep(k,n)if(d[i][j][k]!=INF)minch(dc[j][k],cost[i][d[i][j][k]]);
		rep(k,n)rep(i,n)rep(j,n)minch(dc[i][j],dc[i][k]+dc[k][j]);
		if(dc[s][g]==INF)printf("-1\n");
		else printf("%d\n", dc[s][g]);
	}
	return 0;
}

Measured memory_bytes: 5908
#include <iostream>

int main()
{
    int n, q;
    std::string str;
    std::cin >> n >> q >> str;
    int sum[100000];
    sum[0] = 0;
    for (int i = 1; (i < n); ++i) {
        if (str[i - 1] == 'A' && str[i] == 'C') sum[i] = sum[i - 1] + 1;
        else sum[i] = sum[i - 1];
    }
    for (int i = 0; (i < q); ++i) {
        int l, r;
        std::cin >> l >> r;
        std::cout << (sum[r - 1] - sum[l - 1]) << std::endl;
    }
    return 0;
}

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

from collections import Counter
c = Counter(A)
m = {}
total = 0
for k, v in c.items():
    a = v*(v-1)//2
    m[k] = a
    total += a

for i in range(N):
    a = total - m[A[i]] + ((c[A[i]]-1)*(c[A[i]]-2)//2)
    print(a)


Measured memory_bytes: 96332
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
using namespace std;
const int max_n= 10000;
int n,a=0,b,W,L,kk,c,m,V,e,r,ML, MD, E, v;
const int INF = 1e9+1;
const int mod = 1e9 + 7;
bool used[max_n][max_n];
string s1,s2;
int x[max_n],y[max_n],s[max_n],d[max_n][max_n],ppar[max_n],rrank[max_n],spf[max_n],co[max_n];
typedef pair<long , long> pii;
vector<long long> G[max_n];
vector<int> ls;
struct edge{
    int from,to,cost;
};
bool comp(const edge& e1, const edge& e2){
    return e1.cost < e2.cost;   
}
edge es[max_n];
typedef pair<int, int> P;
struct Cmp{
    bool operator()(const pii &a,const pii &b){
        return a.second > b.second;
    }
};

void solve(){
    for(int k=0 ; k<v ; k++){
        for(int i=0 ; i<v ; i++){
            for(int j=0 ; j<v ; j++){
                if(d[i][j] > d[i][k] + d[k][j]){
                    puts("-1"); return;
                }
                if(d[i][j] == d[i][k] + d[k][j] && d[i][k]>0 && d[k][j]>0){
                    used[i][j] = true;
                }
            }
        }
    }
    long long ans = 0;
    for(int i=0 ; i<v ; i++){
        for(int j=0 ; j<v ; j++){
            if(!used[i][j]){
                ans += d[i][j];
            }
        }
    }
    cout << ans/2 << endl;
}
int main(){
    cin >> v;
    for(int i=0 ; i<v ; i++){
        for(int j=0 ; j<v ; j++){
            cin >> d[i][j];
        }
    }
    solve();
    return 0;
}

Measured memory_bytes: 14976
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
map<ll, int> prime_factor(ll n)
{
    map<ll, int> res;
    for (ll i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            res[i]++;
            n /= i;
        }
    }
    if (n != 1)
    {
        res[n] = 1;
    }
    return res;
}
ll Pow(ll n,int i)
{
    ll ans=1;
    while(i--)
    {
        ans *= n;
    }
    return ans;
}
map<ll,ll> memo;
ll rec(vll A,ll m)
{
    if(m == 0)
    return 0;
    if(m == 1)
    return A.back();
    if(memo.count(m))
    {
        return memo[m];
    }
    ll res=INF;
    if(__builtin_mul_overflow(A.back(),m,&res))res=INF;
    vll div = {2,3,5};
    for (int i = 0;i<3;i++)
    {
        for (int j = 0; j < div[i]; j++)
        {
            if((m+j) % div[i] == 0)
            chmin(res,j*A.back()+A[i]+rec(A,(m+j)/div[i]));
            if((m-j)%div[i] == 0)
            chmin(res,j*A.back()+A[i]+rec(A,(m-j)/div[i]));
        }
        
    }
    memo[m]=res;
    return res;
}
void solve(ll N,vll A)
{
    memo.clear();
    cout<<rec(A,N)<<endl;
}

int main()
{
    int T;
    cin>>T;
    for (size_t i = 0; i < T; i++)
    {
        ll N;
        vll A(4);
        cin>>N>>A[0]>>A[1]>>A[2]>>A[3];
        solve(N,A);
    }
    
    return 0;
}

Measured memory_bytes: 4332
n,x,y = [int(x) for x in input().split()]
count = [0]*(n+1)
for i in range(1,n):
    for j in range(i+1,n+1):
        if i < x and j <= x:
            nagasa = j - i
        elif i < x and x < j and j < y:
            nagasa = x-i + min(j-x,y-j+1)
        elif i < x and y <= j:
            nagasa = x-i + j - y + 1
        elif x <= i and i < y and j <= y:
            nagasa = min(j-i,i-x+y-j+1)
        elif x <= i and i < y and y < j:
            nagasa = j - y + min(y-i,i-x+1)
        elif y <= i:
            nagasa = j -i
        count[nagasa] += 1
for i in range(1,n):
    print(count[i])

Measured memory_bytes: 3444
#include<stdio.h>
int main()
{
	int i,a[3],b[3],suma=0,sumb=0;
	for(i=0;i<4;i++){
		scanf("%d",&a[i]);
		suma+=a[i];
	}
	for(i=0;i<4;i++){
		scanf("%d",&b[i]);
		sumb+=b[i];
	}
	if(suma>=sumb)
		printf("%d\n",suma);
	else
		printf("%d\n",sumb);
	return 0;
}	


Measured memory_bytes: 2056
a = input().split()

N = int(a[0])
A = int(a[1])
B = int(a[2])

i = int(N/(A+B))

cut = N - (A+B)*i

if N < A:
  Blue_Ball_Num = N
elif N < A+B:
  Blue_Ball_Num = A
elif cut > A:
  Blue_Ball_Num = A*(i+1)
else:
  Blue_Ball_Num = A*i + (N - (A+B)*i)
  
print(Blue_Ball_Num)

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

int main() {
    int a, b, temp, ans;
    cin >> a >> b;
    temp = b - a - 1;
    temp = temp * (temp + 1) / 2;
    ans = temp - a;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int main(){
  int h,w,k; cin >> h >> w >> k;
  vector<vector<char>> c(h,vector<char>(w));
  rep(i,h)rep(j,w) cin >> c[i][j];
  ll ans = 0;
  rep(i,1<<h)rep(j,1<<w){
    vector<vector<char>> d = c;
    rep(l,h){
      if(i>>l&1){
        rep(m,w){
          d[l][m] = 'r';
        }
      }
    }
    rep(l,w){
      if(j>>l&1){
        rep(m,h){
          d[m][l] = 'r';
        }
      }
    }
    int cnt = 0;
    rep(l,h)rep(m,w){
      if(d[l][m] == '#') cnt++;
    }
    if(cnt == k) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <complex>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,C,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
const long double EPS = 1e-9;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main() {
    cin>>N>>K>>Q;
    vec memo(N,K-Q);
    rep(i,Q){
        cin>>A;
        --A;
        ++memo[A];
    }
    rep(i,N){
        cout<<((memo[i] > 0) ? "Yes" : "No")<<endl;
    }

}

Measured memory_bytes: 1408
const main = stdin => {
  const input = stdin.trim().split('\n')
  const [A, B] = input[0].split(' ').map(x => parseInt(x))

  if (A <= 8 && B <= 8) {
    console.log('Yay!')
  } else {
    console.log(':(')
  }
}
// 標準入力
main(require("fs").readFileSync("/dev/stdin", "utf8"))


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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[][] F = new int[N][10];
		int[][] P = new int[N][11];
		int ans = Integer.MIN_VALUE;
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < 10; j++)
				F[i][j] = sc.nextInt();
		}
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < 11; j++)
				P[i][j] = sc.nextInt();
		}

      for(int i = 1; i < 1 << 10; i++) {
			int sum = 0;
			for(int j = 0; j < N; j++) {
				int count = 0;
				for(int k = 0; k < 10; k++) {
					if((1 & (i >> k)) == 1 && F[j][k] == 1)
						count++;
				}
				sum += P[j][count];
			}
			ans = Math.max(ans, sum);
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 26632
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int n, m; cin >> n >> m;
    cout << (n-1) * (m-1) << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
typedef long long ll;

bool visited[401][401] = {false};
bool matrix[401][401] = {false}; // false for black

ll black, yellow;
int h, w;

void dfs(int i, int j, bool color) {
    if (color)
        yellow ++;
    else
        black ++;
    // cerr << i << ' ' << j << ' ' << black << ' ' << yellow << endl;

    if (0 <= (i - 1)) {
        if (!visited[j][i-1] && matrix[j][i-1] != color) {
            visited[j][i-1] = true;
            dfs(i-1, j, !color);
        }
    }
    if (i + 1 < w) {
        if (!visited[j][i+1] && matrix[j][i+1] != color) {
            visited[j][i+1] = true;
            dfs(i+1, j, !color);
        }
    }
    if (0 <= j - 1) {
        if (!visited[j-1][i] && matrix[j-1][i] != color) {
            visited[j-1][i] = true;
            dfs(i, j-1, !color);
        }
    }
    if (j + 1 < h) {
        if (!visited[j+1][i] && matrix[j+1][i] != color) {
            visited[j+1][i] = true;
            dfs(i, j+1, !color);
        }
    }
}

int main() {
    cin >> h >> w;

    for (int j = 0; j < h; j ++) {
        string row;
        cin >> row;
        for (int i = 0; i < w; i ++)
            matrix[j][i] = (row[i] == '.') ? true : false;
    }

    ll ans = 0;
    for (int j = 0; j < h; j ++) {
        for (int i = 0; i < w; i ++) {
            black = yellow = 0;
            if (!visited[j][i]) {
                visited[j][i] = true;
                dfs(i, j, matrix[j][i]);
            }
            ans += black * yellow;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 15488
#include <iostream>
#include <unordered_map>
#include <vector>
using namespace std;

bool anti(int n,int k){
    return k <= (n+1)/2;


}

template <typename T>
void add_vector_map(unordered_map<T, vector<T>>& mp, T key, T val){
    auto itr = mp.find(key);
    if (itr != mp.end()){
        vector<T>& vec = (*itr).second;//ここでcopyは怒る？
        vec.push_back(val);
    }else{
        mp[key] = vector<T>{val};
    }

}

bool path(const unordered_map<int, vector<int>>& mp){
    vector<int> one_naver = {};
    vector<int> two_naver = {};
    for(auto& pair: mp) {
        int a = pair.first;
        auto a_navers = pair.second;
        if (a_navers.size() == 1)
            one_naver.push_back(a);
        else if (a_navers.size() == 2)
            two_naver.push_back(a);
        else
            return false;
    }

    return (one_naver.size() == 2 && two_naver.size() == 2);



}



int main(){
    unordered_map<int, vector<int>> mp;

    for(int i = 0; i <3; i++){
        int a,b;
        cin >> a >> b;
        add_vector_map(mp, a,b);
        add_vector_map(mp, b,a);
    }
    if (path(mp))
        cout << "YES";
    else
        cout << "NO";

    return 0;

}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    string a; cin>>a;
    string b; cin>>b;
    string c; cin>>c;
    int x=a.size();
    int y=b.size();
    
    if(a[x-1]==b[0])
        if(b[y-1]==c[0])
            cout<<"YES";
        else cout<<"NO";
    else cout<<"NO";
    
    
    
    
}


Measured memory_bytes: 256
// ALDS1_4_B    
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
namespace you {
    std::string to_string(char val) {
        return std::string(1, val);
        // return std::string{val};
        // you::to_string(char)
    }
}

vector<int> s(100000+1);
vector<int> t(50000+1);

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

    int n,q;
    cin>>n;
    rep(i,n) cin>>s[i];
    cin>>q;
    rep(i,q) cin>>t[i];
    
    int ans=0;
    rep(i,q){
        int l=-1,r=n;
        int mid=(l+r)/2;
        int find=t[i];
        while(r-l>=0){
            //cout<<find<<" "<<s[mid]<<endl;
            if(s[mid]==find){
                ans+=1;
                //cout<<find<<endl;
                break;
            }else if(s[mid]<find){
                l=mid+1;
            }else{
                r=mid-1;
            }
            mid=(l+r)/2;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3444
/*痛みを受け取れ，痛みを知れ*/
#include<bits/stdc++.h>
#define f(i,a,b) for(register int i=a;i<=b;++i)
#define ff(i,a,b) for(register int i=a;i>=b;--i)
#define debug(x) cerr << #x << " : " << x << " " << endl
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
const ll mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const double tiaohe = 0.57721566490153286060651209;
ll oula(ll x) { ll res = x;f(i, 2, x / i) { if (x % i == 0) { res = res / i * (i - 1);while (x % i == 0) x /= i; } }if (x > 1) res = res / x * (x - 1);return res; }
ll quickmod(ll a, ll n, ll m) { ll s = 1;while (n) { if (n & 1) { s = s * a % m; }a = (a*a) % m;n = n / 2; }return s; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
void ex_gcd(ll a, ll b, ll &x, ll &y, ll &d) { if (!b) { d = a, x = 1, y = 0; } else { ex_gcd(b, a % b, y, x, d);y -= x * (a / b); } }
ll inv(ll t, ll p) { ll d, x, y;ex_gcd(t, p, x, y, d);return d == 1 ? (x % p + p) % p : -1; }
bool isPrime(ll x) { if (x == 2)return true;if (x % 2 == 0)return false;for (ll i = 2;i*i <= x;i++) if (x % i == 0)return false; return true; }
//double a = log(n) +tiaohe + 1.0 / (2 * n);
double eqa = (1 + sqrt(5.0)) / 2.0;
const int N = 6e5 + 5;
int a[N];
int main()
{
	//freopen("in.txt", "r", stdin);
	int n;
	while (cin >> n)
	{
		f(i, 1, n)scanf("%d", &a[i]);
		ll ans = 0;
		int mx = 0;
		f(i, 1, n)
		{
			mx = max(a[i], mx);
			ans += mx - a[i];
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 4492
a,b,h,m=map(int,input().split())

#時針
#x=sin(し０た)
import math
x1 = a*math.sin(math.radians(30*h+30*m/60))
y1 = a*math.cos(math.radians(30*h+30*m/60))

x2 = b*math.sin(math.radians(6*m))
y2 = b*math.cos(math.radians(6*m))

#print(x1,y1,x2,y2)

ans=((x1-x2)**2+(y1-y2)**2)**0.5

print(ans)

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

int main()
{
	int n, sq=1, i=1;
	cin>>n;
	while(sq<=n)
	{
		sq=i*i;
		i++;
	}
	i=i-2;
	sq=i*i;
	cout<<sq;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();
        int d = scanner.nextInt();

        String result = "No";

        int ca = Math.abs(c - a);
        int ba = Math.abs(b - a);
        int cb = Math.abs(c - b);

        if (ca <= d || (ba <= d && cb <= d)) {
            result = "Yes";
        }


        System.out.println(result);

    }
}

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

int main()
{   
	int n;
	cin>>n;
	int a[n+1];
	for (int i=1; i<=n; i++){
		cin>>a[i];
	}
	map<int, pair<int, int>> m;
	for (int i=1; i<=n; i++){
		int p1 = i+(a[i]-1);
		int p2 = i-(a[i]-1);
		if (p1>=1 and p1<=n) m[p1].first += 1;
		if (p2>=1 and p2<=n) m[p2].second += 1;
	}
	long long ans = 0;
	for (int i=1; i<=n; i++){
		int p1 = i+(a[i]-1) +2;
		int p2 = i-(a[i]-1) -2;
		ans += m[p1].second+m[p2].first;
	}
	cout<<ans/2<<endl;
    return 0;
}

Measured memory_bytes: 30032
#include <bits/stdc++.h>
using namespace std;
#define nn 404
#define int long long
#define inf 10000000000000000
main() {
    int n,arr[403];
    cin>>n;
    int i;
    for(i=0;i<n;i++)
        cin>>arr[i];
    int dp[nn][nn];
    for(i=0;i<n;i++){
        dp[i][i]=0;
    }
    int j,len;
    int sum[nn][nn];
    memset(sum, 0, sizeof(sum));
    memset(dp, 0, sizeof(dp));
    for (i = 0; i < n - 1; i++) {
        for (j = i ; j < n; j++) {
            sum[i][j] = (sum[i][j - 1] + arr[j]);
            
        }
    }
    int k;
    for(len = 2;len<=n;len++){
        for(i=0;i<n-len+1;i++){
            j = i+len-1;
            dp[i][j]=inf;
            for(k= i;k<j;k++){
                int q = (dp[i][k] +dp[k+1][j]+sum[i][j]);
                if(q<dp[i][j])
                    dp[i][j]=q;
            }
        }
    }
    cout<<dp[0][n-1];
}

Measured memory_bytes: 2816
#include <iostream>
#include <cstring>

const int MAXN = 3002;
const int P = 998244353;

int a[MAXN];
int64_t f[MAXN][MAXN];

int64_t solve(int n, int sum) {
  memset(f, 0, sizeof(f));
  int64_t ans = 0;
  for (int i = n; i > 0; --i) {
    if (sum > a[i]) ans += i * f[i + 1][sum - a[i]];
    else if (sum == a[i]) ans += i * (n + 1 - i);
    ans %= P;

    for (int j = 1; j <= sum; ++j) {
      f[i][j] = f[i + 1][j];
      if (j >= a[i]) f[i][j] += f[i + 1][j - a[i]];
      f[i][j] %= P;
    }
    f[i][a[i]] += n + 1 - i;
  }
  return ans;
}

int main() {
  int n, sum;
  std::cin >> n >> sum;
  for (int i = 1; i <= n; ++i) std::cin >> a[i];
  std::cout << solve(n, sum) << std::endl;
  return 0;
}


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

#define Flash ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0);
#define F first
#define S second
#define pb push_back
#define nl '\n'
#define NL cout << '\n';
#define EX exit(0)
#define all(s) s.begin(), s.end()
#define ll long long
#define FOR(i, start, finish, k) for(int i = start; i <= finish; i += k)

const long long MXN = 2e5 + 1;
const long long MNN = 1 * 1e4 + 1;
const long long MOD = 1e8;
const long long INF = 1e18;
const long long OO = 1e9 + 500;

typedef long long llong;
typedef unsigned long long ullong;

using namespace std;

llong n, a[MXN], pref[MXN];
llong ans;
map<llong, int> mp;

int main(){
    cin >> n;
    mp[0] = 1;
    for(int i = 1; i <= n; i ++){
        cin >> a[i];
        pref[i] = pref[i - 1] + a[i];
        ans += mp[pref[i]];
        mp[pref[i]]++;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 15872
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int n,x,mx;
long long ans=0;
int main(){
	scanf("%d",&n);
	while(n--){
		scanf("%d",&x);
		ans+=x>=mx?0:mx-x;
		mx=max(mx,x);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1732
N = input()
A = map(int,raw_input().split())
x = 0
for i in range(N):
    minj = i
    for j in range(i,N):
        if A[j] < A[minj]:
            minj = j
    if not minj == i:        
        v = A[i]
        A[i] = A[minj]
        A[minj] = v
        x += 1
    
for i in range(N-1):
    print A[i],
print A[-1]
print x

Measured memory_bytes: 6420
#include<stdio.h>
int main(void){
	int num,h,m,s;
	scanf("%d",&num);
	h=num/3600;
	num=num%3600;
	m=num/60;
	s=num%60;
	printf("%d:%d:%d\n",h,m,s);
	return 0;

}

Measured memory_bytes: 592
#include <algorithm>

#include <bitset>

#include <complex>

#include <deque>

#include <exception>

#include <fstream>

#include <functional>

#include <iomanip>

#include <ios>

#include <iosfwd>

#include <iostream>

#include <istream>

#include <iterator>

#include <limits>

#include <list>

#include <locale>

#include <map>

#include <memory>

#include <new>

#include <numeric>

#include <ostream>

#include <queue>

#include <set>

#include <sstream>

#include <stack>

#include <stdexcept>

#include <streambuf>

#include <string>

#include <typeinfo>

#include <utility>

#include <valarray>

#include <vector>



#if __cplusplus >= 201103L

#include <array>

#include <atomic>

#include <chrono>

#include <condition_variable>

#include <forward_list>

#include <future>

#include <initializer_list>

#include <mutex>

#include <random>

#include <ratio>

#include <regex>

#include <scoped_allocator>

#include <system_error>

#include <thread>

#include <tuple>

#include <typeindex>

#include <type_traits>

#include <unordered_map>

#include <unordered_set>

#endif
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> vec(n);
	for (int i = 0;i < n;i++) {
		cin >> vec[i];
	}
	sort(vec.begin(), vec.end());
	int ans = 0;
	for (int i = 0;i < n-1;i++) {
		ans = ans+vec[i+1] - vec[i];
	}
	cout << ans << endl;
}

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

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

    string tmp1 = S.substr(0, 2); //先MM判定
    string tmp2 = S.substr(2, 2); //後MM判定

    vector<string> month = {"01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"};

    bool can1 = false, can2 = false;
    for(int i = 0; i < 12; i++)
    {
        if(tmp1 == month.at(i)) can1 = true;
        if(tmp2 == month.at(i)) can2 = true;
    }

    if(can1 && !can2)   cout << "MMYY" << endl;
    if(!can1 && can2)   cout << "YYMM" << endl;
    if(can1 && can2)    cout << "AMBIGUOUS" << endl;
    if(!can1 && !can2)  cout << "NA" << endl;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    
    int count = 0;
    
    for (int i = 0; i < N; i++){
        cin >> A.at(i);
        if(A.at(i)%2 == 1) count++;
    }
    
    if(count%2 == 0) cout << "YES" << endl;
    else cout << "NO" <<endl;
    
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
std::string str;
int ptr = 0;
std::vector<int> data;
int find(char a){
  while(ptr < data.size()){
	if(data[ptr] == a)
      return 1;
    if(data[ptr] > a)
      return 0;
    else
      ptr++;
  }
  return 0;
}
int main(){
  cin >> str;
  rep(i,str.size()){
    data.pb(str[i]);
  }
  std::sort(data.begin(),data.end());
  for(char a = 'a';a <='z';a++){
    if(!find(a)){
    	cout << a << endl;
      	break;
    }else if(a == 'z'){
     	cout << "None" << endl;
      	break;
    }
  }
}

Measured memory_bytes: 1020
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner stdIn = new Scanner(System.in);
		int i = stdIn.nextInt();
		if(i == 0) {
			System.out.println(1);
		}else if(i == 1) {
			System.out.println(0);
		}
	}
}

Measured memory_bytes: 35500
#include <bits/stdc++.h>
using namespace std;
inline bool chmin (int& a, int b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
inline bool chmax (int& a, int b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int di[4] = {-1, +1, 0, 0};
int dj[4] = {0, 0, -1, +1};
int main() {
  int h, w;
  cin >> h >> w;
  constexpr int inf = 1e9;
  vector<vector<int>> dst(h, vector<int>(w, inf));
  priority_queue<
    pair<int, pair<int, int>>
  , vector<pair<int, pair<int, int>>>
  , greater<pair<int, pair<int, int>>>
  > que;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      char c;
      cin >> c;
      if (c == '#') {
        que.emplace(
        0
      , pair<int, int>(i, j)
      );
      }
    }
  }
  while (!que.empty()) {
    int crd, cri, crj;
    crd = que.top().first;
    tie(cri, crj) = que.top().second, que.pop();
    if (dst[cri][crj] <= crd) continue;
    chmin(dst[cri][crj], crd);
    for (int k = 0; k < 4; k++) {
      int nxd = crd + 1;
      int nxi = cri + di[k];
      int nxj = crj + dj[k];
      if (
        0 <= nxi && nxi < h &&
        0 <= nxj && nxj < w &&
        dst[nxi][nxj] == inf
      ) {
        que.emplace(
          nxd
        , pair<int, int>(nxi, nxj)
        );
      }
    }
  }
  int ret = 0;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      chmax(ret, dst[i][j]);
    }
  }
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 29548
#include<stdio.h>
#include<string>
#include<algorithm>
#include<iostream>
#include<queue>
#include<math.h>
using namespace std;
struct node
{
    string name;
    int score;
    int num;
}a[105];
bool cmp(node x,node y)
{
    if(x.name!=y.name) return x.name<y.name;
    return x.score>y.score;
}
int main()
{
   int n;
   scanf("%d",&n);
   for(int i=1;i<=n;i++)
   {
       cin>>a[i].name;
       scanf("%d",&a[i].score);
       a[i].num=i;
   }
   sort(a+1,a+n+1,cmp);
   for(int i=1;i<=n;i++)
   {
       printf("%d\n",a[i].num);
   }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<math.h>
using namespace std;
int main(){
  long long a,b,ac,bc;
  std::cin >> a>>b;

  long long big;
  if(a>b)big=a;
  else big=b;

  ac=a;
  bc=b;

  std::vector<long long> a2(big+1,1);
  std::vector<long long> b2(big+1,1);

  for (long long i = 2; i <=a; i++) {
    while (ac%i==0) {
      // std::cout <<i;
      a2[i]*=i;
      ac/=i;
    }
    if(ac==1)break;
  }

  for (long long i = 2; i <=b; i++) {
    while (bc%i==0) {
      b2[i]*=i;
      bc/=i;
    }
    if(bc==1)break;
  }




  long long ans=1;
  for (long long i = 2; i <= big; i++) {
    long long tmp;

    if(a2[i]!=1 || b2[i]!=1){
      if(a2[i]>b2[i])tmp=a2[i];
      else tmp=b2[i];
      // std::cout <<"i"<<i<<":"<<a2[i]<<":"<<b2[i] << '\n';
      ans*=tmp;
    }
  }
  std::cout << ans << '\n';



  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    ll x, a;
    cin >> x >> a;
    cout << ((x >= a) ? 10 : 0) << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

public class Main {

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	void solve() throws IOException {
		long n = nl();
		List<Integer> l = new ArrayList<Integer>();

		long f = 0;
		long[] a = new long[60];
		long[][] range = new long[60][2];
		a[0] = 1;
		for (int i = 1; i < a.length; i++)
			a[i] = a[i - 1] * -2;
		range[0][0] = 0;
		range[0][1] = 1;
		for (int i = 1; i < a.length; i++) {
			range[i][0] = Math.min(range[i - 1][0], range[i - 1][0] + a[i]);
			range[i][1] = Math.max(range[i - 1][1], range[i - 1][1] + a[i]);
		}
//		Helper.tr(a);
//		Helper.tr(range);
		while (n != 0) {
			int p = 0;
			while (!(range[p][0] <= n && range[p][1] >= n))
				p++;
			n -= a[p];
			f |= (1l << p);
//			Helper.tr(n, p);
		}
		out.println(Long.toBinaryString(f));
	}

	private int getP(long n) {
		if (n < 0)
			n = -n;
		int p = 0;
		while (n > 0) {
			n >>= 1;
			p++;
		}
		return p;
	}

	String ns() throws IOException {
		while (!tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine(), " ");
		}
		return tok.nextToken();
	}

	int ni() throws IOException {
		return Integer.parseInt(ns());
	}

	long nl() throws IOException {
		return Long.parseLong(ns());
	}

	double nd() throws IOException {
		return Double.parseDouble(ns());
	}

	String[] nsa(int n) throws IOException {
		String[] res = new String[n];
		for (int i = 0; i < n; i++) {
			res[i] = ns();
		}
		return res;
	}

	int[] nia(int n) throws IOException {
		int[] res = new int[n];
		for (int i = 0; i < n; i++) {
			res[i] = ni();
		}
		return res;
	}

	int[][] nia(int n, int m) throws IOException {
		int[][] res = new int[n][];
		for (int i = 0; i < n; i++) {
			res[i] = nia(m);
		}
		return res;
	}

	long[] nla(int n) throws IOException {
		long[] res = new long[n];
		for (int i = 0; i < n; i++) {
			res[i] = nl();
		}
		return res;
	}

	public static void main(String[] args) throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		tok = new StringTokenizer("");
		Main main = new Main();
		main.solve();
		out.close();
	}
}

Measured memory_bytes: 22996
import random
D = int(input())
C = input().split()
C = [int(c) for c in C]
S = []
for i in range(D):
  s = input().split()
  s = [int(j) for j in s]
  S.append(s)
#T = [1,17,13,14,13]
T = [1] * D
def value():
  M = 0
  last = [0] * 26
  for d in range(1,D+1):
    N = 0
    t = T[d-1]
    last[t-1] = d
    #print(last)
    for j in range(26):
      N = N + C[j]*(d-last[j])
    M = M + S[d-1][t-1] - N
  return(M)
Vmax = value()
#print(Vmax)
Q = []
for i in range(1000):
  Q.append([random.randint(1,D), random.randint(1,26)])
for i in range(1000):
  Tprev = T
  T[Q[i][0]-1] = Q[i][1]
  V = value()
  if V > Vmax:
    Vmax = V
  else:
    T = Tprev
  #print(Vmax)
#print(T)
for t in T:
  print(t)

Measured memory_bytes: 9728
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

int main(){

  ll h,w;
  cin >> h >> w;

  vector<vector<char>> e(h+2,vector<char>(w+2,'a'));

  for(int i=0;i<w+2;i++){
    e[0][i]='#';
    e[h+1][i]='#';
  }

  for(int i=1;i<h+1;i++){
    e[i][0]='#';
    for(int j=1;j<w+1;j++)cin >> e[i][j];
    e[i][w+1]='#';
  }

  ll dp1[h+2][w+2];//縦方向
  ll dp2[h+2][w+2];
  memset(dp1,-1,sizeof(dp1));
  memset(dp2,-1,sizeof(dp2));

  for(int i=1;i<h+1;i++){
    for(int j=1;j<w+1;j++){
      if(dp1[i][j]!=-1)continue;
      if(e[i][j]=='#'){
        dp1[i][j]=0;
        continue;
      }
      ll k=0;
      while(e[i][j+k]=='.'){
        k++;
      }
      for(int l=0;l<k;l++){
        dp1[i][j+l]=k;
      }
    }
  }

  for(int i=1;i<h+1;i++){
    for(int j=1;j<w+1;j++){
      if(dp2[i][j]!=-1)continue;
      if(e[i][j]=='#'){
        dp2[i][j]=0;
        continue;
      }
      ll k=0;
      while(e[i+k][j]=='.'){
        k++;
      }
      for(int l=0;l<k;l++){
        dp2[i+l][j]=k;
      }
    }
  }

  ll m=0;
  for(int i=0;i<h+2;i++){
    for(int j=0;j<w+2;j++)m=max(m,dp1[i][j]+dp2[i][j]-1);
  }
  cout << m << endl;


}

Measured memory_bytes: 66816
o=input()
e=input()
oe=''
if len(o)-len(e)>0:
  for i in range(len(e)):
    oe+=o[i]
    oe+=e[i]
  oe+=o[i+1]
elif len(o)-len(e)==0:
  for i in range(len(e)):
    oe+=o[i]
    oe+=e[i]
elif len(o)-len(e)<0:
  for i in range(len(o)):
    oe+=o[i]
    oe+=e[i]
  oe+=e[i+1]
print(oe)

Measured memory_bytes: 3064
def main():
    N = int(input())
    S = input()
    dp = [[0] * 5005 for _ in range(5005)]
    for i in range(N-1,-1,-1):
        for j in range(N-1,-1,-1):
            if S[i] == S[j]:
                dp[i][j] = dp[i+1][j+1] + 1

    ans = 0
    for i in range(N):
        for j in range(N):
            if i >= j:
                continue
            now = min(dp[i][j], j-i)
            ans = max(ans, now)

    print(ans)
    


if __name__ == "__main__":
    main()

Measured memory_bytes: 231944
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <numeric>
#include <functional>
#include <math.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)


int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    string s;
    cin >> s;
    int K = s.size();
    int l = 0;
    for (int k = 0; k < K; ++k) {
        if (s[k] == 'x') ++l;
    }
    if (l < 8) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}


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

typedef struct point2d{
  int x,y;
} point;

int cmp(const void *a,const void *b){
  point *p=(point *)a;
  point *q=(point *)b;
  if(p->x!=q->x) return p->x-q->x;
  return p->y-q->y;
}

void run(void){
  int h,w,n;
  scanf("%d%d%d",&h,&w,&n);
  point *p=(point *)calloc(n,sizeof(point));
  int i;
  for(i=0;i<n;i++){
    scanf("%d%d",&p[i].y,&p[i].x);
  }
  qsort(p,n,sizeof(point),cmp);
  int min=h;
  int now=1;
  int k=0;
  for(i=1;i<=w && k<n;i++){
    while(k<n && p[k].x<i) k++;
    while(k<n && p[k].x==i && p[k].y<now) k++;
    while(k<n && p[k].x==i && p[k].y==now){
      now++;
      k++;
    }
    if(k<n && p[k].x==i && p[k].y>now){
      if(min>p[k].y-1) min=p[k].y-1;
    }
    now++;
  }
  printf("%d\n",min);
}

int main(void){
  run();
  return 0;
}


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

using namespace std;

using i32 = int32_t;
using u32 = uint32_t;
using f32 = float;
using f64 = double;
using i64 = int64_t; 
using u64 = uint64_t; 

#define SELECTER(_1, _2, _3, _4, _5, _6, _7, _8, SELECT, ...) SELECT

#define _FC1(func, type, _1)      func(type, _1) 
#define _FC2(func, type, _1, ...) func(type, _1); _FC1(func, type, __VA_ARGS__)
#define _FC3(func, type, _1, ...) func(type, _1); _FC2(func, type, __VA_ARGS__) 
#define _FC4(func, type, _1, ...) func(type, _1); _FC3(func, type, __VA_ARGS__)
#define _FC5(func, type, _1, ...) func(type, _1); _FC4(func, type, __VA_ARGS__)
#define _FC6(func, type, _1, ...) func(type, _1); _FC5(func, type, __VA_ARGS__)
#define _FC7(func, type, _1, ...) func(type, _1); _FC6(func, type, __VA_ARGS__)
#define _FC8(func, type, _1, ...) func(type, _1); _FC7(func, type, __VA_ARGS__)

#define _FCN(func, type, ...) SELECTER(__VA_ARGS__, _FC8, _FC7, _FC6, _FC5, _FC4, _FC3, _FC2, _FC1)(func, type, __VA_ARGS__)

constexpr const char *type2fmt(const char *fmt) {
  if(strcmp(fmt, "i32") == 0) return "%d";
  if(strcmp(fmt, "u32") == 0) return "%u";
  if(strcmp(fmt, "f32") == 0) return "%f";
  if(strcmp(fmt, "f64") == 0) return "%lf";
  if(strcmp(fmt, "i64") == 0) return "%lld";
  if(strcmp(fmt, "u64") == 0) return "%llu";
  return "";
}

#define _R(type, _1) type _1; { type _t; scanf(type2fmt(#type), &_t); _1 = _t; }
#define _P(type, _1) { const type _t = (_1); printf(type2fmt(#type), _t); putchar('\n'); }

#define RI(...)   _FCN(_R, i32, __VA_ARGS__)
#define RUI(...)  _FCN(_R, u32, __VA_ARGS__)
#define RF(...)   _FCN(_R, f32, __VA_ARGS__)
#define RD(...)   _FCN(_R, f64, __VA_ARGS__)
#define RLL(...)  _FCN(_R, i64, __VA_ARGS__)
#define RULL(...) _FCN(_R, u64, __VA_ARGS__)

#define PI(...)   _FCN(_P, i32, __VA_ARGS__)
#define PUI(...)  _FCN(_P, u32, __VA_ARGS__)
#define PF(...)   _FCN(_P, f32, __VA_ARGS__)
#define PD(...)   _FCN(_P, f64, __VA_ARGS__)
#define PLL(...)  _FCN(_P, i64, __VA_ARGS__)
#define PULL(...) _FCN(_P, u64, __VA_ARGS__)

#define REP(n) for (int _i = 0; _i < n; _i++)

const u64 mod = 1000000007;

int main() {
  RULL(X);
  if (X == 7 || X == 5 || X == 3) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,T,A;
  cin >> N >> T >>  A;
  vector <int> H(N);
  for (int i=0;i<N ; i++){
    cin >> H[i];
  }
  int res = 3000000;
  int findID=-1;
  for (int i=0;i<N ; i++){
    if((T*1000-H[i]*6)-A*1000>=0){
      if(res>(T*1000-H[i]*6)-A*1000){
        res=(T*1000-H[i]*6)-A*1000;
        findID=i+1;
      }
    }
    if((T*1000-H[i]*6)-A*1000<0){
      if(res>(-T*1000+H[i]*6)+A*1000){
        res=(-T*1000+H[i]*6)+A*1000;
        findID=i+1;
      }
    }
  }
  cout << findID << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define INF 100000000000
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using P = pair<int, int>;

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

int main()
{
    string a, b;
    cin >> a >> b;

    ll lenA = a.length();
    ll lenB = b.length();
    if (lenA == lenB) {
        rep(i,lenA) {
            if ((a[i] - '0') == (b[i] - '0')) {
                continue;
            } else if ((a[i] - '0') > (b[i] - '0')) {
                cout << "GREATER" << endl;
                return 0;
            } else {
                cout << "LESS" << endl;
                return 0;
            }
        }
        cout << "EQUAL";
    } else if (lenA > lenB) {
        cout << "GREATER";
    } else {
        cout << "LESS";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

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

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100000;

struct mint {
    ll x;
    mint(ll x=0):x((x%MOD+MOD)%MOD){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {if ((x+=a.x)>=MOD) x-=MOD; return *this;}
    mint& operator-=(const mint a) {if ((x+=MOD-a.x)>=MOD) 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;}
};

const int cmax = 100010;
mint fac[cmax],finv[cmax],inv[cmax];

void com_init() {
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for (int i=2; i<cmax; i++) {
        fac[i]=fac[i-1]*i;
        inv[i]=-inv[MOD%i]*(MOD/i);
        finv[i]=finv[i-1]*inv[i];
    }
}

mint com(int n, int k) {
    if (n<k) return 0;
    if (n<0||k<0) return 0;
    mint ret=fac[n]*finv[k]*finv[n-k];
    return ret;
}

int main() {
	int n,m;cin>>n>>m;
	bool p[N];
	rep(i,N) p[i]=true;
	p[0]=p[1]=false;
	rep(i,N){
		if(!p[i]) continue;
		for(int j=2*i;j<N;j+=i) p[j]=false;
	}
	com_init();
	mint ans=1;
	rep1(i,N){
		if(!p[i]) continue;
		int c=0;
		while(m%i==0) {c++;m/=i;}
		if(c==0) continue;
		mint a=0;
		for(int j=1;j<=min(c,n);j++) a+=com(n,j)*com(c-1,j-1);
		ans*=a;
	}
	if(m>1) ans*=n;
	cout<<ans.x<<endl;
}


Measured memory_bytes: 2688
package main

import (
	"fmt"
	"sort"
)

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

	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}

	sort.Ints(a)
	for i := 1; i < n; i++ {
		if a[i-1] == a[i] {
			fmt.Println("NO")
			return
		}
	}
	fmt.Println("YES")
}


Measured memory_bytes: 5632
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
int main(){

    vector <char> S(4);
    for (int i = 0; i < 4; i++) cin >> S[i];
    sort(S.begin(), S.end());

    if (S[0] == S[1] && S[2] == S[3] && S[1] != S[2]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    


    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int K = sc.nextInt();
		int Q = sc.nextInt();

		int[] A = new int[Q];

		for (int i=0; i<Q; i++){
			A[i] = sc.nextInt();
		}

		int[] point = new int[N];
		for (int i=0; i<N; i++){
			point[i] = K - Q;
		}

		for (int i=0; i<Q; i++){
			point[A[i]-1]++;
		}
		for (int i=0; i<N; i++){
			if (point[i] > 0){
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}
	}
}

Measured memory_bytes: 57100
#include<stdio.h>
#include<stdlib.h>

int compare_int(const void *a, const void *b)
{
    return *(int*)b - *(int*)a;
}

int main(){
  int i,j,k;
  int N,flg=0;
  scanf("%d",&N);
  int A[N];
  int B[2][N];
  
  for(i=0;i<2;i++){
    for(j=0;j<N;j++){
      scanf("%d ",&B[i][j]);
      A[j]=0;
    }
  }
  
  for(i=0;i<N;i++){
    flg=0;
    for(j=0;j<N;j++){
      A[i]+=B[flg][j];
      if(i==j){
        flg=1;
        A[i]+=B[flg][j];
      }
    }
  }
  
  qsort(A, N, sizeof(int), compare_int);
  printf("%d\n",A[0]);
  return 0;
}

        

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

using namespace std;


int main(){
    int num_query;
    int command,val;
    char key[20];
    char L[20],R[20];
    scanf("%d",&num_query);
    map<string,int> map_array;

    for(int i = 0;i < num_query;i++){
        scanf("%d %s",&command,key);
        if(command == 0){
            scanf("%d",&val);
            map_array[key] = val;
        }else if(command == 1){
            if(map_array.find(key) != map_array.end()) printf("%d\n",map_array[key]);
            else printf("0\n");
        }else if(command == 2){
            if(map_array.find(key) != map_array.end()) map_array.erase(key);
        }else if(command == 3){
            scanf("%s",R);
            map<string,int>::iterator itr = map_array.lower_bound(key);
            while(itr != map_array.upper_bound(R)){
                printf("%s %d\n",itr->first.c_str(),itr->second);
                itr++;
            }
        }
    }

    return 0;   
}



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

using namespace std;

int main(void)
{
  int N;
  uint64_t ans = 1;
  cin >> N;
  for(int i = 1; i <= N; i++){
    ans *= i;
    ans %= 1000000000 + 7;
  }

  cout << ans << endl;

  return 0;
}


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

int main() {
    int n;
    cin >> n;
    int max_len = 0;
    vector<int> l(n + 1);
    for (int i = 0; i < n; i++) {
        int p;
        cin >> p;
        l[p] = l[p - 1] + 1;
        max_len = max(max_len, l[p]);
    }

    cout << n - max_len << endl;
}

Measured memory_bytes: 1024