akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <stack>

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

using namespace std;

struct E {
	int a;
	int b;
	int ra;
	int rb;
};

struct N {
	int r;
	vector<E*> es;
	E* pe = nullptr;
};

void assign_rank(vector<N>& ns, int n)
{
	vector<bool> is_visit(n + 1);

	stack<int> s;
	s.push(1);

	while (!s.empty()) {
		int ci = s.top();
		auto& cn = ns[ci];
		if (is_visit[ci]) {
			cn.r++;
			if (cn.pe != nullptr) {
				auto e = cn.pe;
				if (ci == e->a) {
					e->ra = cn.r;
					e->rb = n - cn.r;
					ns[e->b].r += cn.r;
				}
				else {
					e->rb = cn.r;
					e->ra = n - cn.r;
					ns[e->a].r += cn.r;
				}
			}
			s.pop();
			continue;
		}

		is_visit[ci] = true;
		for (auto e : cn.es) {
			int ni = (e->a == ci) ? e->b : e->a;
			if (!is_visit[ni]) {
				ns[ni].pe = e;
				s.push(ni);
			}
		}
	}
}

int64_t pow_rem(int64_t x, int64_t m, int64_t rem)
{
	if (m == 0) {
		return 1;
	}
	if (m == 1) {
		return x;
	}

	if (m & 1) {
		int64_t val = pow_rem(x, m / 2, rem);
		val = val * val;
		val %= rem;
		val *= x;
		val %= rem;
		return val;
	}
	else {
		int64_t val = pow_rem(x, m / 2, rem);
		val = val * val;
		val %= rem;
		return val;
	}
}

int64_t pow_remdiv(int64_t val, int64_t rem)
{
	return pow_rem(val, rem - 2, rem);
}


int64_t divide_rem(int64_t divident, int64_t dividor, int64_t rem)
{
	int64_t ret = pow_remdiv(dividor, rem);
	ret *= divident;
	ret %= rem;

	return ret;
}

static const int64_t kRem = 1000000007;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int n; cin >> n;

	vector<N> ns(n + 1);
	vector<E> es(n - 1);

	FOR_LT(i, 0, n - 1) {
		int a, b; cin >> a >> b;
		es[i].a = a;
		es[i].b = b;

		ns[a].es.push_back(&es[i]);
		ns[b].es.push_back(&es[i]);
	}

	assign_rank(ns, n);

	int64_t x = 0;
	FOR_LE(i, 1, n) {
		if (ns[i].es.size() == 1) continue;

		int64_t ci = 1;
		int64_t ri = 0;
		for (auto e : ns[i].es) {
			int64_t r  = (e->a == i) ? e->rb : e->ra;
			int64_t cr = pow_rem(2, r, kRem);
			ci *= cr;
			ci %= kRem;
			ri += cr - 1;
			ri %= kRem;
		}
		x += (ci - ri - 1);
		x %= kRem;
		while (x < 0) x += kRem;
	}

	int64_t y = pow_rem(2, n, kRem);

	int64_t z = divide_rem(x, y, kRem);

	cout << z << endl;

	return 0;
}

