akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
vector<int> Zalgo(string s){
  int m=s.size();
  vector<int> res(m);
  res[0]=m;
  int i=1,j=0;
  while(i<m){
    while(i+j<m&&s[j]==s[j+i]){
      j++;
    }
    res[i]=j;
    if(j==0){
      i++;
      continue;
    }
    int k=1;
    while(i+k<m&&k+res[k]<j){
      res[i+k]=res[k];
      k++;
    }
    i+=k,j-=k;
  }
  return res;
}
int main(){
  int n;cin >> n;
  string s;cin >> s;
  int ans=0;
  for(int i=0;i<n;i++){
    string t=s.substr(i);
    auto lcp=Zalgo(t);
    for(int j=0;j<t.size();j++){
      ans=max(ans,min(lcp[j],j));
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#line 1 "../lib/template.hpp"


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>

using namespace std;

#line 2 "tmp.cpp"

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

  int n;
  cin >> n;
  int tmp = n;
  int sn = 0;
  while (tmp != 0) {
    sn += tmp % 10;
    tmp /= 10;
  }
  cout << (n % sn == 0 ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 384
//Coded by tzc_wk
/*
Êý¾Ý²»Çå¿Õ£¬±¬ÁãÁ½ÐÐÀá¡£
¶à²â²»¶ÁÍê£¬±¬ÁãÁ½ÐÐÀá¡£
±ß½ç²»ÌØÅÐ£¬±¬ÁãÁ½ÐÐÀá¡£
Ì°ÐÄ²»Ö¤Ã÷£¬±¬ÁãÁ½ÐÐÀá¡£
D P Ë³Ðò´í£¬±¬ÁãÁ½ÐÐÀá¡£
´óÐ¡ÉÙµÈºÅ£¬±¬ÁãÁ½ÐÐÀá¡£
±äÁ¿²»Í³Ò»£¬±¬ÁãÁ½ÐÐÀá¡£
Ô½½ç²»ÅÐ¶Ï£¬±¬ÁãÁ½ÐÐÀá¡£
µ÷ÊÔ²»×¢ÊÍ£¬±¬ÁãÁ½ÐÐÀá¡£
Òç³ö²» l l£¬±¬ÁãÁ½ÐÐÀá¡£
*/
#include <bits/stdc++.h>
using namespace std;
#define fi			first
#define se			second
#define fz(i,a,b)	for(int i=a;i<=b;i++)
#define fd(i,a,b)	for(int i=a;i>=b;i--)
#define foreach(it,v) for(__typeof(v.begin()) it=v.begin();it!=v.end();it++)
#define all(a)		a.begin(),a.end()
#define giveup(...) return printf(__VA_ARGS__),0;
#define fill0(a)	memset(a,0,sizeof(a))
#define fill1(a)	memset(a,-1,sizeof(a))
#define fillbig(a)	memset(a,0x3f,sizeof(a))
#define fillsmall(a) memset(a,0xcf,sizeof(a))
#define mask(a)		(1ll<<(a))
#define maskx(a,x)	((a)<<(x))
#define _bit(a,x)	(((a)>>(x))&1)
#define _sz(a)		((int)(a).size())
#define filei(a)	freopen(a,"r",stdin);
#define fileo(a)	freopen(a,"w",stdout);
#define fileio(a) 	freopen(a".in","r",stdin);freopen(a".out","w",stdout)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define put(x)		putchar(x)
#define eoln        put('\n')
#define space		put(' ')
#define y1			y_chenxiaoyan_1
#define y0			y_chenxiaoyan_0
#define int long long
typedef pair<int,int> pii;
inline int read(){
	int x=0,neg=1;char c=getchar();
	while(!isdigit(c)){
		if(c=='-')	neg=-1;
		c=getchar();
	}
	while(isdigit(c))	x=x*10+c-'0',c=getchar();
	return x*neg;
}
inline void print(int x){
	if(x<0){
		putchar('-');
		print(abs(x));
		return;
	}
	if(x<=9)	putchar(x+'0');
	else{
		print(x/10);
		putchar(x%10+'0');
	}
}
inline int qpow(int x,int e,int _MOD){
	int ans=1;
	while(e){
		if(e&1)	ans=ans*x%_MOD;
		x=x*x%_MOD;
		e>>=1;
	}
	return ans;
}
int n=read(),d=read(),a[200005];
struct edge{
	int u,v,w;
	edge(){}
	edge(int _u,int _v,int _w){
		u=_u;v=_v;w=_w;
	}
	friend bool operator <(edge a,edge b){
		return a.w<b.w;
	}
};
edge e[200005<<8];
int cnt=0;
inline int calc(int i,int j){
	return d*abs(i-j)+a[i]+a[j];
}
inline void conquer(int l,int r){
	if(l==r)	return;
	int mid=(l+r)>>1;
	int mx1=0x3f3f3f3f3f3f3f3fll,ind1=0;
	fz(i,l,mid)		if(mx1>a[i]-i*d)	mx1=a[i]-i*d,ind1=i;
	int mx2=0x3f3f3f3f3f3f3f3fll,ind2=0;
	fz(i,mid+1,r)	if(mx2>a[i]+i*d)	mx2=a[i]+i*d,ind2=i;
	if(ind2)	fz(i,l,mid)		e[++cnt]={i,ind2,calc(i,ind2)};
	if(ind1)	fz(i,mid+1,r)	e[++cnt]={ind1,i,calc(ind1,i)};
	conquer(l,mid);conquer(mid+1,r);
} 
struct _ufs{
	int fa[200005];
	inline void init(){
		fz(i,1,n)	fa[i]=i;
	}
	inline int find(int x){
		return (fa[x]==x)?x:fa[x]=find(fa[x]);
	}
} ufs;
signed main(){
	fz(i,1,n)	a[i]=read();
	conquer(1,n);
	ufs.init();
	sort(e+1,e+cnt+1);
	int ans=0;
	fz(i,1,cnt){
		int u=e[i].u,v=e[i].v,w=e[i].w;
		int _u=ufs.find(u),_v=ufs.find(v);
		if(_u!=_v){
			ufs.fa[_u]=_v;
			ans+=w;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 89472
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

#define INF	(1 << 30)

#define MAX_N	(3000)
#define MAX_C	(MAX_N * 2)
#define MAX_D	(200 * 10)

#define DBIT	(11)
#define DMASK	((1 << DBIT) - 1)

/* typedef */

typedef vector<int> vi;
typedef map<string,int> msi;
typedef pair<int,int> pii;
typedef vector<pii> vpii;

/* global variables */

msi chash;
int rds[MAX_N][3];
vpii nbrs[MAX_C];
bool gss[MAX_C];
short dists[MAX_C << DBIT];

struct g_dist {
  bool operator()(const int& a, const int& b) const {
    return dists[b] < dists[a];
  }
};

/* subroutines */

/* main */

int main() {

  for (;;) {
    int n, m, cap;
    cin >> n >> m >> cap;
    if ((n | m | cap) == 0) break;

    string scty, dcty;
    cin >> scty >> dcty;

    int nc = 0;
    chash.clear();

    for (int i = 0; i < n; i++) {
      string cti0, cti1;
      int di;
      cin >> cti0 >> cti1 >> di;

      if (chash.find(cti0) == chash.end())
	chash[cti0] = nc++;
      if (chash.find(cti1) == chash.end())
	chash[cti1] = nc++;

      rds[i][0] = chash[cti0];
      rds[i][1] = chash[cti1];
      rds[i][2] = di;
    }

    for (int i = 0; i < nc; i++) nbrs[i].clear();
    
    for (int i = 0; i < n; i++) {
      nbrs[rds[i][0]].push_back(pii(rds[i][1], rds[i][2]));
      nbrs[rds[i][1]].push_back(pii(rds[i][0], rds[i][2]));
    }
    //p edges
    //p nbrs

    memset(gss, false, sizeof(bool) * nc);

    for (int i = 0; i < m; i++) {
      string cty;
      cin >> cty;
      gss[chash[cty]] = true;
    }
    //p gss

    int sc = chash[scty];
    int dc = chash[dcty];
    //p [sc, dc]

    int max_d = cap * 10;

    memset(dists, -1, sizeof(dists));
    int st = sc << DBIT | 0;
    dists[st] = 0;

    priority_queue<int,vi,g_dist> q;
    q.push(st);

    int min_d = INF;
    
    while (! q.empty()) {
      int u = q.top();
      q.pop();

      int uc = u >> DBIT;
      int ug = u & DMASK;
      int ud = dists[u];

      if (uc == dc) {
	if (min_d > ud) min_d = ud;
	break;
      }

      if (gss[uc]) ug = 0;

      for (int i = 0; i < nbrs[uc].size(); i++) {
	int vc = nbrs[uc][i].first;
	int ed = nbrs[uc][i].second;

	int vg = ug + ed;
	if (vg > max_d) continue;

	int v = vc << DBIT | vg;
	int nvd = ud + ed;

	if (dists[v] < 0 || dists[v] > nvd) {
	  dists[v] = nvd;
	  q.push(v);
	}
      }
    }

    cout << (min_d >= INF ? -1 : min_d) << endl;
  }

  return 0;
}

Measured memory_bytes: 35428
#include <stdio.h>

int main(void){
    long num,tmp;
    long a = 0;
    long ans = 0;

    scanf("%ld",&num);
    ans = num-1;

    while(1){
        a++;
        if(num%a == 0){
            tmp=a+num/a-2;
            if(ans>tmp)ans=tmp;
        }
        if(a>=num/a)break;
    }

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


Measured memory_bytes: 1728
import java.io.*;
import java.util.*;

class Main {
	
	public static void main(String[] args) throws IOException {
		
		BufferedReader br = 
			new BufferedReader(new InputStreamReader(System.in));
		
		ArrayList<String> ans = new ArrayList<String>();
		
		while (true) {
			
			String s = br.readLine();
			if (s == null) break;
			
			StringTokenizer st1 = new StringTokenizer(s," ");
			StringTokenizer st2 = new StringTokenizer(br.readLine()," ");
			
			ArrayList<String> str1 = new ArrayList<String>();
			ArrayList<String> str2 = new ArrayList<String>();
			
			while (st1.hasMoreTokens()) {
				str1.add(st1.nextToken());
				str2.add(st2.nextToken());
			}
			
			int cntHit = 0;
			int cntBlow = 0;
			
			for (int i = 0; i < str1.size(); i++) {
				if (str1.get(i).equals(str2.get(i))) cntHit++;
			}
			
			for (int i = 0; i < str2.size(); i++) {
				if (str1.contains(str2.get(i)) && (str1.indexOf(str2.get(i)) != i)) {
					cntBlow++;
				}
			}
			ans.add(String.valueOf(cntHit) + " " + String.valueOf(cntBlow));
		}
		
		for (String a : ans)
			System.out.println(a);
	}
	
}

Measured memory_bytes: 8892
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

void add(ll &x,ll y){
    x=(x+y)%MOD;
}

ll tpl(ll x){
    return (x*3)%MOD;
}

ll dp[4],nxt[4];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    cin>>s;
    
    dp[0]=1;
    rep(i,s.size()){
        char c=s[i];
        if(c=='?') rep(i,4) nxt[i]=tpl(dp[i]);
        else rep(i,4) nxt[i]=dp[i];
        
        if(c=='A'||c=='?') add(nxt[1],dp[0]);
        if(c=='B'||c=='?') add(nxt[2],dp[1]);
        if(c=='C'||c=='?') add(nxt[3],dp[2]);
        swap(dp,nxt);
    }
    cout1(dp[3])
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
  double a,b=100.00;
  int ans=0;
  scanf("%lf",&a);
  while(b<a)
  {
    b=floor(b*1.01);
    ans++;
  }
  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 3828
#include<stdio.h>
int main(){
  while(1){
    int H;
    int W;
    scanf("%d %d", &H, &W);
    if(W == 0 && H == 0)break;
    int h,w;
    for(w = 1 ; w <= W ; w++){
      printf("#");
    }
    printf("\n");
    for(h = 2 ; h < H ; h++){
      printf("#");
      for(w = 2 ; w < W ; w++){
	printf(".");
      }
      printf("#\n");
    }
    for(w = 1 ; w <= W ; w++){
      printf("#");
    }
    printf("\n");
    printf("\n");
  }
  return 0;
}


Measured memory_bytes: 2060
//LthKthNumber
#include <iostream>
#include <algorithm>

using namespace std;
typedef long long ll;

static const int MAX = 200000;

int A[MAX];
ll N, K, L;

bool check(ll num) {
    ll cnt  = 0, kcnt = 0;
    ll r = 0;
    for(int l = 0; l < N; l++) {
        while(kcnt < K && r < N) {
            if(A[r++] <= num) kcnt++;
        }
        if(kcnt == K) cnt += N - r + 1;
        if(A[l] <= num) kcnt--;
    }
    return cnt >= L;
}

int main() {
    cin >> N >> K >> L;
    for(int i = 0; i < N; i++) {
        scanf("%d", &A[i]);
    }

    ll left = 1, right = N, mid;

    while(left < right) {
        mid = (left + right) / 2;
        if(check(mid)) {
            right = mid;
        } else {
            left = mid + 1;
        }
    }

    cout << left << endl;
}


Measured memory_bytes: 3992
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-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; }

int N, M, R;
int r[10];
ll g[210][210];

int main() {
    cin >> N >> M >> R;
    rep(i, R) cin >> r[i];
    rep(i, R) r[i]--;

    rep(i, N) rep(j, N) g[i][j] = LLINF;
    rep(i, N) g[i][i] = 0;
    while (M--) {
        int a, b; ll c;
        cin >> a >> b >> c;
        a--; b--;
        g[a][b] = g[b][a] = c;
    }

    rep(k, N) rep(i, N) rep(j, N) {
        chmin(g[i][j], g[i][k] + g[k][j]);
    }

    vector<int> v(R);
    rep(i, R) v[i] = i;

    ll ans = LLINF;
    do {
        ll sum = 0;
        rep(i, R-1) {
            int from = r[v[i]];
            int to = r[v[i+1]];
            sum += g[from][to];
        }
        chmin(ans, sum);
    } while (next_permutation(all(v)));

    cout << ans << endl;
}


Measured memory_bytes: 3960
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-12;
const double PI = acos(-1.0);
const int INF = INT_MAX/10;

#include <complex>
typedef complex<int> num;

string s;
int p;
bool overflow;

num expression();
num term();
num factor();
num number();
void check(num);

void check(num a) {
	if(10000 < abs(a.real()) || 10000 < abs(a.imag())) {
		overflow = true;
	}
}

num number() {
	if(s[p] == 'i') {
		p++;
		return num(0, 1);
	} else {
		int value = 0;
		while(isdigit(s[p])) {
			value = value*10 + (s[p]-'0');
			if(10000 < value) {
				overflow = true;
			}
			p++;
		}
		check(num(value, 0));
		return num(value, 0);
	}
}

num factor() {
	num result;
	if(s[p] == '(') {
		p++;
		result = expression();
		check(result);
		p++;
	} else {
		result = number();
		check(result);
	}

	return result;
}

num term() {
	num result = factor();
	while(true) {
		if(s[p] == '*') {
			p++;
			result *= factor();
			check(result);
		} else {
			break;
		}
	}

	return result;
}

num expression() {
	num result = term();
	while(true) {
		if(s[p] == '+') {
			p++;
			result += term();
			check(result);
		} else if(s[p] == '-') {
			p++;
			result -= term();
			check(result);
		} else {
			break;
		}
	}
	
	return result;
}

void show(num a) {
	if(a.real() != 0 && a.imag() != 0) {
		cout << a.real();
		if(a.imag() > 0) {
			cout << "+";
		}
		cout << a.imag() << "i" << endl;
	} else if(a.real() != 0 && a.imag() == 0) {
		cout << a.real() << endl;;
	} else if(a.real() == 0 && a.imag() != 0) {
		cout << a.imag() << "i" << endl;
	} else {
		cout << 0 << endl;
	}	
}

int main() {
	while(cin >> s) {
		p = 0;
		overflow = false;
		num result = expression();

		if(overflow) {
			cout << "overflow" << endl;
		} else {
			show(result);
		}
	}

	return 0;
}

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

using namespace std;

int main(){
    string O, E;
    cin >> O >> E;

    for(int i=0; i<E.size(); i++){
        cout << O.at(i);
        cout << E.at(i);
    }
    if(E.size() < O.size()) cout << O.at(O.size()-1);

    cout << endl;
}   

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

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

    static class TaskE
    {
        public void solve(int testNumber, Scanner in, PrintWriter out)
        {
            int T = 1;
            while (T-- > 0)
            {
                solveOne(in, out);
            }
        }

        private void solveOne(Scanner in, PrintWriter out)
        {
            int N = in.nextInt();
            int points[][] = CPUtils.readIntMatrix(N, 2, in);

            int[] x = new int[points.length];
            int[] y = new int[points.length];

            long ans = 0;
            for (int idx = 0; idx < points.length; idx++)
            {
                x[idx] = points[idx][0];
                y[idx] = points[idx][1];
            }

            long max_xi_plus_yi = Integer.MIN_VALUE;
            long min_xi_plus_yi = Integer.MAX_VALUE;
            long max_xi_minus_yi = Integer.MIN_VALUE;
            long min_xi_minus_yi = Integer.MAX_VALUE;

            for (int idx = 0; idx < points.length; idx++)
            {
                max_xi_plus_yi = Math.max(max_xi_plus_yi, x[idx] + y[idx]);
                min_xi_plus_yi = Math.min(min_xi_plus_yi, x[idx] + y[idx]);
                max_xi_minus_yi = Math.max(max_xi_minus_yi, x[idx] - y[idx]);
                min_xi_minus_yi = Math.min(min_xi_minus_yi, x[idx] - y[idx]);
            }
            out.println(Math.max(max_xi_plus_yi - min_xi_plus_yi, max_xi_minus_yi - min_xi_minus_yi));
        }

    }

    static class CPUtils
    {
        public static int[] readIntArray(int size, Scanner in)
        {
            int[] array = new int[size];
            for (int i = 0; i < size; i++)
            {
                array[i] = in.nextInt();
            }
            return array;
        }

        public static int[][] readIntMatrix(int rows, int columns, Scanner in)
        {
            int[][] matrix = new int[rows][columns];
            for (int i = 0; i < rows; i++)
            {
                matrix[i] = CPUtils.readIntArray(columns, in);
            }
            return matrix;
        }

    }
}



Measured memory_bytes: 60192
#include"bits/stdc++.h"
using namespace std;

int main(void) {

	string s;
	cin >> s;

	for (int i = 0; i < s.size() - 1; i++) {
		if (s[i] == s[i + 1]) {
			cout << "Bad" << endl;
			return 0;
		}
	}

	cout << "Good" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)//iをaからn
#define per(i,a,n) for (int i=a-1;i>=n;i--)//iをnからa
#define db(x) cout << #x << " = " << x << endl
#define db2(x, y) cout << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n"; //デバッグ用
#define all(x) (x).begin(), (x).end()
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法


//sort(all(a)); ソート
//sort(all(a),greater<int>()); 逆順ソート

int main() {
  int d,t,s;
  cin >> d>>t>>s;
  
  if(s*t>=d){
 cout<<"Yes"<<endl;
  }else{
cout<<"No"<<endl;
  }
 
 return 0;
}

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

int main()
{
  string s;
  cin>>s;
  
  
    if(s=="SUN")
      cout<<7<<endl;
    else if(s=="MON")
      cout<<6<<endl;   
    else if(s=="TUE")
      cout<<5<<endl;
    else if(s=="WED")
      cout<<4<<endl;
    else if(s=="THU")
      cout<<3<<endl;
    else if(s=="FRI")
      cout<<2<<endl;
    else
      cout<<1<<endl;
  
}
      
      

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

#define R register
#define maxn 100010
struct Poi {
	int x, y, id, type;
	inline bool operator < (const Poi &that) const
	{
		return type < that.type || (type == that.type &&
			(type == 1 ? y < that.y
			: type == 2 ? x < that.x
			: type == 3 ? y > that.y
			: x > that.x));
	}
} pp[maxn << 2];
struct Rect {
	int x1, y1, x2, y2, id;
} p[maxn];
int pcnt, st[maxn << 2];
int main()
{
	R int r, c, n; scanf("%d%d%d", &r, &c, &n);
	for (R int i = 1; i <= n; ++i)
		scanf("%d%d%d%d", &p[i].x1, &p[i].y1, &p[i].x2, &p[i].y2), p[i].id = i;
	for (R int i = 1; i <= n; ++i)
	{
		if (((p[i].x1 == 0 || p[i].x1 == r) || (p[i].y1 == 0 || p[i].y1 == c)) && ((p[i].x2 == 0 || p[i].x2 == r) || (p[i].y2 == 0 || p[i].y2 == c)))
		{
			pp[++pcnt] = (Poi) {p[i].x1, p[i].y1};
			pp[pcnt].id = i;
			if (pp[pcnt].x == 0) pp[pcnt].type = 1;
			else if (pp[pcnt].y == c) pp[pcnt].type = 2;
			else if (pp[pcnt].x == r) pp[pcnt].type = 3;
			else pp[pcnt].type = 4;
			
			pp[++pcnt] = (Poi) {p[i].x2, p[i].y2};
			pp[pcnt].id = i;
			if (pp[pcnt].x == 0) pp[pcnt].type = 1;
			else if (pp[pcnt].y == c) pp[pcnt].type = 2;
			else if (pp[pcnt].x == r) pp[pcnt].type = 3;
			else pp[pcnt].type = 4;
		}
	}
	std::sort(pp + 1, pp + pcnt + 1);
	R int top = 0;
//	for (R int i = 1; i <= pcnt; ++i) printf("x %d y %d id %d type %d\n", pp[i].x, pp[i].y, pp[i].id, pp[i].type);
	for (R int i = 1; i <= pcnt; ++i)
	{
		if (top && st[top] == pp[i].id) --top;
		else st[++top] = pp[i].id;
	}
	puts(top ? "NO" : "YES");
	return 0;
}

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

namespace AtCoder
{

    class Program
    {
        static void Main()
        {
            Solve();

            Console.ReadKey();
        }

        static void Solve()
        {
            var N = GetInt();
            var ans = 0;
            for(int i = 1; i <= N; i+=2)
            {
                var sum = 0;
                for(int j = 1; j <= i; j++)
                {
                    if (i % j == 0) sum++;
                }
                if (sum == 8) ans++;
            }

            Console.Write(ans);
        }



        static public string GetStr() { return Console.ReadLine(); }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
        static public int[] GetIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] GetLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public List<double> GetDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }
        static public void WriteObjects<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }

        static bool eq<T, U>() => typeof(T).Equals(typeof(U));
        static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
        static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                           : eq<T, long>() ? ct<T, long>(long.Parse(s))
                           : eq<T, double>() ? ct<T, double>(double.Parse(s))
                           : eq<T, char>() ? ct<T, char>(s[0])
                                             : ct<T, string>(s);
        static void Multi<T>(out T a) => a = cv<T>(GetStr());
        static void Multi<T, U>(out T a, out U b)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
        }
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n;cin>>n;
   int a[4]={0};
   for(int i=0;i<n;i++)
   { 
       string s;cin>>s;
       if(s=="AC")
       a[0]++;
       if(s=="WA")
       a[1]++;
       if(s=="TLE")
       a[2]++;
       if(s=="RE")
       a[3]++;
   }
   cout<<"AC x "<<a[0]<<endl;
   cout<<"WA x "<<a[1]<<endl;
   cout<<"TLE x "<<a[2]<<endl;
   cout<<"RE x "<<a[3]<<endl;
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
long long n, a[55], l, r, m;
int main(){
	scanf("%lld", &n);
	rep(i,n) scanf("%lld", a+i);
	auto J = [&]{
		for(long long s = m; s > max(-1LL,m-n); s--){
			long long cn = 0;
			rep(i,n) cn += max(0LL,(a[i] + 1 + s) / (n+1));
			if(cn <= s) return false;
		}
		return true;
	};
	for(l=-1,r=1e18;l+1<r;(J()?l:r)=m)m=(l+r)/2;
	printf("%lld\n", r);
}

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

typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)

int main() {
  ll n;
  cin >> n;
  ll ans=0,ans2=0;
  for (ll i=1; i <= sqrt(n);i++){
    if (n%i==0){
      ans=i;
      ans2=n/i;
    }
  }
  cout << ans+ans2-2 << endl;
      
  return 0;
}


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

bool isprime[1000001];

int main(){
	vector<int> v;
	// init
	for(int i = 0 ; i <= 1000000 ; i++)
		isprime[i] = true;
	isprime[0] = isprime[1] = false;
	
	// eratosuteneru
	for(int i = 2 ; i*i <= 1000000 ; i++){
		if( isprime[i] ){ 
			for(int j = i*i ; j <= 1000000 ; j += i ){
				isprime[j] = false;
			}
		}
	}
	
	for(int i = 0 ; i <= 1000000 ; i++){
		if( isprime[i] ){
			v.push_back(i);
		}
	}
	for(int i = 1 ; i < v.size() ; i++){
		v[i] = v[i] + v[i-1];
	}
	int n;
	while( cin >> n && n ){
		cout << v[n-1] << endl;
	}
}

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

int main() {
    ll n,t;
    cin>>n>>t;
    ll a[n];
    for(ll i=0;i<n;i++)cin>>a[i];
    ll ans=0;
    for(ll i=0;i<n-1;i++){
        if((a[i+1]-a[i])<t)ans+=a[i+1]-a[i];
        else ans+=t;
    }
    ans+=t;
    cout<<ans;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
//void IO(){
//	#ifndef ONLINE_JUDGE
//	    freopen("input.txt", "r", stdin);
//	    freopen("output.txt", "w", stdout);
//	#endif
//}
// end of Template

bool isprime[300000];
bool special[300000];
vi prime;
int sum[300000],q;
void sieve(int x){
    for(int i=2;i<=x;i++)isprime[i]=true;
    for(int i=2;i<=x;i++){
        if(isprime[i]){
            prime.pb(i);
            for(int j=2*i;j<=x;j+=i){
                isprime[j]=false;
            }
        }
    }
}
int main(){
	//IO();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    sieve( 200010 );
    for(int i=0;i<prime.size();i++){
        int p = prime[i];
        if(p<=100000){
            int c = 2*p - 1;
            if(isprime[c]){
                special[c]++;
            }
        }
    }
    for(int i=1;i<=100000;i++){
        sum[i] = sum[i-1];
        if(special[i])sum[i]++;
    }
    cin>>q;
    for(int i=1;i<=q;i++){
        int l,r;cin>>l>>r;
        int ans = sum[r] - sum[l-1];
        cout<<ans<<newl;
    }

}


Measured memory_bytes: 1664
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');
		int n = int.Parse(input[0]);
		int m = int.Parse(input[1]);
		int[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
    Array.Sort(nums);
    int[] remains = new int[m];
    int[] equals = new int[m];
		int answer = 0;
    int equalMemo = -10;

    for(int i = 0; i < n; i++)
    {
      remains[nums[i]%m]++;
      if(i > 0)
      {
        if(nums[i] == nums[i-1] && i > equalMemo)
        {
          equals[nums[i]%m]++;
          equalMemo = i+1;
        }
      }
    }

    answer += remains[0]/2;
    if(m % 2 == 0) answer += remains[m/2]/2;
    //Console.WriteLine(answer+"a");

    for(int i = 1; i <= (m-1)/2; i++)
    {
      if(remains[i] > remains[m-i])
      {
        answer += remains[m-i];
        int memo = remains[i] - remains[m-i];
        answer += Math.Min(memo/2, equals[i]);
      }else
      {
        answer += remains[i];
        int memo = remains[m-i] - remains[i];
        answer += Math.Min(memo/2, equals[m-i]);
      }
      //Console.WriteLine(answer+"b");
    }

		Console.WriteLine(answer);
	}
}

Measured memory_bytes: 19296
using System;
using System.Collections.Generic;
using System.Linq;

public class Solution
{
    public static void Main()
    {
        var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var a = vals[0];
        var b = vals[1];

        var s1 = new string(Enumerable.Repeat(a.ToString()[0], b).ToArray());
        var s2 = new string(Enumerable.Repeat(b.ToString()[0], a).ToArray());
        var ss = new string[] { s1, s2 }.OrderBy(x => x).ToArray();
        Console.WriteLine(ss[0]);
    }
}

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

int N;

bool isMatch(vector<int> O, vector<int> Q) {
    for (int i=0; i<N; i++) {
        if (O.at(i)!=Q.at(i)) return false;
    }
    return true;
}

int main() {
    cin >> N;
    vector <int> O(N);
    vector <int> P(N);
    vector <int> Q(N);
    for (int i=0; i<N; i++) O.at(i) = i+1;
    for (int i=0; i<N; i++) cin >> P.at(i);
    for (int i=0; i<N; i++) cin >> Q.at(i);
    int a,b;
    int cnt=0;
    do {
        cnt++;
        if (isMatch(O, P)) a=cnt;
        if (isMatch(O, Q)) b=cnt;
    } while(next_permutation(O.begin(), O.end()));
    cout << abs(a-b);
}

Measured memory_bytes: 3620
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
for i in range(1,n):
   a[i]+=a[i-1]
   b[n-i-1]+=b[n-i]
for i in range(n):
   a[i]+=b[i]
print(max(a))

Measured memory_bytes: 3064
using System;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using static System.Math;
using Debug = System.Diagnostics.Debug;

class P
{
    static void Main()
    {
        string s = Console.ReadLine();
        Console.WriteLine(Min(s.Count(x => x == '1'), s.Count(x => x == '0')) * 2);
    }
}


Measured memory_bytes: 13408
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int a[] = new int[3];
        for (int i = 0; i < 3; i++) {
            a[i] = s.nextInt();
        }
        int c1 = 0;
        int c2 = 0;
        
        for (int i = 0; i < 3; i++) {
            if(a[i] == 5) {
                c1 += 1;
            }
            if(a[i] == 7) {
                c2 += 1;
            }
        }

        if(c1 == 2 && c2 == 1) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}

Measured memory_bytes: 21204
#include <iostream>
#include <algorithm>
using namespace std;
int n,m,l;
long long int s;
int a[100010];
int main(){
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> m >> l;
			for (int j = 0; j < m ; j++) {
				cin >> a[j];
			}
		s = a[m-1] - a[0];
		int d[m-1];
			for (int j = 0; j < m-1 ; j++) {
				d[j] = a[j+1] - a[j];
			}
			sort(d,d+m-1);
			for (int j = 0; j < l-1; j++) {
			s = s - d[m-2-j];
		}
		if (s > 0)
			cout << s << endl; 
		else 
		cout << "0" << endl;
		
	}
}

Measured memory_bytes: 1952
#include <bits/stdc++.h>
using namespace std;
#define pi 3.141592653589

int main() {
	double a, b, x; cin >> a >> b >> x;
	double ans = 0.0;
	double v = a*a*b;
	double t;
	if(x*2>=v){
		t = 2.0*(v-x)/(a*a);
		//s = sqrt(t*t+a*a);
		ans = atan(t/a)*180.0/pi; 
	}else{
		t = 2*x/(a*b);
		//s = sqrt(t*t+b*b);
		ans = atan(b/t)*180.0/pi;
	}
	printf("%.10f\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int n;
	while(cin>>n){
		int count=0;
		for(int i=0;i<10;i++){
			for(int j=0;j<10;j++){
				for(int k=0;k<10;k++){
					for(int p=0;p<10;p++){
						if(i+j+k+p==n)count++;
					}
				}
			}
		}
		cout<<count<<endl;
	}
}


Measured memory_bytes: 1164
n, k = gets.split(" ").map(&:to_i)
 
h = Hash.new(0)
 
k.times do |i|
  d = gets.to_i
  
  aa = gets.split(" ").map(&:to_i)
  aa.each do |a| 
    h[a] += 1
  end
end
 
result = 0
(1..n).each do |i|
  result += 1 if h[i] == 0
end
puts result

Measured memory_bytes: 14284
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <numeric>
using namespace std;
int main(){
    int x;
    cin >> x;
    long long ans = 1000000000000000; 
    vector<int> str(x);
    for(int i=1;i<x;i++){
        string s = to_string(x-i)+to_string(i);
        long long sum=0;
        for(int j=0;j<s.length();j++){
            sum+=stoi(s.substr(j,1));
        }
        if(ans>sum){
            ans = sum;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define che
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define PB push_back
#define MP make_pair
#define fi first
#define se second
using namespace std;
typedef long long LL;
const int M=(1<<18) +10,N= 45 ;
const LL MOD = 1e9 +7;

int n,ns, nt=0;
char s[N], t[N], a[N];
LL ans= 0,f[N][N];

template<typename T>
void upsum(T &a, T b){ a=a+b;}

int main(){
	scanf("%d%s", &n,a);

	for (int S=0; S< 1<<n; ++S){
		ns=0 , nt=0;
		for (int j=0; j<n; j++)
			if ( S&1<<j) s[ns++] = a[j];
				else t[nt++] = a[j];
		s[ns] = t[nt] = '\0';
		for (int i=0; i<=ns; ++i)
			for (int j=0;j<=nt; ++j) f[i][j] = 0;
		f[0][0]  =1;
		for (int i=0; i<=ns; i++)
			for (int j=0; j<=nt; j++){
				if ( a[2*n-1-i-j] == s[i] ) f[i+1][j]+=f[i][j];
				if ( a[2*n-1-i-j] == t[j] ) f[i][j+1]+=f[i][j];
			}
        ans+=f[ns][nt];

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


Measured memory_bytes: 384
import itertools

n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

all_list = list(itertools.permutations(p))
all_list.sort()

p_ans = 0
q_ans = 0

for i in range(len(all_list)):
    if list(all_list[i]) == p:
        p_ans = i
    if list(all_list[i]) == q:
        q_ans = i
print(abs(p_ans - q_ans))

Measured memory_bytes: 8052
#include <bits/stdc++.h>
#include <iostream>
#include <numeric>
#include <string>
#include <list>
#include <limits>
#include <type_traits>
#include <vector>

using namespace std;

int main(void) {

    int k,a,b;

    bool r = false;

    cin >> k;
    cin >> a;
    cin >> b;

    for (int i = a; i <= b; i++) {
        if ( i % k == 0  ) {
            r = true;
            break;
        }

    }

    if ( r == true ) {
        cout << "OK";
    }
    else {
        cout << "NG";
    }   
}

Measured memory_bytes: 3600
use std::io::{stdin, stdout, stderr, Write, BufWriter, BufReader, BufRead};

macro_rules! read_from_line {
    ($inbuf:ident => $($name:ident : $ty:ty),* ) => {
        let mut buf = String::new();
        $inbuf.read_line(&mut buf).unwrap();
        buf.pop();
        let mut words = buf.split_whitespace();
        $(
            let $name:$ty = words.next().unwrap().parse().unwrap();
        )*
    };
}

fn main() {
    let cout = stdout();
    let mut cout = BufWriter::new(cout.lock());
    let cin = stdin();
    let mut cin = BufReader::new(cin.lock());

    //read_from_line!(cin => a:i32, b:String);
    //let xs: Vec<i32> = strio::read_many_from_line(&mut cin);
    
    read_from_line!(cin => n:i32);
    if n % 2 == 0 {
        writeln!(cout, "{}", n).unwrap();
    } else {
        writeln!(cout, "{}", n * 2).unwrap();
    }

}

mod strio {
    use std::str::FromStr;
    use std;

    pub fn read_from_line<T, R> (r: &mut R) -> T where
        T: FromStr,
        <T as std::str::FromStr>::Err : std::fmt::Debug,
        R: std::io::BufRead,
    {
        let mut buf = String::new();
        r.read_line(&mut buf).unwrap();
        buf.pop();
        buf.parse().unwrap()
    }

    pub fn read_many_from_line<T, R> (r: &mut R) -> Vec<T> where
        T: FromStr,
        <T as std::str::FromStr>::Err : std::fmt::Debug,
        R: std::io::BufRead,
    {
        let mut buf = String::new();
        r.read_line(&mut buf).unwrap();
        buf.pop();
        buf.split_whitespace().map(|x| x.parse().unwrap()).collect()
    }
}


Measured memory_bytes: 4352
N = int(input())
L = list(map(int,input().split()))
ANS = ["" for i in range(N)]

if N % 2 == 0 :
    for i in range(N) :
        if i % 2 == 0 :
            ANS[(N+i)//2] = str(L[i])
        else :
            ANS[(N-i)//2] = str(L[i])
else :
    for i in range(N) :
        if i % 2 != 0 :
            ANS[(N+i)//2] = str(L[i])
        else :
            ANS[(N-i)//2] = str(L[i])
        
print(" ".join(ANS))


Measured memory_bytes: 30916
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define PP pair<P,P>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	random_device rnd;
	mt19937_64 mt64(rnd());
	uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt64);
}
/*--------Library Zone!--------*/

int n;
double a[55];
signed main() {
	cin >> n;
	rep(i, n)cin >> a[i];
	sort(a, a + n);
	double ans = a[0];
	REP(i, n) {
		ans = (ans + a[i]) / 2;
	}
	printf("%.12lf\n", ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    ll X,K,D;
    cin >> X >> K >> D;
    X = abs(X);
    if (log(K) + log(D) < log(X)) OUT(X-K*D)
    else {
        ll d = X / D;
        if ((K-d) % 2 == 0) OUT(X-d*D)
        else OUT(abs(X-d*D-D));
    }

    return 0;
}

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

using lli = long long int;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

template <class T>ostream &operator<<(ostream &o,const pair<T, T>&p)
{o<<"("<<p.first<<", "<<p.second<<")";return o;}

#define rep(i, n) for(lli i = 0; i < (lli)(n); i++)

const lli MOD = 1000000007LL;

lli modpow(lli a, lli n){
    lli res = 1;

    for(lli ai = a; n; n>>=1){
        if(1&n) res = (res*ai)%MOD;
        ai=(ai*ai)%MOD;
    }
    return res;
}

lli inv(lli n){
    return modpow(n, MOD-2);
}

lli modperm(lli n, lli k){
    lli res = 1;
    rep(i, k){
        res = (res*(n-i))%MOD;
    }
    return res;
}

lli modcomb(lli n, lli k){
    return (modperm(n, k)*inv(modperm(k, k)))%MOD;
}

lli posmod(lli n){
    lli res = n;
    res %= MOD;
    if(res < 0) res += MOD;
    return res;
}
lli n;
string s;
lli cr, cg, cb;
lli sub;

int main(void){
    //int ti = clock();
    cin >> n >> s;
    cr = cg = cb = sub = 0;
    rep(i, n){
        if(s[i] == 'R') cr++;
        else if(s[i] == 'G') cg++;
        else cb++;
    }
    for(int i = 0; i < n; i++){
        for(int k = 1; i+2*k < n; k++){
            if(s[i] != s[i+k] && s[i+k] != s[i+2*k] && s[i+2*k] != s[i]) sub++;
        }
    }
    cout << cr*cg*cb-sub << endl;
    //cout << fixed << setprecision(10) << 1.0*(clock()-ti)/CLOCKS_PER_SEC << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;

int main()
{
    int N, K;
    int h[100001];
    cin >> N >> K;
    for (int i = 0; i < N; i++)
    {
        cin >> h[i];
    }
    ll dp[100001] = {0};
    dp[1] = abs(h[1] - h[0]);
    ll temp;
    for (int i = 2; i < N; i++)
    {
        temp = dp[i - 1] + abs(h[i] - h[i - 1]);
        for (int j = 0; j < K - 1; j++)
        {
            temp = min(temp, dp[i - j - 2] + abs(h[i] - h[i - j - 2]));
            if ((i - j) == 2)
                break;
        }
        dp[i] = temp;
    }
    cout << dp[N - 1] << endl;
    // system("pause");
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int main(){
	
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	string str;
	int count{0};
	
	while(cin >> str){
		string tmp;
		for(int i=0; i<(int)str.size(); i++){
			tmp.push_back(str[i]);
		}
		reverse(tmp.begin(), tmp.end());
		if(str == tmp){
			count++;
		}
	}
	cout << count << endl;
	return 0;
}

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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
	int h,w,k; scanf("%d%d%d",&h,&w,&k);
	char B[300][301];
	rep(i,h) scanf("%s",B[i]);

	int ans[300][300],pre=0;
	rep(i,h){
		vector<int> X;
		rep(j,w) if(B[i][j]=='#') X.emplace_back(j);
		X.emplace_back(w);
		if(X.size()==1) continue;

		for(int j=0;j<X.size()-1;j++){
			for(int y=pre;y<=i;y++) for(int x=(j==0?0:X[j]);x<min(X[j+1],w);x++) {
				ans[y][x]=k;
			}
			k--;
		}
		pre=i+1;
	}
	while(pre<h){
		rep(x,w) ans[pre][x]=ans[pre-1][x];
		pre++;
	}

	rep(i,h) rep(j,w) printf("%d%c",ans[i][j],j<w-1?' ':'\n');

	return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
int main(){
  int x1,x2,x3,x4,x5;
  cin >>x1>>x2>>x3>>x4>>x5;
  if(x1==0){
    cout<<"1"<<endl;
  }else if (x2==0){
    cout<<"2"<<endl;
  }else if (x3==0){
    cout<<"3"<<endl;
  }else if (x4==0){
    cout<<"4"<<endl;
  }else{
    cout<<"5"<<endl;
  }
}

Measured memory_bytes: 3632
use v5.18; # strict say state
use warnings;
use List::Util qw(reduce first max min sum0);

chomp (my $n = <STDIN>);
chomp (my @a = split / /, <STDIN>);
my ($s, $t);
$s = 1;
$t = $a[0];

for my $i (1..$n-1) {
  $s = $s * $a[$i] + $t;
  $t = $t * $a[$i];
}

say $t / $s;

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }

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

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

struct edge{ int to,num; };

bool used[100010];
vector<edge> G[100010];

int dfs(int v,int par){
	if(G[v].size() >= 4) return v;
	for(edge e : G[v]){
		if(used[e.num] || e.to == par) continue;
		used[e.num] = true;
		if(G[e.to].size() >= 4) return e.to;
		return dfs(e.to,v);
	}
}

signed main(){
	int n,m,a[100010],b[100010];
	cin >> n >> m;
	for(int i = 0;i < m;i++){
		cin >> a[i] >> b[i]; a[i]--;b[i]--;
		G[a[i]].push_back({b[i],i});
		G[b[i]].push_back({a[i],i});
	}
	bool has4 = false;
	for(int i = 0;i < n;i++){
		if(G[i].size() % 2 == 1){
			No();
			return 0;
		}
		if(G[i].size() >= 4) has4 = true;
	}
	if(!has4){
		No();
		return 0;
	}
	int cnt = 0;
	for(int i = 0;i < m;i++){
		if(!used[i]){
			used[i] = true;
			if(dfs(a[i],b[i]) == dfs(b[i],a[i])) cnt += 2;
			else cnt += 1;
		}
	}
	isYes(cnt >= 6);
}


Measured memory_bytes: 9472
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;

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

int f(int x) {
	int res = 0;
	while (x % 2 == 0) {
		res++;
		x /= 2;
	}
	return res;
}


int main() {
	int n, m; cin >> n >> m;
	vector<int>a(n); for (auto&& x : a)cin >> x;
	for (int i = 0; i < n; i++) {
		if (a[i] % 2 == 1) {
			cout << 0 << endl;
			return 0;
		}
		a[i] /= 2;
	}
	int t = f(a[0]);
	for (int i = 0; i < n; i++) {
		if (f(a[i]) != t) {
			cout << 0 << endl;
			return 0;
		}
		a[i] >>= t;
	}
	m >>= t;

	ll l = 1;
	for (int i = 0; i < n; i++) {
		l = lcm(l, a[i]);
		if (l > m) {
			cout << 0 << endl;
			return 0;
		}
	}
	m /= l;
	int ans = (m + 1) / 2;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int a[120],n,m,a1[2],b,c;
int main()
{
    scanf("%d%d",&n,&m);
    a1[0]=1;a1[1]=m;
    for(int i=1;i<=m;i++)
    {
        scanf("%d",a+i);
        if(~a[i]&1) continue;
        a1[b++]=i;
        if(b>2) return puts("Impossible"),0;
    }
    swap(a[1],a[a1[0]]);
    swap(a[m],a[a1[1]]);
    if(m==1&&a[1]==1) return puts("1\n1\n1"),0;
    for(int i=1;i<=m;i++) printf("%d ",a[i]);
    if(m==1) return printf("\n2\n%d 1\n",a[1]-1),0;
    printf("\n%d\n%d ",a[m]>1?m:m-1,a[1]+1);
    for(int i=2;i<m;i++) printf("%d ",a[i]);
    if(a[m]>1) printf("%d\n",a[m]-1);
    return 0;
}

Measured memory_bytes: 256