akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rep(i,l,r) for(int i=(l);i<(r);++i)
#define dd(x) cout << #x << " = " << x << ", "
#define de(x) cout << #x << " = " << x << endl
//-------
const int N = 100;
const int MOD = 1000000007;
int n;
char s1[N], s2[N];
int main() {
	scanf("%d %s %s", &n, s1, s2);
	vector<int> a;
	for (int i = 0; i < n; ++i)
		if (s1[i] == s2[i]) {
			a.pb(1);
		} else {
			a.pb(2);++i;
		}
	int ans = (a[0] == 1 ? 3 : 6);
	rep(i, 1, sz(a))
		if (a[i] == 1) {
			ans = 1ll * ans * (1 + (a[i - 1] == a[i])) % MOD;
		} else {
			ans = 1ll * ans * (2 + (a[i - 1] == a[i])) % MOD;
		}
	printf("%d", ans);
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n,m,x,hi[1001],i,j,cnt[1001],temp,max=-1;
	scanf("%d %d",&n,&m);
	for(i=1;i<=n;i++){
		scanf("%d",&hi[i]);
		cnt[i]=0;
	}
	for(i=0;i<m;i++){
		scanf("%d",&x);
		for(j=1;j<=n;j++){
			if(x>=hi[j]){
				cnt[j]++;
				break;
			}
		}
	}
//	for(j=1;j<=n;j++){
//		printf(":%d\n",cnt[j]);
//	}
	for(i=1;i<=n;i++) {
		if(max<cnt[i]) {
			max=cnt[i];
			temp=i;
		}
	}
	printf("%d\n",temp);
	return 0;
}

Measured memory_bytes: 1032
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
int main(){
  int n,q;
  cin>>n>>q;
  fenwick_tree<int64_t> t(n);
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    t.add(i,a);
  }
  for(int _=0;_<q;_++){
    int f,x,y;
    cin>>f>>x>>y;
    if(f==0)
      t.add(x,y);
    if(f==1)
      cout<<t.sum(x,y)<<endl;
  }
}

Measured memory_bytes: 8212
#include<iostream>
#include<string>
#include<vector>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int n,r,p,c;
	while(1){
		cin>>n>>r;
		if(n==0 && r==0)break;
		int dt[n];
		int alt[n];
		rep(i,n)alt[i]=0;
		for(int i=n;i>0;i--){
			dt[n-i]=i;
			alt[i-1]=0;
		}
		rep(j,r){
			cin>>p>>c;
			loop(i,p+c-1,n)alt[i]=dt[i];
			rep(i,p-1)alt[c+i]=dt[i];
			loop(i,p-1,p+c-1)alt[i-p+1]=dt[i];
			rep(i,n)dt[i]=alt[i];
		}
		cout<<dt[0]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
int main(){
  long H;
  long W;
  cin >> H;
  cin >> W;
  if(W == 1 || H == 1){
    cout << 1 << endl;
  }else if(W % 2 == 0 || H % 2 == 0){
    cout << H*W/2 << endl;
  }else{
    cout << H*W/2+1 << endl;
  }
}

Measured memory_bytes: 256
sx,sy,tx,ty = map(int,input().split())    

go1 = ['U']*(ty-sy)+['R']*(tx-sx)

back1 = ['D']*(ty-sy)+['L']*(tx-sx)

go2 = ['L']+['U']*(ty-sy+1)+['R']*(tx-sx+1)+['D']

back2 = ['R']+['D']*(ty-sy+1)+['L']*(tx-sx+1)+['U']

ans = go1+back1+go2+back2

print(''.join(map(str,ans)))

Measured memory_bytes: 38896
def main():
    k = int(input())
    s = input()
    A = []
    for c in s:
        val = ord(c) - ord('A')
        val = (val + k) % 26
        A.append(chr(val + ord('A')))
    print(''.join(A))

if __name__ == "__main__":
    main()


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

int MAX = 1e9;

int main() {
    cin.tie(0)->sync_with_stdio(false);

    int n, k, s;
    cin >> n >> k >> s;
    vector<int> ans;

    if (k == 0) {
        if (s != MAX) REP(i, n) ans.push_back(MAX);
        else REP(i, n) ans.push_back(MAX - 1);
    } else if (n == k) {
        REP(i, n) ans.push_back(s);
    } else {
        if (s != MAX) {
            REP(i, k) ans.push_back(s);
            REP(i, n - k) ans.push_back(MAX);
        } else {
            REP(i, k) ans.push_back(MAX);
            REP(i, n - k) ans.push_back(MAX - 1);
        }
    }

    REP(i, n) {
        cout << ans[i];
        if (i != n - 1) cout << ' ';
    }
    cout << '\n';
    return 0;
}

Measured memory_bytes: 1912
d[4],e[9],f,k;char s[30];z(){int a,b,c;a=e[f++];a>9?s[k++]=40,b=z(),s[k++]=a,c=z(),s[k++]=41,a=a-43?a-45?b*c:b-c:b+c:(s[k++]=a+48);return a;}y(o,n,i,j){if(i==7){f=k=0;if(z()==10){s[k]=0;puts(s);return 1;}return 0;}if(o)for(;j<3;j++){e[i]="+-*"[j];if(y(o-1,n+1,i+1,0))return 1;}if(n|i==6)for(j=0;j<4;j++)if(e[i]=d[j]){d[j]=0;if(y(o,n-1,i+1,0))return 1;d[j]=e[i];}return 0;}main(){for(;scanf("%d%d%d%d",d,d+1,d+2,d+3),f=*d;)y(3,0,0,0)||puts("0");}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
int GCD(ll a,ll b){return b?GCD(b,a%b):a;}
int LCM(ll a,ll b){return (a*b)/GCD(a,b);}
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	int n, m;
	cin >> n >> m;
	tuple<int, int, int> a[m];
	REP(i, m){
		int p, y;
		cin >> p >> y;
//		a[i] = {y, p, i}; なぜかCEになるので
		a[i] = make_tuple(y, p, i);
	}

	sort(a, a+m);
	int cnt[n+1] = {};
	pair<int, int> id[m];
	REP(i, m){
		int y, p, x;
		tie(y, p, x) = a[i];
		cnt[p]++; // 誕生した順番
		id[x] = {p, cnt[p]};
	}

	REP(i, m){
		cout << setfill('0') << setw(6) << id[i].first;
		cout << setfill('0') << setw(6) << id[i].second << endl;
	}
}