Measured memory_bytes: 18688
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int a = Integer.parseInt(s.substring(0,2)),b=Integer.parseInt(s.substring(2));
		if(checkMM(a)  && checkMM(b)) {
			System.out.println("AMBIGUOUS");
		}else if(checkMM(a)){
			System.out.println("MMYY");
		}else if(checkMM(b)) {
			System.out.println("YYMM");
		}else {
			System.out.println("NA");
		}
	}

	public static boolean checkMM(int i) {
		if(i > 0 && i < 13) return true;
		return false;
	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for (ll i=0; i<(n); ++i)
#define rep1(i,n) for (ll i=1; i<=(n); ++i)
typedef long long ll;
bool debug=false;
string yes = "Yes";
string no = "No";
const ll mod = 998244353;
const double e = 0.000000001;

int main(){
  int a,b,c; cin >> a >> b >> c;
  cout << a*b/2 ;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int inf=1000000000;

bool cmp(pair<int,int> a, pair<int,int> b){
	return a.second<b.second;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >>n;
	int h[n];
	for(int i=0;i<n;i++ ) cin >>h[i];
	int ans[n];
	ans[0]=0;
	ans[1]=abs(h[1]-h[0]);
	for(int i=2;i<n;i++){
		ans[i] = min(ans[i-1]+abs(h[i]-h[i-1]), ans[i-2]+abs(h[i]-h[i-2]));
	}
	cout <<ans[n-1]<<"\n";
}


Measured memory_bytes: 1024
N = int(input())
ans = [0]*10050

for i in range(N+1):
    ans.append(0)

for x in range(1,105):
    for y in range(1,105):
        for z in range(1,105):
            tmp = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if tmp < 10050:
                ans[tmp] += 1
for i in range(N):
    print(ans[i+1])

Measured memory_bytes: 9348
#include <stdio.h>
#include <math.h>
#include <string.h>
int main()
{
    long long n,i;
    while(~scanf("%lld",&n))
    {
        for(i=n; i>0; i--)
        {
            if(i*i<=n)
                break;
        }
        printf("%lld\n",i*i);
    }
    return 0;
}

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


public class Main {
	public static void main(String[] args) throws IOException{
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while(true){
		
		String[] input = br.readLine().split(" ");
		
		int tyuukan = Integer.parseInt(input[0]);
		int kimatu = Integer.parseInt(input[1]);
		int saisiken = Integer.parseInt(input[2]);
		int sum = tyuukan + kimatu;
		
		if(tyuukan == -1 && kimatu == -1 && saisiken == -1){
			break;
		}
		if(tyuukan == -1 || kimatu == -1){
			System.out.println("F");
		}else if(sum >= 80){
			System.out.println("A");
		}else if(65<=sum && sum <80){
			System.out.println("B");
		}else if(50<=sum && sum <65){
			System.out.println("C");
		}else if(30<=sum && sum <50){
			if(saisiken >= 50){
				System.out.println("C");
			}else{
				System.out.println("D");
			}
		}else if(30>sum){
			System.out.println("F");
		}else{
			System.out.println("F");
		}
		
		}
	}
	
}

Measured memory_bytes: 24192
#include <bits/stdc++.h>
using namespace std;
 
 
int main(){
  string str,tmp_str,tmp_str2;
  int count,tmp_length;
  cin>>str;
  count=1;
  tmp_str2="";
  tmp_str=str[0];
  str.erase(str.begin());  
  while(str.length()>0){
    tmp_length=tmp_str.length();
    if(tmp_length==1){
      tmp_str2+=str[0];
      str.erase(str.begin());
      if(tmp_str2==tmp_str&&str.length()>0){
        tmp_str2+=str[0];
        str.erase(str.begin());
        count++;
      }else if(tmp_str2==tmp_str&&str.length()==0){
        break;
      }else{
        count++;
      }
    }else{
      tmp_str2+=str[0];
      str.erase(str.begin());
      count++;
    }
    tmp_str=tmp_str2;
    tmp_str2="";
  }  

  cout<<count<<endl;
}

Measured memory_bytes: 640
/*	
*  Sachin Mittal
*/
#include<bits/stdc++.h>
#define int long long
#define M 998244353
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define mem0(dp) memset(dp,0,sizeof(dp))
#define mem1(dp) memset(dp,-1,sizeof(dp))
#define pb push_back
#define sz(s) (int)(s.size())
using namespace std;
int32_t main(){
ios
int t=1;
//cin>>t;
while(t--)
{
	int n;cin>>n;
	set<int> s;
	s.insert(n);
	for(int i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			int temp=n;
			while(temp%i==0)
				temp/=i;
			if(temp%i==1)s.insert(i);
			temp=n;
			while(temp%(n/i)==0)
				temp/=(n/i);
			if(temp%(n/i)==1)s.insert(n/i);
		}
	}
	//for(auto i:s)cout<<i<<" ";
	n--;
	for(int i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			s.insert(i);
			s.insert(n/i);
		}
	}
	if(n!=1)
	s.insert(n);
	cout<<sz(s);	
}
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <vector>
#include <map>
#include <stdio.h>
using namespace std;
#define MAX 100000;
#define SENTINEL 2000000000;
typedef long long int ll;

struct Card {
	char suit;
	int value;
};

struct Card L[100000 / 2 + 2], R[100000 / 2 + 2];

void merge(struct Card A[], ll left, ll mid, ll right) {
	ll n1 = mid - left, n2 = right - mid;
	for (int i = 0; i < n1; i++) {
		L[i] = A[left + i];
	}
	for (int i = 0; i < n2; i++) {
		R[i] = A[mid + i];
	}
	L[n1].value = R[n2].value = SENTINEL;
	ll i = 0, j = 0;
	for (ll k = left; k < right; k++) {
		if (L[i].value <= R[j].value) {
			A[k] = L[i++];
		}
		else {
			A[k] = R[j++];
		}
	}
}
void MergeSort(struct Card A[], ll N, ll left, ll right) {
	int mid;
	if (left + 1 < right) {
		ll mid = (left + right) / 2;
		MergeSort(A, N, left, mid);
		MergeSort(A, N, mid, right);
		merge(A, left, mid, right);
	}
}
int partition(struct Card A[], int N, int P, int R) {
	int i = P - 1, j;
	struct Card X = A[R], t;
	for (int j = P; j < R; j++) {
		if (A[j].value <= X.value) {
			i++;
			t = A[i]; A[i] = A[j]; A[j] = t;
		}
	}
	t = A[i + 1]; A[i + 1] = A[R]; A[R] = t;
	return i + 1;
}
void QuickSort(struct Card A[], int N, int P, int R) {
	int Q;
	if (P < R) {
		Q = partition(A, N, P, R);
		QuickSort(A, N, P, Q - 1);
		QuickSort(A, N, Q + 1, R);
	}
}
int main() {
	int N, V;
	struct Card A[100000], B[100000];
	char S;
	int stable = 1;

	cin >> N;
	for (int i = 0; i < N; i++ ) {
		cin >> S >> V;
		A[i].suit = B[i].suit = S;
		A[i].value = B[i].value = V;
	}

	MergeSort(A, N, 0, N);
	QuickSort(B, N, 0, N - 1);
	for (int i = 0; i < N; i++) {
		if (A[i].suit != B[i].suit)stable = 0;
	}
	if (stable == 1) cout << "Stable" << endl;
	else cout << "Not stable" << endl;
	for (int i = 0; i < N; i++) {
		cout << B[i].suit << ' ' << B[i].value << endl;
	}
}



Measured memory_bytes: 5436
#include <stdio.h>

int main(void) {
	int a, b;
	scanf("%d %d", &a, &b);
	if(a<b)
		printf("a < b\n");
	else if(a>b)
		printf("a > b\n");
	else
		printf("a == b\n");	
	return 0;
}



Measured memory_bytes: 2100
/**
SXR0aXAkI0JwbXptI3FhI3Z3I293bCNqY2IjUG0jMCNicG0jVHFkcXZvLyNCcG0jQW10bjBhY2phcWFicXZvLyNNYm16dml0MSNWdyNhdGN1am16I2tpdiNhbXF9bSNQcXUjVnd6I0F0bW14MSNQcWEjaXptI2l0dCNicHF2b2EjUXYjYnBtI3BtaWRtdmEjaXZsI3d2I21pemJwMSNFcHcjcWEjYnBtem0ja2l2I3F2Ym16a21sbSNRdiNQcWEjeHptYW12a20jbXtrbXhiI0lhI3BtI3htenVxYmJtYnBHI1BtI3N2d2VtYnAjRXBpYiMraXh4bWl6bWJwI2J3I1BxYSNrem1pYmN6bWEjSWEsI0ptbnd6bSN3eiNJbmJteiN3eiNKbXBxdmwjYnBtdTEjVnd6I2FwaXR0I2JwbXwja3d1eGlhYSNJY29wYiN3biNwcWEjc3Z3ZXRtbG9tI017a214YiNpYSNQbSNlcXR0bWJwMSNQcWEjYnB6d3ZtI2x3YnAjbXtibXZsI1dkbXojYnBtI3BtaWRtdmEjSXZsI3d2I21pemJwLyNpdmwjUG0jbm1tdG1icCNWdyNuaWJxb2NtI3F2I29jaXpscXZvI0l2bCN4em1hbXpkcXZvI2JwbXUvI053eiNQbSNxYSNicG0jVXdhYiNQcW9wMSNCcG0jQWN4em11bSMrcXYjb3R3enwsMQ==
*/
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>

#define F first
#define S second
#define endl '\n'
#define deb(x) cout<<#x<<' '<<x<<endl;
#define pb push_back

/*
#ifdef IZI_KATKA
#define int __int64_t
#else
#define int __int64
#endif
*/

const long long MOD = 1e9 + 7;
const long long MAXN = 1e6 + 1;
using namespace std;

typedef long long ll;

long long readInt() {
    bool minus1 = false;
    long long result = 0;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus1 = true; else result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus1)
        return -result;
    else
        return result;
}

