akhauriyash/Code-Regression huggingface dataset:
mod = 998244353
n = int(input())
a = list(map(int, input().split()))
m = max(a)
cnt = [0]*(m+1)
for ai in a:
    cnt[ai]+=1
ans = 0
res = [0]*(m+1)
for i in range(1, m+1)[::-1]:
    sm = 0
    sq = 0
    for j in range(i, m+1, i):
        sm+=j*cnt[j] 
        sq+=cnt[j]*j*j
        res[i]-=res[j]
    res[i]+=sm*sm-sq
    ans+=res[i]//i
    ans%=mod
print(ans*(pow(2, mod-2, mod))%mod)






Measured memory_bytes: 130636
#include <bits/stdc++.h>
using namespace std;
int m[111][111][111];
int a,b,c;
int f(int x, int y, int z){
    if(x>100||y>100||z>100)return 1e9;
    if(x==y && y==z && z==x)return 0;
    auto &r = m[x][y][z];
    if(r==-1){
        r=1e9;
        r=min(r,f(x+1,y+1,z)+1);
        r=min(r,f(x,y+1,z+1)+1);
        r=min(r,f(x+1,y,z+1)+1);
        r=min(r,f(x+2,y,z)+1);
        r=min(r,f(x,y+2,z)+1);
        r=min(r,f(x,y,z+2)+1);
    }
    return r;
}
int main(){
    for(int i=0;i<101;i++)
        for(int j=0;j<101;j++)
            for(int k=0;k<101;k++)
                m[i][j][k]=-1;
    cin>>a>>b>>c;
    cout<<f(a,b,c)<<'\n';
}


Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
const int MAX = 404;
int cs[4][MAX];

using A = array<int, 8>;
A rotH(A x){
  A y;
  y[0]=x[1];
  y[1]=x[2];
  y[2]=x[3];
  y[3]=x[0];

  y[7]=x[6];
  y[6]=x[5];
  y[5]=x[4];
  y[4]=x[7];
  return y;
}

A rotN(A x){
  A y;
  y[0]=x[3];
  y[3]=x[4];
  y[4]=x[7];
  y[7]=x[0];

  y[1]=x[2];
  y[2]=x[5];
  y[5]=x[6];
  y[6]=x[1];
  return y;
}

using ll = long long;
ll make_hash(ll a,ll b,ll c,ll d){
  return (a<<30)|(b<<20)|(c<<10)|d;
}

using P = pair<ll, ll>;
P make_hash(A x){
  return P(make_hash(x[0],x[1],x[2],x[3]),
           make_hash(x[4],x[5],x[6],x[7]));
}

unordered_map<ll, int> cnt,idx;
ll hs[4][MAX]={};

void inc(ll v){
  int k=idx[v];
  cnt[hs[0][k]]++;
  cnt[hs[1][k]]++;
  cnt[hs[2][k]]++;
  cnt[hs[3][k]]++;
}

void dec(ll v){
  int k=idx[v];
  cnt[hs[0][k]]--;
  cnt[hs[1][k]]--;
  cnt[hs[2][k]]--;
  cnt[hs[3][k]]--;
}

__int128_t check(A x){
  ll a=make_hash(x[0],x[1],x[2],x[3]);
  ll b=make_hash(x[4],x[5],x[6],x[7]);

  ll c=make_hash(x[3],x[2],x[5],x[4]);
  ll d=make_hash(x[2],x[1],x[6],x[5]);
  ll e=make_hash(x[1],x[0],x[7],x[6]);
  ll f=make_hash(x[0],x[3],x[4],x[7]);

  if(!cnt.count(a)) return 0;
  if(!cnt.count(b)) return 0;
  if(!cnt.count(c)) return 0;
  if(!cnt.count(d)) return 0;
  if(!cnt.count(e)) return 0;
  if(!cnt.count(f)) return 0;

  __int128_t res=1;
  res*=cnt[a];dec(a);
  res*=cnt[b];dec(b);
  res*=cnt[c];dec(c);
  res*=cnt[d];dec(d);
  res*=cnt[e];dec(e);
  res*=cnt[f];dec(f);

  inc(a);
  inc(b);
  inc(c);
  inc(d);
  inc(e);
  inc(f);

  return res;
}

signed main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>cs[0][i]>>cs[1][i]>>cs[2][i]>>cs[3][i];
    for(int z=0;z<4;z++){
      hs[z][i]=make_hash(cs[(z+0)%4][i],
                         cs[(z+1)%4][i],
                         cs[(z+2)%4][i],
                         cs[(z+3)%4][i]);
      cnt[hs[z][i]]++;
      idx[hs[z][i]]=i;
    }
  }

  ll ans=0;
  set<P> used;

  vector<A> vs;
  {
    A w;
    set<A> rs;
    for(int i=0;i<8;i++) w[i]=i;
    for(int p=0;p<4;p++){
      for(int q=0;q<4;q++){
        for(int r=0;r<4;r++){
          rs.emplace(w);
          w=rotH(w);
        }
        w=rotN(w);
      }
      w=rotH(w);
    }
    vs=vector<A>(rs.begin(),rs.end());
  }

  for(int i=0;i<n;i++){
    for(int j=0;j<i;j++){
      for(int z=0;z<4;z++){
        A x;
        for(int k=0;k<4;k++){
          x[k+0]=cs[(k+z)%4][i];
          x[k+4]=cs[k][j];
        }

        int way=0;
        A w(x);
        for(auto v:vs){
          A y;
          for(int k=0;k<8;k++) y[k]=x[v[k]];
          if(x==y) way++;
          chmin(w,y);
        }

        if(used.count(make_hash(w))) continue;
        used.emplace(make_hash(w));

        ans+=check(x)/way;
      }
    }
  }

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


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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef long double LD;
typedef pair<LD, LD> PLDLD;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define ALL(a) a.begin(),a.end()