Measured memory_bytes: 3968
#include<iostream>
#include<fstream>
#include<math.h>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<sstream>
#include<set>

using namespace std;

#define forn(i,n) for(int i=0;i<(int)(n); i++)
#define forsn(i,s,n) for(int i=(s);i<(int)(n); i++)
#define esta(x,v) (find((v).begin(),(v).end(),(x)) !=  (v).end())
#define index(x,v) (find((v).begin(),(v).end(),(x)) - (v).begin())
#define debug(x) cout << #x << " = "  << x << endl
#define pb push_back
#define mp make_pair

typedef long long tint;
typedef pair<int,int> pint;
typedef pair<tint,tint> ptint;
typedef unsigned long long utint;
typedef long double ldouble;

typedef vector<int> vint;

int toNumber (string s)
{
	int Number;
	if ( ! (istringstream(s) >> Number) ) Number = 0; // el string vacio lo manda al cero
	return Number;
}

string toString (int number)
{
    ostringstream ostr;
    ostr << number;
    return  ostr.str();
}

tint ele(tint a, tint b){
	if(b==0)return 1;
	if(b%2==0){
		return ele(a*a, b/2);
	}else{
		return a*ele(a*a, b/2);
	}
}

tint mcd(tint a, tint b){
	if(a==0)return b;
	return mcd(b%a, a);
}

double d_abs(long a, long b){
	if(a>b){
		return a-b;
	}
	return b-a;
}

void solve(){
	tint a, b, c, n;
	string s;
	vector<tint> v;
	cin>>a>>b>>c;
	tint ans=0;
	int ciclos=0;
	while(true){
		if(a%2 || b%2 || c%2){
			break;
		}
		tint ta=(b+c)/2;
		tint tb=(a+c)/2;
		tint tc=(a+b)/2;
		a=ta;
		b=tb;
		c=tc;
		ciclos++;
		ans++;
		if(ciclos>10000){
			break;
		}
	}
	if(a%2 || b%2 || c%2){
		cout<<ans<<endl;
	}else{
		cout<<-1<<endl;
	}
}