const int MXN = 1e5 + 7;
int cnt[MAXN];
int a[MAXN];

int main() {
	#ifdef IZI_KATKA
	assert(freopen("input", "r", stdin));
    assert(freopen("output", "w", stdout));
    #endif
    int n = readInt(), k = readInt();
    int G = 0;
    int mx = 0;
    for (int i = 1; i <= n; i++) {
    	a[i] = readInt();
    	G = __gcd(G, a[i]);
    	mx = max(mx, a[i]);
    }
    if (mx < k) {
    	cout << "IMPOSSIBLE";
    } else {
    	cout << (k % G == 0 ? "POSSIBLE" : "IMPOSSIBLE");
    }
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

const int MAX = 100;

int main() {
	int N;
	cin >> N;
	int D[MAX];

	for (int i = 0; i < N ; i++) {
		cin >> D[i];
	}
	sort(D, D+N);
	int c = 1;
	for (int i = 0; i < N-1 ; i++) {
	 if(D[i]!=D[i+1]){
		 c++;
	 }
	}
	cout << c << endl;
	return 0;
}


Measured memory_bytes: 256
import sys
def input():
    return sys.stdin.readline()[:-1]
mod=10**9+7
N=int(input())
A=list(map(int,input().split()))
pr=[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 
71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 
313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 
787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997]
pl=[0]*168
l=[[] for i in range(N)]
for i in range(N):
    t=A[i]
    for j,p in enumerate(pr):
        c=0
        while 1:
            if t%p:
                break
            t//=p
            l[i].append(j)
            c+=1
        if c>pl[j]:
            pl[j]=c
    if t>1:
        pr.append(t)
        l[i].append(len(pl))
        pl.append(1)
lcm=1
for i,p in enumerate(pl):
    lcm=(lcm*pow(pr[i],p,mod))%mod
ipr=[]
for i in pr:
    ipr.append(pow(i,mod-2,mod))
a=0
for i in l:
    t=lcm
    for j in i:
        t=(t*ipr[j])%mod
    a=(a+t)%mod
print(a)

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

using namespace std;

int main(){
  	string a, b; cin >> a >> b;
  	int n1 = int(a.size()), n2 = int(b.size());
 	if(n1 > n2){
    	cout << "GREATER";
      	return 0;
    } else if(n2 > n1){
    	cout << "LESS";
      	return 0;
    }
  	for(int i = 0;i < n1;i++){
    	if(a[i] > b[i]){
        	cout << "GREATER";
          	return 0;
        } else if(a[i] < b[i]){
        	cout << "LESS";
          	return 0;
        }
    }
  	cout << "EQUAL";
	return 0;
}

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

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    int cnt=1;
    while(cnt < (b+1))
    {
        if((a*cnt)%b==c)
        {
            cout << "YES" << endl;
            break;
        }
        cnt++;
    }
    if(cnt==(b+1))
    {

        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll ai,ao,at,aj,al,as,az;cin>>ai>>ao>>at>>aj>>al>>as>>az;
  ll ans=(ai/2)*2+ao+(aj/2)*2+(al/2)*2;
  if(ai%2==1&&aj%2==1&&al%2==1)ans+=3;
  else{
    if(ai>0&&aj>0&&al>0){
      ll c=0;
      if(ai%2==0)c++;
      if(aj%2==0)c++;
      if(al%2==0)c++;
      if(c==1)ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int N_MAX = 5001;
typedef long long ll;
int main()
{
  int n,k,m=0,ss,r,i,j,ii,jj;
  int p[N_MAX],se[N_MAX];
  ll ma,t,re,res;
  ll c[N_MAX],su[N_MAX];
  cin >> n >> k;
  fill(se+1,se+n+1,-1);
  for(i=1;i<=n;i++)
    cin >> p[i];
  for(i=1;i<=n;i++)
    cin >> c[i];
  res=*max_element(c+1,c+n+1);
  for(i=1;i<=n;i++){
    if(se[i]>=0)
      continue;
    ss=0;
    se[i]=m;
    t=c[i];
    su[ss]=t;
    ma=c[i];
    j=p[i];
    ss++;
    while(j!=i){
      se[j]=m;
      t+=c[j];
      su[ss]=t;
      ma=max(ma,c[j]);
      j=p[j];
      ss++;
    }
    m++;
    if(ma<0){
      continue;
    }
    if(t>=0){
      r=(k-1)%ss+1;
    }else{
      r=min(k,ss);
    }
    re=0;
    for(ii=0;ii<ss;ii++)
      for(jj=0;jj<ss;jj++){
        if(jj-ii>r||((jj<=ii)&&(jj+ss-ii>r)))
          continue;
        if(ii<jj){
          re=max(re,su[jj]-su[ii]);
        }else{
          re=max(re,su[jj]+t-su[ii]);
        }
      }
    if(t>=0){
      res=max(res,re+t*((k-1)/ss));
    }else{
      res=max(res,re);
    }
  }
  cout << res << endl;
  return 0;
}

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

int main (){
    double d;
    int n;
    int x[7],y[7];
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>x[i]>>y[i];
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            d+=pow(pow(x[i]-x[j],2.000000)+pow(y[i]-y[j],2.000000),0.50000);
        }
    }
    printf("%f\n",d/n);
}

Measured memory_bytes: 512
import java.io.*;
import java.util.*;
import static java.lang.System.*;

public class Main {
	static FastScanner sc = new FastScanner(System.in);
	public static void main(String[] args) {
		String[] dow = {"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
		int month,day;
		Calendar cal = Calendar.getInstance();
		
		while (true) {
			month = sc.nextInt();
			day = sc.nextInt();
			if (month==0) {break;}
			
			cal.set(2004,month-1,day);
			
			out.println(dow[cal.get(Calendar.DAY_OF_WEEK)-1]);
		}
	}
}



class FastScanner implements Closeable {
	private final InputStream in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	public FastScanner(InputStream in) {this.in = in;}
	private boolean hasNextByte() {
		if (ptr < buflen) {return true;}
		else{
			ptr = 0;
			try {buflen = in.read(buffer);}
			catch (IOException e) {e.printStackTrace();}
			if (buflen <= 0) {return false;}
		}
		return true;
	}
	private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
	private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
	public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
	public String next() {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while(isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext()) throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {throw new NumberFormatException();}
		while(true){
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			}else if(b == -1 || !isPrintableChar(b)){return minus ? -n : n;}
			else{throw new NumberFormatException();}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) nl;
	}
	public double nextDouble() { return Double.parseDouble(next());}
	public void close() {
		try {in.close();}
		catch (IOException e) {}
	}
}


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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii; typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <class F,class ...S> void dbg(const F& f, const S&...s){cerr <<f <<": "; dbg(s...);}


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, m, k;
	cin >>n >>m >>k;
	VI a(n), b(m);
	rep(i, n) cin >>a[i];
	rep(i, m) cin >>b[i];
	
	VL sma(n+1), smb(m+1);
	rep(i, n) sma[i+1]=sma[i]+a[i];
	rep(i, m) smb[i+1]=smb[i]+b[i];
	
	ll ans = 0;
	rep(i, n+1){
		if(sma[i] > k) break;
		ll dk = k - sma[i];
		int zb = lower_bound(all(smb), dk) - smb.begin();
		int pa=1;
		if(zb<m+1 && smb[zb]==dk) pa=0;
		
		//dbg(i, zb, dk);
		ans = max<ll>(ans, i + zb -pa);
	}
	
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 7932
A,B,C = map(int, input().split())
if A==B:
  if A!=C:
    print('Yes')
  else:
    print('No')  
elif A==C:
  if A!=B:
    print('Yes')
  else:
    print('No')
elif C==B:
  if A!=C:
    print('Yes')
  else:
    print('No')
else:
  print('No')

Measured memory_bytes: 3060
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    ArrayList<Integer> expo = new ArrayList<>();
    for (int b = 1; b <= 1000; b++) {
      int tmp = b;
      for (int p = 2; p <= 9; p++) {
        tmp *= b;
        if (tmp <= x) {
          expo.add(tmp);
        }
      }
    }
    Collections.sort(expo);
    System.out.println(expo.get(expo.size() - 1));
  }
}

Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();

		StringBuilder sb = new StringBuilder();
		StringBuilder temp = new StringBuilder();

		for (int i = 0; i < s.length(); i++) {

			String si = s.substring(i, i + 1);

			if (si.equals("A") || si.equals("T") || si.equals("G") || si.equals("C")) {
				temp.append(si);
			} else if (sb.length() < temp.length()) {
				sb.setLength(0);
				sb.append(temp.toString());
				temp.setLength(0);
			} else {
				temp.setLength(0);
			}
		}

		if (sb.length() < temp.length()) {
			sb.setLength(0);
			sb.append(temp.toString());
			temp.setLength(0);
		}

		System.out.println(sb.length());
	}

}