const double eps=1e-5;
const int INF=1e9;



int main()
{
    int n;
    cin>>n;
    vector<int> a(n);
    int s=0;
    int m=101;
    REP(i,n)
    {
        cin>>a[i];
        s+=a[i];
        if(a[i]%10!=0)
        {
            m=min(m,a[i]);
        }
    }
    if(s%10==0)
    {
        if(m==101)
            s=0;
        else
        s-=m;
    }
    cout<<s<<endl;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void) {
    std::deque<int> number;
    std::deque<int> numtoscore;
    std::deque<int> score;
    int p,s,q;
    while (scanf("%d,%d",&p,&s)) {
        if (p==0 && s==0) {
            break;
        } else {
            number.emplace_back(p);
            numtoscore.emplace_back(s);
            auto itr = find(score.begin(),score.end(),s);
            if (*itr==0) {
                score.emplace_back(s);
            }
        }
    }
    sort(score.begin(),score.end(),greater<int>());
    while (cin>>q) {
        auto itr2 = find(number.begin(),number.end(),q);
        int hoge = numtoscore[*itr2-1];
        for (int i=0;i<score.size();i++) {
            if (score[i]==hoge) {
                cout<<i+1<<endl;
                break;
            }
        }
    }
}


Measured memory_bytes: 3164
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        LightScanner in = new LightScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ASimpleCalculator solver = new ASimpleCalculator();
        solver.solve(1, in, out);
        out.close();
    }

    static class ASimpleCalculator {
        public void solve(int testNumber, LightScanner in, PrintWriter out) {
            int x = in.ints(), y = in.ints();
            int ans = Integer.MAX_VALUE;
            // 00
            if (x <= y) {
                ans = Math.min(ans, y - x);
            }
            // 01
            if (x <= -y) {
                ans = Math.min(ans, 1 - x - y);
            }
            // 10
            if (-x <= y) {
                ans = Math.min(ans, 1 + x + y);
            }
            // 11
            if (-x <= -y) {
                ans = Math.min(ans, 2 - y + x);
            }
            out.println(ans);
        }

    }

    static class LightScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public LightScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        public String string() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new UncheckedIOException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int ints() {
            return Integer.parseInt(string());
        }

    }
}



Measured memory_bytes: 23380
#include <iostream>
#include <stdio.h>
using namespace std;

class Dice{

private:

public:

  int num[6];

  void roll(char c){
    int b;
    if(c == 'S'){
      b = num[0];
      num[0] = num[4];
      num[4] = num[5];
      num[5] = num[1];
      num[1] = b;
    }
    if(c == 'W'){
      b = num[0];
      num[0] = num[2];
      num[2] = num[5];
      num[5] = num[3];
      num[3] = b;
    }
    if(c == 'N'){
      b = num[0];
      num[0] = num[1];
      num[1] = num[5];
      num[5] = num[4];
      num[4] = b;
    }
    if(c == 'E'){
      b = num[0];
      num[0] = num[3];
      num[3] = num[5];
      num[5] = num[2];
      num[2] = b;
    }
  }

};

int main(){
  Dice d;
  char c;
  int q, front, top;
  for(int i=0;i<6;i++) cin >> d.num[i];
  cin >> q;
  for(int i=0;i<q;i++){
    cin >> top >> front;
    if(d.num[2] == front || d.num[3] == front) d.roll('W');
    while(d.num[1] != front) d.roll('S');
    while(d.num[0] != top) d.roll('W');
    cout << d.num[2] << endl;
  }
  return 0;
}



Measured memory_bytes: 3112
dic = {'AC':0,'WA':0,'TLE':0,'RE':0}
n = int(input())
for i in range(n):
    a = input()
    if a in dic:dic[a] +=1
    else:dic[a]=1

print('AC x',dic['AC'])
print('WA x',dic['WA'])
print('TLE x',dic['TLE'])
print('RE x',dic['RE'])


