akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int n;
    cin>>n;
    int x, y;
    cin>>x>>y;
    int a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a,a+n);
    int p=-1;
    for(int i=0;i<n;i++){
        if(a[i]>x){
            p=i-1; break;
        }
    }
    if(p==-1){
        cout<<0; return 0;
    }
    int q=-1;
    for(int i=p+1;i<n;i++){
        if(a[i] > y){
            q=i; break;
        }
    }
    if(q==-1){
        cout<<0; return 0;
    }
    cout<<max(0,min(p+1,min(q-p-1,n-q)));
}

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

int main(){

  while(1){
  int H, W;
  cin>>H>>W;
  if(H==0&&W==0)break;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if((i+j)%2==0)cout<<"#";
      if((i+j)%2!=0)cout<<".";

    }cout<<endl;
  }cout<<endl;
  }


  return 0;
}



Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;

int arr[101] = {0};

int main()
{
	int t=9999999;
	string a, b;
	cin >> a >> b;
	for(int i=b.length()-1; i<a.length(); i++)
	{
		int n=0;
		for(int j=i-b.length()+1; j<=i; j++)
		{	
			if(a[j] != b[j-i+b.length()-1])
			{
				n++;			
			}
		}
		t = min(t, n);
	}
	cout << t;
}



Measured memory_bytes: 3600
def main():
    n = int(input())
    s = list(map(int,input().split()))
    r = [0] * n
    for i in range(n,n//2,-1):
        if s[i-1] == 1:
            r[i-1] = 1
    for i in range(n//2,0,-1):
        p = n // i
        c = 0
        for j in range(1,p+1):
            if r[(j * i) - 1] == 1:
                c += 1
        if c % 2 != s[i-1]:
            r[i-1] = 1

    o = sum(r)
    print(o)
    if o > 0:
        u = []
        for i in range(len(r)):
            if r[i] == 1:
                u.append(str(i+1))
        print(" ".join(u))
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 17204
#include<iostream>
#include<stdio.h>

using namespace std;

int main()
{
	int i,c;
	double vsum,lsum,t,v1l;
	int v1,v2;
	int l[11];

	while(scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",&l[1],&l[2],&l[3],&l[4],&l[5],&l[6],&l[7],&l[8],&l[9],&l[10],&v1,&v2)!=EOF)
	{
		lsum=0;
		vsum=v1+v2;
		for(i=1;i<11;i++)
			lsum+=l[i];
		t=lsum/vsum;
		v1l=t*v1;
		i=1;
		while(v1l>0){
			v1l-=l[i];
			i++;
		}

		printf("%d\n",--i);
	}
	return 0;
}

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

using namespace std;

int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m, k;
    cin >> n >> m >> k;
    long long apsum[200001] = {0}, bpsum[200001] = {0};
    for(int i = 1; i <= n; i++) {
        cin >> apsum[i];
        apsum[i] += apsum[i - 1];
    }
    for(int i = 1; i <= m; i++) {
        cin >> bpsum[i];
        bpsum[i] += bpsum[i - 1];
    }
    long long ans = -1e9, j = m;
    for(int i = 0; i <= n; i++) {
        if(apsum[i] > k) {
            break;
        }
        while(bpsum[j] > k - apsum[i]) {
            j--;
        }
        ans = max(ans, i + j);
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 6772
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderD
{
    static void Main()
    {
        long a;
        long b;
        {
            var line = Console.ReadLine();
            var words = line.Split(' ');
            a = long.Parse(words[0]);
            b = long.Parse(words[1]);
        }

        long gcd = Gcd(a, b);
        int count = 0;
        double sqrt = Math.Sqrt(gcd);
        for (int i = 1; i <= sqrt; i++)
        {
            if (gcd % i == 0)
            {
                long c = i;
                long d = gcd / i;
                if (IsPrime(c))
                {
                    count++;
                }
                if (c != d && IsPrime(d))
                {
                    count++;
                }
            }
        }

        Console.WriteLine(count);
    }

    // 最大公約数（long）
    private static long Gcd(long a, long b)
    {
        if (a < b)
        {
            return Gcd(b, a);
        }
        while (b != 0)
        {
            long r = a % b;
            a = b;
            b = r;
        }
        return a;
    }

    // 最小公倍数（long）
    private static long Lcm(long a, long b)
    {
        return a / Gcd(a, b) * b;
    }

    // 素数判定
    private static bool IsPrime(long num)
    {
        if (num <= 2)
        {
            return true;
        }
        if (num % 2 == 0)
        {
            return false;
        }

        double sqrt = Math.Sqrt(num);
        for (int i = 3; i <= sqrt; i += 2)
        {
            if (num % i == 0)
            {
                return false;
            }
        }
        return true;
    }
}

Measured memory_bytes: 11092
n = int(input())
a = sorted((int(x), k) for k, x in enumerate(input().split()))
opt = [[0 for j in range(n + 1)] for i in range(n + 1)]
for i in reversed(range(n)):
    for j in range(i, n):
        val, k = a[j - i]
        opt[i][j] = max(val * abs(k - i) + opt[i + 1][j], val * abs(k - j) + opt[i][j - 1])
print(opt[0][n - 1])


Measured memory_bytes: 136904
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
typedef long long int ll;
typedef long double ld;
using namespace std;

vvl use = vv(101, 101, 0, ll);
struct Dijkstra{
  ll INF=1000000000000000009;
  ll MAX_V=1000000;
  ll st = -1;
  struct edge{ll to, cost;};
  typedef pair<ll, ll> p;
  vector<vector<edge>> G;
  vector<ll> pre, d;
  priority_queue<p, vector<p>, greater<p> > que; //class, inner, compair
  Dijkstra(ll s){
    G.resize(s+2);
    pre.resize(s+2, -1);
    d.resize(s+2, INF);
  }
  inline void insert(ll a, ll b, ll c){
    G[a].push_back(edge{b, c});
  }
  void init(){
    for(int i=0;i<d.size();i++) pre[i] = -1, d[i] = INF;
  }
  void dijkstra(int start){
    init();
    st = start;
    d[start]=0;
    que.push(p(0, start));
    while(!que.empty()){
      p p_now=que.top(); que.pop();
      ll v = p_now.second;
      if(d[v]<p_now.first) continue;
      for(int i=0;i<G[v].size();i++){
        edge e = G[v][i];
        if(d[e.to]>d[v]+e.cost){
          d[e.to]=d[v]+e.cost;
          pre[e.to] = v;
          que.push(p(d[e.to], e.to));
        }
      }
    }
  }
  vll get_path(int now){
    vll ret;
    while(now!=-1){
      ret.push_back(now);
      now = pre[now];
    }
    return ret;
  }
};
int main(int argc, char const *argv[]) {
  ll x, y, z, n, m;std::cin >> n >> m;
  Dijkstra dk(n+1);
  re(i, m){
    std::cin >> x >> y >> z;
    use[x][y] = use[y][x] = 1;
    dk.insert(x, y, z);
    dk.insert(y, x, z);
  }
  rep(i, 1, n+1){
    dk.dijkstra(i);
    rep(j, 1, n+1){
      if(i==j) continue;
      vll t = dk.get_path(j);
      re(k, t.size()-1){
        use[t[k]][t[k+1]] = use[t[k+1]][t[k]] = 0;
      }
    }
  }
  ll ans = 0;
  for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) if(use[i][j]==1) ans++;
  std::cout << ans/2 << '\n';
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
void Fast() {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
}
int main() {
	Fast();
	int n, i, k;
	cin >> n >> k;
	int* v = new int[n];
	bool** dp = new bool* [k];
	for (i = 0; i <= k; i++)dp[i] = new bool[2];
	for (i = 0; i < n; i++)cin >> v[i];
	for (i = 0; i <= k; i++) {
		dp[i][0] = 1, dp[i][1] = 0;
		for (int j = 0; j < n; j++) {
			if (i - v[j] >= 0)dp[i][1] |= dp[i - v[j]][0];
			if (i - v[j] >= 0)dp[i][0] &= dp[i - v[j]][1];
		}
	}
	cout << (dp[k][1] ? "First" : "Second");
}

Measured memory_bytes: 7540
#include <iostream>
#include <utility>
#include <functional>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <stdlib.h>
#include <stdio.h>
using namespace std;
#define rep(i,n,x) for(int i=n;i<x;i++)
#define rem(i,n,x) for(int i=n;i>x;i--)
#define SORT(x) sort(x.begin(),x.end())
#define REV(x) reverse(x.begin(),x.end())
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define setp(x) setprecision(x)
using LL = long long;
using ULL = unsigned long long;

int main() {
	string o, e;
	cin >> o >> e;

	int n = o.size();
	if (o.size() == e.size()) {
		rep(i, 0, n) {
			cout << o[i] << e[i];
		}
		cout << endl;
	}
	else {
		rep(i, 0, n - 1) {
			cout << o[i] << e[i];
		}
		cout << o[n - 1] << endl;
	}

	return 0;
}

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;

#define rep(a,n) for(ll a = 0;a < n;a++)

static const ll INF = 1e18;
static const ll mod = 1e9+7;

template<typename T>
static inline void chmin(T& ref, const T  value) {
    if (ref > value) ref = value;
}

template<typename T>
static inline void chmax(T& ref, const T value) {
    if (ref < value) ref = value;
}

int main() {
    string s, t;
    cin >> s >> t;
    int n1 = s.size();
    int n2 = t.size();
    int ans = n2;
    for (int i = 0; i <= n1 - n2; i++) {
        int match = 0;
        for (int j = 0; j < n2; j++) {
            if (s[i + j] == t[j]) {
                match++;
            }
        }
        chmin(ans, n2 - match);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3592
#include<iostream>
using namespace std;
#include<string>
#include<utility>
#include<algorithm>

int main(){
    int N;
    cin >> N;
    long long int B[N];
    for(int i=1;i<N;++i){
        cin >> B[i];
    }
    long long int C[N];
    B[0]=100000000000000000;
    B[N]=100000000000000000;
   C[0]=B[0];
   C[N]=B[0];
   for(int i=1;i<N+1;++i){
       C[i]=min(B[i-1],B[i]);
   }
   int res=0;
   for(int i=1;i<N+1;++i){
        res+=C[i];
    }
    cout << res;
}

Measured memory_bytes: 256
N=int(input())
L=[list(input().split())+[i+1] for i in range(N)]
L=[[l[0],int(l[1]),l[2]] for l in L]
L.sort(key=lambda x: x[1],reverse=True)
L.sort(key=lambda x: x[0])
for l in L:
  print(l[2])

Measured memory_bytes: 9008
sa = list(input())[::-1]
sb = list(input())[::-1]
sc = list(input())[::-1]

pop_num = "a"
while True:
  if pop_num =="a":
    if sa:
      pop_num = sa[-1]
      del sa[-1]
    else:
      print("A")
      exit()
  elif pop_num =="b":
    if sb:
      pop_num = sb[-1]
      del sb[-1]
    else:
      print("B")
      exit()
  elif pop_num =="c":
    if sc:
      pop_num = sc[-1]
      del sc[-1]
    else:
      print("C")
      exit()

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

using namespace std;

const int N = 555;

int cost[N][N];
int color[N][N];
int have[3][N];

int main() {
  int n, c;
  scanf("%d %d", &n, &c);
  for (int i = 0; i < c; i++) {
    for (int j = 0; j < c; j++) {
      scanf("%d", cost[i] + j);
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      scanf("%d", color[i] + j);
      color[i][j]--;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      have[(i + j + 2) % 3][color[i][j]]++;
    }
  }
  long long ans = (long long) 1e18;
  for (int x = 0; x < c; x++) {
    for (int y = 0; y < c; y++) {
      for (int z = 0; z < c; z++) {
        if (x == y || y == z || x == z) {
          continue;
        }
        long long res = 0;
        for (int rot = 0; rot < 3; rot++) {
          int v = rot == 0 ? x : (rot == 1 ? y : z);
          for (int j = 0; j < c; j++) {
            res += cost[j][v] * 1LL * have[rot][j];
          }
        }
        ans = min(ans, res);
      }
    }
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 1408
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const ll MOD = 1000000007;
// const int INF = 2000000000;

string s;

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

  string ans = "";
  for (int i = 0; i < s.size(); i++) {
    if (i % 2 == 0) {
      ans += s[i];
    }
  }

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

Measured memory_bytes: 592
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000


int main(){
	int n, k;
	int x, y, z;
	long long s, ans;
	bool v = true;
	ans = 0;
	scanf("%d", &n);
	if (n == 3){
		printf("%d %d %d\n", 2, 3, 25);
	}
	else{
		printf("2 4 ");
		n -= 2;
		for (int i = 0; i < 2500 && n>1; i++){
			printf("%d %d", (12 * i) + 3, (12 * i) + 9);
			n -= 2;
			if (n == 0)printf("\n");
			else printf(" ");
		}
		for (int i = 1; i < 5000 && n>1; i++){
			printf("%d %d", (6 * i) + 2, (6 * i) + 4);
			n -= 2;
			if (n == 0)printf("\n");
			else printf(" ");
		}
		for (int i = 0; i < 5000 && n>0; i++){
			printf("%d", (6 * i) + 6);
			n--;
			if (n == 0)printf("\n");
			else printf(" ");
		}
	}


	return 0;
}

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

int main() {
    int N, K;
    scanf("%d %d", &N, &K);
    long long ans = 0;
    for (int i = K + 1; i <= N; i++) {
        ans += (i - K) * (N / i);
        ans += max(0, N % i - K + 1);
        if (K == 0) ans -= 1;
    }

    printf("%lld\n", ans);
    return 0;
}

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

int main()
{
    std::string s;
    std::cin >> s;

    int a_pos = INT_MAX, z_pos = 0;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] == 'A') {
            a_pos = std::min(a_pos, i);
        }

        if (s[i] == 'Z') {
            z_pos = std::max(z_pos, i);
        }
    }

    std::cout << z_pos - a_pos + 1 << std::endl;
}


Measured memory_bytes: 640
program ATCoder
  implicit none
  character(10) :: s
  integer       :: n, y(10), i, j, m, k
  y = 0
  read(*,*) s
  s = trim(adjustl(s))
  n = len_trim(s)
  do i = 1, n
    if (s(i:i).eq."A") y(i) = 1
    if (s(i:i).eq."C") y(i) = 1
    if (s(i:i).eq."G") y(i) = 1
    if (s(i:i).eq."T") y(i) = 1
  end do
  m = 0
  do i = 1, n
    if (y(i).eq.1) then
      j = i
      k = 0
      do
        if (y(j).eq.0) exit
        k = k + 1
        j = j + 1
        if (j.gt.n) exit
      end do
      if (m.lt.k) m = k
    end if
  end do
  write(*,'(i0)') m
end program ATCoder

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int k, x;
    cin >> k >> x;
    int cnt=x-k+1;
    for(int i=cnt; i<x+k; i++)
        cout << i << " ";
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) ((vec).begin(),(vec).end())
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
int n,c[200100],sz[200100],uu,vv;
vector<int> ga[200100];
long long sum[200100],res[200100];
long long Magic(long long x){
	return x*(x+1LL)/2LL;
}
void dfs(int u,int p){
	int co=c[u];
	long long pre=sum[co];
	sz[u]=1;
	for(int v:ga[u]){
		if(v==p)
			continue;
		long long lst=sum[co];
		dfs(v,u);
		long long delta=sum[co]-lst;
		sz[u]+=sz[v];
		res[co]-=Magic(sz[v]-delta);
	}
	sum[co]=pre+sz[u];
}
int main(){
	#ifdef FILIN
		#ifndef LOCAL
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>c[i];
		res[i]=Magic(n); 
	}
	for(int i=1;i<n;i++){
		cin>>uu>>vv;
		ga[uu].push_back(vv);
		ga[vv].push_back(uu);
	}
	dfs(1,0);
	for(int i=1;i<=n;i++){
		res[i]-=Magic(n-sum[i]);
		cout<<res[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 37876
import sys
from collections import deque
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
n,q = map(int,input().split())
tree = [[] for i in range(n)]
ans = [0]*n
for i in range(n-1):
    a,b = map(lambda x:int(x)-1,input().split())
    tree[a].append(b)
    tree[b].append(a)

for i in range(q):
    p,x = map(int, input().split())
    ans[p - 1] += x

d = deque([[0,0]])
c = [False]*n
c[0] = True
while d:
    x,s = d.pop()
    s += ans[x]
    ans[x] = s
    for e in tree[x]:
        if not c[e]:
            c[e] = True
            d.append([e,s])

print(*ans)

Measured memory_bytes: 64784
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.Globalization;
using System.IO.Compression;
using System.IO.Pipes;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Read();
            var T = Read();
            var lastchar = T[T.Length - 1];

            if (S + lastchar == T)
            {
                WriteLine("Yes");
            }
            else
            {
                WriteLine("No");
            }
        }
        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 25800
import sys
import numpy as np
inputs = sys.stdin.readlines()

n = int(inputs[0])
A = np.array(list(map(int, inputs[1].split())))
B = np.empty((n,), dtype=np.int)
B[0] = (sum(A[::2])-sum(A[1::2])) // 2
for i in range(1, n):
    B[i] = A[i-1] - B[i-1]
print(*(B*2))

Measured memory_bytes: 24428
n = [0,31,29,31,30,31,30,31,31,30,31,30,31]
w = ["Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"]
while gets
  m,d = $_.split.map(&:to_i)
  if m == 0 then break
  else puts w[(n[0..m-1].inject(:+)+d)%7] end
end

Measured memory_bytes: 8588
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}

int main(){
    double a,b,x;cin>>a>>b>>x;
    double saka=atan(a/b);
    double t=a*a*b;
    double r=atan(1);
    //cout<<r;return 0;
    if(x<=t/2){
        double ans=atan(2*x/(a*b*b));
        ans*=180/pi;
        ans=90-ans;
        cout<<fixed<<setprecision(12)<<ans<<endl;
    }
    else{
        double ans=atan(2*(t-x)/(a*a*a));
        ans*=180/pi;
        cout<<fixed<<setprecision(12)<<ans<<endl;
    }
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p){os<<"("<<p.first<<","<< p.second<<")";return os;}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v){os<<"{";REP(i,(int)v.size()){if(i)os<<",";os<<v[i];}os<<"}";return os;}
template <typename T, size_t S> void printArray(const T (&array)[S]){for(auto val : array)std::cout << val << ", ";std::cout << "\n";}
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
//const int dx[4] = {1, 0, -1, 0};
//const int dy[4] = {0, 1, 0, -1};
//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve(){
    string s, t;
    cin >> s >> t;
    ll n = min(s.size(), t.size());
    sort(ALL(s));
    sort(RALL(t));
    bool flag = false;
    REP(i, n){
        if(s[i] < t[i]){
            flag = true;
            break;
        }
        else if(s[i] == t[i]){
            if(i == n-1 && t.size() > s.size()){
                flag = true;
                break;
            }
        }
    }
    if(flag) Yes();
    else No();
}

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

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

int main() {

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

  string input;

  long long int w, h;

  while( true ) {

    cin >> w >> h;

    if ( w == 0 ) break;

    vector<string> map;

    for ( long long int y = 0; y < h; y++ ) {

      cin >> input;

      map.push_back( input );

    }

    long long int ans_b = 0;
    long long int ans_w = 0;

    for ( long long int y = 0; y < h; y++ ) {

      for ( long long int x = 0; x < w; x++ ) {

	if ( map[y][x] == '.' ) {

	  map[y][x] = 'C';
	  queue<int> qx, qy;
	  qx.push( x );
	  qy.push( y );

	  long long int ans = 1;
	  bool flag_b = false;
	  bool flag_w = false;

	  while( qx.size() > 0 ) {

	    int mx = qx.front();
	    int my = qy.front();
	    qx.pop();
	    qy.pop();

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

	      mx += dx[i];
	      my += dy[i];

	      if ( mx >= 0 && mx < w && my >= 0 && my < h ) {

		if ( map[my][mx] == '.' ) {
		  map[my][mx] = 'C';
		  qx.push(mx);
		  qy.push(my);
		  ans++;
		}else if ( map[my][mx] == 'B' ) {
		  flag_b = true;
		}else if ( map[my][mx] == 'W' ) {
		  flag_w = true;
		}

	      }

	      mx -= dx[i];
	      my -= dy[i];

	    }

	  }

	  if ( flag_b == true && flag_w == false ) {
	    ans_b += ans;
	  }else if ( flag_b == false && flag_w == true ) {
	    ans_w += ans;
	  }

	}

      }

    }

    cout << ans_b << " " << ans_w << endl;

  }

  return 0;

}

Measured memory_bytes: 1248
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}