Measured memory_bytes: 22740
#include<bits/stdc++.h> 
//compiling code: g++ test.cpp(file) -o script(output) -std=c++11(version) -O2(make it 2x faster)
using namespace std;

queue<pair<int,int>> Q;
int dist[200005];
int N, M, AI, BI;
vector<int> G[200005];

int main(){
    cin >> N >> M;
    for(int i=0; i<M; i++){
        cin >> AI >> BI;
        G[AI].push_back(BI);
        G[BI].push_back(AI);
    }

    memset(dist, -1, sizeof(dist));
    int SOURCE = 1;
    Q.push(make_pair(0, SOURCE));

    while(!Q.empty()){
        int d = Q.front().first, u = Q.front().second;//takes out nearest node
        Q.pop();
        if(dist[u] != -1) continue;//check if visited
        dist[u] = d;//update the distance
        for (int i=0; i<G[u].size(); i++){
            Q.push(make_pair(d + 1, G[u][i]));
        }
    }
    if (dist[N] == 2){
        cout << "POSSIBLE" << "\n";
    } else {
        cout << "IMPOSSIBLE" << "\n";
    }

    return 0;
}

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

using namespace std;

int a[1000010];
int cnt[1000010];
bool flag[1000010];

int gcd(int x,int y) {
    return y ? gcd(y, x % y) : x;
}