int main (){
	int T;
	T=1;
	while(T--){
		solve();
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
    int n,m; cin >> n >> m;
    cout << n*(n-1)/2 + m*(m-1)/2 << endl;
    return 0;
}

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

vector<int> x, y;
int n;

double dist(int i, int j) {
    double dx = x[i]-x[j];
    double dy = y[i]-y[j];
    return sqrt(dx*dx + dy*dy);
}

int main() {
    cin >> n;
    x.resize(n);
    y.resize(n);
    rep(i,n) cin >> x[i] >> y[i];
    int res = 1;
    for (int i = 1; i <= n; ++i) res *= i;

    vector<int> v(n);
    iota(v.begin(), v.end(), 0); 
    double ans = 0.0;
    do {
        for (int i = 0; i < n-1; ++i) {
            ans += dist(v[i],v[i+1])/res;
        }
    } while (next_permutation(v.begin(), v.end()));
    
    cout << std::fixed;
    cout << std::setprecision(10) << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
a=[0]*n
b=[0]*n
c=[0]*m
d=[0]*m
ans=[0]*n

for i in range(n):
    a[i],b[i]=map(int,input().split())
for i in range(m):
    c[i],d[i]=map(int,input().split())
    
for i in range(n):
    dis=[-1]*3
    for j in range(m):
        dis[1]=abs(a[i]-c[j])+abs(b[i]-d[j])
        if (dis[0]<0):
            ans[i]=j+1
            dis[2]=dis[1]
        else:
            if (dis[2]>dis[1]):
                ans[i]=j+1
                dis[2]=dis[1]
        dis[0]=dis[1]
for i in range(n):
    print(ans[i])



Measured memory_bytes: 3064
#coding: utf-8
STDOUT.sync = true

num = []

while data = STDIN.gets do
  num = data.split().map!(&:to_f)
  y = (num[2] * num[3] - num[0] * num[5]) / (num[1] * num[3] - num[0] * num[4])
  x = (num[2] - num[1] * y) / num[0]
  puts "%.3f %.3f" % [x, y]
end

Measured memory_bytes: 8676
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
int main() {
  int H, W;
  cin >> H >> W;
  vector<string> S(H);
  rep(i, H) cin >> S[i];

  vector<string> T;
  rep(i, H) {
    bool existsblack = false;
    rep(j, W) if(S[i][j] == '#') {
      existsblack = true;
      break;
    }
    if(existsblack) T.push_back(S[i]);
  }
  vector<bool> iswhitecl(W, true);
  rep(j, W) {
    rep(i, T.size()) if(T[i][j] == '#') {
      iswhitecl[j] = false;
      break;
    }
  }

  rep(i, T.size()) {
    rep(j, W) if(!iswhitecl[j]) cout << T[i][j];
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long int
#define ld long double
#define pb push_back
#define pf push_front
#define ft first
#define sc second
#define all(v) v.begin(), v.end()
using namespace std;
const int maxn = 200010, mod = 998244353;
signed main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int a;
    cin >> a;
    cout << a + (a * a) + (a * a * a);
}


Measured memory_bytes: 3644
#include<cstdio>
const int N=2002,M=1000000007;
typedef long long ll;
int n,i,j,a[N*100],b[N*100],f[N*2][N*2];
ll fac[N*4],ans;
ll ksm(ll x,int p){
	ll s=1;
	while(p){
		if(p&1)
			s=s*x%M;
		p>>=1;
		x=x*x%M;
	}
	return s;
}
ll inv(ll x){
	return ksm(x,M-2);
}
void init(){
	fac[0]=1;
	for(i=1;i<N*4;i++)
		fac[i]=i*fac[i-1]%M;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d%d",a+i,b+i);
		f[N-a[i]][N-b[i]]++;
		ans=(ans-fac[a[i]*2+b[i]*2]*inv(fac[a[i]*2])%M*inv(fac[b[i]*2])%M+M)%M;
		//printf("%lld\n",fac[a[i]*2+b[i]*2]*inv(fac[a[i]+b[i]])%M*inv(fac[a[i]+b[i]])%M);
	}
}
void work(){
	for(i=1;i<N*2;i++)
		for(j=1;j<N*2;j++)
			f[i][j]=(1ll*f[i][j-1]+f[i-1][j]+f[i][j])%M;
	for(i=1;i<=n;i++){
		//printf("%d\n",f[N+a[i]][N+b[i]]);
		ans=(ans+f[N+a[i]][N+b[i]])%M;
	}
	//printf("%lld\n",ans);
	printf("%lld",ans*inv(2)%M);
}
int main(){
	init();
	work();
	//while(1);
	return 0;
}

Measured memory_bytes: 64384
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a),end(a)
#define MS(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(5)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<short, short> P;
typedef complex<double> Point;
typedef long long ll;
const int INF = 114514810;
const int MOD = 100000007;
const double EPS = 1e-10;
const double PI = acos(-1.0);
struct edge
{
	int from, to, cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///

int n, m;
int main()
{
	while (cin >> n >> m, n)
	{
		vector<int> v, w;
		REP(i, n)
		{
			int a;
			cin >> a;
			w.push_back(a);
		}
		w.push_back(0);
		REP(i, w.size())REP(j, w.size())
		{
			int t = w[i] + w[j];
			v.push_back(w[i] + w[j]);
			
		}
		sort(ALL(v));
		int ans = 0;
		int i = 0;
		int j = v.size() - 1;
		while (i<=j)
		{
			if (v[i] + v[j] <= m)
			{
				ans = max(ans, v[i] + v[j]);
				i++;
			}
			else
			{
				j--;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 9196
n=int(input())
a=[]
b=[]

ans=0

for i in range(n):
  x,y=map(int,input().split())
  
  a.append(x)
  b.append(y)
  

for i in range(n):
  a[i]%=b[i]

a.reverse()
b.reverse()
  

for i in range(n):
  z=b[i]-(a[i]+ans)%b[i]
  if z==b[i]:
    z=0
  ans+=z


print(ans)

Measured memory_bytes: 85696
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	string s;
	int n;
	cin >> s >> n;
	for(int i = 0;i < s.length();i++){
		if(i % n == 0) cout << s[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <cstdio>
typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define max3(x, y, z) max(x, max(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif
using namespace std;
int main() {
  int a,b;
  cin >> a >> b;
  cout << (a-1)*(b-1);
}
/*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
for (int i = 0; i < N; i++) {
cin >> list[i];
}
// for文
for (int i = 0; i < N; i++) {
}
//配列
vector<int> list;
list.at(i)
vector<vector<int>> list(10, vector<int>(10));
sort(all(list));
sort(all(list), greater<int>());
//配列の内容表示
dout << "====listの内容====\n";
for (int i = 0; i < N; i++) dout << list[i] << endl;
dout << "====ここまで====\n";
*/


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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int n, q;
string s;

int main() {
    cin >> n >> q;
    VVi edges(n);
    REP(i, n-1) {
        int a, b; cin >> a >> b;
        a--; b--;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }

    Vl count(n, 0);
    REP(i, q) {
        int p, x; cin >> p >> x;
        p--;
        count[p] += x;
    }

    V<bool> f(n, false);
    stack<int> s;
    s.push(0);
    f[0] = true;
    while (!s.empty()) {
        int node = s.top();
        s.pop();
        FOR(i, edges[node]) {
            if (!f[*i]) {
                f[*i] = true;
                s.push(*i);
                count[*i] += count[node];
            }
        }
    }

    REP(i, n) std::cout << count[i] << ' ';
    std::cout << '\n';

    return 0;
}


Measured memory_bytes: 16372
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 2e5 + 10;
const int INF = 0x3f3f3f3f;
const ll inf = 0x3f3f3f3f3f3f3f3f;
const ll mod = 998244353;
int a, b, c, k;
int main() {
	cin >> a >> b >> c >> k;
	if (a >= k) {
		cout << k << endl;
	}
	else if (a + b >= k) {
		cout << a << endl;
	}
	else {
		cout << a - (k - a - b) << endl;
	}
	return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

int main()
{
  cout<<fixed<<setprecision(20);
  double a,b,c;
  cin>>a>>b>>c;
  c=c/180*M_PI;
  cout<<0.5*a*b*sin(c)<<" ";
  cout<<a+b+sqrt(a*a+b*b-2*a*b*cos(c))<<" ";
  cout<<b*sin(c)<<endl;
}


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

using namespace std;
int a, b, p;
bool is_palindrome(int n){
    int s[5], i = 0;
    while (n > 0){
        s[i] = n % 10;
        n = n / 10;
        i++;
        
    }
    if (s[0] != s[4]) return false;
    if (s[1] != s[3]) return false;
    return true;
}
int main() {
    cin >> a >> b;
    for (int i = a; i <= b; i++){
        if (is_palindrome(i) == true) {
            p++;
        }
    }
    cout << p;
    return 0;
}

Measured memory_bytes: 256
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, N);
    AIN(ll, A, N);
    SORT(A);
    ll M = *max_element(ALL(A));
    vi c(M + 1);
    FOR(a, A)
    {
        ++c[a];
    }
    REP(i, N)
    {
        ll a = A[i];
        if (i >= 1 and A[i - 1] == a)
        {
            c[a] = 0;
            continue;
        }
        for (ll i = 2 * a; i <= M; i += a)
        {
            c[i] = 0;
        }
    }
    ll ans = 0;
    FOR(x, c)
    {
        ans += x;
    }
    OUT(ans);
}

Measured memory_bytes: 12676
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=1e5+10;
int n,X;
ll b[N],L[N],R[N],D;
int rk[N],pos[N];
bool cmp(int x,int y){return L[y]*b[y]+R[y]*(X-b[y])<R[x]*(X-b[x])+L[x]*b[x];}
ll ask(int x){return L[x]*b[x]+R[x]*(X-b[x]);}
ll pre[N];
bool check(ll k){
	ll cnt=k/X,t;k-=cnt*X;
	if(cnt>=n)return pre[n]+D>=0;
	for(int i=1;i<=n;i++) if(pos[i]<=cnt){
		t=pre[cnt+1]-ask(i);
		if(k<=b[i])t+=L[i]*k;else t+=L[i]*b[i]+R[i]*(k-b[i]);
		if(t+D>=0)return 1;
	} else{
		t=pre[cnt];
		if(k<=b[i])t+=L[i]*k;else t+=L[i]*b[i]+R[i]*(k-b[i]);if(t+D>=0)return 1;
	}

	return 0;
}
int main(){
	//freopen("a.in","r",stdin);
	scanf("%d%d",&n,&X);
	for(int i=1;i<=n;i++)scanf("%lld%lld%lld",&b[i],&L[i],&R[i]),D-=b[i]*L[i];
	for(int i=1;i<=n;i++)rk[i]=i;
	sort(rk+1,rk+n+1,cmp);
	for(int i=1;i<=n;i++) pre[i]=pre[i-1]+ask(rk[i]),pos[rk[i]]=i;
	ll l=0,r=1e10,mid;
	while(l<r){
		mid=l+r>>1;
		if(check(mid))r=mid;else l=mid+1;
	}
	cout<<r;
}

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

using namespace std;
using int64 = long long int;

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

	int combined = atoi((to_string(a) + to_string(b)).c_str());
	bool ans = (int) sqrt(combined) * (int) sqrt(combined) == combined;
	cout << (ans ? "Yes" : "No") << endl;
}

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

using namespace std;

struct node { int parent, left, right; };
node t[100005];

int heightcal(int i) {
	if (t[i].left == -1 && t[i].right == -1) {
		return 0;
	}
	int h1 = 0, h2 = 0;;
	if (t[i].left != -1) {
		h1 = heightcal(t[i].left) + 1;
	}
	if (t[i].right != -1) {
		h2 = heightcal(t[i].right) + 1;
	}

	return max(h1, h2);
}

int main() {

	int n;
	cin >> n;

	for (int i = 0; i < n; i++) {
		t[i].parent = -1;
		t[i].left = -1;
		t[i].right = -1;
	}

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

		int nodenum;
		int c1, c2;
		cin >> nodenum >> c1 >> c2;

		t[nodenum].left = c1;
		t[nodenum].right = c2;
		t[c1].parent = nodenum;
		t[c2].parent = nodenum;

	}

	for (int i = 0; i < n; i++) {
		cout << "node " << i << ": parent = " << t[i].parent << ", sibling = ";
		if (t[i].parent != -1) {
			if (t[t[i].parent].left == i) {
				cout << t[t[i].parent].right << ", degree = ";
			}
			else {
				cout << t[t[i].parent].left << ", degree = ";
			}
		}
		else {
			cout << "-1" << ", degree = ";
		}

		if (t[i].left != -1 && t[i].right != -1) {
			cout << 2 << ", depth = ";
		}
		else if (t[i].left == -1 && t[i].right == -1) {
			cout << 0 << ", depth = ";
		}
		else {
			cout << 1 << ", depth = ";
		}

		int counter = 0;
		int tmp = t[i].parent;
		while (tmp != -1) {
			tmp = t[tmp].parent;
			counter++;
		}
		cout << counter << ", height = " << heightcal(i) << ", ";

		if (t[i].parent == -1) {
			cout << "root" << endl;
		}
		else if (t[i].left == -1 && t[i].right == -1) {
			cout << "leaf" << endl;
		}
		else {
			cout << "internal node" << endl;
		}


	}
}


Measured memory_bytes: 3096
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var N = Sarray()[0];
            var Ai = Sarray();
            var num4 = Ai.Count(a => a % 4 == 0);
            var num2 = Ai.Count(a => a % 4 != 0 && a % 2 == 0);
            var numO = N - num4 - num2;
            if (num4 + numO == N)
            {
                if (numO - num4 <= 1)
                {
                    WriteLine("Yes");
                    return;
                }
            }
            if (numO <= num4)
                WriteLine("Yes");
            else
                WriteLine("No");
        }

        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

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

int main(){
    int a,b;
    cin >> a >> b;
    int res=0;
    if(b == 1){
        cout << 0 << endl;
        return 0;
    }else if(b>a){
        while(b>0){
        if(b>a){      
        b -= a-1;
        }else{
            b-=a;
        }
        res++;
        }
    }else{
        res = 1;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}

#define INF 1e9+7
#define LLINF 1e18+7
#define N 250000
ll MOD=998244353;


main(){
    string s;
    cin>>s;
    char pre=':';
    int ans=0;
    bool flag=false;
    rep(i,s.size()){
        if(flag){
            ans++;
            flag=false;
            pre=s[i];
            continue;
        }
        else{
            if(s[i]==pre){
                i++;
                ans++;
                flag=true;
                pre=':';
                if(i==s.size()){
                    ans--;
                }
            }
            else{
                ans++;
                pre=s[i];
                
            }
        }
    }
    cout<<ans;
}


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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define ALL(x) x.begin(),x.end()
#define PB push_back
#define LL long long

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {
    _for(i,0,v.size()) os << v[i] << " ";
    return os;
}

template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){
    for(typename set<T>::iterator it = v.begin();it != v.end();it++)
    os << *it <<" ";
    return os;
}

const int maxn = 105;

string G[maxn];
int row[maxn];
int line[maxn];

int main()
{
    int H,W;
    cin >> H >> W;getchar();
    _for(i,0,H){
        getline(cin,G[i]);
    }

    _for(i,0,H){
        _for(j,0,W){
            if(G[i][j] == '#'){
                row[i] = 1;
                line[j] = 1;
            }
        }
    }
    _for(i,0,H){
        if(!row[i])continue;
        _for(j,0,W){
            if(!line[j]) continue;
            printf("%c",G[i][j]);
        }
        printf("\n");
    }

    return 0;
}


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

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)


void func(long long N, std::string S, std::string T){
    string str = "";
    rep(i,N) {
        str = str + S[i] + T[i];
    }
    cout << str << endl;
}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    func(N, S, T);
    return 0;
}


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

using namespace std;

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

	vector <int> v;
	int mi = 0;

	for(int i=0;i<n;i++)
	{
		int x;
		cin >> x;

		v.push_back(x);
	}

	for(int i=1;i<n;i++)
		mi = max(mi,v[i]-v[i-1]);

	cout << k - max(mi,v[0]+k-v[n-1]) << endl;
}

Measured memory_bytes: 1400
#include <cstdio>
#include <algorithm>
#include <vector>
#include <iostream>
#define maxn 200009
using namespace std;
vector<long long>a[5];
vector<long long>b[5];
int n, m;
int w[maxn], v[maxn];


bool cmp(long long a, long long b){
	return a > b;
}

int main(){
	cin >> n >> m;
	for(int i = 1; i <= n; i++)
		cin >> w[i] >> v[i];
	for(int i = 0; i < 4; i++)
		a[i].push_back(0);
	
	//puts("!!!");
	for(int i = 1; i <= n; i++){
		b[w[i] - w[1]].push_back(v[i]);
	}
	
	for(int i = 0; i < 4; i++){
		sort(b[i].begin(), b[i].end(), cmp);
		for(int j = 0; j < (int)b[i].size(); j++)
			a[i].push_back(b[i][j]);
		int sz = a[i].size();
		for(int j = 1; j < sz; j++)
			a[i][j] += a[i][j - 1];
	}
	
	long long ans = 0;
	for(int i = 0; i < a[0].size(); i++){
		for(int j = 0; j < a[1].size(); j++)
			for(int k = 0; k < a[2].size(); k++){
				long long tot = 1LL * w[1] * i + 1LL * (w[1] + 1) * j + 1LL * (w[1] + 2) * k;
				if(tot > m)
					continue;
				int pick = (m - tot) / (w[1] + 3);
				pick = min(pick, (int)a[3].size() - 1);
				
				ans = max(ans, a[0][i] + a[1][j] + a[2][k] + a[3][pick]);
			}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
/*Made by Shivam Solanki*/
#include<bits/stdc++.h>
using namespace std;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define ll long long int
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<pii> vp;
typedef vector<pll> vpll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef set<int> sii;
typedef set<ll> sll;
typedef unordered_map<int,int> umii;
typedef unordered_map<ll,ll> umll;
#define rep(i,k,n) for (int i = k; i < n; ++i) 
#define repr(i,k,n) for (int i = n; i>=k; --i)
#define REP(i,k,n) for (int i = k; i <= n; ++i) 
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define repll(i,k,n) for (ll i = k; i < n; ++i) 
#define pb push_back
#define mp make_pair
#define __gcd gcd
#define F first
#define S second
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int INF = 1e9+5;
const int MOD = 1e9+7;

int comp(const void* a, const void* b) { return *(int*)a > *(int*)b ; }  

int findNumberOfTriangles(int arr[], int n){  
    qsort(arr, n, sizeof(arr[0]), comp);  
    int count = 0;  
    for (int i = 0; i < n - 2; ++i){  

        int k = i + 2; 
        for (int j = i + 1; j < n; ++j){  
            while (k < n && arr[i] + arr[j] > arr[k])  
            ++k;  
            if(k > j)  
            count += k - j - 1;  
        }  
    }  
    return count;  
} 

void solve(){
    int n;
    cin>>n;
    int a[n];
    rep(i,0,n) cin>>a[i];
    cout<<findNumberOfTriangles(a,n);
}

int main(){
    // #ifndef ONLINE_JUDGE  
        // freopen("input.txt", "r", stdin); 
        // freopen("output.txt", "w", stdout); 
    // #endif 
    // fastio;
    int t=1;
    // cin>>t;
    while(t--)
        solve();
    return 0;
}

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

int gcd(int a,int b){
	return b ? gcd(b,a%b) : a;
}
int lcm(int a,int b)
{
	return a/gcd(a,b)*b;
}
int main()
{
	int x,y;
	while(cin >> x >> y && x != -1)
		printf("%d %d\n",gcd(x,y),lcm(x,y));
}

Measured memory_bytes: 0
//Utkarsh.25dec
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set s ; s.order_of_key(val)  no. of elements strictly less than val
// s.find_by_order(i)  itertor to ith element (0 indexed)
typedef vector<vector<ll>> matrix;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500023;
bool vis[N];
vector <int> adj[N];
void solve()
{
    string s;
    cin>>s;
    int n=s.length();
    s='%'+s;
    int nxt[30][n+5];
    for(int i=0;i<30;i++)
        nxt[i][n+1]=n+1;
    for(int i=n;i>=1;i--)
    {
        for(int j=0;j<26;j++)
        {
            nxt[j][i]=nxt[j][i+1];
        }
        nxt[s[i]-'a'][i]=i;
    }
    ll dp[n+10];
    dp[n+1]=1;
    for(int i=n;i>=1;i--)
    {
        dp[i]=mod;
        for(char ch='a';ch<='z';ch++)
        {
            if(nxt[ch-'a'][i]==n+1)
                dp[i]=1;
            else
                dp[i]=min(dp[i],1+dp[nxt[ch-'a'][i]+1]);
        }
    }
    ll len=dp[1];
    if(len==1)
    {
        for(char ch='a';ch<='z';ch++)
        {
            if(nxt[ch-'a'][1]==n+1)
            {
                cout<<ch;
                return;
            }
        }
    }
    string ans="";
    int curr=1;
    while(ans.length()<len)
    {
        if(curr>n)
        {
            ans.pb('a');
            break;
        }
        for(char ch='a';ch<='z';ch++)
        {
            if(nxt[ch-'a'][curr]==n+1)
            {
                ans.pb(ch);
                break;
            }
            if(dp[nxt[ch-'a'][curr]+1]+ans.length()==len-1)
            {
                ans.pb(ch);
                curr=nxt[ch-'a'][curr]+1;
                break;
            }
        }
    }
    cout<<ans<<'\n';
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    //cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

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

int main(){
    ll n;
    cin >> n;
    vector<ll> dp(3);
    
    for(ll i =0;i < n; i++){
        vector<ll> a(3);
        for(ll i = 0; i < 3; i++){
            cin >> a[i];
        }
        vector<ll> dp2(3, 0);
        for(ll i= 0; i < 3; i++){
            for(ll j = 0; j < 3;j++){
                if(i != j){
                    dp2[i] = max(dp2[i], dp[j] + a[i]);
                }
                
            }
        }
        dp = dp2;
    }
    cout << max(dp[0], max(dp[1], dp[2])) << endl;
    
}

Measured memory_bytes: 256
q = int(input())
lis=[]
maxr=0
minl=float('inf')
for i in range(q):
    l,r = map(int, input().split())
    maxr=max(maxr,r)
    minl=min(minl,int((l+1)/2))
    lis.append((l,r))
primes=[0]*(maxr+1)
if maxr>=2:
    primes[2]=1
for i in range(minl, maxr+1):
    if i%2==0:
        continue
    is_prime=True
    maxcheck=int(i**0.5+1)
    for j in range(3,maxcheck+1):
        if i%j==0:
            is_prime=False
            break
    if is_prime:
        primes[i]=1
like2017=[0]*(maxr+1)
#print(primes)
for i in range(3,maxr+1):
    if primes[i]==1 and primes[int((i+1)/2)]==1:
        like2017[i]=1
    like2017[i]+=like2017[i-1]
#print(like2017)
for l,r in lis:
    print(like2017[r]-like2017[l-1])


Measured memory_bytes: 21196
n,*a = map(int,open(0).read().split())

ans = 0 

def BublbleSort(a,m):
    global ans
    flag = 1
    while flag:
        flag = 0
        for j in range(m-1,0,-1):
            if a[j] < a[j-1]:
                a[j],a[j-1]=a[j-1],a[j]
                ans += 1
                flag = 1
BublbleSort(a,n)
  
            
print(*a)

print(ans)


Measured memory_bytes: 5616
#include <stdio.h>

int main(void){
  int N;
  int a[100] = {};
  int i, j, k;
  int Alice, Bob;
  int max;
  scanf("%d", &N);
  for(i = 0; i < N; i++){
    scanf("%d", &a[i]);
  }
  for(i = 0; i <= N/2; i++){
    max = 0;
    for(j = 0; j < N; j++){
      if(a[j] > max){
        max = a[j];
      }
    }
    Alice += max;
    for(j = 0; j < N; j++){
      if(a[j] == max){
        a[j] = 0;
        break;
      }
    }

    max = 0;
    for(j = 0; j < N; j++){
      if(a[j] > max){
        max = a[j];
      }
    }
    Bob += max;
    for(j = 0; j < N; j++){
      if(a[j] == max){
        a[j] = 0;
        break;
      }
    }
  }
  if(N%2 == 1){
    max = 0;
    for(j = 0; j < N; j++){
      if(a[j] > max){
        max = a[j];
      }
    }
    Alice += max;
    for(j = 0; j < N; j++){
      if(a[j] == max){
        a[j] = 0;
        break;
      }
    }
  }
  printf("%d\n", Alice - Bob);
  return 0;
}


Measured memory_bytes: 128
n = int(input())
a = list(map(int,input().split()))
count = 0
for i in range(1,n-1):
  if min(a[i-1],a[i+1]) < a[i] and max(a[i-1],a[i+1]) > a[i]:
    count += 1
    
print(count)

Measured memory_bytes: 9060
#include <cstdio>
#include <algorithm>
using namespace std;
int N,MAX;
int i=1;
int ans;
int HEIHOUSUU(int N){
  while(N>=i*i){
    MAX=i*i;
    i++;
  }
  return MAX;
}
int main(){
  scanf("%d",&N);
  ans=HEIHOUSUU(N);
  printf("%d\n",MAX);
  return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int R = sc.nextInt();
    double pi = 3.141592653558209749448214808651;
    double l = 2*pi*R;
    System.out.println(l);
  }
}

Measured memory_bytes: 35792
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#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++)

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

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

typedef long long ll;

#define MAX_N 10000
#define ORD_MONEY 1000000000000000

struct Edge {
    int to;
    ll cost;
    Edge(int t, int c)
        : to(t)
        , cost(c)
    {
    }
};
using Graph = vector<vector<int>>;
using Graph_e = vector<vector<Edge>>;

vector<int> dx = { 1, 0, -1, 0 };
vector<int> dy = { 0, 1, 0, -1 };
typedef pair<int, int> P; // first:最短距離，second:頂点番号

typedef pair<ll, ll> P_dij;

ll dijkstra(int s, int g, Graph_e G)
{
    ll d[110];
    fill(d, d + 110, INF_64);
    d[s] = 0;

    priority_queue<P, vector<P>, greater<P>> que;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        ll v = p.second;
        if (d[v] < p.first)
            continue;
        for (auto e : G.at(v)) {
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }

    if (d[g] != INF_64) {
        return d[g];
    } else {
        return -1;
    }
}

int main()
{
    int N, M, R;
    cin >> N >> M >> R;
    vector<int> r(R);
    rep(i, R)
    {
        cin >> r.at(i);
        r.at(i)--;
    }
    vector<vector<ll>> d(N, vector<ll>(N, INF_64));

    rep(i, N)
    {
        d.at(i).at(i) = 0;
    }

    rep(i, M)
    {
        int a, b;
        ll c;
        cin >> a >> b >> c;
        a--;
        b--;
        d.at(a).at(b) = c;
        d.at(b).at(a) = c;
    }

    for (int k = 0; k < N; k++) {
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                d.at(i).at(j) = min(d.at(i).at(j), d.at(i).at(k) + d.at(k).at(j));
            }
        }
    }

    ll ans = INF_64;
    sort(r.begin(), r.end());
    do {
        ll sum = 0;
        for (int i = 1; i < R; i++) {
            sum += d.at(r.at(i)).at(r.at(i - 1));
        }
        chmin(ans, sum);
    } while (next_permutation(r.begin(), r.end()));

    cout << ans << endl;
}


Measured memory_bytes: 512
#pragma target("avx")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define rep(i,b,e) for(ll i=b; i<e; i++)
#define be(vec) vec.begin(),vec.end()
#define print(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define scan(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
	int n, k;
	scanf("%d %d", &n, &k);
	V a(n); scan(a);
	ll ans = 1e18;
	rep(i, 0, n-k+1){
		ll l=a[i], r=a[i+k-1];
		ans = std::min(ans, r-l+std::min(abs(l),abs(r)));
	}
	printf("%ld\n", ans);
	return 0;
}


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

/**
 * Built using CHelper plug-in Actual solution is at the top
 *
 * @author Silviase
 */
public class Main {

  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    Scanner in = new Scanner(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    ABC134D solver = new ABC134D();
    solver.solve(1, in, out);
    out.close();
  }

  static class ABC134D {

    public void solve(int testNumber, Scanner in, PrintWriter out) {
      int n = in.nextInt();
      boolean[] bool = new boolean[n];
      int[] array = new int[n];
      int cnt = 0;
      ArrayList<Integer> al = new ArrayList<>();
      for (int i = 0; i < n; i++) {
        bool[i] = false;
        array[i] = in.nextInt();
      }

      for (int i = n - 1; i >= 0; i--) {
        int tmpcnt = 0;
        for (int j = i; j < n; j += (i + 1)) {
          if (bool[j]) {
            tmpcnt = (tmpcnt + 1) % 2;
          }
        }
        if (tmpcnt != array[i]) {
          bool[i] = true;
        }
      }

      for (int i = 0; i < n; i++) {
        if (bool[i]) {
          cnt++;
          al.add(i + 1);
        }
      }
      out.println(cnt);
      StringBuilder sb = new StringBuilder();
      for (int i = 0; i < al.size(); i++) {
        sb.append(al.get(i) + " ");
      }
      out.println(new String(sb));
    }

  }
}



Measured memory_bytes: 94232
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	string S = "Sunny", C = "Cloudy", R = "Rainy";
	string s;
	cin >> s;

	if (s == S) { cout << C << endl; }
	if (s == C) { cout << R << endl; }
	if (s == R) { cout << S << endl; }

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define INF 2e9
#define MOD (1000000007)
#define EPS 1e-9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long long int lli;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  lli N, M;
  cin >> N >> M;
  vector< lli > x(M);
  REP(i, M) { cin >> x[i]; }
  sort(ALL(x));
  //  reverse(ALL(x));
  if (N >= M) {
    cout << 0 << endl;
  } else {
    vector< lli > xdif(M - 1);

    REP(i, M - 1) { xdif[i] = -x[i + 1] + x[i]; }
    lli ans = x[M - 1] - x[0];
    sort(ALL(xdif));
    REP(i, N - 1) { ans += xdif[i]; }
    cout << ans << "\n";
  }
}

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

using namespace std;

typedef long long ll;

int main() {
    ll a;
    cin >> a;
    set<ll>s;
    for (ll i = 1; i * i <= a ; i++) {
        if(a % i == 0) {
            s.insert(i);
            s.insert(a/i);
        }
    }
    vector<ll>v(s.begin(), s.end());
    ll l = INT_MAX, p;
    ll g, ans = INT_MAX;
    for (ll i = 0; i < v.size(); i++) {
        for (ll j = 0; j < v.size(); j++) {
            ll z = v[i] * v[j];
            if(z == a) {
                // p = abs(v[i] - v[j]);
               // if(p <= l) {
                   // l = p;
                    string w = to_string(v[i]);
                    string u = to_string(v[j]);
                    ll o = w.size();
                    ll k = u.size();
                    g = max(o, k);
                    ans = min(ans, g);

               // }
            }
        }
    }

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


Measured memory_bytes: 384
import math
def is_prime(n):
    if n in [2, 3, 5]:
        return True
    for i in range(2, int(math.sqrt(n))+1):
        if n % i == 0:
            return False
        
    return True

n = int(input())
nums = [int(input()) for i in range(n)]
res = len([i for i in nums if is_prime(i)])
print(res)


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

int main(){

  int n,a[101],b[101],maxnum=0,l;
  int ruiseki_a[101],ruiseki_b[101];

  ruiseki_a[0] = 0; b[0] = 0;
  cin >> n;
  for(int i =1; i<=n ; i++) {cin >> a[i]; ruiseki_a[i]=a[i]+ruiseki_a[i-1];}
  for(int i =1; i<=n ; i++) {cin >> b[i];}
  ruiseki_b[n] = b[n];
  for(int i=n-1; i>=1; i--){ ruiseki_b[i] =b[i] + ruiseki_b[i+1];
  }

  for(int i =1; i<=n; i++){
      l = ruiseki_a[i] + ruiseki_b[i];
      if(l > maxnum) maxnum = l;
    }

  /*  for(int i=1; i<=n; i++){
        cout<<"ra" << i << ':' <<ruiseki_a[i] << endl;
        cout<<"rb" <<  i << ':' <<ruiseki_b[i] << endl;
    }
  */
  
  cout << maxnum;
  return 0;
}

Measured memory_bytes: 256