//-----------------------ここから-----------

int main(void){
    string s;
    cin >> s;
    bool ok = true;
    for(int i = 0; i < s.size(); i++){
        for(int j = 0; j < s.size(); j++){
            if(i == j) continue;
            if(s[i] == s[j]){
                ok = false;
                break;
            }
        }
        if(!ok)break;
    }
    if(ok){
        cout << "yes" << endl; 
    } else {
        cout << "no" << endl;
    }
}

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

int main(){
    int n; cin>>n;
    int bunshi=n-n/2;
    //cout<<bunshi<<endl;
    double ans=double(bunshi)/double(n);
    //cout<<ans<<endl;
    printf("%.8f",ans);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		double[] stack = new double[40];
		while(scan.hasNext()){
			int sp = 0;
			String[] str = scan.nextLine().split(" ");
			for(int i = 0;i < str.length;i++){
				if(str[i].equals("+")){
					double a = stack[--sp];
					double b = stack[--sp];
					stack[sp++] = a + b;
				}else if(str[i].equals("-")){
					double a = stack[--sp];
					double b = stack[--sp];
					stack[sp++] = b - a;
				}else if(str[i].equals("*")){
					double a = stack[--sp];
					double b = stack[--sp];
					stack[sp++] = a * b;
				}else if(str[i].equals("/")){
					double a = stack[--sp];
					double b = stack[--sp];
					stack[sp++] = b / a;
				}else{
					stack[sp++] = Double.parseDouble(str[i]);
				}
			}
			for(int i = 0;i < sp;i++){
				System.out.printf("%.6f\n",stack[i]);
			}
		}
	}
}