int main() {
    int n;
    cin >>n;
    for(int i = 1;i <= n; i++) {
        cin >> a[i];
        cnt[a[i]]++;
    }
    int x = gcd(a[1],a[2]);
    for(int i=3;i<=n;i++) {
        x = gcd(x,a[i]);
        if(x == 1)break;
    }
    if(x > 1) {
        cout << "not coprime" << endl;
        return 0;
    } else {
        for(int i=2;i<=1000000;i++) {
            if(flag[i]) continue;
            int t = 0;
            for(int j = i;j <= 1000000;j += i){
                t += cnt[j];
                flag[j]=1;
            }
            if(t > 1) {
                cout << "setwise coprime" << endl;
                return 0;
            }
        }
    }
    cout << "pairwise coprime" << endl;
    return 0;
}


Measured memory_bytes: 12272
#include<bits/stdc++.h>
using namespace std;
const int maxn = 500 + 7, maxm = 250000 + 7;
int n, xd[maxm], yd[maxm], ans[maxn][maxn], sum;
bool vis[maxn][maxn];

void dfs(int x, int y) {
	int p = vis[x][y]? 0 : 1;
	if(ans[x - 1][y] > ans[x][y] + p) {
		ans[x - 1][y] = ans[x][y] + p;
		dfs(x - 1, y);
	}
	if(ans[x + 1][y] > ans[x][y] + p) {
		ans[x + 1][y] = ans[x][y] + p;
		dfs(x + 1, y);
	}
	if(ans[x][y - 1] > ans[x][y] + p) {
		ans[x][y - 1] = ans[x][y] + p;
		dfs(x, y - 1);
	}
	if(ans[x][y + 1] > ans[x][y] + p) {
		ans[x][y + 1] = ans[x][y] + p;
		dfs(x, y + 1);
	}
}

void debug() {
	printf("debug:\n");
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= n; ++j) {
			printf("%d ", ans[i][j]);
		}
		printf("\n");
	}
}

int main() {
	scanf("%d", &n);
	int x, y;
	for (int i = 1; i <= n * n; ++i) {
		scanf("%d", &x);
		y = x; x = (x + n - 1) / n;
		y = y - (x - 1) * n;
		xd[i] = x; yd[i] = y;
	}
	for (int i = 1; i <= n; ++i) 
		for (int j = 1; j <= n; ++j) {
			ans[i][j] = min(i, j) - 1;
			ans[i][j] = min(ans[i][j], n - max(i, j));
		}
	for (int i = 1; i <= n * n; ++i) {
		x = xd[i]; y = yd[i];
		sum += ans[x][y];
		vis[x][y] = 1;
		if(ans[x - 1][y] > ans[x][y]) {
			ans[x - 1][y] = ans[x][y];
			dfs(x - 1, y);
		}
		if(ans[x + 1][y] > ans[x][y]) {
			ans[x + 1][y] = ans[x][y];
			dfs(x + 1, y);
		}
		if(ans[x][y - 1] > ans[x][y]) {
			ans[x][y - 1] = ans[x][y];
			dfs(x, y - 1);
		}
		if(ans[x][y + 1] > ans[x][y]) {
			ans[x][y + 1] = ans[x][y];
			dfs(x, y + 1);
		}
		//debug();
	}
	printf("%d\n", sum);
	return 0;
}

Measured memory_bytes: 33440
#include <iostream>

int main()
{
    long long N, in[5];
    std::cin >> N;
    std::cin >> in[0];
    std::cin >> in[1];
    std::cin >> in[2];
    std::cin >> in[3];
    std::cin >> in[4];

    long long m = 1e15l + 1l;
    for (int i = 0; i < 5; ++i)
    {
        if (m >= in[i])
        {
            m = in[i];
        }
    }

    std::cout << (((N + m - 1l) / m) + 4l) << std::endl;

    return 0;
}


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

typedef long long ll;

int main() {
    string s, t;
    cin >> s >> t;
    int n = int(s.size());
    int m = int(t.size());
    vector<vector<int>> is(26);
    for (int i=0;i<n;i++) is[s[i]-'a'].push_back(i);
    for (int i=0;i<n;i++) is[s[i]-'a'].push_back(i+n);
    ll ans = 0;
    int p = 0;
    for (int i=0;i<m;i++){
        int c = t[i] - 'a';
        if (int(is[c].size()) == 0){
            cout << "-1" << endl;
            return 0;
        }
        p = *lower_bound(is[c].begin(), is[c].end(), p) + 1;
        if (p >= n){
            p -= n;
            ans += n;
        }
    }
    ans += p;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1724
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF INT_MAX
#define LLINF LLONG_MAX
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 
#define MODB  998244353

template <typename T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
    for (T& x: vec) { is >> x; }
    return is;
}