Measured memory_bytes: 9204
#include<stdio.h>
#include<algorithm>
using namespace std;
int dat[10];
int use[10];
char str[10][21];
int w[10];
int s[10];
int sum;
int n;
int best[10];
int val;
void solve(int a,int b){
	if(a==n){
		int p=0;
		for(int i=0;i<n;i++)p+=w[dat[i]]*(i+1);
		if(p<val){
			val=p;
			for(int i=0;i<n;i++)best[i]=dat[i];
		}
	}else{
		for(int i=0;i<n;i++){
			if(!use[i]&&s[i]>=b-w[i]){
				use[i]=1;
				dat[a]=i;
				solve(a+1,b-w[i]);
				use[i]=0;
			}
		}
	}
}
int main(){
	while(scanf("%d",&n),n){
		val=999999999;
		for(int i=0;i<n;i++)scanf("%s%d%d",str[i],w+i,s+i);
		sum=0;
		for(int i=0;i<n;i++)sum+=w[i];
		solve(0,sum);
		for(int i=0;i<n;i++)printf("%s\n",str[best[i]]);
	}
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii;
typedef pair<ld,ld> id;

#define FOR(i, a, b) for(ll i=(a); i<=(b); i++)
#define ROF(i, a, b) for(ll i=(a); i>=(b); i--)
#define MEM(x, v) memset(x, v, sizeof(x))
#define FILL(x, n, v) fill(x, x+n, v);
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort((x).begin(), (x).end())
#define CMPSORT(x, cp) sort((x).begin(), (x).end(), cp)
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define f first
#define s second
#define ins insert
#define e emplace
#define eb emplace_back
#define ef emplace_front
#define p push
#define pf push_front
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define ft front
#define bk back
#define pp pop
#define ppb pop_back
#define ppf pop_front

#define db cout<<"YEET\n";
#define ct(x) cout<<x<<'\n';

const ll MOD = 1e9+7; //998244353
const ll MAXN = 2e5+5;
const ll INF = 1e18;
const ld PI = acos((ld)-1);

ll fast_exp(ll base, ll power, ll mod){
    ll res=1;
    while (power){
        if (power&1) res*=base;
        res%=mod;
        base*=base;
        base%=mod;
        power>>=1;
    }
    return res;
}

int main(){
    FAST
    ll n;
    cin >> n;
    map<ll, ll> abs;

    ll powr=n/2;
    if (n&1){
        FOR(i,0,n/2) abs[i*2]=0;
    } else {
        FOR(i,1,n/2) abs[i*2-1]=0;
    }

    bool poss=true;
    FOR(i, 1, n){
        ll x;
        cin >> x;
        if (abs.find(x) == abs.end()){
            poss=0;
            break;
        }
        else abs[x]++;

        if (x == 0 && abs[x]>1){
            poss=0;
            break;
        } else if (abs[x]>2) {
            poss=0;
            break;
        }
    }

    if (!poss) cout << "0";
    else cout << fast_exp(2,powr,MOD);
}

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

ll N,M,H,W,K,A,B;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const int MOD = 1000000007, MAX_N = 200000;
typedef pair<ll,ll> P;
mat  G(MAX_N,vec(0));//1-indexed
vector<P> dp(MAX_N,P(-1,-1));
vector<bool> used(MAX_N,false);

P solve(ll v){ //white,blackの順に格納
    if(dp.at(v).fi != -1) return dp.at(v);
    used.at(v) = true;
    ll b=1,w=1;
    for(ll i : G.at(v)){
        if(used.at(i)) continue;
        P p = solve(i);
        (b *= p.fi)%=MOD;
        (w *= p.fi + p.se)%=MOD;
    }
    dp.at(v) = {w,b};
    return {w,b};
}

int main() {
    cin>>N;
    rep(i,N-1){
        int s,t;
        scanf("%d %d", &s, &t);
        G[s].push_back(t);
        G[t].push_back(s);
    }
    P ans = solve(1);
    cout<<(ans.fi+ans.se)%MOD<<endl;
}

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

public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;
	
	public static void Main(string[] args)
	{
		var p = Input().ToInt();
		var a = p[0];
		var b = p[1];
		var c = p[2];
		var d = p[3];
		
		for(;;)
		{
			c-=b;
			if(c <= 0)
			{
				Console.WriteLine("Yes");
				return;
			}
			a-=d;
			if(a <= 0)
			{
				Console.WriteLine("No");
			return;
			}
		}
	}
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}

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

int main(){
    long N, A, B;
    cin >> N >> A >> B;
    vector<long> X(N);
    for (int i=0; i<N; i++){
        cin >> X[i];
    }
    long ans = 0;
    for (int i=0; i<N-1; i++){
        if ((X[i+1]-X[i]) * A < B){
            ans += (X[i+1]-X[i]) * A;
        }
        else ans += B;
    }
    cout << ans << endl;
    return 0;
}

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

#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//以降 cin の入力元が 'input.txt' になる
//std::ifstream in("input.txt");
//std::cin.rdbuf(in.rdbuf());

signed main()
{   
    gearup;
    int n,W; cin >> n >> W;

    int init_w,init_v;
    vvl va(4);
    cin >> init_w >> init_v;
    va[0].push_back(init_v);
    rep1(i,n){
        int w,v; cin >> w >> v;
        va[w-init_w].push_back(v);
    }
    rep(i,4)sort(rall(va[i]));

    vl sva1(va[0].size()+1);
    rep(i,va[0].size())sva1[i+1] = sva1[i] + va[0][i];
    vl sva2(va[1].size()+1);
    rep(i,va[1].size())sva2[i+1] = sva2[i] + va[1][i];
    vl sva3(va[2].size()+1);
    rep(i,va[2].size())sva3[i+1] = sva3[i] + va[2][i];
    vl sva4(va[3].size()+1);
    rep(i,va[3].size())sva4[i+1] = sva4[i] + va[3][i];

    ll res = 0;
    rep(i,va[0].size() + 1){
        rep(j,va[1].size() + 1){
            rep(k,va[2].size() + 1){
                rep(v,va[3].size() + 1){
                    ll t_wei = init_w * i + (init_w + 1) * j + (init_w + 2) * k + 
                    (init_w + 3) * v;
                    if(t_wei <= W)res = max(res,sva1[i]+sva2[j]+sva3[k]+sva4[v]);
                }
            }
        }
    }
    out(res);

}

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