Measured memory_bytes: 17344
N = int(input())

s_x = 0
s_y = 0
s_t = 0
travel_flag = True

def judge_ok(d_p, d_t):
  if d_p > d_t:
    return False
  if d_p % 2 != d_t % 2:
    return False
  return True

for n in range(N):
  n_t, n_x, n_y = list(map(lambda x:int(x), input().split(" ")))

  if not judge_ok(abs(n_x - s_x) + abs(n_y - s_y), n_t - s_t):
    travel_flag = False
  
  s_x = n_x
  s_y = n_y
  s_t = n_t

if travel_flag:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define vec vector
#define ll long long

int main(void)
{
  ll n, m;
  cin >> n >> m;
  vec<pair<ll, ll> > x(n);
  rep(i, n) cin >> x[i].first >> x[i].second;

  sort(x.begin(), x.end());
  ll cost = 0;
  rep(i, n) {
    if (m == 0) break;
    if (m > x[i].second) {
      m -= x[i].second;
      cost += x[i].first * x[i].second;
      continue;
    }
    cost += x[i].first * m;
    break;
  }
  cout << cost << endl;
  return 0;
}


Measured memory_bytes: 1792
#include<cstdio>
int n,m,dp[611][311][311],a[601],p[601],cnt,tot,ki,mo;
int main()
{
	scanf("%d",&n);
	m=2*n;
	mo=1000000007;
	for(int i=1;i<=m;i++)scanf("%d",&a[i]);
	for(int i=1;i<=m;i++)if(a[i]>0)a[i]=m+1-a[i];
	for(int i=1;i<=m;i++)p[i]=0;
	for(int i=1;i<=m;i++)if(a[i]>0)	p[a[i]]=1;
	cnt=tot=0;
	for(int i=1;i<=m;i++)if((i%2)==1)
	{
		if((a[i]<0)||(a[i+1]<0))
		{
			if((a[i]<0)^(a[i+1]<0))	
			{
				cnt++;
				if(a[i]<0)p[a[i+1]]++;
				else p[a[i]]++;
			}
			else tot++;
		}
	}
	dp[m+1][0][0]=1;
	ki=0;
	for(int i=m+1;i>=2;i--)
	{
	for(int j=0;j<=n;j++)
	for(int k=0;k<=cnt;k++)
	{
		if(p[i-1]==0)
		{
			dp[i-1][j][k+1]=(dp[i-1][j][k+1]+dp[i][j][k])%mo;
			dp[i-1][j+1][k]=(dp[i-1][j+1][k]+1ll*(tot-((m-i+1+j-ki-k)/2))*dp[i][j][k])%mo;
			if(j>0)dp[i-1][j-1][k]=(dp[i-1][j-1][k]+dp[i][j][k])%mo;
		}
		else
		{
			if(p[i-1]==2)
			{
				dp[i-1][j+1][k]=(dp[i-1][j+1][k]+dp[i][j][k])%mo;
				if(k>0)dp[i-1][j][k-1]=(dp[i-1][j][k-1]+1ll*dp[i][j][k]*k)%mo;
			}
			else 	dp[i-1][j][k]=dp[i][j][k];
		}
	}
		ki=ki+p[i-1];
	}
	dp[1][0][0]=(dp[1][0][0]+mo)%mo;
	printf("%d\n",dp[1][0][0]);
} 