int main() {
	ll ans = 0;
	ll tmp;
	//int n; cin >> n;
	string s, t; cin >> s >> t;
	int ma = 0;
	REP(i, s.size() - t.size() + 1){
		int now = 0;
		REP(j, t.size()){
			if(s[i+j] == t[j]) now ++;
		}
		ma = max(ma, now);
	}
	cout << t.size() - ma << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__",", __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 112000000012345678LL

class SegTree{
public:
  vector<long> data, lazy;
  int n;

  SegTree(int n_){
    n = 1;
    while(n<n_) n*=2;
    data.resize(2*n-1, INF);
    lazy.resize(2*n-1, 0);
  }

  inline void lazyupd(int k){
    if(lazy[k]>0){
      data[k] += lazy[k];
      if(k<n-1){
        lazy[2*k+1] += lazy[k];
        lazy[2*k+2] += lazy[k];
      }
      lazy[k] = 0;
    }
  }

  void updmin(int d, long x, int k, int l, int r){
    lazyupd(k);
    if(r<=d || d+1<=l) return;
    if(d<=l && r<=d+1){
      data[k] = min(data[k], x);
      return;
    }
    int m =(l+r)/2;
    updmin(d,x,k*2+1,l,m);
    updmin(d,x,k*2+2,m,r);
    data[k] = min(data[2*k+1], data[2*k+2]);
    return;
  }
  void updmin(int d, long x){ updmin(d,x,0,0,n); }

  long getmin(int a, int b, int k, int l, int r){
    lazyupd(k);
    if(r<=a || b<=l) return INF;
    if(a<=l && r<=b){
      return data[k];
    }
    int m=(l+r)/2;
    long vl = getmin(a,b,k*2+1,l,m);
    long vr = getmin(a,b,k*2+2,m,r);
    return min(vl,vr);
  }
  long getmin(int l, int r){ return getmin(l,r,0,0,n);}

  void add(int a, int b, long x, int k, int l, int r){
    lazyupd(k);
    if(r<=a || b<=l) return;
    if(a<=l && r<=b){
      lazy[k] += x;
      lazyupd(k);
      return;
    }
    int m=(l+r)/2;
    add(a,b,x,k*2+1,l,m);
    add(a,b,x,k*2+2,m,r);
    data[k] = min(data[2*k+1], data[2*k+2]);
    return;
  }
  void add(int l, int r, long x){ add(l,r,x,0,0,n); }
};

int main(){
  int n,q,a,b;
  cin>>n>>q>>a>>b;
  a--;b--;
  vector<int> x(q);
  rep(i,q) cin>>x[i], x[i]--;

  SegTree stl(n), str(n);
  // use a
  stl.updmin(b, abs(x[0]-a) - b);
  str.updmin(b, abs(x[0]-a) - (n-b));
  // use b
  stl.updmin(a, abs(x[0]-b) - a);
  str.updmin(a, abs(x[0]-b) - (n-a));

  repl(i,1,q){
    long tmp = min(stl.getmin(0,x[i]+1) + x[i], str.getmin(x[i], n) + (n-x[i]));
    stl.add(0,n,abs(x[i-1]-x[i]));
    str.add(0,n,abs(x[i-1]-x[i]));
    stl.updmin(x[i-1], tmp - x[i-1]);
    str.updmin(x[i-1], tmp - (n-x[i-1]));
  }

  long ans = INF;
  rep(i,n) ans = min(ans, stl.getmin(i,i+1)+i);

  cout << ans << endl;

  return 0;
}


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

using namespace std;

using ll = long long;

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

    int n, m;

    cin >> n >> m;
    struct Item { ll a, b, c; };
    vector<Item> item(n);
    for (int i = 0; i < n; ++i)
        cin >> item[i].a >> item[i].b >> item[i].c;

    const vector<vector<int>> dir = {{1, 1, 1}, {1, 1, -1}, {1, -1, 1},
                                     {1, -1, -1}, {-1, 1, 1}, {-1, 1, -1},
                                     {-1, -1, 1}, {-1, -1, -1}};

    ll ans = 0;
    vector<ll> v(n);
    for (auto d : dir) {
        for (int i = 0; i < n; ++i)
            v[i] = d[0] * item[i].a + d[1] * item[i].b + d[2] * item[i].c;
        sort(v.begin(), v.end(), greater<ll>());

        ll sum = accumulate(v.begin(), v.begin() + m, 0LL);
        ans = max(ans, sum);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
use std::io::Read;

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let n: usize = it.next().unwrap().parse().unwrap();
    let m: usize = it.next().unwrap().parse().unwrap();
    let mut g = vec![vec![]; n + 1];
    let mut d = vec![0; n + 1];
    for _ in 0..m {
        let x: usize = it.next().unwrap().parse().unwrap();
        let y: usize = it.next().unwrap().parse().unwrap();
        g[x].push(y);
        d[y] += 1;
    }
    for i in 1..(n + 1) {
        g[0].push(i);
        d[i] += 1;
    }
    let mut q = vec![];
    let mut stack = vec![0];
    while let Some(v) = stack.pop() {
        q.push(v);
        for &u in &g[v] {
            d[u] -= 1;
            if d[u] == 0 {
                stack.push(u);
            }
        }
    }
    let mut dp = vec![0; n + 1];
    for &v in q.iter().rev() {
        for &u in &g[v] {
            dp[v] = std::cmp::max(dp[v], dp[u] + 1);
        }
    }
    let ans = dp[0] - 1;
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 16636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
  ll N;
  cin >> N;
  vector<int> vec(N);
  ll sum = 0;
  rep(i, N) {
    cin >> vec.at(i);
    sum += vec.at(i);
  }
  ll ans = 0;
  rep(i, N) {
    ans += vec.at(i) * (sum - vec.at(i));
  }
  cout << ans / 2 << endl;
}

Measured memory_bytes: 3544
#include <iostream>
using namespace std;
void ABC100(void);
void ABC101(void);
void ABC102(void);
void ABC103(void);
void ABC104(void);
void ABC105(void);
void ABC106(void);
void ABC107(void);
void ABC108(void);
void ABC109(void);

int main(void){
    ABC102();
}

void ABC102(){
    long int n;
    cin>>n;
    if(n%2==0)cout<<n<<endl;
    else cout<<n*2<<endl;
}

Measured memory_bytes: 256
n = int(input())
t = [0]
x = [0]
y = [0]
for _ in range(n):
    T, X, Y = map(int, input().split())
    t.append(T)
    x.append(X)
    y.append(Y)

for num in range(n):
    dif_t = t[num+1] - t[num]
    dif_x = abs(x[num+1] - x[num])
    dif_y = abs(y[num+1] - y[num])
    i = dif_t - (dif_x + dif_y)
    if i%2 == 1 or i <= -1:
        print('No')
        exit()

print('Yes')

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

#define ALL(a) (a).begin(), (a).end()
#define llong long long

using namespace std;

vector<int> calc(const vector<int> &v, int k, vector<int> &idx){
	vector<int> ret(k+1);
	vector<int> acc(k+1);
	for(int i = 1; i <= k; i++)acc[i] = acc[i-1] + v[i-1];
	set<int> l;
	for(int i = 1; i <= k; i++){
		vector<int> tmp(k+1);
		tmp[i] = acc[i-1] + v[i-1];
		l.insert(v[i-1]);
		auto itr = l.begin();
		for(int j = 1; j <= k-i && itr != l.end(); j++){
			tmp[i+j] = tmp[i+j-1] - (*itr); ++itr;
//			cerr << j;
		}
//		cerr << endl;
		for(int j = 0; j <= k; j++){
			if(ret[j] < tmp[j]){
				idx[j] = i-1;
				ret[j] = tmp[j];
			}
		}
//		cerr << l.size() << "calc "  << i << endl;
//		for(auto e : tmp)cerr << e << " "; cerr << endl;
	}
	return ret;
}
		

signed main(){
	int n, k; cin >> n >> k;
	vector<int> v(n);
	for(auto &e : v)cin >> e;
	vector<int> l,r;
	vector<int> li(k+1),ri(k+1);
	l = calc(v, k, li);
	reverse(ALL(v));
	r = calc(v,k,ri);
//	for(auto e : l)cerr << e << " "; cerr << endl;
//	for(auto e : r)cerr << e << " "; cerr << endl;
	int ans = 0;
	for(int i = 0; i <= k; i++){
		for(int j = 0; j <= min(k-i,n-li[i]-1); j++){
//			if(ans < l[i]+r[j])cerr << i << ":" << j << endl;
			ans = max(ans, l[i] + r[j]);
		}
	}
	cout << ans << endl;


	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
    return a < b && (a = b, true);
}
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
    return a > b && (a = b, true);
}
template <typename T> istream &operator>>(istream &is, vector<T> &v) {
    for(T &in : v)
        is >> in;
    return is;
}
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) {
    for(int i = 0; i < (int)v.size(); i++)
        os << (i ? " " : "") << v[i];
    return os;
}
/*-------------------------------------------*/

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

    ll a, b;
    cin >> a >> b;
    if(a % b == 0) {
        cout << -1 << endl;
    } else {
        cout << a << endl;
    }

    return 0;
}

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