namespace AtCoderRegularContest069
{
    public class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(program1(new String[] { Console.ReadLine(), Console.ReadLine() }));
        }

        public static string program1(string[] args)
        {
            var n = int.Parse(args[0]);
            var s = args[1].ToCharArray();

            var animalPattern = new List<char>[] { new List<char>() { 'S', 'S' }, new List<char> { 'S', 'W' }, new List<char> { 'W', 'W' }, new List<char> { 'W', 'S' } };

            return string.Join("", animalPattern.Select(animals => {
                s.Skip(1).Aggregate(animals.First(), (ani, ans) =>
                {
                    var current = animals.Last();
                    if (ans == 'o' && current == 'S' || ans == 'x' && current == 'W')
                    {
                        animals.Add(ani);
                    }
                    else
                    {
                        animals.Add(ani == 'S' ? 'W' : 'S');
                    }
                    return current;
                });

                return animals;
            })
            .Where(animals => animals.First() == animals.Last())
            .Select(animals => animals.Take(n))
            .FirstOrDefault(animals => {
                if (s.First() == 'o' && animals.First() == 'S' || s.First() == 'x' && animals.First() == 'W')
                {
                    return animals.ElementAt(1) == animals.Last();
                }
                else
                {
                    return animals.ElementAt(1) != animals.Last();
                }
            }) ?? new List<char>() { '-', '1' }) ;
        }
    }
}


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

class Main{
	
	public static void main(String[] args) throws IOException
	{
		int[] azArray = new int[26];
		char ch = 'a';

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in) );

		while(true)
		{
			String str = br.readLine();

			if(str==null) break;

			char[] cArray = str.toCharArray();

			for(int n : cArray)
			{
				for(int i=0; i<azArray.length; i++)
				{
					if(n==65+i || n==(97+i) ) azArray[i]++;
				}
			}
		}
		
		for(int n : azArray) System.out.printf("%c : %d\n",ch++,n);
	}
}

Measured memory_bytes: 24552
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	const initialBufSize = 4096
	const maxBufSize = 1000000
	scanner.Buffer(make([]byte, initialBufSize), maxBufSize)
	scanner.Split(bufio.ScanWords)
	var A int
	scanner.Scan()
	A, _ = strconv.Atoi(scanner.Text())
	var B float64
	scanner.Scan()
	B, _ = strconv.ParseFloat(scanner.Text(), 64)
	fmt.Println(solve(A, B))
}
func solve(A int, B float64) int {
	return A * int(math.Round(B*100)) / 100
}


Measured memory_bytes: 1728
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main() {
  string s;
  cin >> s;
  if(s[2] == s[3] && s[4] == s[5]) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

using namespace std;

int binarySearch(vector<int> &vec, int i)
{
    int left = 0;
    int right = vec.size();
    
    while(left < right)
    {
        int mid = (left + right) / 2;
        
        if(vec[mid] == i)
            return 1;
        else if( i < vec[mid])
            right = mid;
        else 
            left = mid + 1;
    }
    
    return 0;
}
int main()
{
    int N, M;
    vector<int> vec1, vec2;
    
    cin >> N;
    vec1.reserve(N);
    
    for(int i = 0; i < N; ++i)
    {
        int tmp; cin >> tmp;
        vec1.push_back(tmp);
    }
    
    cin >> M;
    vec2.reserve(M);
    for(int i = 0; i < M; ++i)
    {
        int tmp; cin >> tmp;
        vec2.push_back(tmp);
    }
    
    int ans = 0;
    
    //sort(vec1.begin(), vec2.end());
    
    for(int i = 0; i < M; ++i)
        ans += binarySearch(vec1, vec2[i]);
    
    cout << ans << endl;
    
    return 0;
}



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

int main(){
  int N;
  cin>>N;
  int A[N];
  for (int i=0;i<N;i++){
    cin>>A[i];
  }
  int ns=N/2;
  int mi[N];
  int ma[N];
  for (int i=0;i<N;i++){
    mi[i]=A[i];
    ma[i]=A[i];
  }
  sort(mi,mi+N);
  sort(ma,ma+N,greater<int>());
  long s=0;
  for (int j=0;j<ns;j++){
    if (j==0){
      s+=ma[j]-mi[j];
    }
    else {
      s+=ma[j-1]-mi[j];
      s+=ma[j]-mi[j-1];
    }
  }
  int b,c;
  if (N%2!=0){
    b=ma[ns-1]-mi[ns];
    c=ma[ns]-mi[ns-1];
    if (b>c){
      s+=b;
    }
    else{
      s+=c;
    }
  }
  cout<<s;
  return 0;
}


Measured memory_bytes: 1408
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

const ll MOD = 1e9 + 7;
const int MAXN = 120000;

ll dp[MAXN];
ll dp2[MAXN];
int n, k;

void add(ll &a, ll b) {
	a = (a + b) % MOD;
}

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	cin >> n >> k;
	dp[0] = 1;
	for (int i = 0; i < n; ++i) {
		memset(dp2, 0, sizeof(dp2));
		int x;
		cin >> x;
		ll sum = 0;
		for (int i = 0; i <= k; ++i) {
			add(sum, dp[i]);
			if (i > x)
				add(sum, MOD - dp[i - x - 1]);
			dp2[i] = sum;
		}
		memcpy(dp, dp2, sizeof(dp));
	}
	cout << dp[k] << "\n";
	return 0;
}




Measured memory_bytes: 2176
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
using namespace std;
//绑在一起