Measured memory_bytes: 227072
import java.io.BufferedReader;
import java.io.InputStreamReader;
  
public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder st = new StringBuilder();
          
        int x,y;
        String[]  data;
          
        while(true){
            data = br.readLine().split(" ");
            x = Integer.parseInt(data[0]);
            y = Integer.parseInt(data[1]);
            if(x ==0 && y == 0){
                break;
            }
            if(x<y){
            	st.append(data[0]).append(" ").append(data[1]).append("\n");
            }else{
            	st.append(data[1]).append(" ").append(data[0]).append("\n");
            }
        }
          
        System.out.print(st);
    }
}

Measured memory_bytes: 26436
import sys,math,collections,itertools
input = sys.stdin.readline

s = input().rstrip()[::-1]
DP=[0 for _ in range(13)]

DP[0]=1
m = 10**9+7
mul = 1
for i in range(len(s)):
    dig = s[i]
    nextDP = [0 for _ in range(13)]
    if dig == '?':
        for j in range(10):
            for k in range(13):
                nextDP[(k+mul*j)%13] += DP[k]
                nextDP[(k+mul*j)%13]%=m
    else:
        j = int(dig)
        for k in range(13):
            nextDP[(k+mul*j)%13] += DP[k]
            nextDP[(k+mul*j)%13]%=m

    mul *= 10
    mul%=13
    DP = nextDP