int main() {
  int N;
  vector<int> num(4,0);
  vector<int> numans = {1,1,2,2};
  for (int i=0; i<6; i++) {
    cin >> N;
    num[N-1]++;
  }
  sort(num.begin(),num.end());
  if (num == numans) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}

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

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

namespace ae86
{
	const int bufl = 1<<15;
	
	char buf[bufl],*s=buf,*t=buf;
	
	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}
	
	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

const int _ = 200007;

int n,len,val[_]={0},got[_]={0};

int main()
{
	n=ty(),len=ty();
	for(int i=1;i<=n;i++)val[i]=ty()+1;

	int ans=n-len+1,mcnt=0;
	for(int i=1,now=0;i<=n;i++)
	{
		if(val[i]>val[i-1])now++;
		else now=1;
		if(now>=len)got[i]=1,mcnt++;
	}
	ans-=max(mcnt-1,0);
	set<int> s(val+1,val+len+1);
	for(int i=len+1;i<=n;i++)
	{
		s.erase(val[i-len]);
		if(!got[i] && val[i-len]<*s.begin() && val[i]>*s.rbegin())ans--;
		s.emplace(val[i]);
	}

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

	return 0;
}


Measured memory_bytes: 10496
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

MOD = 10 ** 9 + 7

n = int(input())

factorial = [0] * (n + 1)
factorial[0] = 1

for i in range(1, n + 1):
    factorial[i] = factorial[i-1] * i

prime_factors = []

i = 2
target = factorial[n]
while i ** 2 <= target:
    if target % i != 0:
        i += 1
        continue

    ext = 0
    while target % i == 0:
        ext += 1
        target //= i
    prime_factors.append((i, ext))
    i += 1

if target != 1:
    prime_factors.append((target, 1))

ans = 1
for pf in prime_factors:
    ans = (ans * (pf[1] + 1)) % MOD
print(ans)


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

#define T 1
#define F 0

int isprime(int x);

int main(){

  int n,i,count=0;
  int *a;

  scanf("%d",&n);
  a=(int *)malloc(sizeof(int)*n);
  for(i=0;i<n;i++)scanf("%d",&a[i]);
  for(i=0;i<n;i++)if(isprime(a[i])==T)count++;
  printf("%d\n",count);

  return 0;

}

int isprime(int x){

  int i;

  if(x==2)return T;
  if(x<2 || x%2==0)return F;
  i=3;
  while(i*i<=x){
    if(x%i==0)return F;
    i+=2;
  }
  return T;

}

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

#define rep(i,n) for(int i=0; i<n ; ++i)
#define REP(i,a,b) for(int i=a; i<b; ++i)
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

//プロトタイプ宣言
void faster(void);
template <class T>
T gcd(T , T);
template <class T>
T get_digent(T);
template <class T>
T POW(T , T);

int h,w,cost_max=0;
vector<vector<char>> s(21 , vector<char>(21));
vvi cost;
int dy[4]={1,0,-1,0} , dx[4]={0,1,0,-1};

int bfs(int y , int x){
  queue<pair<int,int>> que;
  que.push(make_pair(y,x));
  cost[y][x]=0;

  while(!que.empty()){
    pair<int,int> p=que.front();
    que.pop();

    rep(i,4){
      int ny = p.first + dy[i] , nx = p.second + dx[i];
      if(ny<0 || nx<0 || ny>=h || nx>=w) continue;
      if(s[ny][nx]=='#') continue;
      if(cost[ny][nx]!=-1) continue;
      que.push(make_pair(ny,nx));
      cost[ny][nx] = cost[p.first][p.second] + 1;
    }
  }

  rep(i,h)rep(j,w){
    cost_max = max(cost_max , cost[i][j]);
  }

  return cost_max;
}