int gcd(int x,int y)
{
	if(x<y)
	{
		return gcd(y,x);
	}
	if(y==0)
		return x;
	return gcd(y,x%y);
}
int egcd(int a,int b,int&x,int &y)
{
	int d;
	if(b==0)
	{	d=a;
		x=1;
		y=0;
		
	}
	else 
	{	
		d=egcd(b,a%b,y,x);
		y-=a/b*x;
	}
	return d;
}
int main()
{	//人工模拟栈	
	int x,y,a,b;
	cin>>a>>b;
	egcd(a,b,x,y);
	cout<<x<<" "<<y<<endl;

	return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define MAX_E 1000000
#define MAX_V 100000
#define INF 1e9
typedef long long ll;
using namespace std;
/*??????????????????????????? O(V*E)*/

//??????from????????????to???????????????cost??????
struct edge{int from, to, cost;};
edge es[MAX_E]; //???
ll d[MAX_V];   //???????????¢
int V,E;        //V???????????°???E????????°

//s???????????????????????????????????????????????¢????±???????.
void Bellman_Ford(int s){
  for(int i=0; i<V ;i++) d[i]=INF;
  d[s]=0;
  while(true){
    bool update=false;
    for(int i=0; i<E ;i++){
      edge e = es[i];
      if(d[e.from] != INF && d[e.to]> d[e.from] + e.cost){
	d[e.to] = d[e.from] + e.cost;
	update = true;
      }
    }
    if(!update) break;
  }
}

//true??????????????????????????¨??????
bool find_negative_loop(){
  memset(d,0,sizeof(d));

  for(int i=0; i<V ;i++){
    for(int j=0; j<E ;j++){
      edge e = es[j];
      if(d[e.to] > d[e.from] + e.cost){
	d[e.to] = d[e.from] + e.cost;
	
	//n??????????????´??°???????????????????????????????????¨?????????
	if(i == V-1) return true;
      }
    }
  }
  return false;
}

int main(){
  cin>>V;
  for(int i=0;i<V;i++){
    int u,k;
    cin>>u>>k;
    for(int j=0,v,c;j<k;j++){
      cin>>v>>c;
      es[E++]=(edge){u,v,c};
    }
  }
  Bellman_Ford(0);
  for(int i=0;i<V;i++)
    cout<<i<<' '<<d[i]<<endl;
}

Measured memory_bytes: 3136
#include <iostream>

using namespace std;

int main(){
    int n, k;
    cin >> n >> k;
    int ans = 1;
    for (size_t i = 0; i < n; i++)
    {
        if(ans*2 < ans+k) ans*=2;
        else ans += k;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c,N;
    cin >> N;
    a = N/100;
    b = (N%100)/10;
    c = (N%100)%10;
    if(a==7 || b==7 || c==7){
        cout << "Yes";
    }else {
        cout << "No";
    }
}


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

#define REP(i, a) for(int i=0; i<(int)(a); i++)
#define REP1(i, a, b) for(int i=(int)(a); i<=(int)(b); i++)
typedef long long LL;

const int MAX_N = 100005;
int n, A[3][MAX_N], dp[3][MAX_N];
void solve() {
    scanf("%d", &n);    
    REP(i, n) scanf("%d %d %d", &A[0][i], &A[1][i], &A[2][i]);

    REP(i, 3) dp[i][0] = 0;
    REP(i, n) {
        REP(j, 3) {
            REP(k, 3) {
                if(j == k) continue;
                dp[j][i+1] = max(dp[j][i+1], dp[k][i] + A[j][i]);
            }
        }
    }
    int mx = 0;
    REP(i, 3) mx = max(mx, dp[i][n]);
    printf("%d\n", mx);
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		//Input
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int K = Integer.parseInt(sc.next());
		String inputS = sc.next();

		String[] S = inputS.split("");

		sc.close();

		//Logic
		S[K-1] = S[K-1].toLowerCase();

		//Output
		for(int i = 0 ; i < N ; i++ ) {
			System.out.print(S[i]);
		}
	}

}


Measured memory_bytes: 21844
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();
        int count = 0;
        for(int i = A; i <= B; i++) {
            String tmp = String.valueOf(i);
            boolean ok = true;
            for(int j = 0; j < tmp.length() / 2; j++) {
                if(tmp.charAt(j) != tmp.charAt(tmp.length() - j - 1)) {
                    ok = false;
                    break;
                }
            }
            if(ok) count++;
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 28372
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  vector<int> h(n);
  for(int i=0;i<n;i++)cin>>h[i];
  sort(h.begin(),h.end());
  reverse(h.begin(),h.end());
  for(int i=0;i<min(n,k);i++)h[i]=0;
  long long ans=0;
  for(int i=0;i<n;i++)ans+=h[i];
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 4008
function Main(input) {
	input = input.split(" ");
  	const N = Number(input[0]) // 数字
  	const K = Number(input[1]) // 進数
    const decimalNum = parseInt(N, 10) // 10進数に変換
    const converted = decimalNum.toString(K) // K進数に変換
    console.log(String(converted).length)
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main() {
    int N;
    cin >> N;
    int ans = 0;
    for(int i = 1; i <= N; i+=2){
        int yakusu = 0;
        for(int j = 1; j <= N; j++){
            if(i % j == 0){
                yakusu++;
            }
        }
        if(yakusu == 8){
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <map>
#include <sstream>
#include <utility>
#include <stack>
#include <queue>
#include <stdio.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(vecto) vecto.begin(), vecto.end()
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
using ll = long long;

const int MOD = 1000000007;

template <class T>
T GCD(T a, T b)
{
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}

template <class T>
T LCM(T a, T b)
{
    return (a * b) / GCD(a, b);
}

template <class T>
T max_(std::vector<T> vec) //O(nlogn)
{
    std::sort(all(vec));
    return vec.at(vec.size() - 1);
}
template <class T>
T min_(std::vector<T> vec) //O(nlogn)
{
    std::sort(all(vec));
    return vec.at(0);
}

void ans(bool t_or_f)
{
    if (t_or_f == true)
        std::cout << "Yes" << std::endl;
    else
        std::cout << "No" << std::endl;
}

void Ans(bool t_or_f)
{
    if (t_or_f == true)
        std::cout << "YES" << std::endl;
    else
        std::cout << "NO" << std::endl;
}

using namespace std;

////////////////////////////////////////////////////////////////////

const int m = 1000003; //prime number

//define hash functions
ll hash1(ll key){
    //default hash function
    return key % m;
}

ll hash2(ll key){
    //re-hash (open-address)
    return 1 + key % (m - 1);
}

ll hash_(ll key, int i)
{
    return (hash1(key) + (i * hash2(key))) % m;
}

int insert(ll key, ll T[]){
    int i = 0;
    while (true){
        int j = hash_(key, i);
        if (T[j] == 0){
            T[j] = key;
            return j;
        }
        else
            i++;
    }
}

bool search(ll key, ll T[]){
    int i = 0;
    while (true){
        int j = hash_(key, i);
        if (T[j] == key){
            return true;
        }
        else if (T[j] == 0 || i >= m){
            return false;
        }
        else
            i++;
    }
}

int c_to_i(char c){
    if (c == 'A')
        return 1;
    else if (c == 'C')
        return 2;
    else if (c == 'G')
        return 3;
    else
        return 4;
}

ll str_to_ll(string s){
    int l = s.size();
    ll sum = 0;
    for (int i = 0; i < l; i++){
        sum += c_to_i(s[i]) * pow(10, (l - i - 1));
    }
    return sum;
}

int main(){
    int n;
    cin >> n;
    string cmd[n][2];
    ll T[m];
    rep(i,n){
        rep(j,2){
            cin >> cmd[i][j];
        }
    }
    rep(i,n){
        if (cmd[i][0] == "insert")
        {
            insert(str_to_ll(cmd[i][1]), T);
        }
        else if (cmd[i][0] == "find")
        {
            bool s = search(str_to_ll(cmd[i][1]), T);
            if (s)
            {
                cout << "yes" << endl;
            }
            else
            {
                cout << "no" << endl;
            }
        }
    }
}


Measured memory_bytes: 126780
using System;
using System.Linq;

namespace A___Expired
{
    class Program
    {
        static void Main(string[] args)
        {
            var X_A_B = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int X = X_A_B[0], A = X_A_B[1], B = X_A_B[2];

            Console.WriteLine(A >= B ? "delicious" : X + A >= B ? "safe" : "dangerous");
        }
    }
}


Measured memory_bytes: 13268
open Batteries
module EnumL = Enum.Labels
module ListL = List.Labels
module ArrayL = Array.Labels

let dbg0 x = Printf.eprintf "[debug]%s\n" @@ dump x
let dbg1 x = dbg0 x; x

let id = identity

let (++) n m = if n <= m then List.range n `To m else []
let (++-) n m = if n >= m then List.range n `Downto m else []
let (++^) n m = if n < m then List.range n `To (pred m) else []

module ModOp = struct
  let prime = 1_000_000_007
  let (-) a b = (a + prime - b) mod prime
  let (+) a b = (a + b) mod prime
  let ( * ) a b = (a * b) mod prime

  let rec pow x n =
    if n = 0 then 1
    else if n mod 2 = 0 then pow (x*x) (n/2)
    else x * pow (x*x) (n/2)
end

let scan fmt = Scanf.sscanf (read_line ()) fmt

let scan_lines n fmt f =
  if n = 0 then []
  else List.map (fun _ -> scan fmt f) (1 ++ n)

let scan_list ?sep cnv =
  let line = read_line () in
  (match sep with
   | None -> List.map String.of_char @@ String.to_list line
   | Some sep -> String.split_on_char sep line)
  |> List.map cnv

let scan_array ?sep cnv = Array.of_list @@ scan_list ?sep cnv

let scan_matrix n m e ?sep conv =
  let arr = Array.make_matrix n m e in
  ListL.iter (0 ++^ n)
    ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list ?sep conv);
  arr

let atoi c = Char.code c - Char.code '0'

let rec powerset = function
  | [] -> [[]]
  | hd::tl ->
    let pws =  powerset tl in
    pws @ ListL.map pws ~f:(fun pw -> hd::pw)

let permutations l =
  let rec interleave x = function
    | [] -> [[x]]
    | (hd::tl) as l ->
      (x::l) :: (interleave x tl |> ListL.map ~f:(fun l -> hd::l)) in
  let rec aux = function
    | [] -> [[]]
    | a::rest ->
      aux rest |> ListL.map ~f:(interleave a) |> List.concat in
  aux l

let intersection l =
  EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)

let zip l m =
  let n = min (List.length l) (List.length m) in
  List.combine (List.take n l) (List.take n m)

let lower_bound n f =
  let rec aux l u =
    if u - l > 1 then
      let m = (l + u) / 2 in
      if f m then aux l m
      else aux m u
    else u in aux (-1) n

let between n x m = n <= x && x < m

let (n, k) = scan "%d %d" Tuple2.make

let () =
  let open ModOp in
  let arr = Array.make (k+1) 0  in
  ListL.iter (k++-1) ~f:(fun x ->
      let i = k/x in
      arr.(x) <- pow (k / x) n -
                 ((ListL.map (2++i) ~f:(fun i -> arr.(i*x))) |> ListL.fold_left ~init:0 ~f:(+));
      (* Printf.eprintf "%d %d\n" x arr.(x); *)
    );
  ArrayL.mapi arr  ~f:( * )
  |> ArrayL.fold_left ~init:(0) ~f:(+)
  |> Printf.printf "%d\n"


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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
bool chmin(T &a,T b){if(a>b){a=b;return true;}else return false;}
template<typename T>
bool chmax(T &a,T b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  vector<ll>a={
    1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
  };
  ll k;cin>>k;
  cout<<a[k-1]<<endl;
  return 0;
}

Measured memory_bytes: 256
#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 FORR(i, m, n) for (int i = m; i >= n; i--)
#define pb(a) push_back(a)
using namespace std;
typedef long long ll;

int main()
{
    int N;
    cin >> N;
    vector<int> a(N);
    REP(i, N)
    {
        cin >> a.at(i);
    }

    int now;
    int i = 0;
    int ans = 0;
    while (i < N)
    {
        now = a.at(i);
        i++;
        int row = 1;
        if (i < N)
        {
            while (now == a.at(i))
            {
                row++;
                i++;

                if (i == N)
                    break;
            }
        }
        ans += row / 2;
    }

    cout << ans;
}

Measured memory_bytes: 256
// C - Unification

// スタックを用いた解法

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

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

	int ans = 0;

	stack<char> stk;

	for (int i=0; i<S.size(); i++) {
		char c = S[i];

		if (stk.empty()) {
			stk.push(c);
			continue;
		}

		if (c == '0') {
			if (stk.top() == '1') {
				stk.pop();
				ans += 2;
			} else {
				stk.push(c);
			}
		}

		if (c == '1') {
			if (stk.top() == '0') {
				stk.pop();
				ans += 2;
			} else {
				stk.push(c);
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3732
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAXN 1000
int n,p;
char s[MAXN+5];
int main()
{
    scanf("%d%s",&n,s+1);
    for(int i=1;i<=n;i++)
    {
        if(s[i]=='R')p++;
    }
    printf("%s",(p>(n/2))?"Yes":"No");
}

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


int main()
{
    int n , m;
    cin >> n >> m;
   
    priority_queue<int> price;
    rep(i,n) {
        int a;
        cin >> a;
        price.push(a);
    }

    for(int i = 0; i < m; i++)
    {    
        price.push(price.top()/2);
        price.pop();
          
    }

    ll total = 0;
    for(int i = 0;i<n ; i++){
        total += price.top();
        price.pop();
    }
    cout << total << endl;


    return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

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

signed main() {
    double a, b, x;
    cin >> a >> b >> x;
    if (2 * x > a * a * b) {
        x = a * a * b - x;
        x /= a;
        cout << setprecision(10) << 180 / M_PI * atan2(2 * x / a, a) << endl;
    } else {
        x /= a;
        cout << setprecision(10) << 180 / M_PI * atan2(b, 2 * x / b) << endl;
    }
}

Measured memory_bytes: 4072
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 1e18;
#define REP(i,n) for(int i=0;i<n;i++)
#define ALL(v) v.begin(),v.end()

int main(){
	int n; cin >> n;
	VVI dp(n+1,VI(4,0));
	dp[0][0]=1;
	REP(i,n){
		REP(j,10){
			if(j==1||j==2){
				dp[i+1][j]+=dp[i][j]+dp[i][0];
				dp[i+1][3]+=dp[i][3]+dp[i][3^j];
			}
			else{
				REP(k,4){
					dp[i+1][k]+=dp[i][k];
				}
			}
		}
		REP(k,4){
			dp[i+1][k]%=MOD;
		}
	}
	cout << dp[n][3] << endl;
	return 0;
}

Measured memory_bytes: 73320
#include <bits/stdc++.h>
using namespace std;
int main() {
	// your code goes here
	int n;
	int k;
	cin>>n;
	cin>>k;
	vector<int> arr (n);
	for(int i=0;i<n;i++)
	    cin>>arr[i];
	for(int i=0;i<n-k;i++)
	{
	    if(arr[k+i]>arr[i])
	        cout<<"Yes"<<endl;
	    else
	        cout<<"No"<<endl;
	}
}


Measured memory_bytes: 4044
# -*- coding: utf-8 -*-

import sys
import copy

# input = sys.stdin.readline

# ---------------------------------------------------------

N, K = map(int, input().split())
S = input()

cnt = []
kind = []

i, j = 0, 0
while i < N:
    while j < N and S[i] == S[j]:
        j += 1
    cnt.append(j - i)
    kind.append(int(S[i]) - int('0'))
    i = j

ans = 0
sum = 0
zero = 0
L = len(cnt)
right = 0
for left in range(len(cnt)):
    if left > right:
        right = left
    while right < len(cnt) and zero <= K:
        if kind[right] == 0 and zero == K:
            break
        if kind[right] == 0:
            zero += 1
        sum += cnt[right]
        right += 1

    ans = max(ans, sum)
    sum -= cnt[left]
    if kind[left] == 0:
        zero -= 1

print(ans)


Measured memory_bytes: 5356
from bisect import *
n = int(input())
A = [*map(int, input().split())]
B = [*map(int, input().split())]
C = [*map(int, input().split())]
A.sort()
C.sort()
ans = 0
for b in B:
    ia = bisect_left(A, b)
    ic = bisect_right(C, b)
    ans += ia * (n-ic)
print(ans)


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

long long f(long long n) {
  long long res = 0;
  while (n > 0) {
    res += n%10;
    n /= 10;
  }
  return res;
}

double g(long long n) {
  return (double)(n)/f(n);
}

int main() {
  vector<long long> res;
  long long base = 1;

  // まずは候補を (1〜150)99999 的なやつを全列挙
  for (int i = 0; i < 15; ++i) {
    for (int j = 1; j < 150; ++j) {
      res.push_back(base * (j+1) - 1);
    }
    base *= 10;
  }
  sort(res.begin(), res.end());
  res.erase(unique(res.begin(), res.end()), res.end());

  // ダメなやつを除く: O(n^2) かかる効率悪い実装だけどとりあえず
  for (long long i = 0; i < res.size(); ++i) {
    for (long long j = i+1; j < res.size(); ++j) {
      if (g(res[i]) > g(res[j])) {
        res.erase(res.begin() + i--);
        break;
      }
    }
  }

  long long K;
  cin >> K;
  for (long long i = 0; i < K; ++i) {
    cout << res[i] << endl;
  }
}

Measured memory_bytes: 256
n=int(input())
A=sorted([int(input()) for i in range(n)])
if n%2==0:
  ans=-2*sum(A[:n//2-1])-A[n//2-1]+A[n//2]+2*sum(A[n//2+1:])
  print(ans)
else:
  ans=-2*sum(A[:n//2])+A[n//2]+A[n//2+1]+2*sum(A[n//2+2:])
  ans=max(ans,-2*sum(A[:n//2-1])-A[n//2-1]-A[n//2]+2*sum(A[n//2+1:]))
  print(ans)

Measured memory_bytes: 8284
#include <iostream>
#include <iomanip>
#include <bits/stdc++.h>

int main(int argc, char const *argv[])
{
    double r;

    std::cin >> r;

    std::cout << std::fixed << std::setprecision(6) << r * r * M_PI << " " << 2 * r * M_PI << std::endl;

    return 0;
}



Measured memory_bytes: 3240
import java.util.*;
import static java.lang.System.out;
import static java.lang.Math.*;

class Main{
  public static void main(String args[]){
    Scanner scan = new Scanner(System.in);
    int n;
    while((n = scan.nextInt()) != 0){
      int mas[][] = new int[n][n];
      for(int i=1,x=n/2+1,y=n/2;i<=n*n;i++,x=(x+1)%n,y=(y+1)%n){
        if(mas[x][y] != 0){
          x = (x + 1) % n;
          y = (y - 1 + n) % n;
        }
        mas[x][y] = i;
      }
      for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
          out.printf("%4d",mas[i][j]);
        }
        out.println();
      }
    }
  }
}

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

using namespace std;
int main(){

    string st;
    cin>>st;
    int ans=0;
    int l=0;

    for(int i=0;i<st.length();i++)
            ans+=st[i]-'0';
           
     if(ans%9==0) cout<<"Yes"<<endl;
     else cout<<"No"<<endl;
}


Measured memory_bytes: 3732
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

int F[110];
int P[110][20];

signed main()
{
    int N; cin>>N;
    REP(i,N) REP(j,10){
        int t; cin>>t;
        F[i]|=t<<j;
    }
    REP(i,N) REP(j,11) cin>>P[i][j];

    int ans=-1e18;
    for(int S=1;S<(1<<10);S++){
        int sum=0;
        REP(i,N){
            int cnt=__builtin_popcount(S&F[i]);
            sum+=P[i][cnt];
        }
        ans=max(ans,sum);
    }
    cout<<ans<<endl;

}


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

using namespace std;

void split(string s, vector<string> &v) {
	s += '"';
	string buf = "";
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '"') {
			v.push_back(buf);
			buf = "";
		}
		else buf += s[i];
	}
}

int main() {

	while (1) {
		string S1, S2;
		cin >> S1;
		if (S1 == ".")break;
		cin >> S2;
		//すでに完全に一致ならば
		if (S1 == S2) {
			cout << "IDENTICAL" << endl;
			continue;
		}
		vector<string> v1, v2;
		split(S1, v1), split(S2, v2);

		if (v1.size() != v2.size()) {
			cout << "DIFFERENT" << endl;
			continue;
		}
		
		int cnt = 0;
		for (int i = 0; i < v1.size(); i++) {
			if (i % 2 == 0) {
				if (v1[i] != v2[i]) {
					cout << "DIFFERENT" << endl;
					goto next;
				}
			}
			else {
				if (v1[i] != v2[i]) {
					cnt++;
				}
			}
		}
		if (cnt > 1) {
			cout << "DIFFERENT" << endl;
		}
		else {
			cout << "CLOSE" << endl;
		}
	next:;
	}
	
	return 0;
}


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

int main(){
	
	int n,b,ib,p[50],q;
	while(1){
		cin>>n>>b;ib=b;
		if(n==0&&b==0)return 0;
		for(int i=0;i<n;i++)p[i]=0;
		q=0;
		while(1){
			if(b>0){p[q]++;b--;if(p[q]==ib){cout<<q<<endl;break;}}
			else {b+=p[q];p[q]=0;}
			q++;if(q==n)q=0;
		}
	}
}

Measured memory_bytes: 0
#include<stdio.h>

int main (void)
{
  int a[100],stay[100];
  int i,j=0;
  

  while(scanf("%d",&a[i])!=EOF){

    if(a[i]==0){
      printf("%d\n",stay[j-1]);
      j--;
    }else{
      stay[j]=a[i];
      j++;
    }
  }
  
  return 0;
}

Measured memory_bytes: 596
n, y = map(int, input().split())

s = '-1 -1 -1'
for i in range(n + 1):
    for j in range(n + 1 - i):
        if i * 10000 + j * 5000 + (n - i - j) * 1000 == y:
            s = '{} {} {}'.format(i, j, n - i - j)
print(s)


Measured memory_bytes: 9120
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		System.out.println((a + b) % 2 == 0 ? (a + b) / 2 : "IMPOSSIBLE");
	}
}

Measured memory_bytes: 24404
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int d, t, s;
    cin >> d >> t >> s;
    cout << ((d <= t * s) ? "Yes" : "No");
    
    
    return 0;
}


Measured memory_bytes: 3648