print(DP[5]%m)
        


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

int main(void){
 
  int n, w, a[9];
  cin >> n;
  w = n;
  for( int i = 0 ; i < 9 ; i++ ){
    int b = 100000000;
    for( int j = 0 ; j < i; j++ ){
      b /= 10;
//      cout << b <<endl;
    }
    a[i] = w / b;
    w -= a[i] * b ;
//    cout << a[i] << "  " << w << endl;
  }
  int m = 0;
  for( int i = 0 ; i < 9 ; i++ ){
    m += a[i];
  }
  if( n % m == 0 ){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3568
using System;
using System.Collections.Generic;

class alds14a
{
    static void Main()
    {
        Console.ReadLine();
        List<int> S = read();
        Console.ReadLine();
        List<int> T = read();
        int ct = 0;
        foreach (int tgt in T)
        {
            if (S.BinarySearch(tgt)>-1) ct++;
        }
        Console.WriteLine(ct);
    }
    static List<int> read()
    {
        List<int> ret = new List<int>();
        string[] input = Console.ReadLine().Split(' ');
        foreach (string data in input)
        {
            int num;
            if (int.TryParse(data, out num))
            {
                ret.Add(num);
            }
        }
        return ret;
    }
}

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

const int maxn = 1e6 + 10;
vector <int> adj[maxn];
int v[1010];
int indeg[maxn];
int dp[maxn];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	for (int i = 0; i < n; i++){
		fill(v, v + n, 0);
		for (int j = 0; j < n - 1; j++){
			cin >> v[j];
			v[j] --;
		}
		for (int j = 0; j < n - 2; j++){
			adj[min(i, v[j]) * n + max(i, v[j])].push_back(min(i, v[j + 1]) * n + max(i, v[j + 1]));
			indeg[min(i, v[j + 1]) * n + max(i, v[j + 1])] ++;
		}
	}
	queue <int> Q;
	for (int i = 0; i < n * n; i++){
		if (!indeg[i])
			Q.push(i);
	}
	vector <int> TS;
	while (Q.size()){
		int v = Q.front();
		Q.pop();
		TS.push_back(v);
		for (auto u: adj[v]){
			indeg[u] --;
			if (!indeg[u])
				Q.push(u);
			dp[u] = max(dp[u], dp[v] + 1);
		}
	}
	if (TS.size() != n * n){
		cout << -1;
		return 0;
	}
	cout << *(max_element(dp, dp + n * n)) + 1;
}


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

using namespace std;

#define ll long long
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef set<int> si;
typedef set<vi> svi;
typedef set<ll> sll;
typedef set<vll> svll;
typedef set<pii> spii;
typedef set<vpii> svpii;
typedef set<pll> spll;
typedef set<vpll> svpll;
typedef vector<si> vsi;
typedef vector<sll> vsll;
typedef vector<spii> vspii;
typedef vector<spll> vspll;
#define ft first
#define sc second
#define pb push_back
#define ins insert
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define all(v) v.begin(),v.end()
#define Sort(v) sort(all(v))
#define sortarr(a,n) sort(a,a+n)
#define tt ll tc; cin >> tc; while(tc--)
#define rep(var,start,end,interval) for(ll var=start;(interval>0 and var<end) or (interval<0 and var>end);var+=interval)
#define each(x,v) for(auto x : v)
#define takearr0(a,n) rep(z,0,n,1) cin >> a[z];
#define takearr1(a,n) rep(z,1,n+1,1) cin >> a[z];

const ll max_n = 3e3 + 5;

ll r,c,k;

int main()
{
	io;
	cin >> r >> c >> k;
	vvll a(r,vll(c,0));
	rep(i,0,k,1)
	{
		ll x,y,v;
		cin >> x >> y >> v;
		a[--x][--y] = v;
	}
	vector<vvll> dp(r,vvll(c,vll(4,0)));
	vvll mdp(r,vll(c,0));
	ll ans = 0;
	dp[0][0][1] = a[0][0];
	ans = max(ans,a[0][0]);
	mdp[0][0] = ans;
	rep(i,1,c,1)
	{
		dp[0][i][1] = max(a[0][i],dp[0][i-1][1]);
		dp[0][i][2] = max(dp[0][i-1][2],dp[0][i-1][1]+a[0][i]);
		dp[0][i][3] = max(dp[0][i-1][3],dp[0][i-1][2]+a[0][i]);
		mdp[0][i] = max(max(dp[0][i][0],dp[0][i][1]),max(dp[0][i][2],dp[0][i][3]));
		ans = max(ans,mdp[0][i]);
	}
	rep(i,1,r,1)
	{
		dp[i][0][0] = max(dp[i-1][0][1],dp[i-1][0][0]);
		dp[i][0][1] = dp[i][0][0] + a[i][0];
		mdp[i][0] = max(max(dp[i][0][0],dp[i][0][1]),max(dp[i][0][2],dp[i][0][3]));
		ans = max(ans,mdp[i][0]);
	}
	rep(i,1,r,1)
	{
		rep(j,1,c,1)
		{
			dp[i][j][0] = max(mdp[i-1][j],dp[i][j-1][0]);
			dp[i][j][1] = max(mdp[i-1][j]+a[i][j],max(dp[i][j-1][0]+a[i][j],dp[i][j-1][1]));
			dp[i][j][2] = max(dp[i][j-1][2],dp[i][j-1][1]+a[i][j]);
			dp[i][j][3] = max(dp[i][j-1][3],dp[i][j-1][2]+a[i][j]);
			mdp[i][j] = max(max(dp[i][j][0],dp[i][j][1]),max(dp[i][j][2],dp[i][j][3]));
			ans = max(ans,mdp[i][j]);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 776548
#include<algorithm>//sort(all(変数),greater<型名>())　で降順に
#include<cmath>//切り上げceil(値)
#include<deque>
#include<iomanip>//setprecision(数字)
#include<iostream>
#include<list>
#include<map>
#include<numeric> //xとyの最大公約数は__gcd(x,y),xとyの最小公倍数は(x*y)/__gcd
#include<queue>//priority_queue<型名> 変数：優先度付きキュー　最大値の探索が早い
#include<set>
#include<stack>
#include<string>
#include<vector>

#include<bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<limits>
#include<tuple>
#include<utility>
#define rep0(i,n)  for(ll i=0; i<n; i++)
#define rrep0(i,n) for(ll i=n-1; 0<=i; i--)
#define rep1(i,n)  for(ll i=1; i<=n; i++)
#define rrep1(i,n) for(ll i=n; 1<=i; i--)
#define vll vector<ll>
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define INF 1e18
using ll = long long;
using namespace std;

int main(){
  ll n;  cin >> n;
  ll ans = 0;
  rep0(i,n){
    ll a;  cin >> a;
    ans = __gcd(ans,a);
  }
  cout << ans;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <set>
#define lowbit(x) (x&(-x))
#define MAX(a,b) (a<b?b:a)
#define MIN(a,b) (a<b?a:b)
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
const int N = 1e7;
const int maxn = 3e5 + 5;
ll mod = 1e9 + 7;

int n;
ll a[maxn], x;

int main()
{
	scanf("%d%lld", &n, &x);
	for (int i = 1; i <= n; i++) scanf("%d", a + i);

	ll ans = 0;
	if (a[1] > x)
	{
		ans += a[1] - x;
		a[1] -= ans;
	}
	for (int i = 1; i <= n; i++)
	{
		if (a[i] + a[i - 1] > x)
		{
			ans += a[i] + a[i - 1] - x;
			a[i] -= a[i] + a[i - 1] - x;
		}
	}
	printf("%lld", ans);
}

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

using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> X(N);
    for (int i = 0; i < N; ++i) cin >> X[i];

    int ans = 0;
    for(int i = 0; i < N; ++i)
        ans += min(X[i], abs(K - X[i])) * 2;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <iomanip>
#include <math.h>
#include <time.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define repf(i, a, b) for (int i = (int)a; i < (int)b; i++)
#define repr(i, a, b) for (int i = (int)a; i > (int)b; i--)
#define all(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define pb(x) push_back(x)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 1147483600;
const ll infl = 1e18 + 5;
const char ENDL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 998244353;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    if (n&1){
        int m = n * (n - 1) / 2;
        m -= (n - 1) / 2;
        cout << m << ENDL;
        repf(i,1,n){
            repf(j,i+1,n+1){
                if (i+j==n)
                    continue;
                cout << i << " " << j << ENDL;
            }
        }
    }
    else{
        int m = n * (n - 1) / 2;
        m -= n / 2;
        cout << m << ENDL;
        repf(i,1,n){
            repf(j,i+1,n+1){
                if (i+j==n+1)
                    continue;
                cout << i << " " << j << ENDL;
            }
        }
    }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC087A
{
    class Program
    {
        static void Main(string[] args)
        {
            int x, a, b, c;

            x = int.Parse(Console.ReadLine());
            a = int.Parse(Console.ReadLine());
            b = int.Parse(Console.ReadLine());

            c = (x - a) % b;

            Console.WriteLine(c);

            Console.ReadKey();

        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K, y=0;
  cin >> N >> K;
  
	for (int i = 0; i < N; i++){
		int x;
      	cin >> x;
      if(x <= K-x) y+=2*x;
      else y+=2*(K-x);
      
	}
  
  cout << y << endl;
  
  
 }

Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <cmath>
#include <cstdio>
#include <string>
#include <sstream>

using namespace std;

const int primemax = 500000;
bool prime[primemax];

void init() {
    for (int i = 0; i < primemax; i++) {
        prime[i] = true;
    }
    prime[0] = prime[1] = false;
    for (int i = 2; i * i < primemax; i++) {
        if (prime[i]) {
            for (int j = i * 2; j < primemax; j += i) {
                prime[j] = false;
            }
        }
    }
}

int main() {
    init();
    int n;
    while(1) {
        cin >> n;
        if (n == 0)break;
        int res = 0;
        for (int i = 0; i <= n - i; i++) {
            if (prime[i] == true && prime[n-i] == true)res++;
        }
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 1648
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
//////////////////////////////////

int main() {
  int x[3];
  int n; cin >> n >> x[0] >> x[1] >> x[2];
  vector<string> s(n);
  string ans = "";
  for(int i=0; i<n; i++) cin >> s[i];
  for(int i=0; i<n; i++) {
    int p = s[i][0]-'A';
    int q = s[i][1]-'A';
    if (x[p] == 0 && x[q] == 0) {
      cout << "No" << endl;
      return 0;
    }
    if (x[p] > x[q]) {
      char c = q + 'A'; x[p]--; x[q]++;
      ans += c;
    } else if(x[p] < x[q]) {
      char c = p + 'A'; x[q]--; x[p]++;
      ans += c;
    } else {
      if (x[p] >= 2 || i == n-1) {
        char c = p + 'A'; x[q]--; x[p]++;
        ans += c;
      } else {
        int np = s[i+1][0]-'A';
        int nq = s[i+1][1]-'A';
        if (p == np || p == nq ) {
          char c = p + 'A'; x[q]--; x[p]++;
          ans += c;
        } else {
          char c = q + 'A'; x[p]--; x[q]++;
          ans += c;
        }
      }
    }
  }

  cout << "Yes" << endl;
  for(int i=0; i<n; i++) cout << ans[i] << endl;

  return 0;
}

// EOF


Measured memory_bytes: 6608
import sys
input = sys.stdin.readline

import heapq

N = int(input())
A = list(map(int, input().split()))

A_even=[]
A_odd=[]
A_evenq = []
A_oddq = []
heapq.heapify(A_evenq)
heapq.heapify(A_oddq)

for i in range(N):
    if i%2==0:
        A_even.append(A[i])
    else:
        A_odd.append(A[i])

A_even.sort()
A_odd.sort()
i=0
max_even=0
i_even=0
while i < N//2:
    j = i
    count=0
    while j < N//2:
        if A_even[i] == A_even[j]:
            count+=1
            j+=1
        else:
            heapq.heappush(A_evenq,-count)
            if max_even < count:
                max_even=count
                i_even = A_even[i]
            break
    i=j
heapq.heappush(A_evenq,-count)
if max_even < count:
    max_even=count
    i_even = A_even[i-1]

i=0
max_odd=0
i_odd=0
while i < N//2:
    j = i
    count=0
    while j < N//2:
        if A_odd[i] == A_odd[j]:
            count+=1
            j+=1
        else:
            heapq.heappush(A_oddq,-count)
            if max_odd < count:
                max_odd=count
                i_odd = A_odd[i]
            break
    i=j
heapq.heappush(A_oddq,-count)
if max_odd < count:
    max_odd=count
    i_odd = A_odd[i-1]

ans=N-max_odd-max_even
if i_even == i_odd:
    if len(A_evenq) == 1 and len(A_oddq) == 1:
        ans = N//2
    elif len(A_evenq) == 1:
        heapq.heappop(A_oddq)
        odd2 = -heapq.heappop(A_oddq)
        ans = N-max_even-odd2
    elif len(A_oddq) == 1:
        heapq.heappop(A_evenq)
        even2 = -heapq.heappop(A_evenq)
        ans = N-max_odd-even2
    else:
        ans=0
        heapq.heappop(A_oddq)
        odd2 = -heapq.heappop(A_oddq)
        heapq.heappop(A_evenq)
        even2 = -heapq.heappop(A_evenq)
        ans = min(N-even2-max_odd,N-odd2-max_even)
print(ans)


Measured memory_bytes: 56024
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <iomanip>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<ll,ll> > vpll;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
typedef map<int, int> mii;
typedef set<int> si;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
// #define endl '\n';
#define fi first
#define se second
#define NONVOID [[nodiscard]]
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
template <class T> inline void dump(T &v){irep(i, v){cout<<*i<<((i==--v.end())?'\n':' ');}}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main() {

    int n;
    cin>>n;
    vi v(n),w(101010,0);
    rep(i,n){
        cin>>v[i];
        if(v[i]==0){
            w[v[i]]++;
            w[v[i]+1]++;
        } else {
            w[v[i]]++;
            w[v[i]+1]++;
            w[v[i]-1]++;
        }
    }
    int ans=0;
    rep(i,101010){
        chmax(ans,w[i]);
    }
    fin(ans);
}

Measured memory_bytes: 1024
import sys
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

a,b,c,d,e,f = na()

p = e*100/(100+e)
a*=100
b*=100
ans = [a,0,0]

h = f//a
for i in range(h+1):
    w = (f-a*i)//b
    for j in range(w+1):
        q = f-a*i-b*j
        v = q//c
        for k in range(v+1):
            u = (q-c*k)//d
            for l in range(u+1):
                if c*k+d*l+a*i+b*j == 0:
                    continue
                n = (c*k+d*l)*100/(c*k+d*l+a*i+b*j)
                if n <= p and ans[2] < n:
                    ans = [c*k+d*l+a*i+b*j,c*k+d*l,n]

print(ans[0],ans[1])

Measured memory_bytes: 42860
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
#include <random>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define REPE(i, n) for (int (i)=0; (i) <= (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
#define CONTAINS_SET(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
//void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }


signed main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;

	int ac = a * c;
	int ad = a * d;
	int bc = b * c;
	int bd = b * d;

	cout << max(ac, max(ad, max(bc, bd))) << endl;

}




Measured memory_bytes: 3596