int main(){
  faster();
  cin >> h >> w;
  rep(i,h)rep(j,w) cin >> s[i][j];
  int ans=0;
  rep(i,h)rep(j,w){
    if(s[i][j]=='#') continue;
    cost = vvi(21 , vector<int>(21,-1));
    ans = max(ans , bfs(i,j));
  }
  cout << ans << endl;
}



























//同期解除
void faster(void){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

//ユークリッドの互除法
template <class T>
T gcd(T a, T b) {
  return (b ? gcd(b, a%b) : a);
} 

//桁数取得
template <class T>
T get_digent(auto x){
  string s;
  s = to_string(x);
  ll digent = s.size();
  return digent;
} 

//べき乗計算
template <class T>
T POW(T x, T y){
  if(y==0) return 1;
  if(y%2 == 1){
    ll temp = POW(x,y-1);
    return (temp*x);
  }
  else{
    ll temp = POW(x,y/2);
    return temp*temp;
  }
} 



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

using namespace std;

int main(){

	int n;
	cin >> n;
	string s;
	cin >> s;
	vector<int> vw;
	vector<int> vr;

	for(int i=0;i<s.length();i++){
		if(s[i] == 'W')
			vw.push_back(i);
		else
			vr.push_back(i);
	}
	int idx = vr.size()-1;	
	int iw = 0;
	int count = 0;
	if(vw.size() > 0){
		while(idx >= 0 && vr[idx] > vw[iw] && iw < vw.size()){
			count++;
			iw++;
			idx--;
		}
	}
	cout << count << endl;

	return 0;
}


Measured memory_bytes: 4684
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bits/stdc++.h>
#include<queue>
#include <numeric>
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define fore(i,a) for(auto &i:a)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 

LL gcd(LL a, LL b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

LL lcm(LL a, LL b){
    LL g = gcd(a,b);
    return a/g *b;
}

int main(){
    int N;
    cin >> N;
    int A[N];
    for(int i=0;i<N;++i){
        cin >> A[i];
    }
    int init_num=0;
    int count=0;
    int j=0;
    for(int i=1;i<=N-1;++i){
        init_num=A[i];
        j=i-1;
        for(int k=0;k<N;++k){
            if(k!=N-1){
                cout << A[k] << " ";
            }
            else{
                cout << A[k] << endl;
            }
        }
        while(j >= 0 && A[j] > init_num){
            A[j+1]=A[j];
            --j;
            A[j+1] = init_num;
        }
        
    }
    
        for(int k=0;k<N;++k){
            if(k!=N-1){
                cout << A[k] << " ";
            }
            else{
                cout << A[k] << endl;
            }
        }
}


Measured memory_bytes: 3096
###==================================================
### import
#import bisect
#from collections import Counter, deque, defaultdict
#from copy import deepcopy
#from functools import reduce, lru_cache
#from heapq import heappush, heappop
#import itertools
#import math
#import string
import sys
### stdin
def input(): return sys.stdin.readline()
def iIn(): return int(input())
def iInM(): return map(int, input().split())
def iInM1(): return map(int1, input().split())
def iInLH(): return list(map(int, input().split()))
def iInLH1(): return list(map(int1, input().split()))
def iInLV(n): return [iIn() for _ in range(n)]
def iInLV1(n): return [iIn()-1 for _ in range(n)]
def iInLD(n): return [iInLH() for _ in range(n)]
def iInLD1(n): return [iInLH1() for _ in range(n)]
def sInLH(): return list(input().split())
def sInLV(n): return [input().rstrip("\n") for _ in range(n)]
def sInLD(n): return [sInLH() for _ in range(n)]
### stdout
def OutH(lst): print(*lst)
def OutV(lst): print(*lst, sep="\n")
### setting
sys.setrecursionlimit(10 ** 6)
### utils
int1 = lambda x: int(x) - 1
### constants
INF = int(1e9)
MOD = 1000000007
dx = (-1, 0, 1, 0)
dy = (0, -1, 0, 1)
###---------------------------------------------------

## begin library factorial
## usage: fac = Factorial()
## usage: nCr = fac.comb(n, r)
## usage: nPr = fac.perm(n, r)
class Factorial:

    def __init__(self, N):
        self.fact = [0] * (N+1)
        self.fact_inv = [0] * (N+1)
        self.calc_factorial(N)
        self.calc_inv_factorial(N)

    def calc_factorial(self, N):
        self.fact[0] = 1
        for i in range(N):
            self.fact[i+1] = self.fact[i] * (i+1) % MOD

    def calc_inv_factorial(self, N):
        self.fact_inv[N] = pow(self.fact[N], MOD-2, MOD)
        for i in range(N, 0, -1):
            self.fact_inv[i-1] = self.fact_inv[i] * i % MOD

    def comb(self, n, r):
        if (n < 0 or r < 0 or n < r): return 0
        res = self.fact[n]
        res = res * self.fact_inv[r] % MOD
        res = res * self.fact_inv[n-r] % MOD
        return res

    def perm(self, n, r):
        if (n < 0 or r < 0 or n < r): return 0
        res = self.fact[n]
        res = res * self.fact_inv[n-r] % MOD
        return res

## end library factorial

N, M = iInM()

fac = Factorial(500000)
ans = 0

for i in range(N+1):
    res = (-1)**(i) * fac.comb(N, i)
    res = res * fac.perm(M, i) % MOD
    res = res * fac.perm(M-i, N-i) % MOD
    res = res * fac.perm(M-i, N-i) % MOD
    ans = (ans + res) % MOD

print(ans) 

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

int main() {
  int A,B;
  cin >> A >> B;
  int C[1010];
  int sum = 0;
  for(int i = 0;i < A;i++){
    cin >> C[i];
  }
sort(C,C + A);
  for(int i = 0;i < B;i++){
    sum += C[i];
  }
cout << sum << endl;
}


Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int Happy = X/500;
		int happy = (X%500)/5;
		System.out.println(1000 * Happy + 5 * happy);
	}
}

Measured memory_bytes: 22996